From b0411e8799585b1c8a119c5a2530e8f9b6d3e974 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 2 Mar 2016 17:03:20 +1100 Subject: [PATCH] SPIGOT-1622: Add drop chance methods for off hand. --- .../inventory/CraftEntityEquipment.java | 24 ++++++++++++++++++- .../inventory/CraftInventoryPlayer.java | 24 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java index e95fb3a8b9..3ed9e2bb09 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java @@ -113,14 +113,36 @@ public class CraftEntityEquipment implements EntityEquipment { return entity; } + @Override public float getItemInHandDropChance() { + return getItemInMainHandDropChance(); + } + + @Override + public void setItemInHandDropChance(float chance) { + setItemInMainHandDropChance(chance); + } + + @Override + public float getItemInMainHandDropChance() { return getDropChance(EnumItemSlot.MAINHAND); } - public void setItemInHandDropChance(float chance) { + @Override + public void setItemInMainHandDropChance(float chance) { setDropChance(EnumItemSlot.MAINHAND, chance); } + @Override + public float getItemInOffHandDropChance() { + return getDropChance(EnumItemSlot.OFFHAND); + } + + @Override + public void setItemInOffHandDropChance(float chance) { + setDropChance(EnumItemSlot.OFFHAND, chance); + } + public float getHelmetDropChance() { return getDropChance(EnumItemSlot.HEAD); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 8f78b8c65b..afdc796a27 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -191,11 +191,33 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i return (HumanEntity) inventory.getOwner(); } + @Override public float getItemInHandDropChance() { + return getItemInMainHandDropChance(); + } + + @Override + public void setItemInHandDropChance(float chance) { + setItemInMainHandDropChance(chance); + } + + @Override + public float getItemInMainHandDropChance() { return 1; } - public void setItemInHandDropChance(float chance) { + @Override + public void setItemInMainHandDropChance(float chance) { + throw new UnsupportedOperationException(); + } + + @Override + public float getItemInOffHandDropChance() { + return 1; + } + + @Override + public void setItemInOffHandDropChance(float chance) { throw new UnsupportedOperationException(); }