Ok, I'm trying to attach data to Minecraft Bukkit ItemStack. I would like the object that it fell to also have it, but this is not necessary. If I cannot do this directly, is there any other way I can store a piece of data (java int, java string) with an element when moving it around the players and their inventory slots? Thanks!
EDIT: Here is a sample code.
package path.to.the.package; import org.bukkit.event.*; import org.bukkit.event.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; public ExamplePlugin extends JavaPlugin { public List<ItemStack> stacks = new ArrayList<ItemStack>(); public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("tester123")) { ItemStack stack = new ItemStack(272, 0, (byte)0); Player p = (Player)sender; stacks.add(stack); p.getLocation().getWorld().dropItem(player.getLocation(), stack); } return true; } @EventHandler(priority = EventPriority.HIGHEST) public void onItemStackRightClick(PlayerInteractEvent e) { Player player = e.getPlayer(); for(ItemStack item : items) { if(player.getItemInHand() == item) {
I weighed this example, but it does not work when I right-click one special sword.
source share