My currently nodrop: Code: @EventHandler public void onItemDrop(ItemSpawnEvent event){ if (isEnabled()) event.setCancelled(true); } I don't have idea on how to do, but I want a nodrop that the items go to ground but is not possible get it and after 3 secounds the item disappear. If a player die or drop a item, these items go to ground normally but the players can't get it and after 3 secounds these items disappear. Can someone make this code or a pseudo for me? if yes thanks very much!
Tux2 Can you please make a pseudo? And if you can add the 3 secounds of item on ground too. Thanks! Tux2 Technius What is wrong with the code? I put 60 for 3 secounds but not worked... Code: @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { Integer time = (60); if (time != null) { final Item itm = event.getItemDrop(); Bukkit.getScheduler().runTaskLater(this, new Runnable() { public void run() { if ((itm != null) && (!itm.isDead())) { itm.remove(); } } } , time.intValue() / 40); } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Dont remove the entire line, just remove the part where you divide by 40, like this: Code: } , time.intValue() / 40); } becomes Code: } , time.intValue()); } Also, the time has to be a long.
Works pretty well thanks! Also I'm brazilian too! Also I have a problem: I would like to when a player get killed the items be removed on the same time too, but it is not working. LucasEmanuel I do this code but getting error on the 9 line: - Type safety: The constructor ArrayList(Collection) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized - ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized - List is a raw type. References to generic type List<E> should be parameterized Code: @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Integer time = (80); if (time != null) { World w = event.getEntity().getWorld(); List iss = new ArrayList(event.getDrops()); event.getDrops().clear(); final Item[] items = new Item[iss.size()]; for (int i = 0; i < iss.size(); i++) { items[i] = w.dropItemNaturally(event.getEntity().getLocation(), (ItemStack)iss.get(i)); } Bukkit.getScheduler().runTaskLater(this, new Runnable() { public void run() { for (Item itm : items) { if ((itm != null) && (!itm.isDead())) { itm.remove(); } } } } , time.intValue()); } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Iervolino Change this line: Code: List iss = new ArrayList(event.getDrops()); to Code: List iss = event.getDrops();
Change and getting this warn on List: List is a raw type. References to generic type List<E> should be parameterized
Can I see your code? EDIT: It's because you clear the droplist. EDIT2: If you wanna stop players from dropping items when they die do this instead of what you have above: Code: public void onPlayerDeath(PlayerDeathEvent event) { if(isEnabled()) { event.getDrops().clear(); } }
I want the deathdrop enabled, but It get removed from the ground in 3 secounds... Code: @SuppressWarnings("rawtypes") @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Integer time = (60); if (time != null) { World w = event.getEntity().getWorld(); @SuppressWarnings("unchecked") List iss = new ArrayList(event.getDrops()); event.getDrops().clear(); final Item[] items = new Item[iss.size()]; for (int i = 0; i < iss.size(); i++) { items[i] = w.dropItemNaturally(event.getEntity().getLocation(), (ItemStack)iss.get(i)); } Bukkit.getScheduler().runTaskLater(this, new Runnable() { public void run() { for (Item itm : items) { if ((itm != null) && (!itm.isDead())) { itm.remove(); } } } } , time.intValue()); } }