I am new to coding for bukkit and I can not figure out why this is not working?? All i want is for when a player rightclicks with a blazerod it shoots an arrow out of their inventory. Code: package me.superj.wand2; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.Material; import org.bukkit.event.block.Action; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractEvent; public class Main extends JavaPlugin { public void onEnable() { System.out.println("Wand has been enabled.");} public void onPlayerUse(PlayerInteractEvent event) { final Player player = event.getPlayer(); if (player.getItemInHand().getType() == Material.BLAZE_ROD && event.getAction() == Action.RIGHT_CLICK_AIR) { if(player.getInventory().contains(Material.ARROW)) { player.launchProjectile(Arrow.class); } } } }
You forgot to register the events, implement Listener and @EventHandler I suggest reading this first: http://wiki.bukkit.org/Event_API_Reference
So all I need to do it put in the @EventHandler Code: getServer().getPluginManager().registerEvents(Listener, Plugin); I am confused on how to add a listener plugin?
You need to make your class implement Listener, e.g. Code: public class Main extends JavaPlugin implements Listener { Then you do: Code: this.getServer().getPluginManager().registerEvents(this, this); In onEnable(). Why does this work? Because the first parameter asks for a Listener, which is your Main class instance (as it implements Listener), and the second parameter asks for a Plugin, which is your Main class instance too (as it extends JavaPlugin which extends PluginBase which implements Plugin).
@superj I think the best advice I can give you is to look up Java and Bukkit tutorials. With your current knowledge we will have to basically write out all of the code for you and most of the users here will not and should not do that.