Hello i need a plugin that not only allows players to drop items upon death but can be configured to any item and quantity in game. If there already is a plugin out there it would be awesome if someone could link me to it. Otherwise if someone could make it for me that would be amazing. I have no coding experience so i don't know if what i'm asking is possible/easy/difficult. Thx for your time.
@DJ_BLADERUNNER Here you go! Works with mobs, players, and animals. http://dev.bukkit.org/server-mods/cookiemonster/
Here is an example I ad from a previous Project. Code: @EventHandler public void onEntityDeath(EntityDeathEvent event) { Entity ent = (Entity) event.getEntity(); if (ent instanceof Player) { Player player = (Player) ent; if (player.getName().equals("PLAYER")) { ent.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.MELON_BLOCK.getId(), 1, (short) 0)); } } }
@Wundark Why not edit the drop list directly? Code:java public void manipulateDrops(EntityDeathEvent event) { List<ItemStack> dropList = event.getDrops(); dropList.clear(); // To remove everything from the list. you could also iterate over it and remove some things, example to remove all apples: /* Iterator<ItemStack> iter = dropList.iterator(); ItemStack is; while(iter.hasNext()) { is = iter.next(); if(is.getType() == Material.APPLE) iter.remove(); } */ dropList.add(new ItemStack(Material.APPLE)); // To add a apple to the list... }
@V10lator He specifically asked for Players and he never asked for drops to be removed just for a customisable drop upon death. We can add both of out code together. As for customisation you can add it via a config and permissions. EG. If the config had a string that contained a item value for a drop. (member: "1,1;2,5"). This would drop 1 of Stone and 5 of Grass Blocks. Code: @EventHandler public void onEntityDeath(EntityDeathEvent event) { Entity ent = (Entity) event.getEntity(); if (ent instanceof Player) { Player player = (Player) ent; if(player.hasPermission("death.member")) { for(String itemProcess : getConfig().getString("member").split(";")) { String[] itemProc = itemProcess.split(","); event.getDrops().add(new ItemStack(Integer.valueOf(itemProc[0]) , Integer.valueOf(itemProc[1]), (short) 0)); } } } }
Copy&paste error, sorry, simply change public void manipulateDrops(EntityDeathEvent event) to public void manipulateDrops(PlayerDeathEvent event) then. true, but removing drops would be a nice optional feature, wouldn't it? Also I could say "and he never asked for permissions". But what I wanted to ask with my last post was why you where creating extra drops instead of adding the new items to the existent drop list. The seconds sounds better cause it may be faster code (have to check CB code to confirm and don't want right now) + higher compatibility with other drop handling plugins (like the ones that take the list and flush it directly into the killers inventory instead of dropping).