mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 02:47:44 +01:00
Adding PLAYER_DROP_ITEM event hook
This commit is contained in:
parent
71f97ffc5b
commit
82931a601d
@ -4,9 +4,12 @@ import java.util.List;
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftItemDrop;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public abstract class EntityHuman extends EntityLiving {
|
public abstract class EntityHuman extends EntityLiving {
|
||||||
@ -216,6 +219,22 @@ public abstract class EntityHuman extends EntityLiving {
|
|||||||
entityitem.motZ += Math.sin((double) f1) * (double) f;
|
entityitem.motZ += Math.sin((double) f1) * (double) f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
Player player = (Player)this.getBukkitEntity();
|
||||||
|
CraftServer server = ((WorldServer)world).getServer();
|
||||||
|
CraftItemDrop drop = new CraftItemDrop(server, entityitem);
|
||||||
|
PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
org.bukkit.inventory.ItemStack stack = drop.getItemStack();
|
||||||
|
stack.setAmount(1);
|
||||||
|
player.getInventory().addItem(stack);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
this.a(entityitem);
|
this.a(entityitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user