diff --git a/Core/pom.xml b/Core/pom.xml index f114a157..99af6bf9 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../ diff --git a/Core/src/main/java/com/songoda/core/SongodaCore.java b/Core/src/main/java/com/songoda/core/SongodaCore.java index 5d645341..1bdf90ae 100644 --- a/Core/src/main/java/com/songoda/core/SongodaCore.java +++ b/Core/src/main/java/com/songoda/core/SongodaCore.java @@ -53,7 +53,7 @@ public class SongodaCore { /** * This has been added as of Rev 6 */ - private final static String coreVersion = "2.4.38"; + private final static String coreVersion = "2.4.39"; /** * This is specific to the website api diff --git a/Core/src/main/java/com/songoda/core/utils/ItemUtils.java b/Core/src/main/java/com/songoda/core/utils/ItemUtils.java index 6b562d81..cc9296dc 100644 --- a/Core/src/main/java/com/songoda/core/utils/ItemUtils.java +++ b/Core/src/main/java/com/songoda/core/utils/ItemUtils.java @@ -7,6 +7,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import com.songoda.core.compatibility.CompatibleHand; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.nms.NmsManager; import org.apache.commons.lang.StringUtils; @@ -120,21 +121,38 @@ public class ItemUtils { } public static ItemStack addDamage(ItemStack item, int damage) { - if (item == null) { + return addDamage(null, item, damage); + } + + public static ItemStack addDamage(Player player, ItemStack item, int damage) { + if (item == null) return null; - } else if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11) - ? NmsManager.getNbt().of(item).has("Unbreakable") - : item.getItemMeta().isUnbreakable()) { + + int maxDurability = item.getType().getMaxDurability(); + int durability; + + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11) + ? NmsManager.getNbt().of(item).has("Unbreakable") + : item.getItemMeta().isUnbreakable()) { return item; } else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { // ItemStack.setDurability(short) still works in 1.13-1.14, but use these methods now ItemMeta meta = item.getItemMeta(); if (meta instanceof Damageable) { - ((Damageable) meta).setDamage(((Damageable) meta).getDamage() + damage); + Damageable damageable = ((Damageable) meta); + damageable.setDamage(((Damageable) meta).getDamage() + damage); item.setItemMeta(meta); + durability = damageable.getDamage(); + } else { + return item; } } else { item.setDurability((short) Math.max(0, item.getDurability() + damage)); + durability = item.getDurability(); + } + if (durability >= maxDurability && player != null) { + player.getInventory().removeItem(item); + CompatibleSound.ENTITY_ITEM_BREAK.play(player); } return item; } diff --git a/NMS/NMS-API/pom.xml b/NMS/NMS-API/pom.xml index 07babf47..b8973f8c 100644 --- a/NMS/NMS-API/pom.xml +++ b/NMS/NMS-API/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_10_R1/pom.xml b/NMS/NMS-v1_10_R1/pom.xml index c655f3af..569139a5 100644 --- a/NMS/NMS-v1_10_R1/pom.xml +++ b/NMS/NMS-v1_10_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_11_R1/pom.xml b/NMS/NMS-v1_11_R1/pom.xml index 1792cd3e..cf235464 100644 --- a/NMS/NMS-v1_11_R1/pom.xml +++ b/NMS/NMS-v1_11_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_12_R1/pom.xml b/NMS/NMS-v1_12_R1/pom.xml index 9467fb8b..b663af52 100644 --- a/NMS/NMS-v1_12_R1/pom.xml +++ b/NMS/NMS-v1_12_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_13_R1/pom.xml b/NMS/NMS-v1_13_R1/pom.xml index 3cbffbe6..c403479f 100644 --- a/NMS/NMS-v1_13_R1/pom.xml +++ b/NMS/NMS-v1_13_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_13_R2/pom.xml b/NMS/NMS-v1_13_R2/pom.xml index e6afd1f4..e33b47a2 100644 --- a/NMS/NMS-v1_13_R2/pom.xml +++ b/NMS/NMS-v1_13_R2/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_14_R1/pom.xml b/NMS/NMS-v1_14_R1/pom.xml index 9f84a2f8..77ea767a 100644 --- a/NMS/NMS-v1_14_R1/pom.xml +++ b/NMS/NMS-v1_14_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_15_R1/pom.xml b/NMS/NMS-v1_15_R1/pom.xml index 785da4a6..099c96b7 100644 --- a/NMS/NMS-v1_15_R1/pom.xml +++ b/NMS/NMS-v1_15_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_16_R1/pom.xml b/NMS/NMS-v1_16_R1/pom.xml index 008bc098..896cece3 100644 --- a/NMS/NMS-v1_16_R1/pom.xml +++ b/NMS/NMS-v1_16_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_16_R2/pom.xml b/NMS/NMS-v1_16_R2/pom.xml index d1f42dbe..59d7863b 100644 --- a/NMS/NMS-v1_16_R2/pom.xml +++ b/NMS/NMS-v1_16_R2/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_16_R3/pom.xml b/NMS/NMS-v1_16_R3/pom.xml index 6feb1be2..724b2043 100644 --- a/NMS/NMS-v1_16_R3/pom.xml +++ b/NMS/NMS-v1_16_R3/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_8_R1/pom.xml b/NMS/NMS-v1_8_R1/pom.xml index 955afb4d..41fd1c3c 100644 --- a/NMS/NMS-v1_8_R1/pom.xml +++ b/NMS/NMS-v1_8_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_8_R2/pom.xml b/NMS/NMS-v1_8_R2/pom.xml index 20393e79..da77222b 100644 --- a/NMS/NMS-v1_8_R2/pom.xml +++ b/NMS/NMS-v1_8_R2/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_8_R3/pom.xml b/NMS/NMS-v1_8_R3/pom.xml index 3fa70d82..84486014 100644 --- a/NMS/NMS-v1_8_R3/pom.xml +++ b/NMS/NMS-v1_8_R3/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_9_R1/pom.xml b/NMS/NMS-v1_9_R1/pom.xml index 8b606691..cbc81f62 100644 --- a/NMS/NMS-v1_9_R1/pom.xml +++ b/NMS/NMS-v1_9_R1/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/NMS/NMS-v1_9_R2/pom.xml b/NMS/NMS-v1_9_R2/pom.xml index 1c534eee..7cb08511 100644 --- a/NMS/NMS-v1_9_R2/pom.xml +++ b/NMS/NMS-v1_9_R2/pom.xml @@ -3,7 +3,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 ../../ diff --git a/README.md b/README.md index 657ccc3b..87c42c20 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Maven Information com.songoda SongodaCore - 2.4.38 + 2.4.39 provided ``` @@ -37,6 +37,6 @@ repositories { * Artifact: ```groovy dependencies { - compileOnly 'com.songoda:SongodaCore:2.4.38' + compileOnly 'com.songoda:SongodaCore:2.4.39' } ``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index e3a98b0d..9d1cdf3f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda SongodaCore-Modules - 2.4.38 + 2.4.39 4.0.0 pom