mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Fixed bugs from legacy target system
This commit is contained in:
parent
610594f38d
commit
d6ea9cd027
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.anvil;
|
||||
import com.willfp.ecoenchants.config.ConfigManager;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.util.Pair;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -41,7 +42,7 @@ public class AnvilMerge {
|
||||
|
||||
if(left.getEnchantments().containsKey(EcoEnchants.PERMANENCE_CURSE)) return new Pair<>(null, null);
|
||||
|
||||
if(!Target.Applicable.ALL.getMaterials().contains(left.getType()) || right == null || !Target.Applicable.ALL.getMaterials().contains(right.getType())) {
|
||||
if(!EnchantmentTarget.ALL.contains(left.getType()) || right == null || EnchantmentTarget.ALL.contains(right.getType())) {
|
||||
ItemStack out = left.clone();
|
||||
ItemMeta outMeta = out.getItemMeta();
|
||||
outMeta.setDisplayName(name);
|
||||
|
@ -5,6 +5,7 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.config.ConfigManager;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -82,7 +83,7 @@ public class EnchantDisplay {
|
||||
public static ItemStack revertDisplay(ItemStack item) {
|
||||
if(item == null) return null;
|
||||
|
||||
if(!Target.Applicable.ALL.getMaterials().contains(item.getType()))
|
||||
if(!EnchantmentTarget.ALL.contains(item.getType()))
|
||||
return item;
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
@ -129,7 +130,7 @@ public class EnchantDisplay {
|
||||
|
||||
ItemStack oldItem = item.clone();
|
||||
|
||||
if(!Target.Applicable.ALL.getMaterials().contains(item.getType()))
|
||||
if(!EnchantmentTarget.ALL.contains(item.getType()))
|
||||
return oldItem;
|
||||
|
||||
item = revertDisplay(item);
|
||||
|
@ -55,16 +55,17 @@ public class Abrasion extends EcoEnchant {
|
||||
if (armorPiece == null)
|
||||
continue;
|
||||
|
||||
if (Target.Applicable.HELMET.getMaterials().contains(armorPiece.getType())) {
|
||||
|
||||
if(armorPiece.equals(victim.getInventory().getHelmet())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getHelmet(), level, 39);
|
||||
}
|
||||
if (Target.Applicable.CHESTPLATE.getMaterials().contains(armorPiece.getType())) {
|
||||
if(armorPiece.equals(victim.getInventory().getChestplate())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getChestplate(), level, 38);
|
||||
}
|
||||
if (Target.Applicable.LEGGINGS.getMaterials().contains(armorPiece.getType())) {
|
||||
if(armorPiece.equals(victim.getInventory().getLeggings())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getLeggings(), level, 37);
|
||||
}
|
||||
if (Target.Applicable.BOOTS.getMaterials().contains(armorPiece.getType())) {
|
||||
if(armorPiece.equals(victim.getInventory().getBoots())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getBoots(), level, 36);
|
||||
}
|
||||
}
|
||||
|
@ -55,16 +55,17 @@ public class Corrosive extends EcoEnchant {
|
||||
if (armorPiece == null)
|
||||
continue;
|
||||
|
||||
if (Target.Applicable.HELMET.getMaterials().contains(armorPiece.getType())) {
|
||||
|
||||
if(armorPiece.equals(victim.getInventory().getHelmet())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getHelmet(), level, 39);
|
||||
}
|
||||
if (Target.Applicable.CHESTPLATE.getMaterials().contains(armorPiece.getType())) {
|
||||
if(armorPiece.equals(victim.getInventory().getChestplate())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getChestplate(), level, 38);
|
||||
}
|
||||
if (Target.Applicable.LEGGINGS.getMaterials().contains(armorPiece.getType())) {
|
||||
if(armorPiece.equals(victim.getInventory().getLeggings())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getLeggings(), level, 37);
|
||||
}
|
||||
if (Target.Applicable.BOOTS.getMaterials().contains(armorPiece.getType())) {
|
||||
if(armorPiece.equals(victim.getInventory().getBoots())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getBoots(), level, 36);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Farmhand extends EcoEnchant {
|
||||
|
||||
if (!EnchantChecks.item(item, this)) return;
|
||||
|
||||
if (!(Target.Applicable.HOE.getMaterials().contains(item.getType())))
|
||||
if (!item.getType().toString().endsWith("_HOE"))
|
||||
return;
|
||||
|
||||
if(!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) return;
|
||||
|
@ -89,17 +89,17 @@ public abstract class EnchantChecks {
|
||||
armorPoints.addAndGet(getItemLevel(itemStack, enchantment));
|
||||
if(damage > 0 && isPlayer) {
|
||||
Player player = (Player) entity;
|
||||
if (Target.Applicable.HELMET.getMaterials().contains(itemStack.getType())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getHelmet(), 1, 39);
|
||||
if(itemStack.equals(entity.getEquipment().getHelmet())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getHelmet(), level, 39);
|
||||
}
|
||||
if (Target.Applicable.CHESTPLATE.getMaterials().contains(itemStack.getType())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getChestplate(), 1, 38);
|
||||
if(itemStack.equals(entity.getEquipment().getChestplate())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getChestplate(), level, 38);
|
||||
}
|
||||
if (Target.Applicable.LEGGINGS.getMaterials().contains(itemStack.getType())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getLeggings(), 1, 37);
|
||||
if(itemStack.equals(entity.getEquipment().getLeggings())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getLeggings(), level, 37);
|
||||
}
|
||||
if (Target.Applicable.BOOTS.getMaterials().contains(itemStack.getType())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getBoots(), 1, 36);
|
||||
if(itemStack.equals(entity.getEquipment().getBoots())) {
|
||||
ItemDurability.damageItem(player, player.getInventory().getBoots(), level, 36);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class EnchantingListeners implements Listener {
|
||||
}
|
||||
|
||||
double multiplier = 0.01;
|
||||
if (Target.Applicable.BOOK.getMaterials().contains(item.getType())) {
|
||||
if(item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) {
|
||||
multiplier /= ConfigManager.getConfig().getInt("enchanting-table.book-times-less-likely");
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class EnchantingListeners implements Listener {
|
||||
continue;
|
||||
if (enchantment.getRarity().getMinimumLevel() > cost)
|
||||
continue;
|
||||
if(enchantment.isEnabled())
|
||||
if(!enchantment.isEnabled())
|
||||
continue;
|
||||
if (!enchantment.canGetFromTable())
|
||||
continue;
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.listeners;
|
||||
import com.willfp.ecoenchants.config.ConfigManager;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -84,7 +85,7 @@ public class VillagerListeners implements Listener {
|
||||
@EventHandler
|
||||
public void onVillagerGainItemTrade(VillagerAcquireTradeEvent event) {
|
||||
|
||||
if(!Target.Applicable.ALL.getMaterials().contains(event.getRecipe().getResult().getType()))
|
||||
if(!EnchantmentTarget.ALL.contains(event.getRecipe().getResult().getType()))
|
||||
return;
|
||||
|
||||
if(event.getRecipe().getResult().getType().equals(Material.BOOK)) return;
|
||||
@ -118,6 +119,8 @@ public class VillagerListeners implements Listener {
|
||||
continue;
|
||||
if(!enchantment.canEnchantItem(result))
|
||||
continue;
|
||||
if(!enchantment.isEnabled())
|
||||
continue;
|
||||
|
||||
AtomicBoolean anyConflicts = new AtomicBoolean(false);
|
||||
toAdd.forEach((enchant, integer) -> {
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.naturalloot;
|
||||
import com.willfp.ecoenchants.config.ConfigManager;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
@ -38,7 +39,7 @@ public class LootPopulator extends BlockPopulator {
|
||||
|
||||
for(ItemStack item : inventory) {
|
||||
if(item == null) continue;
|
||||
if(!Target.Applicable.ALL.getMaterials().contains(item.getType())) continue;
|
||||
if(!EnchantmentTarget.ALL.contains(item.getType())) continue;
|
||||
if(item.getType().equals(Material.BOOK)) continue;
|
||||
|
||||
HashMap<Enchantment, Integer> toAdd = new HashMap<>();
|
||||
@ -47,7 +48,7 @@ public class LootPopulator extends BlockPopulator {
|
||||
Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis
|
||||
|
||||
double multiplier = 0.01;
|
||||
if (Target.Applicable.BOOK.getMaterials().contains(item.getType())) {
|
||||
if (item.getType().equals(Material.BOOK) || item.getType().equals(Material.ENCHANTED_BOOK)) {
|
||||
multiplier /= ConfigManager.getConfig().getInt("loot.book-times-less-likely");
|
||||
}
|
||||
|
||||
@ -64,6 +65,8 @@ public class LootPopulator extends BlockPopulator {
|
||||
continue;
|
||||
if(!enchantment.canEnchantItem(item))
|
||||
continue;
|
||||
if(!enchantment.isEnabled())
|
||||
continue;
|
||||
|
||||
AtomicBoolean anyConflicts = new AtomicBoolean(false);
|
||||
toAdd.forEach((enchant, integer) -> {
|
||||
|
Loading…
Reference in New Issue
Block a user