diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index b20ccacf..beeb8091 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Numeral; +import com.willfp.ecoenchants.util.NumberUtils; import org.apache.commons.lang.WordUtils; import org.bukkit.ChatColor; import org.bukkit.NamespacedKey; @@ -210,7 +210,7 @@ public class EnchantDisplay { if(!(isMaxLevelOne || type == EcoEnchant.EnchantmentType.CURSE)) { if (useNumerals && finalItem.getEnchantmentLevel(enchantment) < numbersThreshold) { - name += " " + Numeral.getNumeral(integer); + name += " " + NumberUtils.toNumeral(integer); } else { name += " " + integer; } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/Artifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/Artifact.java index 1f9323a1..44f710eb 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/Artifact.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/Artifact.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.block.Block; @@ -94,7 +94,7 @@ public abstract class Artifact extends EcoEnchant { double yDelta = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "y-delta"); double radiusMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier"); - double offset = Rand.randFloat(0, 0.75); + double offset = NumberUtils.randFloat(0, 0.75); new BukkitRunnable() { @Override @@ -134,7 +134,7 @@ public abstract class Artifact extends EcoEnchant { int noteColor = 0; AtomicDouble color = new AtomicDouble(0); if(particle.equals(Particle.NOTE)) { - noteColor = Rand.randInt(0, 24); + noteColor = NumberUtils.randInt(0, 24); color.set((double) noteColor/24); } final double finalColor = color.get(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java index 6c4f9bac..b923fbf7 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/BreaklessnessCurse.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockDamageEvent; @@ -24,7 +24,7 @@ public class BreaklessnessCurse extends EcoEnchant { if (!EnchantChecks.mainhand(player, this)) return; - if (Rand.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance")) + if (NumberUtils.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance")) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java index ac85b9a6..b4455dd8 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/CallingCurse.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoRunnable; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.LocationUtils; +import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.Monster; import org.bukkit.entity.PigZombie; @@ -35,7 +35,7 @@ public class CallingCurse extends EcoEnchant implements EcoRunnable { Vector vector = player.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); - if(LocationUtils.isFinite(vector)) { + if(VectorUtils.isFinite(vector)) { e.setVelocity(vector); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java index 209a7926..4388e0a2 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/FragilityCurse.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; @@ -27,6 +27,6 @@ public class FragilityCurse extends EcoEnchant { int min = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "minimum-extra-durability"); int max = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "maximum-extra-durability"); - event.setDamage(event.getDamage() * Rand.randInt(min, max)); + event.setDamage(event.getDamage() * NumberUtils.randInt(min, max)); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java index 33e9eb3c..c229998b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/HarmlessnessCurse.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; @@ -33,7 +33,7 @@ public class HarmlessnessCurse extends EcoEnchant { if (!EnchantChecks.mainhand(player, this)) return; - if (Rand.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance")) + if (NumberUtils.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance")) return; event.setDamage(0); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java index 4523726b..8f4001ea 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/InaccuracyCurse.java @@ -5,12 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.AbstractArrow; -import org.bukkit.entity.Arrow; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -42,7 +37,7 @@ public class InaccuracyCurse extends EcoEnchant { Vector velocity = event.getProjectile().getVelocity().clone(); - velocity.add(new Vector(Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread))); + velocity.add(new Vector(NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread))); event.getProjectile().setVelocity(velocity); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java index d6a7b9f1..fe3821cb 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/MisfortuneCurse.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; @@ -24,7 +24,7 @@ public class MisfortuneCurse extends EcoEnchant { if (!EnchantChecks.mainhand(player, this)) return; - if (Rand.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance")) + if (NumberUtils.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance")) return; event.setDropItems(false); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java index 0e29bcae..2ca4ef1d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Arcanic.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; @@ -34,7 +34,7 @@ public class Arcanic extends EcoEnchant { return; double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point"); - if (Rand.randFloat(0, 1) > totalArcanicPoints * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > totalArcanicPoints * 0.01 * chance) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java index 7a9c33ff..be06f08e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Beheading.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.queue.DropQueue; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -38,7 +38,7 @@ public class Beheading extends EcoEnchant { 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) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; ItemStack item; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java index 7a28ed31..6e48b904 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Bleed.java @@ -8,7 +8,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -45,7 +45,7 @@ public class Bleed extends EcoEnchant { return; int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java index 634b937b..3b0eba03 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Blind.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,7 +46,7 @@ public class Blind extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java index 1b04f2fd..654f45a7 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/BlockBreather.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; @@ -34,7 +34,7 @@ public class BlockBreather extends EcoEnchant { double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); - if (Rand.randFloat(0, 1) > level * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java index 76d784f9..beaefa92 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Buckshot.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Sound; import org.bukkit.SoundCategory; import org.bukkit.enchantments.Enchantment; @@ -50,7 +50,7 @@ public class Buckshot extends EcoEnchant { Vector velocity = event.getProjectile().getVelocity().clone(); - velocity.add(new Vector(Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread))); + velocity.add(new Vector(NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread), NumberUtils.randFloat(-spread, spread))); Arrow arrow = player.launchProjectile(Arrow.class, velocity); if(EnchantChecks.mainhand(player, Enchantment.ARROW_FIRE)) arrow.setFireTicks(Integer.MAX_VALUE); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java index cc58b4ab..2d845c4b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java @@ -6,10 +6,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.Rand; -import org.bukkit.entity.Arrow; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.entity.Trident; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -38,7 +36,7 @@ public class Conclude extends EcoEnchant { if (!EnchantChecks.item(item, this)) return; int level = EnchantChecks.getItemLevel(item, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java index 47b989e0..38306788 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Disable.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -44,7 +44,7 @@ public class Disable extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 10, 5)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java index 8ff834ab..9155e856 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Drill.java @@ -9,7 +9,7 @@ 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.SimplifyVector; +import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -49,7 +49,7 @@ public class Drill extends EcoEnchant { AnticheatManager.exemptPlayer(player); for(int i = 1; i <= level; i++) { - Vector simplified = SimplifyVector.simplifyVector(player.getLocation().getDirection().normalize()).multiply(i); + Vector simplified = VectorUtils.simplifyVector(player.getLocation().getDirection().normalize()).multiply(i); Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified)); block1.setMetadata("from-drill", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java index ff98db34..2d1748d6 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Dullness.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,7 +43,7 @@ public class Dullness extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; int durationPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java index a0e6665c..06d3f21e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Electroshock.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.util.Lightning; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -46,7 +46,7 @@ public class Electroshock extends EcoEnchant { double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage"); double finalChance = (chance * level)/100; - if(Rand.randFloat(0, 1) > finalChance) return; + if(NumberUtils.randFloat(0, 1) > finalChance) return; Lightning.strike(victim, damage); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java index c01195f6..d0a8f6f5 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Evasion.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; @@ -32,7 +32,7 @@ public class Evasion extends EcoEnchant { double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point"); - if (Rand.randFloat(0, 1) > totalEvasionPoints * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > totalEvasionPoints * 0.01 * chance) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java index 612d6558..47a8e9b3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Extinguishing.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; @@ -34,7 +34,7 @@ public class Extinguishing extends EcoEnchant { return; double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point"); - if (Rand.randFloat(0, 1) > totalExtinguishingPoints * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > totalExtinguishingPoints * 0.01 * chance) return; player.setFireTicks(0); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java index 389d811f..61c838bd 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Famine.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,7 +43,7 @@ public class Famine extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, level * 40, level)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java index ec8bcbaa..17162ad0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Farmhand.java @@ -6,9 +6,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.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.ItemDurability; -import com.willfp.ecoenchants.util.Square; +import com.willfp.ecoenchants.util.VectorShapes; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -56,9 +55,9 @@ public class Farmhand extends EcoEnchant { Vector[] vecs; if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "use-cube")) { - vecs = Cube.getCube(radius); + vecs = VectorShapes.getCube(radius); } else { - vecs = Square.getSquare(radius); + vecs = VectorShapes.getSquare(radius); } if (!this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "per-block-damage")) { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java index 796cfdb3..5bbed7d7 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -37,7 +37,7 @@ public class Finality extends EcoEnchant { if (!EnchantChecks.arrow(arrow, this)) return; int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java index ab6d6753..20a456eb 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -33,7 +33,7 @@ public class Finishing extends EcoEnchant { if (!EnchantChecks.mainhand(player, this)) return; int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java index e5008fa0..0f1ff104 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Flinch.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -47,7 +47,7 @@ public class Flinch extends EcoEnchant { int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); double finalChance = (chance * level)/100; - if(Rand.randFloat(0, 1) > finalChance) return; + if(NumberUtils.randFloat(0, 1) > finalChance) return; int finalDuration = duration * level; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java index 0aec2092..edac4cc8 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Freerunner.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; @@ -33,7 +33,7 @@ public class Freerunner extends EcoEnchant { double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); - if (Rand.randFloat(0, 1) > level * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java index 48e75f96..19d77ba6 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Frozen.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -39,7 +39,7 @@ public class Frozen extends EcoEnchant { if (points == 0) return; - if (Rand.randFloat(0, 1) > points * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point")) + if (NumberUtils.randFloat(0, 1) > points * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point")) return; int divisor = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "points-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java index b7d5010b..69b42bd7 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java @@ -7,8 +7,8 @@ import com.willfp.ecoenchants.enchantments.util.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.LocationUtils; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.VectorUtils; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -42,7 +42,7 @@ public class Fury extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); @@ -59,7 +59,7 @@ public class Fury extends EcoEnchant { Vector vector = player.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); - if(LocationUtils.isFinite(vector)) { + if(VectorUtils.isFinite(vector)) { e.setVelocity(vector); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java index 965c3bab..85290b59 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Graceful.java @@ -5,8 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; -import org.bukkit.Bukkit; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -38,7 +37,7 @@ public class Graceful extends EcoEnchant { if(!EnchantChecks.boots(player, this)) return; int level = EnchantChecks.getBootsLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 5, false, false, true)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java index e06f4aec..45b9954a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IceShot.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -45,7 +45,7 @@ public class IceShot extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.setVelocity(new Vector(0, 0, 0)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java index c9eb2174..e664d09e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Identify.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,7 +48,7 @@ public class Identify extends EcoEnchant { int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); double finalChance = (chance * level)/100; - if(Rand.randFloat(0, 1) > finalChance) return; + if(NumberUtils.randFloat(0, 1) > finalChance) return; int finalDuration = duration * level; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java index 1ec23dfd..bb8ba4de 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Ignite.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -47,7 +47,7 @@ public class Ignite extends EcoEnchant { if (!AntigriefManager.canBreakBlock(player, block)) return; - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; BlockFace face = event.getHitBlockFace(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java index 2f5c38e6..a0a04a9a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/IllusionAspect.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -43,7 +43,7 @@ public class IllusionAspect extends EcoEnchant { 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) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, level * 10 + 15, level)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java index 8e59a0f5..6cc1d593 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.nms.TridentStack; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Trident; @@ -45,7 +45,7 @@ public class Impact extends EcoEnchant { int level = EnchantChecks.getItemLevel(item, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java index 996af704..56f14a2d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java @@ -6,13 +6,11 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.LocationUtils; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.VectorUtils; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; public class Infuriate extends EcoEnchant { @@ -47,7 +45,7 @@ public class Infuriate extends EcoEnchant { double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); double finalChance = (chance * level)/100; - if(Rand.randFloat(0, 1) > finalChance) return; + if(NumberUtils.randFloat(0, 1) > finalChance) return; double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); final double distance = distancePerLevel * level; @@ -63,7 +61,7 @@ public class Infuriate extends EcoEnchant { Vector vector = player.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); - if(LocationUtils.isFinite(vector)) { + if(VectorUtils.isFinite(vector)) { e.setVelocity(vector); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java index a1c4f732..2fbae79a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockDamageEvent; @@ -27,7 +27,7 @@ public class Instantaneous extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; if(event.getBlock().getDrops(player.getInventory().getItemInMainHand()).isEmpty()) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java index 19088207..f4545234 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lesion.java @@ -8,8 +8,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; -import org.bukkit.entity.Arrow; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Trident; @@ -50,7 +49,7 @@ public class Lesion extends EcoEnchant { if (!EnchantChecks.item(item, this)) return; int level = EnchantChecks.getItemLevel(item, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java index 77f51bb5..14d05032 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Levitate.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -45,7 +45,7 @@ public class Levitate extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java index b94e2133..ee1777d3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Lumberjack.java @@ -9,7 +9,7 @@ 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.RecursiveBlock; +import com.willfp.ecoenchants.util.BlockUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -59,7 +59,7 @@ public class Lumberjack extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); int limit = level * blocksPerLevel; - Set treeBlocks = RecursiveBlock.getVein(block, materials, limit); + Set treeBlocks = BlockUtils.getVein(block, materials, limit); AnticheatManager.exemptPlayer(player); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java index 4b76764d..146b6fe4 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/MagmaWalker.java @@ -8,7 +8,7 @@ import com.willfp.ecoenchants.enchantments.util.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.VectorShapes; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -38,7 +38,7 @@ public class MagmaWalker extends EcoEnchant { if (!EnchantChecks.boots(player, this)) return; - Vector[] circle = Circle.getCircle(this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius") + Vector[] circle = VectorShapes.getCircle(this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "initial-radius") + (this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "per-level-radius") * EnchantChecks.getBootsLevel(player, this) - 1)); AnticheatManager.exemptPlayer(player); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java index 8036fbab..0e5ff51a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Magnetic.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoRunnable; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.LocationUtils; +import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Item; @@ -39,7 +39,7 @@ public class Magnetic extends EcoEnchant implements EcoRunnable { Vector vector = player.getLocation().toVector().subtract(e.getLocation().toVector()).normalize().multiply(0.1 * level); - if(LocationUtils.isFinite(vector)) { + if(VectorUtils.isFinite(vector)) { e.setVelocity(vector); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java index 26bd4913..a1205d7b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.queue.DropQueue; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.entity.WitherSkeleton; @@ -37,7 +37,7 @@ public class Necrotic extends EcoEnchant { 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) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java index 0b3f35e6..b1e7767f 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Oxygenate.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.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.NumberUtils; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -39,7 +39,7 @@ public class Oxygenate extends EcoEnchant { int oxygenLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "oxygen-per-level"); int oxygen = level * oxygenLevel; int newOxygen = player.getRemainingAir() + oxygen; - newOxygen = EqualIfOver.equalIfOver(newOxygen, player.getMaximumAir()); + newOxygen = NumberUtils.equalIfOver(newOxygen, player.getMaximumAir()); player.setRemainingAir(newOxygen); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java index 0b5ec2af..18d49fd3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Paralyze.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,7 +48,7 @@ public class Paralyze extends EcoEnchant { int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); double finalChance = (chance * level)/100; - if(Rand.randFloat(0, 1) > finalChance) return; + if(NumberUtils.randFloat(0, 1) > finalChance) return; int finalDuration = duration * level; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java index 8b2d4e80..5b227584 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java @@ -6,8 +6,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.LocationUtils; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.VectorUtils; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -41,7 +41,7 @@ public class Rage extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level"); @@ -58,7 +58,7 @@ public class Rage extends EcoEnchant { Vector vector = player.getLocation().toVector().clone().subtract(e.getLocation().toVector()).normalize().multiply(0.23d); - if(LocationUtils.isFinite(vector)) { + if(VectorUtils.isFinite(vector)) { e.setVelocity(vector); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java index 772127f3..d4dc165a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sating.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.FoodLevelChangeEvent; @@ -32,7 +32,7 @@ public class Sating extends EcoEnchant { double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); - if (Rand.randFloat(0, 1) > level * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java index dd7dcb29..1aa2ae0a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Sickening.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,7 +46,7 @@ public class Sickening extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java index 02e5c93f..482f6340 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Spearfishing.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.nms.TridentStack; import com.willfp.ecoenchants.queue.DropQueue; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -53,14 +53,14 @@ public class Spearfishing extends EcoEnchant { int level = EnchantChecks.getItemLevel(item, this); double chance = level * (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")/100); - if(Rand.randFloat(0, 1) > chance) return; + if(NumberUtils.randFloat(0, 1) > chance) return; List potentialDrops = new ArrayList<>(); this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops").forEach(material -> { potentialDrops.add(Material.getMaterial(material.toUpperCase())); }); - Collections.shuffle(potentialDrops, new Random(Rand.randInt(0, 100000))); + Collections.shuffle(potentialDrops, new Random(NumberUtils.randInt(0, 100000))); ItemStack drop = new ItemStack(potentialDrops.get(0), 1); new DropQueue(player) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java index bf1c7f08..fc8ed389 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Stamina.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.FoodLevelChangeEvent; @@ -34,7 +34,7 @@ public class Stamina extends EcoEnchant { double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); - if (Rand.randFloat(0, 1) > level * 0.01 * chance) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; event.setCancelled(true); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java index 75f86297..86127dd6 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StoneSwitcher.java @@ -7,8 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.EqualIfOver; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; @@ -45,16 +44,16 @@ public class StoneSwitcher extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); - if(Rand.randFloat(0, 1) > level * chance * 0.01) + if(NumberUtils.randFloat(0, 1) > level * chance * 0.01) return; event.setDropItems(false); Material material; - double random = Rand.randFloat(0, 1); + double random = NumberUtils.randFloat(0, 1); double band = 1/(double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size(); int selectedIndex = (int) Math.floor(random/band); - selectedIndex = EqualIfOver.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); + selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex); material = Material.getMaterial(materialName.toUpperCase()); if(material == null) material = Material.COBBLESTONE; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java index d354632c..fe010105 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/StrayAspect.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,7 +43,7 @@ public class StrayAspect extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, level * 10, level)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java index dd5f58e0..59ffe525 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java @@ -6,8 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Cooldown; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; -import org.bukkit.attribute.Attribute; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -39,7 +38,7 @@ public class Supercritical extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java index 65d857a7..c13de18d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Thor.java @@ -8,7 +8,7 @@ import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Cooldown; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.util.Lightning; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -44,7 +44,7 @@ public class Thor extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java index 3191261f..ea917bb8 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Toxic.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,7 +43,7 @@ public class Toxic extends EcoEnchant { return; int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, level * 10 + 20, level)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java index 7f7a4327..da03a2c0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Transfuse.java @@ -7,8 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.EqualIfOver; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; @@ -46,16 +45,16 @@ public class Transfuse extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"); - if(Rand.randFloat(0, 1) > level * chance * 0.01) + if(NumberUtils.randFloat(0, 1) > level * chance * 0.01) return; event.setDropItems(false); Material material; - double random = Rand.randFloat(0, 1); + double random = NumberUtils.randFloat(0, 1); double band = 1/(double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size(); int selectedIndex = (int) Math.floor(random/band); - selectedIndex = EqualIfOver.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); + selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1); String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex); material = Material.getMaterial(materialName.toUpperCase()); if(material == null) material = Material.COBBLESTONE; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java index cb89700d..66d9c048 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/VampireAspect.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,7 +43,7 @@ public class VampireAspect extends EcoEnchant { return; int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java index cb3e0ee6..6781a2b3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Vein.java @@ -9,7 +9,7 @@ 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.RecursiveBlock; +import com.willfp.ecoenchants.util.BlockUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -59,7 +59,7 @@ public class Vein extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); int limit = level * blocksPerLevel; - Set blockSet = RecursiveBlock.getVein(block, materials, limit); + Set blockSet = BlockUtils.getVein(block, materials, limit); AnticheatManager.exemptPlayer(player); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java index 8b9ad7ae..01f91aa0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Venom.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -44,7 +44,7 @@ public class Venom extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level)); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java index a1ed4f6d..5fe50d80 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Wound.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,7 +46,7 @@ public class Wound extends EcoEnchant { if (!EnchantChecks.arrow(arrow, this)) return; int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java index 073e72d8..02285284 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Zeus.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.util.Lightning; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -41,7 +41,7 @@ public class Zeus extends EcoEnchant { int level = EnchantChecks.getArrowLevel(arrow, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java index 16feafaf..f3690b48 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java @@ -6,7 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.EqualIfOver; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Arrow; @@ -52,7 +52,7 @@ public class Aiming extends EcoEnchant { double distance = level * multiplier; double force = arrow.getVelocity().clone().length() / 3; - force = EqualIfOver.equalIfOver(force, 1); + force = NumberUtils.equalIfOver(force, 1); if(this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "require-full-force")) { if(force < 0.9) return; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java index 71cbb14d..17e911a4 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bolt.java @@ -8,7 +8,7 @@ import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.Cooldown; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.util.Lightning; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -42,7 +42,7 @@ public class Bolt extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java index 97b06677..1a822a90 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -46,7 +46,7 @@ public class Confusion extends EcoEnchant { 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) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance) return; List hotbar = new ArrayList(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java index b35d2571..2f07815e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Indestructibility.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerItemDamageEvent; import org.bukkit.inventory.ItemStack; @@ -27,7 +27,7 @@ public class Indestructibility extends EcoEnchant { double level = EnchantChecks.getItemLevel(item, this); double levelbonus = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "level-bonus"); - if(Rand.randFloat(0, 1) < (100/ (level + (1 + levelbonus))/100)) return; + if(NumberUtils.randFloat(0, 1) < (100/ (level + (1 + levelbonus))/100)) return; event.setCancelled(true); event.setDamage(0); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java index 0a3d32d4..30b073ea 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Volatile.java @@ -7,7 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.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.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -42,7 +42,7 @@ public class Volatile extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); - if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) return; boolean fire = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "fire"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/listeners/EnchantingListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/listeners/EnchantingListeners.java index d30c5ea1..d60f1710 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/listeners/EnchantingListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/listeners/EnchantingListeners.java @@ -5,9 +5,7 @@ import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Bias; -import com.willfp.ecoenchants.util.EqualIfOver; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentOffer; @@ -79,7 +77,7 @@ public class EnchantingListeners implements Listener { if (!enchantment.canEnchantItem(item)) continue; - if (Rand.randFloat(0, 1) > enchantment.getRarity().getProbability() * multiplier) + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getProbability() * multiplier) continue; if (enchantment.getRarity().getMinimumLevel() > cost) continue; @@ -108,19 +106,19 @@ public class EnchantingListeners implements Listener { double maxLevelDouble = enchantment.getMaxLevel(); if(enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = Rand.randFloat(0, 1); - double enchantlevel2 = Bias.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / maxLevelDouble; level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { int maxLevel = ConfigManager.getConfig().getInt("enchanting-table.maximum-obtainable-level"); double enchantlevel1 = (cost / (double) enchantment.getRarity().getMinimumLevel()) / (maxLevel / (double) enchantment.getRarity().getMinimumLevel()); - double enchantlevel2 = Rand.triangularDistribution(0, 1, enchantlevel1); + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); double enchantlevel3 = 1 / maxLevelDouble; level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } - level = EqualIfOver.equalIfOver(level, enchantment.getMaxLevel()); + level = NumberUtils.equalIfOver(level, enchantment.getMaxLevel()); toAdd.put(enchantment, level); if(ConfigManager.getConfig().getBool("enchanting-table.cap-amount.enabled")) { @@ -172,7 +170,7 @@ public class EnchantingListeners implements Listener { @EventHandler public void allowElytraEnchant(PrepareItemEnchantEvent event) { try { - event.getOffers()[2].setCost(EqualIfOver.equalIfOver(event.getOffers()[2].getCost(), ConfigManager.getConfig().getInt("enchanting-table.maximum-obtainable-level"))); + event.getOffers()[2].setCost(NumberUtils.equalIfOver(event.getOffers()[2].getCost(), ConfigManager.getConfig().getInt("enchanting-table.maximum-obtainable-level"))); } catch (ArrayIndexOutOfBoundsException | NullPointerException ignored) {} if (!secondary.contains(event.getItem().getType())) @@ -187,10 +185,10 @@ public class EnchantingListeners implements Listener { } - int level2 = (int) Math.ceil(Rand.randFloat(1.1, 2.5)); + int level2 = (int) Math.ceil(NumberUtils.randFloat(1.1, 2.5)); EnchantmentOffer offer2 = new EnchantmentOffer(Enchantment.DURABILITY, level2, (int) Math.floor(bonus * 1.5)); - EnchantmentOffer offer3 = new EnchantmentOffer(Enchantment.DURABILITY, Rand.randInt(2, 3), bonus * 2); + EnchantmentOffer offer3 = new EnchantmentOffer(Enchantment.DURABILITY, NumberUtils.randInt(2, 3), bonus * 2); if (offer3.getEnchantmentLevel() < offer2.getEnchantmentLevel()) { int temp = offer2.getEnchantmentLevel(); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/listeners/VillagerListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/listeners/VillagerListeners.java index a6ff484f..3d0e7b9e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/listeners/VillagerListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/listeners/VillagerListeners.java @@ -4,8 +4,7 @@ import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Bias; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -47,7 +46,7 @@ public class VillagerListeners implements Listener { double multiplier = 0.01 / ConfigManager.getConfig().getDouble("villager.book-times-less-likely"); for(EcoEnchant enchantment : enchantments) { - if (Rand.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) continue; if (!enchantment.canGetFromVillager()) continue; @@ -55,14 +54,14 @@ public class VillagerListeners implements Listener { int level; if(enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = Rand.randFloat(0, 1); - double enchantlevel2 = Bias.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { int cost = event.getRecipe().getIngredients().get(0).getAmount(); double enchantlevel1 = cost / 64; - double enchantlevel2 = Rand.triangularDistribution(0, 1, enchantlevel1); + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } @@ -114,7 +113,7 @@ public class VillagerListeners implements Listener { double multiplier = 0.01; for(EcoEnchant enchantment : enchantments) { - if (Rand.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getVillagerProbability() * multiplier) continue; if (!enchantment.canGetFromVillager()) continue; @@ -135,14 +134,14 @@ public class VillagerListeners implements Listener { int level; if(enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = Rand.randFloat(0, 1); - double enchantlevel2 = Bias.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { int cost = event.getRecipe().getIngredients().get(0).getAmount(); double enchantlevel1 = cost / 64; - double enchantlevel2 = Rand.triangularDistribution(0, 1, enchantlevel1); + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/naturalloot/LootPopulator.java b/Plugin/src/main/java/com/willfp/ecoenchants/naturalloot/LootPopulator.java index 6d181120..acabb472 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/naturalloot/LootPopulator.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/naturalloot/LootPopulator.java @@ -4,8 +4,7 @@ import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.nms.Target; -import com.willfp.ecoenchants.util.Bias; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.World; @@ -60,7 +59,7 @@ public class LootPopulator extends BlockPopulator { for (EcoEnchant enchantment : enchantments) { if(enchantment == null || enchantment.getRarity() == null) continue; - if (Rand.randFloat(0, 1) > enchantment.getRarity().getLootProbability() * multiplier) + if (NumberUtils.randFloat(0, 1) > enchantment.getRarity().getLootProbability() * multiplier) continue; if (!enchantment.canGetFromLoot()) continue; @@ -81,12 +80,12 @@ public class LootPopulator extends BlockPopulator { int level; if(enchantment.getType().equals(EcoEnchant.EnchantmentType.SPECIAL)) { - double enchantlevel1 = Rand.randFloat(0, 1); - double enchantlevel2 = Bias.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); + double enchantlevel1 = NumberUtils.randFloat(0, 1); + double enchantlevel2 = NumberUtils.bias(enchantlevel1, ConfigManager.getConfig().getDouble("enchanting-table.special-bias")); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { - double enchantlevel2 = Rand.triangularDistribution(0, 1, 1); + double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, 1); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/queue/DropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/queue/DropQueue.java index 9a8d2531..99e00b26 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/queue/DropQueue.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/queue/DropQueue.java @@ -2,7 +2,7 @@ package com.willfp.ecoenchants.queue; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; -import com.willfp.ecoenchants.util.Rand; +import com.willfp.ecoenchants.util.NumberUtils; import org.bukkit.*; import org.bukkit.entity.EntityType; import org.bukkit.entity.ExperienceOrb; @@ -126,7 +126,7 @@ public class DropQueue { Bukkit.getPluginManager().callEvent(event); player.giveExp(event.getAmount()); - player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.AMBIENT, 1f, (float) Rand.randFloat(0.7, 1.2)); + player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.AMBIENT, 1f, (float) NumberUtils.randFloat(0.7, 1.2)); } } } else { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Bias.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Bias.java deleted file mode 100644 index 3a2c2946..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Bias.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoenchants.util; - -public class Bias { - - /** - * Bias the input value according to a curve - * @param input The input value - * @param bias The bias between -1 and 1, where higher values bias input values to lower output values - * @return The biased output - */ - public static double bias(double input, double bias) { - double k = Math.pow(1-bias, 3); - - return (input * k) / (input * k - input + 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/RecursiveBlock.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java similarity index 97% rename from Plugin/src/main/java/com/willfp/ecoenchants/util/RecursiveBlock.java rename to Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java index 7301bae3..82010d74 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/RecursiveBlock.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/BlockUtils.java @@ -8,7 +8,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class RecursiveBlock { +public class BlockUtils { private static Set getNearbyBlocks(Block start, List allowedMaterials, HashSet blocks, int limit) { for (BlockFace face : BlockFace.values()) { Block block = start.getRelative(face); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Circle.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Circle.java deleted file mode 100644 index 35aa88c0..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Circle.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.util.Vector; - -import java.util.ArrayList; - -public class Circle { - - /** - * Get circle as relative vectors - * @param radius The radius - * @return An array of {@link Vector}s - */ - public static Vector[] getCircle(int radius) { - ArrayList circleVecs = new ArrayList(); - - int xoffset = -radius; - int zoffset = -radius; - - while (zoffset <= radius) { - while (xoffset <= radius) { - if (Math.round(Math.sqrt((xoffset * xoffset) + (zoffset * zoffset))) <= radius) { - circleVecs.add(new Vector(xoffset, 0, zoffset)); - } else { - xoffset++; - continue; - } - xoffset++; - } - xoffset = -radius; - zoffset++; - } - - return circleVecs.toArray(new Vector[0]); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Cube.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Cube.java deleted file mode 100644 index 163dab34..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Cube.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.util.Vector; - -import java.util.ArrayList; - -public class Cube { - - /** - * Get cube as relative vectors - * @param radius The radius of the cube - * @return An array of {@link Vector}s - */ - public static Vector[] getCube(int radius) { - ArrayList cubeVecs = new ArrayList(); - - int xoffset = -radius; - int zoffset = -radius; - int yoffset = -radius; - - while (yoffset <= radius) { - while (zoffset <= radius) { - while (xoffset <= radius) { - cubeVecs.add(new Vector(xoffset, yoffset, zoffset)); - xoffset++; - } - xoffset = -radius; - zoffset++; - } - zoffset = -radius; - yoffset++; - } - - return cubeVecs.toArray(new Vector[0]); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/EqualIfOver.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/EqualIfOver.java deleted file mode 100644 index 46087582..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/EqualIfOver.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.willfp.ecoenchants.util; - -public class EqualIfOver { - - /** - * If value is above maximum, set it to maximum - * @param toChange The value to test - * @param limit The maximum - * @return The new value - */ - public static int equalIfOver(int toChange, int limit) { - if (toChange > limit) { - toChange = limit; - } - return toChange; - } - - /** - * If value is above maximum, set it to maximum - * @param toChange The value to test - * @param limit The maximum - * @return The new value - */ - public static double equalIfOver(double toChange, double limit) { - if (toChange > limit) { - toChange = limit; - } - return toChange; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/LocationUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/LocationUtils.java deleted file mode 100644 index b24ac892..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/LocationUtils.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - -public class LocationUtils { - public static boolean isFinite(Vector vector) { - try { - NumberConversions.checkFinite(vector.getX(), "x not finite"); - NumberConversions.checkFinite(vector.getY(), "y not finite"); - NumberConversions.checkFinite(vector.getZ(), "z not finite"); - } catch (IllegalArgumentException e) { - return false; - } - - return true; - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java new file mode 100644 index 00000000..3010b3df --- /dev/null +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/NumberUtils.java @@ -0,0 +1,123 @@ +package com.willfp.ecoenchants.util; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class NumberUtils { + /** + * Bias the input value according to a curve + * @param input The input value + * @param bias The bias between -1 and 1, where higher values bias input values to lower output values + * @return The biased output + */ + public static double bias(double input, double bias) { + double k = Math.pow(1-bias, 3); + + return (input * k) / (input * k - input + 1); + } + + /** + * If value is above maximum, set it to maximum + * @param toChange The value to test + * @param limit The maximum + * @return The new value + */ + public static int equalIfOver(int toChange, int limit) { + if (toChange > limit) { + toChange = limit; + } + return toChange; + } + + /** + * If value is above maximum, set it to maximum + * @param toChange The value to test + * @param limit The maximum + * @return The new value + */ + public static double equalIfOver(double toChange, double limit) { + if (toChange > limit) { + toChange = limit; + } + return toChange; + } + + /** + * Get Roman Numeral from number + * @param number The number to convert + * @return The number, converted to a roman numeral + */ + public static String toNumeral(int number) { + + LinkedHashMap roman_numerals = new LinkedHashMap(); + roman_numerals.put("M", 1000); + roman_numerals.put("CM", 900); + roman_numerals.put("D", 500); + roman_numerals.put("CD", 400); + roman_numerals.put("C", 100); + roman_numerals.put("XC", 90); + roman_numerals.put("L", 50); + roman_numerals.put("XL", 40); + roman_numerals.put("X", 10); + roman_numerals.put("IX", 9); + roman_numerals.put("V", 5); + roman_numerals.put("IV", 4); + roman_numerals.put("I", 1); + StringBuilder res = new StringBuilder(); + for (Map.Entry entry : roman_numerals.entrySet()) { + int matches = number / entry.getValue(); + res.append(repeat(entry.getKey(), matches)); + number = number % entry.getValue(); + } + return res.toString(); + } + + private static String repeat(String s, int n) { + if (s == null) { + return null; + } + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < n; i++) { + sb.append(s); + } + return sb.toString(); + } + + /** + * Generate random integer in range + * @param min Minimum + * @param max Maximum + * @return Random integer + */ + public static int randInt(int min, int max) { + return (int) ((long) min + Math.random() * ((long) max - min + 1)); + } + + /** + * Generate random double in range + * @param min Minimum + * @param max Maximum + * @return Random double + */ + public static double randFloat(double min, double max) { + java.util.Random rand = new java.util.Random(); + return rand.nextFloat() * (max - min) + min; + } + + /** + * Generate random double with a triangular distribution + * @param a Minimum + * @param b Maximum + * @param c Peak + * @return Random double + */ + public static double triangularDistribution(double a, double b, double c) { + double F = (c - a) / (b - a); + double rand = Math.random(); + if (rand < F) { + return a + Math.sqrt(rand * (b - a) * (c - a)); + } else { + return b - Math.sqrt((1 - rand) * (b - a) * (b - c)); + } + } +} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Numeral.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Numeral.java deleted file mode 100644 index bb5e1887..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Numeral.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.ecoenchants.util; - -import java.util.LinkedHashMap; -import java.util.Map; - -public class Numeral { - - /** - * Get Roman Numeral from number - * @param number The number to convert - * @return The number, converted to a roman numeral - */ - public static String getNumeral(int number) { - - LinkedHashMap roman_numerals = new LinkedHashMap(); - roman_numerals.put("M", 1000); - roman_numerals.put("CM", 900); - roman_numerals.put("D", 500); - roman_numerals.put("CD", 400); - roman_numerals.put("C", 100); - roman_numerals.put("XC", 90); - roman_numerals.put("L", 50); - roman_numerals.put("XL", 40); - roman_numerals.put("X", 10); - roman_numerals.put("IX", 9); - roman_numerals.put("V", 5); - roman_numerals.put("IV", 4); - roman_numerals.put("I", 1); - StringBuilder res = new StringBuilder(); - for (Map.Entry entry : roman_numerals.entrySet()) { - int matches = number / entry.getValue(); - res.append(repeat(entry.getKey(), matches)); - number = number % entry.getValue(); - } - return res.toString(); - } - - private static String repeat(String s, int n) { - if (s == null) { - return null; - } - final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < n; i++) { - sb.append(s); - } - return sb.toString(); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Rand.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Rand.java deleted file mode 100644 index 9688f680..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Rand.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.willfp.ecoenchants.util; - -/** - * Simple class containing random methods - */ -public class Rand { - /** - * Generate random integer in range - * @param min Minimum - * @param max Maximum - * @return Random integer - */ - public static int randInt(int min, int max) { - return (int) ((long) min + Math.random() * ((long) max - min + 1)); - } - - /** - * Generate random double in range - * @param min Minimum - * @param max Maximum - * @return Random double - */ - public static double randFloat(double min, double max) { - java.util.Random rand = new java.util.Random(); - return rand.nextFloat() * (max - min) + min; - } - - /** - * Generate random double with a triangular distribution - * @param a Minimum - * @param b Maximum - * @param c Peak - * @return Random double - */ - public static double triangularDistribution(double a, double b, double c) { - double F = (c - a) / (b - a); - double rand = Math.random(); - if (rand < F) { - return a + Math.sqrt(rand * (b - a) * (c - a)); - } else { - return b - Math.sqrt((1 - rand) * (b - a) * (b - c)); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Square.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Square.java deleted file mode 100644 index 527a7107..00000000 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Square.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.willfp.ecoenchants.util; - -import org.bukkit.util.Vector; - -import java.util.ArrayList; - -public class Square { - - /** - * Get square as relative vectors - * @param radius The radius of the square - * @return An array of {@link Vector}s - */ - public static Vector[] getSquare(int radius) { - ArrayList circleVecs = new ArrayList(); - - int xoffset = -radius; - int zoffset = -radius; - - while (zoffset <= radius) { - while (xoffset <= radius) { - circleVecs.add(new Vector(xoffset, 0, zoffset)); - xoffset++; - } - xoffset = -radius; - zoffset++; - } - - return circleVecs.toArray(new Vector[0]); - } -} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java new file mode 100644 index 00000000..23ac8877 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java @@ -0,0 +1,87 @@ +package com.willfp.ecoenchants.util; + +import org.bukkit.util.Vector; + +import java.util.ArrayList; + +public class VectorShapes { + + /** + * Get circle as relative vectors + * @param radius The radius + * @return An array of {@link Vector}s + */ + public static Vector[] getCircle(int radius) { + ArrayList circleVecs = new ArrayList(); + + int xoffset = -radius; + int zoffset = -radius; + + while (zoffset <= radius) { + while (xoffset <= radius) { + if (Math.round(Math.sqrt((xoffset * xoffset) + (zoffset * zoffset))) <= radius) { + circleVecs.add(new Vector(xoffset, 0, zoffset)); + } else { + xoffset++; + continue; + } + xoffset++; + } + xoffset = -radius; + zoffset++; + } + + return circleVecs.toArray(new Vector[0]); + } + + /** + * Get square as relative vectors + * @param radius The radius of the square + * @return An array of {@link Vector}s + */ + public static Vector[] getSquare(int radius) { + ArrayList circleVecs = new ArrayList(); + + int xoffset = -radius; + int zoffset = -radius; + + while (zoffset <= radius) { + while (xoffset <= radius) { + circleVecs.add(new Vector(xoffset, 0, zoffset)); + xoffset++; + } + xoffset = -radius; + zoffset++; + } + + return circleVecs.toArray(new Vector[0]); + } + + /** + * Get cube as relative vectors + * @param radius The radius of the cube + * @return An array of {@link Vector}s + */ + public static Vector[] getCube(int radius) { + ArrayList cubeVecs = new ArrayList(); + + int xoffset = -radius; + int zoffset = -radius; + int yoffset = -radius; + + while (yoffset <= radius) { + while (zoffset <= radius) { + while (xoffset <= radius) { + cubeVecs.add(new Vector(xoffset, yoffset, zoffset)); + xoffset++; + } + xoffset = -radius; + zoffset++; + } + zoffset = -radius; + yoffset++; + } + + return cubeVecs.toArray(new Vector[0]); + } +} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/SimplifyVector.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java similarity index 69% rename from Plugin/src/main/java/com/willfp/ecoenchants/util/SimplifyVector.java rename to Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java index 17bea0c0..4d15e126 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/SimplifyVector.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorUtils.java @@ -1,8 +1,20 @@ package com.willfp.ecoenchants.util; +import org.bukkit.util.NumberConversions; import org.bukkit.util.Vector; -public class SimplifyVector { +public class VectorUtils { + public static boolean isFinite(Vector vector) { + try { + NumberConversions.checkFinite(vector.getX(), "x not finite"); + NumberConversions.checkFinite(vector.getY(), "y not finite"); + NumberConversions.checkFinite(vector.getZ(), "z not finite"); + } catch (IllegalArgumentException e) { + return false; + } + + return true; + } /** * Only keep largest part of normalised vector.