diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java index 2d567235..d61e666c 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.util.DurabilityUtils; +import com.willfp.ecoenchants.util.Logger; import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,7 +23,7 @@ import java.util.Set; public class DecayCurse extends EcoEnchant implements EcoRunnable { private final Set players = new HashSet<>(); - private int amount = 10000; + private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); public DecayCurse() { super( @@ -64,15 +65,15 @@ public class DecayCurse extends EcoEnchant implements EcoRunnable { private void refresh() { players.clear(); EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, EcoEnchants.DECAY_CURSE))) + if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) players.add(player); }); - amount = EcoEnchants.DECAY_CURSE.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "damage"); + amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); } private void refreshPlayer(Player player) { players.remove(player); - if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, EcoEnchants.DECAY_CURSE))) + if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) players.add(player); } @@ -80,7 +81,8 @@ public class DecayCurse extends EcoEnchant implements EcoRunnable { public void run() { players.forEach((player -> { for(ItemStack item : player.getInventory().getContents()) { - if(!EnchantChecks.item(item, EcoEnchants.DECAY_CURSE)) continue; + int level = EnchantChecks.getItemLevel(item, this); + if(level == 0) continue; if(!(item.getItemMeta() instanceof Repairable)) continue; @@ -89,6 +91,7 @@ public class DecayCurse extends EcoEnchant implements EcoRunnable { if(player.getItemOnCursor().equals(item)) continue; DurabilityUtils.damageItemNoBreak(item, amount, player); + player.updateInventory(); } })); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java index d30d1bfa..b10f93ac 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.util.DurabilityUtils; +import com.willfp.ecoenchants.util.Logger; import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,7 +23,7 @@ import java.util.Set; public class Repairing extends EcoEnchant implements EcoRunnable { private final Set players = new HashSet<>(); - private int amount = 10000; + private int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); public Repairing() { super( @@ -64,15 +65,15 @@ public class Repairing extends EcoEnchant implements EcoRunnable { private void refresh() { players.clear(); EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach(player -> { - if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, EcoEnchants.REPAIRING))) + if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) players.add(player); }); - amount = EcoEnchants.REPAIRING.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "damage"); + amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "multiplier"); } private void refreshPlayer(Player player) { players.remove(player); - if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, EcoEnchants.REPAIRING))) + if(Arrays.stream(player.getInventory().getContents()).parallel().anyMatch(item -> EnchantChecks.item(item, this))) players.add(player); } @@ -80,7 +81,8 @@ public class Repairing extends EcoEnchant implements EcoRunnable { public void run() { players.forEach((player -> { for(ItemStack item : player.getInventory().getContents()) { - if(!EnchantChecks.item(item, EcoEnchants.REPAIRING)) continue; + int level = EnchantChecks.getItemLevel(item, this); + if(level == 0) continue; if(!(item.getItemMeta() instanceof Repairable)) continue; @@ -88,7 +90,8 @@ public class Repairing extends EcoEnchant implements EcoRunnable { if(player.getInventory().getItemInOffHand().equals(item)) continue; if(player.getItemOnCursor().equals(item)) continue; - DurabilityUtils.repairItem(item, amount); + DurabilityUtils.repairItem(item, amount * level); + player.updateInventory(); } })); } diff --git a/Plugin/src/main/resources/enchants/curse/decaycurse.yml b/Plugin/src/main/resources/enchants/curse/decaycurse.yml index 37204467..b5238c0a 100644 --- a/Plugin/src/main/resources/enchants/curse/decaycurse.yml +++ b/Plugin/src/main/resources/enchants/curse/decaycurse.yml @@ -22,4 +22,4 @@ general-config: config: repeat-ticks: 100 # How often (in ticks) to repair items - damage: 1 \ No newline at end of file + multiplier: 1 \ No newline at end of file