mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-03 02:21:21 +01:00
Prevented Unbreakable items from being damaged
This commit is contained in:
parent
e05dbf9ab6
commit
cd525553ac
@ -6,6 +6,7 @@
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.willfp.ecoenchants</groupId>
|
||||
<version>5.0.0-beta27</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -27,6 +27,9 @@ public class ItemDurability {
|
||||
*/
|
||||
public static void damageItem(Player player, ItemStack item, int damage, int slot) {
|
||||
if(item == null) return;
|
||||
if(item.getItemMeta() == null) return;
|
||||
|
||||
if(item.getItemMeta().isUnbreakable()) return;
|
||||
|
||||
PlayerItemDamageEvent event3 = new PlayerItemDamageEvent(player, item, damage);
|
||||
Bukkit.getPluginManager().callEvent(event3);
|
||||
@ -61,6 +64,9 @@ public class ItemDurability {
|
||||
*/
|
||||
public static void damageItemNoBreak(ItemStack item, int damage, Player player) {
|
||||
if(item == null) return;
|
||||
if(item.getItemMeta() == null) return;
|
||||
|
||||
if(item.getItemMeta().isUnbreakable()) return;
|
||||
|
||||
PlayerItemDamageEvent event3 = new PlayerItemDamageEvent(player, item, damage);
|
||||
Bukkit.getPluginManager().callEvent(event3);
|
||||
@ -89,6 +95,9 @@ public class ItemDurability {
|
||||
*/
|
||||
public static void repairItem(ItemStack item, int repair) {
|
||||
if(item == null) return;
|
||||
if(item.getItemMeta() == null) return;
|
||||
|
||||
if(item.getItemMeta().isUnbreakable()) return;
|
||||
if(item.getItemMeta() instanceof Damageable) {
|
||||
Damageable meta = (Damageable) item.getItemMeta();
|
||||
meta.setDamage(meta.getDamage() - repair);
|
||||
|
Loading…
Reference in New Issue
Block a user