I’m trying to create a minecraft plugin with Java, bukkit.
@EventHandler
public void onItemDrop(PlayerDropItemEvent e) {
/*
* Dropping items
*/
Item item = e.getItemDrop();
item.setMetadata("NODROP", new FixedMetadataValue(plugin, e.getPlayer()));
if (!e.getPlayer().hasPermission("nodrop.drop")) {
e.getItemDrop().remove();
e.getPlayer().sendMessage(colorizeText(ChatColor.RED + getConfig().getString("drop-message")));
}
}
The error I’m getting is ‘plugin’ on
item.setMetadata("NODROP", new FixedMetadataValue(plugin, e.getPlayer()));
which is:
plugin cannot be resolved to a variable
Please help!
So what needs to happen is a line of code like this within the method body:
Or you could declare
pluginas an instance variable: