mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-21 14:55:17 +01:00
Cleaned up chance system
This commit is contained in:
parent
b8c31b49b4
commit
08946c6233
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,7 +20,7 @@ public class BreaklessnessCurse extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDamageBlock(Player player, Block block, int level, BlockDamageEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -18,7 +19,7 @@ public class HarmlessnessCurse extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setDamage(0);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,7 +20,7 @@ public class MisfortuneCurse extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setDropItems(false);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -20,8 +21,8 @@ public class Arcanic extends EcoEnchant {
|
||||
if (!(event.getCause().equals(EntityDamageEvent.DamageCause.POISON) || event.getCause().equals(EntityDamageEvent.DamageCause.WITHER)))
|
||||
return;
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point");
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.queue.DropQueue;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Material;
|
||||
@ -36,8 +37,7 @@ public class Beheading extends EcoEnchant {
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
ItemStack item;
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -27,7 +28,7 @@ public class Bleed extends EcoEnchant {
|
||||
if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -23,7 +24,8 @@ public class Blind extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -22,9 +23,8 @@ public class BlockBreather extends EcoEnchant {
|
||||
if(!event.getCause().equals(EntityDamageEvent.DamageCause.SUFFOCATION))
|
||||
return;
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Trident;
|
||||
@ -20,7 +21,8 @@ public class Conclude extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -28,7 +29,7 @@ public class Disable extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 10, 5));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -26,7 +27,8 @@ public class Dullness extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int durationPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.Lightning;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -19,11 +20,10 @@ public class Electroshock extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage");
|
||||
|
||||
double finalChance = (chance * level)/100;
|
||||
if(NumberUtils.randFloat(0, 1) > finalChance) return;
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
Lightning.strike(attacker, damage);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -18,9 +19,8 @@ public class Evasion extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point");
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -20,8 +21,8 @@ public class Extinguishing extends EcoEnchant {
|
||||
if(!event.getCause().equals(EntityDamageEvent.DamageCause.FIRE_TICK))
|
||||
return;
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point");
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.setFireTicks(0);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -27,7 +28,8 @@ public class Famine extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, level * 40, level));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -20,7 +21,8 @@ public class Finality extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -18,7 +19,8 @@ public class Finishing extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,11 +22,10 @@ public class Flinch extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
|
||||
double finalChance = (chance * level)/100;
|
||||
if(NumberUtils.randFloat(0, 1) > finalChance) return;
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int finalDuration = duration * level;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -18,9 +19,8 @@ public class Freerunner extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onFallDamage(LivingEntity faller, int level, EntityDamageEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -38,7 +39,8 @@ public class Frozen extends EcoEnchant {
|
||||
if (points == 0)
|
||||
return;
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > points * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-point"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, points))
|
||||
return;
|
||||
|
||||
int divisor = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "points-per-level");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import com.willfp.ecoenchants.util.VectorUtils;
|
||||
@ -25,7 +26,8 @@ public class Fury extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level");
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -36,7 +37,8 @@ public class Graceful extends EcoEnchant {
|
||||
if(!EnchantChecks.boots(player, this)) return;
|
||||
int level = EnchantChecks.getBootsLevel(player, this);
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 5, false, false, true));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -22,7 +23,8 @@ public class IceShot extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.setVelocity(new Vector(0, 0, 0));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,11 +23,10 @@ public class Identify extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
|
||||
double finalChance = (chance * level)/100;
|
||||
if(NumberUtils.randFloat(0, 1) > finalChance) return;
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int finalDuration = duration * level;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Material;
|
||||
@ -33,7 +34,8 @@ public class Ignite extends EcoEnchant {
|
||||
if (!AntigriefManager.canBreakBlock(shooter, event.getHitBlock()))
|
||||
return;
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
BlockFace face = event.getHitBlockFace();
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -27,8 +28,8 @@ public class IllusionAspect extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, level * 10 + 15, level));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Trident;
|
||||
@ -20,7 +21,8 @@ public class Impact extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier"));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import com.willfp.ecoenchants.util.VectorUtils;
|
||||
import org.bukkit.entity.*;
|
||||
@ -21,9 +22,8 @@ public class Infuriate extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
double finalChance = (chance * level)/100;
|
||||
if(NumberUtils.randFloat(0, 1) > finalChance) return;
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level");
|
||||
final double distance = distancePerLevel * level;
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.block.Block;
|
||||
@ -20,7 +21,7 @@ public class Instantaneous extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDamageBlock(Player player, Block block, int level, BlockDamageEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
AnticheatManager.exemptPlayer(player);
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Trident;
|
||||
@ -24,7 +25,7 @@ public class Lesion extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -22,7 +23,7 @@ public class Levitate extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.queue.DropQueue;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.Material;
|
||||
@ -35,8 +36,7 @@ public class Necrotic extends EcoEnchant {
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,11 +23,10 @@ public class Paralyze extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) {
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
|
||||
|
||||
double finalChance = (chance * level)/100;
|
||||
if(NumberUtils.randFloat(0, 1) > finalChance) return;
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int finalDuration = duration * level;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import com.willfp.ecoenchants.util.VectorUtils;
|
||||
import org.bukkit.entity.*;
|
||||
@ -21,7 +22,7 @@ public class Rage extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double distancePerLevel = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level");
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -29,9 +30,7 @@ public class Sating extends EcoEnchant {
|
||||
|
||||
int level = EnchantChecks.getHelmetLevel(player, this);
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -23,7 +24,7 @@ public class Sickening extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.TridentStack;
|
||||
import com.willfp.ecoenchants.queue.DropQueue;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
@ -50,9 +51,8 @@ public class Spearfishing extends EcoEnchant {
|
||||
if (!EnchantChecks.item(item, this)) return;
|
||||
|
||||
int level = EnchantChecks.getItemLevel(item, this);
|
||||
|
||||
double chance = level * (this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")/100);
|
||||
if(NumberUtils.randFloat(0, 1) > chance) return;
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
List<Material> potentialDrops = new ArrayList<>();
|
||||
this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops").forEach(material -> {
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -30,10 +31,7 @@ public class Stamina extends EcoEnchant {
|
||||
if(event.getFoodLevel() > player.getFoodLevel()) return;
|
||||
|
||||
int level = EnchantChecks.getBootsLevel(player, this);
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.queue.DropQueue;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.GameMode;
|
||||
@ -27,10 +28,7 @@ public class StoneSwitcher extends EcoEnchant {
|
||||
return;
|
||||
|
||||
if(!block.getType().equals(Material.STONE)) return;
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if(NumberUtils.randFloat(0, 1) > level * chance * 0.01)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setDropItems(false);
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -26,8 +27,7 @@ public class StrayAspect extends EcoEnchant {
|
||||
if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, level * 10, level));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -25,7 +26,7 @@ public class Supercritical extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier"));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.Lightning;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
@ -26,7 +27,7 @@ public class Thor extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -27,7 +28,7 @@ public class Toxic extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, level * 10 + 20, level));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.queue.DropQueue;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.GameMode;
|
||||
@ -27,9 +28,7 @@ public class Transfuse extends EcoEnchant {
|
||||
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)
|
||||
return;
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if(NumberUtils.randFloat(0, 1) > level * chance * 0.01)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
event.setDropItems(false);
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
@ -30,33 +31,7 @@ public class VampireAspect extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void vampireAspectHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getDamager();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) return;
|
||||
|
||||
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level));
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -21,7 +22,7 @@ public class Venom extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, level * 10 + 20, level));
|
||||
|
@ -4,6 +4,7 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -24,7 +25,7 @@ public class Wound extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.Lightning;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
@ -20,7 +21,7 @@ public class Zeus extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.Lightning;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
@ -25,8 +26,7 @@ public class Bolt extends EcoEnchant {
|
||||
if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
double damage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "lightning-damage");
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -32,9 +33,7 @@ public class Confusion extends EcoEnchant {
|
||||
if (Cooldown.getCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
}
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * chance)
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
List<ItemStack> hotbar = new ArrayList<ItemStack>();
|
||||
|
@ -3,6 +3,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
@ -28,8 +29,7 @@ public class Volatile extends EcoEnchant {
|
||||
|
||||
if (Cooldown.getCooldown(attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
return;
|
||||
|
||||
if (NumberUtils.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
boolean fire = this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "fire");
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.willfp.ecoenchants.enchantments.util;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
|
||||
public class EnchantmentUtils {
|
||||
public static double getDamageMultiplier(EcoEnchant enchantment, int level) {
|
||||
return 1 + ((enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier") * level)/ 100);
|
||||
}
|
||||
|
||||
public static boolean passedChance(EcoEnchant enchantment, int level) {
|
||||
return NumberUtils.randFloat(0, 1) < ((enchantment.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level") * level) / 100);
|
||||
}
|
||||
|
||||
public static double getDamageBonus(EcoEnchant enchant, int level) {
|
||||
return (level * enchant.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"));
|
||||
}
|
||||
}
|
@ -24,4 +24,4 @@ general-config:
|
||||
conflicts: []
|
||||
|
||||
config:
|
||||
chance: 15
|
||||
chance-per-level: 15
|
@ -22,4 +22,4 @@ general-config:
|
||||
conflicts: []
|
||||
|
||||
config:
|
||||
chance: 15
|
||||
chance-per-level: 15
|
@ -25,4 +25,4 @@ general-config:
|
||||
- fortune
|
||||
|
||||
config:
|
||||
chance: 15
|
||||
chance-per-level: 15
|
@ -25,4 +25,4 @@ general-config:
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
chance-per-point: 2 #Chance of ignoring potion damage = Total points (16 points * 3 chance = 48% chance)
|
||||
chance-per-level: 2 #Chance of ignoring potion damage = Total points (16 points * 3 chance = 48% chance)
|
@ -26,4 +26,4 @@ general-config:
|
||||
|
||||
config:
|
||||
# Each level of evasion on each piece of armor counts as a point, so if a player is wearing 4 pieces of armor all with Evasion 3, then that would be 12 points
|
||||
chance-per-point: 0.5
|
||||
chance-per-level: 0.5
|
@ -25,4 +25,4 @@ general-config:
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
chance-per-point: 4 #Chance of being extinguished = Total points (12 points * 4 chance = 48% chance)
|
||||
chance-per-level: 4 #Chance of being extinguished = Total points (12 points * 4 chance = 48% chance)
|
@ -25,5 +25,5 @@ general-config:
|
||||
maximum-level: 6
|
||||
|
||||
config:
|
||||
chance-per-point: 0.6
|
||||
chance-per-level: 0.6
|
||||
points-per-level: 6 # Points of frozen required to increment slowness level by 1
|
||||
|
Loading…
Reference in New Issue
Block a user