debug command tells arrow information

master
Soper Aylamo 2021-05-04 06:49:11 -04:00
parent 98b0abf421
commit e8f19d8b42
Signed by: Soper
GPG Key ID: A27AC885ACC3BEAE
8 changed files with 122 additions and 30 deletions

View File

@ -3,8 +3,8 @@ version: 0.0.1
author: Soper Aylamo
main: xyz.soper.arty.Artillery
api-version: 1.16
website: https://home.soper.xyz/projects/Artillery
website: https://home.soper.xyz/projects/minecraft/Artillery
commands:
test:
description: swag test
usage: sex
arty-debug:
description: Artillery debug command
usage: /<command>

View File

@ -5,43 +5,58 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import javax.naming.Name;
import java.util.ArrayList;
import java.util.List;
import xyz.soper.arty.debug.DebugCommand;
public class Artillery extends JavaPlugin {
@Override
public void onEnable(){
//START OF BASE MORTAR RECIPE
ItemStack baseMortar = new ItemStack(Material.BREWING_STAND);
ItemMeta mortarMeta = baseMortar.getItemMeta();
ItemMeta baseMortarMeta = baseMortar.getItemMeta();
List<String> mortarLore = new ArrayList<String>();
mortarLore.add(ChatColor.GRAY + "" + ChatColor.UNDERLINE + "Mortal Level I");
mortarLore.add("Max Initial Velocity: ");
mortarLore.add("Dispersion: ");
mortarLore.add("Chance of Failure: ");
assert baseMortarMeta != null;
baseMortarMeta.setDisplayName(ChatColor.GRAY + "Basic Mortar");
baseMortar.setItemMeta(baseMortarMeta);
assert mortarMeta != null;
mortarMeta.setDisplayName(ChatColor.GRAY + "Mortar");
mortarMeta.setLore(mortarLore);
baseMortar.setItemMeta(mortarMeta);
NamespacedKey mortarKey = new NamespacedKey(this, "mortar");
ShapedRecipe baseMortarRecipe = new ShapedRecipe(mortarKey, baseMortar);
NamespacedKey basicMortarKey = new NamespacedKey(this, "basic_mortar");
ShapedRecipe baseMortarRecipe = new ShapedRecipe(basicMortarKey, baseMortar);
baseMortarRecipe.shape("S S", "SPS", "SFS");
baseMortarRecipe.setIngredient('S', Material.SMOOTH_STONE);
baseMortarRecipe.setIngredient('P', Material.STONE_PRESSURE_PLATE);
baseMortarRecipe.setIngredient('F', Material.FLINT);
Bukkit.addRecipe(baseMortarRecipe);
//END OF BASE MORTAR RECIPE
//getServer().getPluginManager().registerEvents();
//START OF NORMAL MORTAR RECIPE
ItemStack mortar = new ItemStack(Material.BREWING_STAND);
ItemMeta mortarMeta = mortar.getItemMeta();
assert mortarMeta != null;
mortarMeta.setDisplayName(ChatColor.GRAY + "Mortar");
mortar.setItemMeta(mortarMeta);
NamespacedKey mortarKey = new NamespacedKey(this, "mortar");
ShapedRecipe mortarRecipe = new ShapedRecipe(mortarKey, mortar);
mortarRecipe.shape("IRI", "IMI", "IPI");
mortarRecipe.setIngredient('R', Material.REDSTONE);
mortarRecipe.setIngredient('I', Material.IRON_INGOT);
mortarRecipe.setIngredient('P', Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
mortarRecipe.setIngredient('M', new RecipeChoice.ExactChoice(baseMortar));
Bukkit.addRecipe(mortarRecipe);
//END OF NORMAL MORTAR RECIPE
this.getCommand("arty-debug").setExecutor(new DebugCommand());
//DEBUGGING:
getServer().getPluginManager().registerEvents(new DebugCommand(), this);
}
@Override

View File

@ -1,2 +1,48 @@
package xyz.soper.arty.debug;public class DebugCommand {
package xyz.soper.arty.debug;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
public class DebugCommand implements CommandExecutor, Listener {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player){
Player player = (Player) sender;
if(args[0].equalsIgnoreCase("fire")){
try{
double multiplier = (double)Integer.parseInt(args[1])/10;
Arrow arrow = player.getWorld().spawn(player.getLocation().add(0,1,0), Arrow.class);
arrow.setShooter(player);
arrow.setVelocity(player.getLocation().getDirection().multiply(multiplier));
player.sendMessage(ChatColor.GOLD + "You just fired an arrow with a velocity " + multiplier);
return true;
} catch (NumberFormatException e) {
player.sendMessage(ChatColor.RED + "Incorrect usage. A number was expected.");
}
}
else player.sendMessage(ChatColor.RED + "Incorrect usage. This command does not exist.");
}
return false;
}
@EventHandler
public void onArrowHit(ProjectileHitEvent event){
if(event.getEntity().getShooter() instanceof Player && event.getEntity() instanceof Arrow){
int x = event.getHitBlock().getLocation().getBlockX();
int y = event.getHitBlock().getLocation().getBlockY();
int z = event.getHitBlock().getLocation().getBlockZ();
((Player) event.getEntity().getShooter()).sendMessage(ChatColor.GOLD + "Arrow you have shot landed at " + x + ", " + y + ", " + z);
}
}
}

View File

@ -1,4 +1,15 @@
package xyz.soper.arty.Events.Listeners;
package xyz.soper.arty.event.Listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
public class MortarInteract implements Listener {
@EventHandler
public void onClick(PlayerInteractEvent event){
if(event.getHand() == EquipmentSlot.OFF_HAND) return;
}
public class MortarInteract {
}

View File

@ -3,11 +3,17 @@ package xyz.soper.arty.item;
import org.bukkit.Location;
import org.bukkit.block.Block;
public class Mortar {
public class BaseMortar {
Location location;
Mortar(Block mortar){
int failMultiplier = 25;
int maxCaliber = 125;
int dispersion = 20;
int range = 25;
boolean incendiaryCapable = false;
BaseMortar(Block mortar){
location = mortar.getLocation();
}

View File

@ -1,4 +1,4 @@
package xyz.soper.arty.Items;
package xyz.soper.arty.item;
public class MortarTuner {
}

View File

@ -1,2 +1,16 @@
package xyz.soper.arty.item;public class NormalMortar {
package xyz.soper.arty.item;
import org.bukkit.block.Block;
public class NormalMortar extends BaseMortar {
int failMultiplier = 3;
int maxCaliber = 125;
int dispersion = 10;
int range = 50;
boolean incendiaryCapable = false;
NormalMortar(Block mortar) {
super(mortar);
}
}

View File

@ -1,4 +1,4 @@
package xyz.soper.arty.Blocks;
package xyz.soper.arty.util;
public class MortarHandler {
}