I'm trying to get the plugin to remove the item that the player is currently holding, doesn't seem to work... Code: package com.bukkit.jakkeren; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; public class TrixoHand extends JavaPlugin { @Override public void onEnable() { getLogger().info(ChatColor.GREEN + "Dette plugin er blevet aktiveret"); } @Override public void onDisable() { getLogger().info(ChatColor.RED +"Dette plugin er blevet deaktiveret"); } @EventHandler public void onPlayerClickEvent(PlayerInteractEvent event) { final Player player = event.getPlayer(); } @SuppressWarnings("deprecation") public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("handclear")) { Player player = (Player) sender; player.getInventory().getItemInHand().setAmount(player.getInventory().getItemInHand().getAmount()-1); } if(cmd.getName().equalsIgnoreCase("hclear")) { Player player = (Player) sender; player.getInventory().getItemInHand().setAmount(player.getInventory().getItemInHand().getAmount()-1); } if(cmd.getName().equalsIgnoreCase("hc")) { Player player = (Player) sender; player.getInventory().getItemInHand().setAmount(player.getInventory().getItemInHand().getAmount()-1); } return false; } }
@Jakkeren You didn't register your event. You never check if the sender is a player. https://jd.bukkit.org/org/bukkit/in...setItemInHand(org.bukkit.inventory.ItemStack)
Use another package. You do not own bukkit.com, so you should not use it. Only use domains you own, your email adress, or use the format "me.<yourname>.<yourproject>" Don't log your own plugins. Bukkit does that for you. Always check if the sender is a player before casting .What if the console sends that command? What about another plugin or a commandblock?
First of all, thanks Second of all, if i should do as you say, (me.<yourname>.<yourproject>), should i then write the same in my plugin.yml file? This might sound dumb, but where should i insert that? I'm kind of new to coding, so... I'll try that in a second I tried it, and it did not work. It hits me with the error "The constructor ItemStack(Material) is undenified". EDIT: Never mind, the error suddenly disappeared! EDIT by Moderator: merged posts, please use the edit button instead of double posting.