NoDropItems
Welcome to my first, very simple, yet useful Bukkit plugin.
BASIC INFORMATION
It is a plugin that disallows users without the right permission to drop items from their inventories and warns them for attempting to do so. If the warning is unacknowledged, a player who attempts to drop items from their inventory five times will be auto-killed. The plugin is compatible with almost all versions of Minecraft, even 1.8 and beyond. I made this plugin mainly for minigame servers that have inventory menus for selecting items. Currently, I am a very average coder, and do not thing that a config is necessary for such a simple plugin, but if anyone desires a config for possibly disabling the warnings and being killed, or changing the number of times required to be killed, please let me know and I will do my best to make it.
USAGE
Installed as any plugin is, put the jar in your plugins folder of your server and the plugin will work it's magic after a reload or restart. The permission "NoDrop.dropAllow" is required by a player to be able to drop items freely.
THANKS
Thanks to StormCoreFilms for making a tutorial on how to create Bukkit Plugins!
Could you make the option to turn off the warnings and die ?
@EventHandler
public void onDrop(PlayerDropItemEvent e){
Player p = e.getPlayer();
if(!p.hasPermission("nodrop.dropallow"){
e.setCancelled(true);
}
}
Thats basically your entire code for such a simple plugin :o.
Also, just using a HashMap for storing a player's count that they have tried to drop items for is simple as well.
public static HashMap<Player, Integer> h = new HashMap<Player, Integer>();
Then the bulk of the code.
@EventHandler
public void onDrop(PlayerDropItemEvent e){
Player p = e.getPlayer();
if(!p.hasPermission("nodrop.dropallow"){
e.setCancelled(true);
if(!h.contains(p){
h.put(p, 1);
}else{
int count = (int))h.get(p) + 1;
h.put(p, count);
if(count >= (Set number)){
p.sendMessage("MESSAGE");
}else if(count >= (Set Number)){
p.sendMessage("MESSAGE");
}else if(count >= (Set Number)){
p.kickPlayer("Kick Message);
}
}
}