mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Refactored util classes
This commit is contained in:
parent
d76de144f3
commit
2134e27dfa
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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")) {
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
|
@ -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"));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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<Block> treeBlocks = RecursiveBlock.getVein(block, materials, limit);
|
||||
Set<Block> treeBlocks = BlockUtils.getVein(block, materials, limit);
|
||||
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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<Material> 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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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"));
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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<Block> blockSet = RecursiveBlock.getVein(block, materials, limit);
|
||||
Set<Block> blockSet = BlockUtils.getVein(block, materials, limit);
|
||||
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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<ItemStack> hotbar = new ArrayList<ItemStack>();
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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<Block> getNearbyBlocks(Block start, List<Material> allowedMaterials, HashSet<Block> blocks, int limit) {
|
||||
for (BlockFace face : BlockFace.values()) {
|
||||
Block block = start.getRelative(face);
|
@ -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<Vector> circleVecs = new ArrayList<Vector>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
@ -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<Vector> cubeVecs = new ArrayList<Vector>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<String, Integer> roman_numerals = new LinkedHashMap<String, Integer>();
|
||||
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<String, Integer> 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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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<String, Integer> roman_numerals = new LinkedHashMap<String, Integer>();
|
||||
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<String, Integer> 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();
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Vector> circleVecs = new ArrayList<Vector>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
@ -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<Vector> circleVecs = new ArrayList<Vector>();
|
||||
|
||||
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<Vector> circleVecs = new ArrayList<Vector>();
|
||||
|
||||
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<Vector> cubeVecs = new ArrayList<Vector>();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
@ -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.
|
Loading…
Reference in New Issue
Block a user