Changed enchant detection system

This commit is contained in:
Auxilor 2020-08-29 17:53:28 +01:00
parent 901cb281a5
commit 648e706f6f
154 changed files with 670 additions and 756 deletions

View File

@ -2,9 +2,9 @@ package com.willfp.ecoenchants.enchantments;
import com.google.common.util.concurrent.AtomicDouble;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -47,7 +47,7 @@ public abstract class Artifact extends EcoEnchant {
if(!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "on-blocks").contains(block.getType().name().toLowerCase())) return;
if (!HasEnchant.playerHeld(player, this)) return;
if(!EnchantChecks.mainhand(player, this)) return;
int amount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount");
block.getWorld().spawnParticle(particle, block.getLocation().add(0.5, 0.5, 0.5), amount, 0.4, 0.4, 0.4, 0, extra, false);
@ -59,7 +59,7 @@ public abstract class Artifact extends EcoEnchant {
if(!player.isGliding()) return;
if (!HasEnchant.playerElytra(player, this)) return;
if (!EnchantChecks.chestplate(player, this)) return;
Location location = player.getLocation();
Vector direction = player.getLocation().clone().getDirection();
@ -86,7 +86,7 @@ public abstract class Artifact extends EcoEnchant {
Player player = (Player) event.getDamager();
LivingEntity entity = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
double radius = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius");
@ -127,7 +127,7 @@ public abstract class Artifact extends EcoEnchant {
item = TridentStack.getTridentStack((Trident) entity);
}
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "particle-tick-delay");

View File

@ -0,0 +1,41 @@
package com.willfp.ecoenchants.enchantments.checks;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.Map;
public class ArrowListeners implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onLaunch(ProjectileLaunchEvent event) {
if(!(event.getEntity() instanceof Arrow))
return;
if(!(event.getEntity().getShooter() instanceof LivingEntity))
return;
Arrow arrow = (Arrow) event.getEntity();
LivingEntity entity = (LivingEntity) arrow.getShooter();
if(entity.getEquipment() == null)
return;
ItemStack item = entity.getEquipment().getItemInMainHand();
if(item == null) return;
if(item.getType().equals(Material.AIR)) return;
if(!item.hasItemMeta()) return;
if(item.getItemMeta() == null) return;
Map<Enchantment, Integer> enchantments = item.getItemMeta().getEnchants();
arrow.setMetadata("enchantments", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), enchantments));
}
}

View File

@ -0,0 +1,164 @@
package com.willfp.ecoenchants.enchantments.checks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import sun.nio.cs.ArrayEncoder;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@SuppressWarnings("unchecked")
public abstract class EnchantChecks {
public static boolean item(ItemStack item, Enchantment enchantment) {
return getItemLevel(item, enchantment) != 0;
}
public static int getItemLevel(ItemStack item, Enchantment enchantment) {
if(item == null) return 0;
if(item.getType().equals(Material.AIR)) return 0;
if(!item.hasItemMeta()) return 0;
if(item.getItemMeta() == null) return 0;
return item.getItemMeta().getEnchantLevel(enchantment);
}
public static boolean arrow(Arrow arrow, Enchantment enchantment) {
return getArrowLevel(arrow, enchantment) != 0;
}
public static int getArrowLevel(Arrow arrow, Enchantment enchantment) {
if (arrow.getMetadata("enchantments").isEmpty()) return 0;
MetadataValue enchantmentsMetaValue = arrow.getMetadata("enchantments").get(0);
if (!(enchantmentsMetaValue.value() instanceof Map))
return 0;
Map<Enchantment, Integer> enchantments = (Map<Enchantment, Integer>) enchantmentsMetaValue.value();
if (enchantments == null) return 0;
if(!enchantments.containsKey(enchantment)) return 0;
return enchantments.get(enchantment);
}
public static boolean mainhand(LivingEntity entity, Enchantment enchantment) {
return getMainhandLevel(entity, enchantment) != 0;
}
public static int getMainhandLevel(LivingEntity entity, Enchantment enchantment) {
if(entity.getEquipment() == null)
return 0;
ItemStack item = entity.getEquipment().getItemInMainHand();
return getItemLevel(item, enchantment);
}
public static boolean offhand(LivingEntity entity, Enchantment enchantment) {
return getOffhandLevel(entity, enchantment) != 0;
}
public static int getOffhandLevel(LivingEntity entity, Enchantment enchantment) {
if(entity.getEquipment() == null)
return 0;
ItemStack item = entity.getEquipment().getItemInOffHand();
return getItemLevel(item, enchantment);
}
public static int getArmorPoints(LivingEntity entity, Enchantment enchantment) {
return getArmorPoints(entity, enchantment, 0);
}
public static int getArmorPoints(LivingEntity entity, Enchantment enchantment, int damage) {
if(entity.getEquipment() == null)
return 0;
boolean isPlayer = entity instanceof Player;
AtomicInteger armorPoints = new AtomicInteger(0);
List<ItemStack> armor = Arrays.asList(entity.getEquipment().getArmorContents());
armor.forEach((itemStack -> {
int level = getItemLevel(itemStack, enchantment);
if(level != 0) {
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 (Target.Applicable.CHESTPLATE.getMaterials().contains(itemStack.getType())) {
ItemDurability.damageItem(player, player.getInventory().getChestplate(), 1, 38);
}
if (Target.Applicable.LEGGINGS.getMaterials().contains(itemStack.getType())) {
ItemDurability.damageItem(player, player.getInventory().getLeggings(), 1, 37);
}
if (Target.Applicable.BOOTS.getMaterials().contains(itemStack.getType())) {
ItemDurability.damageItem(player, player.getInventory().getBoots(), 1, 36);
}
}
}
}));
return armorPoints.get();
}
public static boolean helmet(LivingEntity entity, Enchantment enchantment) {
return getHelmetLevel(entity, enchantment) != 0;
}
public static int getHelmetLevel(LivingEntity entity, Enchantment enchantment) {
if(entity.getEquipment() == null)
return 0;
ItemStack item = entity.getEquipment().getHelmet();
return getItemLevel(item, enchantment);
}
public static boolean chestplate(LivingEntity entity, Enchantment enchantment) {
return getChestplateLevel(entity, enchantment) != 0;
}
public static int getChestplateLevel(LivingEntity entity, Enchantment enchantment) {
if(entity.getEquipment() == null)
return 0;
ItemStack item = entity.getEquipment().getChestplate();
return getItemLevel(item, enchantment);
}
public static boolean leggings(LivingEntity entity, Enchantment enchantment) {
return getLeggingsLevel(entity, enchantment) != 0;
}
public static int getLeggingsLevel(LivingEntity entity, Enchantment enchantment) {
if(entity.getEquipment() == null)
return 0;
ItemStack item = entity.getEquipment().getLeggings();
return getItemLevel(item, enchantment);
}
public static boolean boots(LivingEntity entity, Enchantment enchantment) {
return getBootsLevel(entity, enchantment) != 0;
}
public static int getBootsLevel(LivingEntity entity, Enchantment enchantment) {
if(entity.getEquipment() == null)
return 0;
ItemStack item = entity.getEquipment().getBoots();
return getItemLevel(item, enchantment);
}
}

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -22,7 +22,7 @@ public class BreaklessnessCurse extends EcoEnchant {
public void onDamageBlock(BlockDamageEvent event) {
Player player = event.getPlayer();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Rand.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance"))
return;

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.enchantments.EcoRunnable;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.LocationUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster;
@ -21,7 +21,7 @@ public class CallingCurse extends EcoEnchant implements EcoRunnable {
@Override
public void run() {
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().stream().filter(player -> HasEnchant.getArmorPoints(player, EcoEnchants.CALLING_CURSE, false) > 0).forEach((player -> {
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().stream().filter(player -> EnchantChecks.getArmorPoints(player, EcoEnchants.CALLING_CURSE, 0) > 0).forEach((player -> {
double distance = EcoEnchants.CALLING_CURSE.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
for (Entity e : player.getWorld().getNearbyEntities(player.getLocation(), distance, distance, distance)) {

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.enchantments.EcoRunnable;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Repairable;
@ -22,11 +22,11 @@ public class DecayCurse extends EcoEnchant implements EcoRunnable {
@Override
public void run() {
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().forEach((player -> {
if(Arrays.stream(player.getInventory().getContents()).parallel().noneMatch(item2 -> HasEnchant.item(item2, EcoEnchants.DECAY_CURSE)))
if(Arrays.stream(player.getInventory().getContents()).parallel().noneMatch(item2 -> EnchantChecks.item(item2, EcoEnchants.DECAY_CURSE)))
return;
for(ItemStack item : player.getInventory().getContents()) {
if(!HasEnchant.item(item, EcoEnchants.DECAY_CURSE)) continue;
if(!EnchantChecks.item(item, EcoEnchants.DECAY_CURSE)) continue;
if(!(item.getItemMeta() instanceof Repairable)) continue;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerItemDamageEvent;
@ -22,7 +22,7 @@ public class FragilityCurse extends EcoEnchant {
public void onItemDamage(PlayerItemDamageEvent event) {
ItemStack item = event.getItem();
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
int min = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "minimum-extra-durability");
int max = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "maximum-extra-durability");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
@ -31,7 +31,7 @@ public class HarmlessnessCurse extends EcoEnchant {
Player player = (Player) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Rand.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance"))
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -24,7 +24,7 @@ public class HungerCurse extends EcoEnchant {
Player player = (Player) event.getEntity();
if(!HasEnchant.playerHelmet(player, this)) return;
if(!EnchantChecks.helmet(player, this)) return;
if(event.getFoodLevel() > player.getFoodLevel()) return;
int delta = player.getFoodLevel() - event.getFoodLevel();

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -22,7 +22,7 @@ public class MisfortuneCurse extends EcoEnchant {
public void onBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Rand.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance"))
return;

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -40,9 +40,9 @@ public class Abrasion extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
boolean notcharged = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged");
if (Cooldown.getCooldown(player) != 1.0f && !notcharged)

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -22,36 +22,15 @@ public class Aerial extends EcoEnchant {
// START OF LISTENERS
@EventHandler
public void onShoot(ProjectileLaunchEvent event) {
if (event.getEntityType() != EntityType.ARROW)
return;
if (!(event.getEntity().getShooter() instanceof Player))
return;
Player player = (Player) event.getEntity().getShooter();
if(player.isOnGround())
return;
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!(event.getEntity() instanceof Arrow)) return;
Arrow a = (Arrow) event.getEntity();
a.setMetadata("from-aerial", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), level));
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Arrow))
return;
if (!event.getDamager().hasMetadata("from-aerial"))
return;
Arrow arrow = (Arrow) event.getDamager();
if(EnchantChecks.arrow(arrow, this)) return;
int level = event.getDamager().getMetadata("from-aerial").get(0).asInt();
int level = EnchantChecks.getArrowLevel(arrow, this);
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -43,9 +43,9 @@ public class Aquatic extends EcoEnchant {
if(!player.getLocation().getBlock().getType().equals(Material.WATER))
return;
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
int level = HasEnchant.getItemLevel(item, this);
int level = EnchantChecks.getItemLevel(item, this);
double perLevelDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-more-per-level");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,7 +28,7 @@ public class Arcanic extends EcoEnchant {
Player player = (Player) event.getEntity();
int totalArcanicPoints = HasEnchant.getArmorPoints(player, this, false);
int totalArcanicPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalArcanicPoints == 0)
return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.queue.DropQueue;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
@ -33,9 +33,9 @@ public class Beheading extends EcoEnchant {
LivingEntity victim = event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
if (Rand.randFloat(0, 1) > level * 0.01 * chance)

View File

@ -4,11 +4,11 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -32,7 +32,7 @@ public class BlastMining extends EcoEnchant {
return;
}
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (event.isCancelled())
return;

View File

@ -4,10 +4,10 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -39,12 +39,12 @@ public class Bleed extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
@ -35,16 +35,16 @@ public class Blind extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if(!AntigriefManager.canInjure(player, victim)) return;
if(event.isCancelled()) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boss;
import org.bukkit.entity.ElderGuardian;
@ -31,8 +31,8 @@ public class BossHunter extends EcoEnchant {
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.arrow(arrow, this)) return;
int level = EnchantChecks.getArrowLevel(arrow, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
@ -35,8 +35,8 @@ public class Buckshot extends EcoEnchant {
Player player = (Player) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.mainhand(player, this)) return;
int level = EnchantChecks.getMainhandLevel(player, this);
event.getProjectile().remove();
player.playSound(player.getLocation(), Sound.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0f, 1.0f);
@ -53,7 +53,7 @@ public class Buckshot extends EcoEnchant {
velocity.add(new Vector(Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread)));
Arrow arrow = player.launchProjectile(Arrow.class, velocity);
if(HasEnchant.playerHeld(player, Enchantment.ARROW_FIRE)) arrow.setFireTicks(Integer.MAX_VALUE);
if(EnchantChecks.mainhand(player, Enchantment.ARROW_FIRE)) arrow.setFireTicks(Integer.MAX_VALUE);
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
}
}

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
@ -30,9 +30,9 @@ public class Butchering extends EcoEnchant {
Player player = (Player) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
event.setDamage(event.getDamage() + (level * multiplier));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -34,8 +34,8 @@ public class Cerebral extends EcoEnchant {
if (!(arrow.getLocation().getY() >= victim.getLocation().getY() + victim.getEyeHeight() - 0.22)) return;
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.arrow(arrow, this)) return;
int level = EnchantChecks.getArrowLevel(arrow, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -31,7 +31,7 @@ public class Chopless extends EcoEnchant {
if(!Target.Applicable.AXE.getMaterials().contains(damager.getInventory().getItemInMainHand().getType()))
return;
int totalChoplessPoints = HasEnchant.getArmorPoints(player, this, true);
int totalChoplessPoints = EnchantChecks.getArmorPoints(player, this, 1);
if (totalChoplessPoints == 0)
return;

View File

@ -4,10 +4,10 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -39,12 +39,12 @@ public class Cleave extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double damagePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-percentage-per-level") * 0.01;
double radiusPerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-per-level");

View File

@ -2,8 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -28,9 +28,9 @@ public class Collateral extends EcoEnchant {
Player player = (Player) event.getEntity().getShooter();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if (!(event.getEntity() instanceof Arrow)) return;
Arrow a = (Arrow) event.getEntity();

View File

@ -1,13 +1,10 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.comphenix.protocol.PacketType;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
@ -43,12 +40,13 @@ public class Corrosive extends EcoEnchant {
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Player victim = (Player) event.getEntity();
Arrow arrow = (Arrow) event.getDamager();
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
ArrayList<ItemStack> armor = new ArrayList<ItemStack>(Arrays.asList(victim.getInventory().getArmorContents()));
if (armor.isEmpty())

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
@ -38,8 +38,8 @@ public class Cranial extends EcoEnchant {
ItemStack item = TridentStack.getTridentStack(trident);
if (!HasEnchant.item(item, this)) return;
int level = HasEnchant.getItemLevel(item, this);
if (!EnchantChecks.item(item, this)) return;
int level = EnchantChecks.getItemLevel(item, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -29,12 +29,12 @@ public class Criticals extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (!(player.getFallDistance() > 0 && !player.isOnGround()))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
event.setDamage(event.getDamage() * ((level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level")) + 1));
}

View File

@ -2,8 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
@ -30,10 +30,11 @@ public class Defender extends EcoEnchant {
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Tameable entity = (Tameable) event.getEntity();
Arrow arrow = (Arrow) event.getDamager();
if(entity.getOwner() == null) return;
if(!entity.getOwner().equals(player)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
event.setCancelled(true);
}

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -36,9 +36,9 @@ public class Deflection extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
int level;
if (!HasEnchant.playerOffhand(player, this) && !HasEnchant.playerHeld(player, this)) return;
if(HasEnchant.playerOffhand(player, this)) level = HasEnchant.getPlayerOffhandLevel(player, this);
else level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.offhand(player, this) && !EnchantChecks.mainhand(player, this)) return;
if(EnchantChecks.offhand(player, this)) level = EnchantChecks.getOffhandLevel(player, this);
else level = EnchantChecks.getMainhandLevel(player, this);
double perlevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-deflected-per-level");
double damagePercent = (perlevel/100) * level;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -29,9 +29,9 @@ public class Defusion extends EcoEnchant {
Creeper victim = (Creeper) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
event.setDamage(event.getDamage() + (level * multiplier));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -25,13 +25,13 @@ public class Dexterous extends EcoEnchant {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItem(event.getNewSlot());
if (!HasEnchant.item(item, this)) {
if (!EnchantChecks.item(item, this)) {
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0);
return;
}
int level = HasEnchant.getItemLevel(item, this);
int level = EnchantChecks.getItemLevel(item, this);
double bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "add-speed-per-level");
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(4.0 + (level * bonus));
}

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -32,7 +32,7 @@ public class Disappear extends EcoEnchant {
if(player.getHealth() > EcoEnchants.DISAPPEAR.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "threshold"))
return;
final int points = HasEnchant.getArmorPoints(player, this, true);
final int points = EnchantChecks.getArmorPoints(player, this, 1);
if (points == 0)
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -31,9 +31,9 @@ public class Diurnal extends EcoEnchant {
if(!(player.getWorld().getTime() < 12300 && player.getWorld().getTime() > 23850)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -31,9 +31,9 @@ public class Diverse extends EcoEnchant {
if(!Target.Applicable.SWORD.getMaterials().contains(victim.getInventory().getItemInMainHand().getType()))
return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -4,11 +4,11 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.SimplifyVector;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -35,7 +35,7 @@ public class Drill extends EcoEnchant {
return;
}
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (event.isCancelled())
return;
@ -44,7 +44,7 @@ public class Drill extends EcoEnchant {
if(player.isSneaking() && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-sneak")) return;
int level = HasEnchant.getPlayerLevel(player, this) * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level");
int level = EnchantChecks.getMainhandLevel(player, this) * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level");
AnticheatManager.exemptPlayer(player);

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -36,12 +36,12 @@ public class Dullness extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Lightning;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
@ -38,9 +38,9 @@ public class Electroshock extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
int level;
if (!HasEnchant.playerOffhand(player, this) && !HasEnchant.playerHeld(player, this)) return;
if(HasEnchant.playerOffhand(player, this)) level = HasEnchant.getPlayerOffhandLevel(player, this);
else level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.offhand(player, this) && !EnchantChecks.mainhand(player, this)) return;
if(EnchantChecks.offhand(player, this)) level = EnchantChecks.getOffhandLevel(player, this);
else level = EnchantChecks.getMainhandLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -29,9 +29,9 @@ public class EndInfusion extends EcoEnchant {
if(!player.getWorld().getEnvironment().equals(World.Environment.THE_END))
return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -38,9 +38,9 @@ public class EnderSlayer extends EcoEnchant {
Player player = (Player) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
event.setDamage(event.getDamage() + (level * multiplier));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.World;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
@ -28,14 +28,15 @@ public class Enderism extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
assert player != null;
if(!player.getWorld().getEnvironment().equals(World.Environment.THE_END))
return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -25,7 +25,7 @@ public class Evasion extends EcoEnchant {
Player player = (Player) event.getEntity();
int totalEvasionPoints = HasEnchant.getArmorPoints(player, this, true);
int totalEvasionPoints = EnchantChecks.getArmorPoints(player, this, 1);
if (totalEvasionPoints == 0)
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,7 +28,7 @@ public class Extinguishing extends EcoEnchant {
Player player = (Player) event.getEntity();
int totalExtinguishingPoints = HasEnchant.getArmorPoints(player, this, false);
int totalExtinguishingPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalExtinguishingPoints == 0)
return;

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -43,9 +43,9 @@ public class Extract extends EcoEnchant {
if(!AntigriefManager.canInjure(player, (LivingEntity) event.getEntity())) return;
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
int level = HasEnchant.getItemLevel(item, this);
int level = EnchantChecks.getItemLevel(item, this);
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -36,12 +36,12 @@ public class Famine extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.Cube;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import com.willfp.ecoenchants.util.Square;
import org.bukkit.Location;
@ -42,7 +42,7 @@ public class Farmhand extends EcoEnchant {
ItemStack item = event.getItem();
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
if (!(Target.Applicable.HOE.getMaterials().contains(item.getType())))
return;
@ -52,7 +52,7 @@ public class Farmhand extends EcoEnchant {
event.getClickedBlock().setType(Material.FARMLAND);
int initial = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius");
int levelrad = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius");
int radius = initial + (HasEnchant.getItemLevel(item, this) - 1) * levelrad;
int radius = initial + (EnchantChecks.getItemLevel(item, this) - 1) * levelrad;
Vector[] vecs;
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-cube")) {

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -30,11 +30,11 @@ public class Finality extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.arrow(arrow, this)) return;
int level = EnchantChecks.getArrowLevel(arrow, this);
double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level");
if (!(((LivingEntity) event.getEntity()).getHealth() <= level * minhealth))

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -29,8 +29,8 @@ public class Finishing extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.mainhand(player, this)) return;
int level = EnchantChecks.getMainhandLevel(player, this);
double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level");
if (!(((LivingEntity) event.getEntity()).getHealth() <= level * minhealth))

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -27,11 +27,11 @@ public class FireAffinity extends EcoEnchant {
Player player = (Player) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if(player.getFireTicks() == 0) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-more-per-level");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -30,12 +30,12 @@ public class FirstStrike extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (!(((LivingEntity) event.getEntity()).getHealth() == ((LivingEntity) event.getEntity()).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double damagemultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");
event.setDamage(event.getDamage() * ((level * damagemultiplier) + 1));

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -39,9 +39,9 @@ public class Flinch extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
int level;
if (!HasEnchant.playerOffhand(player, this) && !HasEnchant.playerHeld(player, this)) return;
if(HasEnchant.playerOffhand(player, this)) level = HasEnchant.getPlayerOffhandLevel(player, this);
else level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.offhand(player, this) && !EnchantChecks.mainhand(player, this)) return;
if(EnchantChecks.offhand(player, this)) level = EnchantChecks.getOffhandLevel(player, this);
else level = EnchantChecks.getMainhandLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.enchantments.EcoRunnable;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Monster;
public class Forcefield extends EcoEnchant implements EcoRunnable {
@ -18,8 +18,8 @@ public class Forcefield extends EcoEnchant implements EcoRunnable {
@Override
public void run() {
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().stream().filter(player -> HasEnchant.getArmorPoints(player, EcoEnchants.FORCEFIELD, false) > 0).forEach((player -> {
int level = HasEnchant.getArmorPoints(player, EcoEnchants.FORCEFIELD, false);
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().stream().filter(player -> EnchantChecks.getArmorPoints(player, EcoEnchants.FORCEFIELD, 0) > 0).forEach((player -> {
int level = EnchantChecks.getArmorPoints(player, EcoEnchants.FORCEFIELD, 0);
double initialDistance = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
double bonus = EcoEnchants.FORCEFIELD.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
@ -32,7 +32,7 @@ public class Forcefield extends EcoEnchant implements EcoRunnable {
((Monster) e).damage(damage, player);
HasEnchant.getArmorPoints(player, EcoEnchants.FORCEFIELD, true);
EnchantChecks.getArmorPoints(player, EcoEnchants.FORCEFIELD, 1);
}
}));
}

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,8 +28,8 @@ public class Freerunner extends EcoEnchant {
Player player = (Player) event.getEntity();
if(!HasEnchant.playerBoots(player, this)) return;
int level = HasEnchant.getPlayerBootsLevel(player, this);
if(!EnchantChecks.boots(player, this)) return;
int level = EnchantChecks.getBootsLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@ -34,7 +34,7 @@ public class Frozen extends EcoEnchant {
Player player = (Player) event.getEntity();
LivingEntity victim = (LivingEntity) event.getDamager();
final int points = HasEnchant.getArmorPoints(player, this, true);
final int points = EnchantChecks.getArmorPoints(player, this, 1);
if (points == 0)
return;

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.LocationUtils;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.*;
@ -35,12 +35,12 @@ public class Fury extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -30,12 +30,12 @@ public class Goliath extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (victim.getHealth() <= player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double timesMoreHealth = victim.getHealth() / player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -37,9 +37,9 @@ public class Grapple extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier");
Vector vector = player.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier);

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -34,7 +34,7 @@ public class GreenThumb extends EcoEnchant {
if (!event.getClickedBlock().getType().equals(Material.DIRT))
return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if(!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.ItemDurability;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -33,7 +33,7 @@ public class Grit extends EcoEnchant {
if(!AntigriefManager.canInjure(attacker, player)) return;
int totalGritPoints = HasEnchant.getArmorPoints(player, this, false);
int totalGritPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalGritPoints == 0)
return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -33,16 +33,16 @@ public class Hook extends EcoEnchant {
if(event.isCancelled()) return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if(victim.hasMetadata("NPC")) return;
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier");
Vector vector = player.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier);

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -25,9 +25,9 @@ public class Horde extends EcoEnchant {
Player player = (Player) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level") * level;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
@ -34,16 +34,16 @@ public class IceShot extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if(!AntigriefManager.canInjure(player, victim)) return;
if(event.isCancelled()) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -26,7 +26,7 @@ public class Ignite extends EcoEnchant {
@EventHandler
public void onLand(ProjectileHitEvent event) {
if (event.getEntityType() != EntityType.ARROW)
if (!(event.getEntity() instanceof Arrow))
return;
if (!(event.getEntity().getShooter() instanceof Player))
@ -36,14 +36,12 @@ public class Ignite extends EcoEnchant {
return;
Block block = event.getHitBlock();
Arrow arrow = (Arrow) event.getEntity();
Player player = (Player) event.getEntity().getShooter();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
if (!(event.getEntity() instanceof Arrow)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
float power = (float) (0.5 + (level * 0.5));

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -35,12 +35,12 @@ public class IllusionAspect extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
if (Rand.randFloat(0, 1) > level * 0.01 * chance)

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ public class Incandescence extends EcoEnchant {
Player player = (Player) event.getEntity();
LivingEntity victim = (LivingEntity) event.getDamager();
int totalIncandescencePoints = HasEnchant.getArmorPoints(player, this, true);
int totalIncandescencePoints = EnchantChecks.getArmorPoints(player, this, 1);
if (totalIncandescencePoints == 0)
return;

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.queue.DropQueue;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -38,7 +38,7 @@ public class InfernalTouch extends EcoEnchant {
Player player = event.getPlayer();
Block block = event.getBlock();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)
return;
@ -87,13 +87,13 @@ public class InfernalTouch extends EcoEnchant {
if(drop.getType().equals(Material.IRON_INGOT)) {
experience += 1;
if(HasEnchant.playerHeld(player, Enchantment.LOOT_BONUS_BLOCKS)) {
int level = HasEnchant.getPlayerLevel(player, LOOT_BONUS_BLOCKS);
if(EnchantChecks.mainhand(player, Enchantment.LOOT_BONUS_BLOCKS)) {
int level = EnchantChecks.getMainhandLevel(player, LOOT_BONUS_BLOCKS);
drop.setAmount((int) Math.ceil(1/((double) level + 2) + ((double) level + 1)/2));
}
} else if(drop.getType().equals(Material.GOLD_INGOT)) {
if(HasEnchant.playerHeld(player, Enchantment.LOOT_BONUS_BLOCKS)) {
int level = HasEnchant.getPlayerLevel(player, LOOT_BONUS_BLOCKS);
if(EnchantChecks.mainhand(player, Enchantment.LOOT_BONUS_BLOCKS)) {
int level = EnchantChecks.getMainhandLevel(player, LOOT_BONUS_BLOCKS);
drop.setAmount((int) Math.ceil(1/((double) level + 2) + ((double) level + 1)/2));
}
}

View File

@ -2,9 +2,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
@ -33,7 +33,7 @@ public class Inferno extends EcoEnchant {
Trident trident = (Trident) event.getEntity();
ItemStack item = TridentStack.getTridentStack(trident);
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
trident.setFireTicks(Integer.MAX_VALUE);
}
@ -49,7 +49,7 @@ public class Inferno extends EcoEnchant {
ItemStack item = TridentStack.getTridentStack(trident);
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
if(trident.getFireTicks() <= 0) return;
victim.setFireTicks(100);

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -23,9 +23,9 @@ public class Instantaneous extends EcoEnchant {
public void onDamageBlock(BlockDamageEvent event) {
Player player = event.getPlayer();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -28,7 +28,7 @@ public class Invigoration extends EcoEnchant {
if (player.getHealth() > this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "below-health"))
return;
int totalInvigorationPoints = HasEnchant.getArmorPoints(player, this, false);
int totalInvigorationPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalInvigorationPoints == 0)
return;
@ -47,7 +47,7 @@ public class Invigoration extends EcoEnchant {
if (player.getHealth() > this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "below-health"))
return;
int totalInvigorationPoints = HasEnchant.getArmorPoints(player, this, false);
int totalInvigorationPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalInvigorationPoints == 0)
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
@ -26,9 +26,9 @@ public class Kinetic extends EcoEnchant {
Player player = (Player) event.getEntity();
if(!HasEnchant.playerElytra(player, this)) return;
if(!EnchantChecks.chestplate(player, this)) return;
int level = HasEnchant.getPlayerChestplateLevel(player, this);
int level = EnchantChecks.getChestplateLevel(player, this);
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level");
double multiplier = 1 - ((reduction/100) * level);

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -35,9 +35,9 @@ public class Launch extends EcoEnchant {
if(!player.isGliding())
return;
if(!HasEnchant.playerElytra(player, this)) return;
if(!EnchantChecks.chestplate(player, this)) return;
int level = HasEnchant.getPlayerChestplateLevel(player, this);
int level = EnchantChecks.getChestplateLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
double boost = 1 + (multiplier * level);

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -35,9 +35,9 @@ public class Leeching extends EcoEnchant {
if(!AntigriefManager.canInjure(player, (LivingEntity) event.getEntity())) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
@ -34,16 +34,16 @@ public class Levitate extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if(!AntigriefManager.canInjure(player, victim)) return;
if(event.isCancelled()) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -26,13 +26,14 @@ public class LiquidShot extends EcoEnchant {
if (!(event.getEntity() instanceof LivingEntity)) return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if(!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman))
return;
if (!HasEnchant.playerHeld(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
if (!EnchantChecks.arrow(arrow, this)) return;
int level = EnchantChecks.getArrowLevel(arrow, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");

View File

@ -4,11 +4,11 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.BlockBreak;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.RecursiveBlock;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -40,7 +40,7 @@ public class Lumberjack extends EcoEnchant {
return;
}
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (event.isCancelled())
return;
@ -56,7 +56,7 @@ public class Lumberjack extends EcoEnchant {
return;
int blocksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "blocks-per-level");
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
int limit = level * blocksPerLevel;
Set<Block> treeBlocks = RecursiveBlock.getVein(block, materials, limit);

View File

@ -4,11 +4,11 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.Circle;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -36,10 +36,10 @@ public class MagmaWalker extends EcoEnchant {
if(event.getTo() == null) return;
if(event.getFrom().getBlock().equals(event.getTo().getBlock())) return;
if (!HasEnchant.playerBoots(player, this)) return;
if (!EnchantChecks.boots(player, this)) return;
Vector[] circle = Circle.getCircle(this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius")
+ (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius") * HasEnchant.getPlayerBootsLevel(player, this) - 1));
+ (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius") * EnchantChecks.getBootsLevel(player, this) - 1));
AnticheatManager.exemptPlayer(player);

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.enchantments.EcoRunnable;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.LocationUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
@ -21,8 +21,8 @@ public class Magnetic extends EcoEnchant implements EcoRunnable {
@Override
public void run() {
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().stream().filter(player -> HasEnchant.getArmorPoints(player, EcoEnchants.MAGNETIC, false) > 0).forEach((player -> {
int level = HasEnchant.getArmorPoints(player, EcoEnchants.MAGNETIC, false);
EcoEnchantsPlugin.getInstance().getServer().getOnlinePlayers().stream().filter(player -> EnchantChecks.getArmorPoints(player, EcoEnchants.MAGNETIC, 0) > 0).forEach((player -> {
int level = EnchantChecks.getArmorPoints(player, EcoEnchants.MAGNETIC, 0);
double initialDistance = EcoEnchants.MAGNETIC.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
double bonus = EcoEnchants.MAGNETIC.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");

View File

@ -4,9 +4,9 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Bukkit;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
@ -37,14 +37,14 @@ public class Marking extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if (!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
int ticks = ticksPerLevel * level;

View File

@ -4,8 +4,8 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ public class Marksman extends EcoEnchant {
Player player = (Player) event.getEntity().getShooter();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (!(event.getEntity() instanceof Arrow)) return;
Arrow a = (Arrow) event.getEntity();

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.queue.DropQueue;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -32,9 +32,9 @@ public class Necrotic extends EcoEnchant {
Player player = event.getEntity().getKiller();
WitherSkeleton victim = (WitherSkeleton) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
if (Rand.randFloat(0, 1) > level * 0.01 * chance)

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,9 +28,9 @@ public class NetherInfusion extends EcoEnchant {
if(!player.getWorld().getEnvironment().equals(World.Environment.NETHER))
return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.World;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
@ -28,14 +28,15 @@ public class Netheric extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
assert player != null;
if(!player.getWorld().getEnvironment().equals(World.Environment.NETHER))
return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -30,9 +30,9 @@ public class Nocturnal extends EcoEnchant {
if(!(player.getWorld().getTime() > 12300 && player.getWorld().getTime() < 23850)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "per-level-multiplier");
event.setDamage(event.getDamage() * (1 + (level * multiplier)));

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Location;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
@ -28,14 +28,14 @@ public class Optics extends EcoEnchant {
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
Location land = arrow.getLocation();
Location source = player.getLocation();
double distance = land.distance(source);
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "block-multiplier");

View File

@ -3,10 +3,10 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.EqualIfOver;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -25,7 +25,7 @@ public class Oxygenate extends EcoEnchant {
Player player = event.getPlayer();
Block block = event.getBlock();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if (event.isCancelled())
return;
@ -34,7 +34,7 @@ public class Oxygenate extends EcoEnchant {
if(player.getRemainingAir() == player.getMaximumAir()) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
int oxygenLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "oxygen-per-level");
int oxygen = level * oxygenLevel;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -30,11 +30,11 @@ public class Paladin extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
if(!(player.getVehicle() instanceof Horse)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
event.setDamage(event.getDamage() * ((level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level")) + 1));
}

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
@ -36,12 +36,12 @@ public class Parasitic extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
if(!AntigriefManager.canInjure(player, (LivingEntity) event.getEntity())) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -27,9 +27,9 @@ public class Parry extends EcoEnchant {
Player player = (Player) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level");

View File

@ -2,8 +2,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
@ -29,7 +29,7 @@ public class Protector extends EcoEnchant {
if(entity.getOwner() == null) return;
if(!entity.getOwner().equals(player)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
event.setCancelled(true);
}

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -29,13 +29,13 @@ public class Proximity extends EcoEnchant {
LivingEntity victim = (LivingEntity) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
double distance = player.getLocation().distance(victim.getLocation());
double decreaseAfter = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "when-closer-than-blocks");
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
if(distance <= decreaseAfter) {
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-more-per-level");

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -42,9 +42,9 @@ public class Puncture extends EcoEnchant {
if(!(victim instanceof Turtle || victim instanceof Shulker))
return;
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
int level = HasEnchant.getItemLevel(item, this);
int level = EnchantChecks.getItemLevel(item, this);
double perLevelDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-more-per-level");

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -32,9 +32,9 @@ public class Radiance extends EcoEnchant {
Arrow arrow = (Arrow) event.getEntity();
Player player = (Player) event.getEntity().getShooter();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
double radius = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier");
int duration = level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");

View File

@ -3,10 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Cooldown;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.LocationUtils;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.*;
@ -33,14 +32,14 @@ public class Rage extends EcoEnchant {
return;
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
Arrow arrow = (Arrow) event.getDamager();
LivingEntity victim = (LivingEntity) event.getEntity();
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.arrow(arrow, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getArrowLevel(arrow, this);
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,9 +28,9 @@ public class Rapid extends EcoEnchant {
Player player = (Player) event.getEntity();
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double multiplier = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-faster-per-level")/100) * level);

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -36,9 +36,9 @@ public class Reel extends EcoEnchant {
if(!AntigriefManager.canInjure(player, victim)) return;
if (!HasEnchant.playerHeld(player, this)) return;
if (!EnchantChecks.mainhand(player, this)) return;
int level = HasEnchant.getPlayerLevel(player, this);
int level = EnchantChecks.getMainhandLevel(player, this);
double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier");
Vector vector = player.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier);

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
@ -26,9 +26,9 @@ public class Reinforcement extends EcoEnchant {
Player player = (Player) event.getEntity();
if(!HasEnchant.playerElytra(player, this)) return;
if(!EnchantChecks.chestplate(player, this)) return;
int level = HasEnchant.getPlayerChestplateLevel(player, this);
int level = EnchantChecks.getChestplateLevel(player, this);
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level");
double multiplier = 1 - ((reduction/100) * level);

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityRegainHealthEvent;
@ -27,7 +27,7 @@ public class Rejuvenation extends EcoEnchant {
Player player = (Player) event.getEntity();
int totalRejuvenationPoints = HasEnchant.getArmorPoints(player, this, false);
int totalRejuvenationPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalRejuvenationPoints == 0)
return;

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.Ageable;
@ -28,7 +28,7 @@ public class Replenish extends EcoEnchant {
Block block = event.getBlock();
Material type = block.getType();
if(!HasEnchant.playerHeld(player, this)) return;
if(!EnchantChecks.mainhand(player, this)) return;
if(!AntigriefManager.canBreakBlock(player, block)) return;
if(event.isCancelled()) return;

View File

@ -3,8 +3,8 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.HasEnchant;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -25,10 +25,10 @@ public class Sating extends EcoEnchant {
Player player = (Player) event.getEntity();
if(!HasEnchant.playerHelmet(player, this)) return;
if(!EnchantChecks.helmet(player, this)) return;
if(event.getFoodLevel() > player.getFoodLevel()) return;
int level = HasEnchant.getPlayerHelmetLevel(player, this);
int level = EnchantChecks.getHelmetLevel(player, this);
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");

View File

@ -3,9 +3,9 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.nms.TridentStack;
import com.willfp.ecoenchants.util.HasEnchant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
@ -40,9 +40,9 @@ public class Serrated extends EcoEnchant {
ItemStack item = TridentStack.getTridentStack(trident);
if (!HasEnchant.item(item, this)) return;
if (!EnchantChecks.item(item, this)) return;
int level = HasEnchant.getItemLevel(item, this);
int level = EnchantChecks.getItemLevel(item, this);
double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-more-base");
double perLevelDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-more-per-level");

Some files were not shown because too many files have changed in this diff Show More