The code for my main class: Code:java import java.awt.List;import java.util.ArrayList; import org.bukkit.ChatColor;import org.bukkit.Material;import org.bukkit.entity.Entity;import org.bukkit.entity.Player;import org.bukkit.event.Event;import org.bukkit.event.EventHandler;import org.bukkit.event.entity.EntityDamageEvent;import org.bukkit.event.entity.EntityEvent;import org.bukkit.inventory.ItemStack;import org.bukkit.inventory.meta.ItemMeta;import org.bukkit.plugin.java.JavaPlugin; public class TNTsword extends JavaPlugin { public static Object TNTsword; @Override public void onEnable() { getLogger().info("The TnT Sword PLugin has been enabled!"); TNTsword = null; //in your onEnable //your usual stuff, and register a listener getServer().getPluginManager().registerEvents(new TNTListener(), this); //initialize TNTsword ItemStack TNTsword = new ItemStack(Material.IRON_SWORD, 1); ItemMeta tntmeta = TNTsword.getItemMeta(); tntmeta.setDisplayName(ChatColor.RED + "TNT " + ChatColor.WHITE + "Sword"); ArrayList<String> lore = new ArrayList<String>(); lore.add("Explodes on hit!"); tntmeta.setLore(lore); TNTsword.setItemMeta(tntmeta); Player sender = null; if(sender instanceof Player){ ((Player) sender).getInventory().addItem(TNTsword); return; if(Event.getEntity() instanceof Player && Event.getCause() instanceof Player){ if(((Player) Event.getCause()).getItemInHand().getType().equals(Material.IRON_SWORD)){ ((Player) Event.getCause()).setItemInHand(new ItemStack(Material.AIR)); {}}}} } public void onDisable() {} { getLogger().info("The TnT Sword PLugin has been disabled!"); } public Entity getEntity() { // TODO Auto-generated method stub return null;}} This is my code for my TNTListener class: Code:java import org.bukkit.entity.Entity;import org.bukkit.entity.Player;import org.bukkit.event.Event;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.entity.EntityDamageByEntityEvent;import org.bukkit.event.entity.EntityDamageEvent;import org.bukkit.event.entity.EntityEvent; public class TNTListener implements Listener { private static final EntityDamageByEntityEvent e = null; @EventHandler public void onDamage(EntityDamageByEntityEvent e){ if(e.getDamager() instanceof Player); } Player p = (Player) e.getDamager(); { //check if the item in hand is the sword from TNTClass if(p.getItemInHand().equals(TNTsword.TNTsword)); { Object e; //create explosion ((TNTsword) e).getEntity().getWorld().createExplosion(((TNTsword) e).getEntity().getLocation(), 0f); Entity sender; Player target = sender.getWorld().getPlayer(args[0]); target.setHealth(0); }}} I know I have a few errors but I need your help to find them and fix them. Whats the point of this plugin you may ask? A person can create a TnT Sword (didn't add crafting yet) so when a player gets hit with the sword there becomes an explosion that is the power of 2 TnT. Thank you.
Given the code as is, have you tested it? If it didn't work in the test server, what exceptions, if any, were raised/thrown? [i.e. if you got an exception, post its stack trace - it tells you where the problem is!]
Well, to start, if I looked at that right, you have a sender argument in the onEnable method (?). Also, like... look at this: Code:java private static final EntityDamageByEntityEvent e = null; Why do you have this?
For your information: Code: private static final EntityDamageByEntityEvent e = null; Is being laughed at, because: If you put final in front of your variable, you can't assign another value to this variable, this is handy in case you got a variable you don't want to be changed. You are assigning 'null' to the variable which is nothing, and you won't be able to change this anymore. That makes that you got a variable, that is null, that you can't change, which is pretty pointless...
Yeah I messed up a bit. I understand that. That's why I need your help to fix the errors I have made. Sorry if I made a few stupid mistakes but people learn from trial and error. Please help me. Thank you. And again, it was a stupid accident.