disable drop stat - with listener as requested in #1289

This commit is contained in:
Rosenthalk0 2023-05-14 19:02:34 -05:00
parent 7f8afdff65
commit 1c350339a4
2 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,7 @@ public class ItemStats {
DISABLE_REPAIRING = new DisableStat("REPAIRING", Material.ANVIL, "Disable Repairing", new String[]{"!block", "all"}, "Players can't use this item in anvils."), DISABLE_REPAIRING = new DisableStat("REPAIRING", Material.ANVIL, "Disable Repairing", new String[]{"!block", "all"}, "Players can't use this item in anvils."),
DISABLE_ARROW_SHOOTING = new DisableStat("ARROW_SHOOTING", Material.ARROW, "Disable Arrow Shooting", new Material[]{Material.ARROW}, "Players can't shoot this", "item using a bow."), DISABLE_ARROW_SHOOTING = new DisableStat("ARROW_SHOOTING", Material.ARROW, "Disable Arrow Shooting", new Material[]{Material.ARROW}, "Players can't shoot this", "item using a bow."),
DISABLE_ATTACK_PASSIVE = new DisableStat("ATTACK_PASSIVE", Material.BARRIER, "Disable Attack Passive", new String[]{"piercing", "slashing", "blunt"}, "Disables the blunt/slashing/piercing", "passive effects on attacks."), DISABLE_ATTACK_PASSIVE = new DisableStat("ATTACK_PASSIVE", Material.BARRIER, "Disable Attack Passive", new String[]{"piercing", "slashing", "blunt"}, "Disables the blunt/slashing/piercing", "passive effects on attacks."),
DISABLE_DROP = new DisableStat("DROPING", Material.LAVA_BUCKET, "Disable Item Dropping", new String[]{"all"}, "Disables the dropping of this item!"),
// RPG Stats // RPG Stats
REQUIRED_LEVEL = new RequiredLevel(), REQUIRED_LEVEL = new RequiredLevel(),

View File

@ -22,6 +22,7 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
@ -31,6 +32,15 @@ import org.bukkit.inventory.ItemStack;
public class DisableInteractions implements Listener { public class DisableInteractions implements Listener {
@EventHandler(ignoreCancelled = true)
public void itemDropping(PlayerDropItemEvent event){
ItemStack itemStack = event.getItemDrop().getItemStack();
if (isDisabled(NBTItem.get(itemStack),"drop")){
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void anvilInteractions(InventoryClickEvent event) { public void anvilInteractions(InventoryClickEvent event) {
Inventory inv = event.getClickedInventory(); Inventory inv = event.getClickedInventory();