Improved codestyle (6/?)

This commit is contained in:
Auxilor 2020-12-28 14:43:16 +00:00
parent 40f237317e
commit 4c9df0ee9f
97 changed files with 572 additions and 166 deletions

View File

@ -89,12 +89,14 @@
<!-- Checks for Javadoc comments. --> <!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/config_javadoc.html --> <!-- See https://checkstyle.org/config_javadoc.html -->
<!--
<module name="InvalidJavadocPosition"/> <module name="InvalidJavadocPosition"/>
<module name="JavadocMethod"/> <module name="JavadocMethod"/>
<module name="JavadocType"/> <module name="JavadocType"/>
<module name="JavadocVariable"/> <module name="JavadocVariable"/>
<module name="JavadocStyle"/> <module name="JavadocStyle"/>
<module name="MissingJavadocMethod"/> <module name="MissingJavadocMethod"/>
-->
<!-- Checks for Naming Conventions. --> <!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html --> <!-- See https://checkstyle.org/config_naming.html -->

View File

@ -26,7 +26,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
int level = '\uffff' & compound.getShort("lvl"); int level = '\uffff' & compound.getShort("lvl");
Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key)); Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key));
if(found != null) { if (found != null) {
foundEnchantments.put(found, level); foundEnchantments.put(found, level);
} }
} }
@ -42,7 +42,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
for (NBTBase base : enchantmentNBT) { for (NBTBase base : enchantmentNBT) {
NBTTagCompound compound = (NBTTagCompound) base; NBTTagCompound compound = (NBTTagCompound) base;
String key = compound.getString("id"); String key = compound.getString("id");
if(!key.equals(enchantment.getKey().toString())) { if (!key.equals(enchantment.getKey().toString())) {
continue; continue;
} }

View File

@ -26,7 +26,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
int level = '\uffff' & compound.getShort("lvl"); int level = '\uffff' & compound.getShort("lvl");
Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key)); Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key));
if(found != null) { if (found != null) {
foundEnchantments.put(found, level); foundEnchantments.put(found, level);
} }
} }

View File

@ -69,7 +69,11 @@ public class EnchantmentCache implements Updatable {
); );
name = String.valueOf(Configs.LANG.getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name")); name = String.valueOf(Configs.LANG.getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name"));
type = enchantment.isCursed() ? EnchantmentType.CURSE : EnchantmentType.NORMAL; type = enchantment.isCursed() ? EnchantmentType.CURSE : EnchantmentType.NORMAL;
rarity = enchantment.isTreasure() ? EnchantmentRarity.getByName(Configs.CONFIG.getString("rarity.vanilla-treasure-rarity")) : EnchantmentRarity.getByName(Configs.CONFIG.getString("rarity.vanilla-rarity")); if(enchantment.isTreasure()) {
rarity = EnchantmentRarity.getByName(Configs.CONFIG.getString("rarity.vanilla-treasure-rarity"));
} else {
rarity = EnchantmentRarity.getByName(Configs.CONFIG.getString("rarity.vanilla-rarity"));
}
} }
color = type.getColor(); color = type.getColor();

View File

@ -13,4 +13,4 @@ public class HeartArtifact extends Artifact {
public Particle getParticle() { public Particle getParticle() {
return Particle.HEART; return Particle.HEART;
} }
} }

View File

@ -13,4 +13,4 @@ public class HoneyArtifact extends Artifact {
public Particle getParticle() { public Particle getParticle() {
return Particle.FALLING_HONEY; return Particle.FALLING_HONEY;
} }
} }

View File

@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class HarmlessnessCurse extends EcoEnchant { public class HarmlessnessCurse extends EcoEnchant {
public HarmlessnessCurse() { public HarmlessnessCurse() {
@ -17,9 +18,13 @@ public class HarmlessnessCurse extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull final LivingEntity attacker,
if (!EnchantmentUtils.passedChance(this, level)) @NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) {
return; return;
}
event.setDamage(0); event.setDamage(0);
event.setCancelled(true); event.setCancelled(true);

View File

@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.jetbrains.annotations.NotNull;
public class HungerCurse extends EcoEnchant { public class HungerCurse extends EcoEnchant {
public HungerCurse() { public HungerCurse() {
@ -18,15 +19,24 @@ public class HungerCurse extends EcoEnchant {
// START OF LISTENERS // START OF LISTENERS
@EventHandler @EventHandler
public void onHunger(FoodLevelChangeEvent event) { public void onHunger(@NotNull final FoodLevelChangeEvent event) {
if (!(event.getEntity() instanceof Player)) if (!(event.getEntity() instanceof Player)) {
return; return;
}
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (!EnchantChecks.helmet(player, this)) return; if (!EnchantChecks.helmet(player, this)) {
if (event.getFoodLevel() > player.getFoodLevel()) return; return;
if (this.getDisabledWorlds().contains(player.getWorld())) return; }
if (event.getFoodLevel() > player.getFoodLevel()) {
return;
}
if (this.getDisabledWorlds().contains(player.getWorld())) {
return;
}
int delta = player.getFoodLevel() - event.getFoodLevel(); int delta = player.getFoodLevel() - event.getFoodLevel();
delta *= this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "times-more-hunger"); delta *= this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "times-more-hunger");

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class InaccuracyCurse extends EcoEnchant { public class InaccuracyCurse extends EcoEnchant {
public InaccuracyCurse() { public InaccuracyCurse() {
@ -20,7 +21,10 @@ public class InaccuracyCurse extends EcoEnchant {
@Override @Override
public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { public void onBowShoot(@NotNull final LivingEntity shooter,
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityShootBowEvent event) {
double spread = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread"); double spread = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread");
Vector velocity = event.getProjectile().getVelocity().clone(); Vector velocity = event.getProjectile().getVelocity().clone();

View File

@ -6,6 +6,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.jetbrains.annotations.NotNull;
public class MisfortuneCurse extends EcoEnchant { public class MisfortuneCurse extends EcoEnchant {
public MisfortuneCurse() { public MisfortuneCurse() {
@ -18,7 +19,7 @@ public class MisfortuneCurse extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -28,7 +28,9 @@ public class Famine extends EcoEnchant {
@NotNull final LivingEntity victim, @NotNull final LivingEntity victim,
final int level, final int level,
@NotNull final EntityDamageByEntityEvent event) { @NotNull final EntityDamageByEntityEvent event) {
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { if (attacker instanceof Player
&& ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f
&& !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class Graceful extends EcoEnchant { public class Graceful extends EcoEnchant {
@ -22,25 +23,35 @@ public class Graceful extends EcoEnchant {
// START OF LISTENERS // START OF LISTENERS
@EventHandler @EventHandler
public void onFall(PlayerMoveEvent event) { public void onFall(@NotNull final PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.isOnGround()) if (player.isOnGround()) {
return; return;
}
if(player.getVelocity().getY() > -1) return; if (player.getVelocity().getY() > -1) {
if(player.getLocation().clone().add(0, -3, 0).getBlock().getType().equals(Material.AIR))
return; return;
}
if (player.getLocation().clone().add(0, -3, 0).getBlock().getType().equals(Material.AIR)) {
return;
}
if (!EnchantChecks.boots(player, this)) {
return;
}
if(!EnchantChecks.boots(player, this)) return;
int level = EnchantChecks.getBootsLevel(player, this); int level = EnchantChecks.getBootsLevel(player, this);
if(this.getDisabledWorlds().contains(player.getWorld())) return; if (this.getDisabledWorlds().contains(player.getWorld())) {
if(!EnchantmentUtils.passedChance(this, level))
return; return;
}
if (!EnchantmentUtils.passedChance(this, level)) {
return;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 5, false, false, true)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 5, false, false, true));
} }

View File

@ -7,6 +7,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Grapple extends EcoEnchant { public class Grapple extends EcoEnchant {
public Grapple() { public Grapple() {
super( super(
@ -18,11 +20,14 @@ public class Grapple extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier");
Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier);
if(VectorUtils.isFinite(vector)) { if (VectorUtils.isFinite(vector)) {
victim.setVelocity(vector); victim.setVelocity(vector);
} }
} }

View File

@ -11,6 +11,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.jetbrains.annotations.NotNull;
public class GreenThumb extends EcoEnchant { public class GreenThumb extends EcoEnchant {
public GreenThumb() { public GreenThumb() {
super( super(
@ -21,27 +23,40 @@ public class GreenThumb extends EcoEnchant {
// START OF LISTENERS // START OF LISTENERS
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent event) { public void onInteract(@NotNull final PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!event.getAction().equals(Action.LEFT_CLICK_BLOCK)) if (!event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
return; return;
}
if (event.getClickedBlock() == null) if (event.getClickedBlock() == null) {
return; return;
}
if (!event.getClickedBlock().getType().equals(Material.DIRT)) if (!event.getClickedBlock().getType().equals(Material.DIRT)) {
return; return;
}
if (!EnchantChecks.mainhand(player, this)) return; if (!EnchantChecks.mainhand(player, this)) {
return;
}
if(this.getDisabledWorlds().contains(player.getWorld())) return; if (this.getDisabledWorlds().contains(player.getWorld())) {
return;
}
if(!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) return; if (!AntigriefManager.canBreakBlock(player, event.getClickedBlock())) {
if(!AntigriefManager.canPlaceBlock(player, event.getClickedBlock())) return; return;
}
if(this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage")) if (!AntigriefManager.canPlaceBlock(player, event.getClickedBlock())) {
return;
}
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage")) {
DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot()); DurabilityUtils.damageItem(player, player.getInventory().getItemInMainHand(), 1, player.getInventory().getHeldItemSlot());
}
event.getClickedBlock().setType(Material.GRASS_BLOCK); event.getClickedBlock().setType(Material.GRASS_BLOCK);
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.jetbrains.annotations.NotNull;
public class Grit extends EcoEnchant { public class Grit extends EcoEnchant {
public Grit() { public Grit() {
@ -21,26 +22,35 @@ public class Grit extends EcoEnchant {
// START OF LISTENERS // START OF LISTENERS
@EventHandler @EventHandler
public void onGritHurt(EntityDamageByEntityEvent event) { public void onGritHurt(@NotNull final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player)) if (!(event.getEntity() instanceof Player)) {
return; return;
}
if (!(event.getDamager() instanceof Player)) if (!(event.getDamager() instanceof Player)) {
return; return;
}
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
Player attacker = (Player) event.getDamager(); Player attacker = (Player) event.getDamager();
if (!AntigriefManager.canInjure(attacker, player)) return; if (!AntigriefManager.canInjure(attacker, player)) {
return;
}
int totalGritPoints = EnchantChecks.getArmorPoints(player, this, 0); int totalGritPoints = EnchantChecks.getArmorPoints(player, this, 0);
if (totalGritPoints == 0) if (totalGritPoints == 0) {
return; return;
if (this.getDisabledWorlds().contains(player.getWorld())) return; }
if (!(attacker.getInventory().getItemInMainHand() instanceof Damageable)) if (this.getDisabledWorlds().contains(player.getWorld())) {
return; return;
}
if (!(attacker.getInventory().getItemInMainHand() instanceof Damageable)) {
return;
}
int damage = (int) Math.ceil(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * totalGritPoints); int damage = (int) Math.ceil(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * totalGritPoints);

View File

@ -7,6 +7,7 @@ import org.bukkit.World;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Hellish extends EcoEnchant { public class Hellish extends EcoEnchant {
public Hellish() { public Hellish() {
@ -19,9 +20,14 @@ public class Hellish extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull final LivingEntity attacker,
if(!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) @NotNull final LivingEntity victim,
@NotNull final Trident trident,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) {
return; return;
}
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Hook extends EcoEnchant { public class Hook extends EcoEnchant {
public Hook() { public Hook() {
@ -20,7 +21,11 @@ public class Hook extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier");
Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier);
if (VectorUtils.isFinite(vector)) { if (VectorUtils.isFinite(vector)) {

View File

@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Horde extends EcoEnchant { public class Horde extends EcoEnchant {
public Horde() { public Horde() {
@ -17,7 +18,10 @@ public class Horde extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level") * level; double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance-per-level") * level;
int entitiesNearby = (int) attacker.getNearbyEntities(distance, distance, distance).stream().filter(entity -> entity instanceof LivingEntity).count(); int entitiesNearby = (int) attacker.getNearbyEntities(distance, distance, distance).stream().filter(entity -> entity instanceof LivingEntity).count();

View File

@ -9,6 +9,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class IceShot extends EcoEnchant { public class IceShot extends EcoEnchant {
public IceShot() { public IceShot() {
super( super(
@ -20,10 +22,15 @@ public class IceShot extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level)) {
return; return;
}
victim.setVelocity(new Vector(0, 0, 0)); victim.setVelocity(new Vector(0, 0, 0));
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30, level)); victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 30, level));

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class Identify extends EcoEnchant { public class Identify extends EcoEnchant {
public Identify() { public Identify() {
@ -21,11 +22,15 @@ public class Identify extends EcoEnchant {
@Override @Override
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { public void onDeflect(@NotNull final Player blocker,
@NotNull final LivingEntity attacker,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
if(!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level)) {
return; return;
}
int finalDuration = duration * level; int finalDuration = duration * level;

View File

@ -10,6 +10,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.jetbrains.annotations.NotNull;
public class Ignite extends EcoEnchant { public class Ignite extends EcoEnchant {
public Ignite() { public Ignite() {
@ -22,20 +23,26 @@ public class Ignite extends EcoEnchant {
@Override @Override
public void onArrowHit(LivingEntity uncastShooter, int level, ProjectileHitEvent event) { public void onArrowHit(@NotNull final LivingEntity uncastShooter,
if (!(uncastShooter instanceof Player)) final int level,
@NotNull final ProjectileHitEvent event) {
if (!(uncastShooter instanceof Player)) {
return; return;
}
if (event.getHitBlock() == null) if (event.getHitBlock() == null) {
return; return;
}
Player shooter = (Player) uncastShooter; Player shooter = (Player) uncastShooter;
if (!AntigriefManager.canBreakBlock(shooter, event.getHitBlock())) if (!AntigriefManager.canBreakBlock(shooter, event.getHitBlock())) {
return; return;
}
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level)) {
return; return;
}
BlockFace face = event.getHitBlockFace(); BlockFace face = event.getHitBlockFace();

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class IllusionAspect extends EcoEnchant { public class IllusionAspect extends EcoEnchant {
public IllusionAspect() { public IllusionAspect() {
@ -23,14 +24,20 @@ public class IllusionAspect extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull final LivingEntity attacker,
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { @NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (attacker instanceof Player
&& ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f
&& !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }
if(!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level)) {
return; return;
}
victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, level * 10 + 15, level)); victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, level * 10 + 15, level));
victim.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, level * 10 + 15, level)); victim.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, level * 10 + 15, level));

View File

@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Impact extends EcoEnchant { public class Impact extends EcoEnchant {
public Impact() { public Impact() {
@ -19,10 +20,15 @@ public class Impact extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Trident trident,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level)) {
return; return;
}
event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier"));
} }

View File

@ -6,6 +6,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.jetbrains.annotations.NotNull;
public class Inferno extends EcoEnchant { public class Inferno extends EcoEnchant {
public Inferno() { public Inferno() {
super( super(
@ -17,12 +19,12 @@ public class Inferno extends EcoEnchant {
@Override @Override
public void onTridentLaunch(LivingEntity shooter, Trident trident, int level, ProjectileLaunchEvent event) { public void onTridentLaunch(@NotNull LivingEntity shooter, @NotNull Trident trident, int level, @NotNull ProjectileLaunchEvent event) {
trident.setFireTicks(Integer.MAX_VALUE); trident.setFireTicks(Integer.MAX_VALUE);
} }
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(trident.getFireTicks() <= 0) return; if(trident.getFireTicks() <= 0) return;
victim.setFireTicks(100); victim.setFireTicks(100);

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Infuriate extends EcoEnchant { public class Infuriate extends EcoEnchant {
public Infuriate() { public Infuriate() {
@ -24,7 +25,7 @@ public class Infuriate extends EcoEnchant {
@Override @Override
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { public void onDeflect(@NotNull Player blocker, @NotNull LivingEntity attacker, int level, @NotNull EntityDamageByEntityEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Spider; import org.bukkit.entity.Spider;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Insecticide extends EcoEnchant { public class Insecticide extends EcoEnchant {
public Insecticide() { public Insecticide() {
@ -19,7 +20,7 @@ public class Insecticide extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Spider)) if(!(victim instanceof Spider))
return; return;

View File

@ -7,6 +7,8 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.jetbrains.annotations.NotNull;
public class Instantaneous extends EcoEnchant { public class Instantaneous extends EcoEnchant {
public Instantaneous() { public Instantaneous() {
super( super(
@ -18,7 +20,7 @@ public class Instantaneous extends EcoEnchant {
@Override @Override
public void onDamageBlock(Player player, Block block, int level, BlockDamageEvent event) { public void onDamageBlock(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockDamageEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -5,6 +5,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
public class Kinetic extends EcoEnchant { public class Kinetic extends EcoEnchant {
public Kinetic() { public Kinetic() {
super( super(
@ -16,7 +18,7 @@ public class Kinetic extends EcoEnchant {
@Override @Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
if(!event.getCause().equals(EntityDamageEvent.DamageCause.FLY_INTO_WALL)) return; if(!event.getCause().equals(EntityDamageEvent.DamageCause.FLY_INTO_WALL)) return;
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level"); double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level");

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Leeching extends EcoEnchant { public class Leeching extends EcoEnchant {
public Leeching() { public Leeching() {
super( super(
@ -17,7 +19,7 @@ public class Leeching extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level");
double amountToHeal = level * multiplier; double amountToHeal = level * multiplier;
double newHealth = attacker.getHealth() + amountToHeal; double newHealth = attacker.getHealth() + amountToHeal;

View File

@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -21,7 +22,7 @@ public class Lesion extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -10,6 +10,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Levitate extends EcoEnchant { public class Levitate extends EcoEnchant {
public Levitate() { public Levitate() {
super( super(
@ -21,7 +23,7 @@ public class Levitate extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -9,6 +9,8 @@ import org.bukkit.entity.Enderman;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube; import org.bukkit.entity.MagmaCube;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class LiquidShot extends EcoEnchant { public class LiquidShot extends EcoEnchant {
public LiquidShot() { public LiquidShot() {
super( super(
@ -20,7 +22,7 @@ public class LiquidShot extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman)) if(!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman))
return; return;

View File

@ -13,6 +13,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,7 +30,7 @@ public class Lumberjack extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
if (block.hasMetadata("block-ignore")) if (block.hasMetadata("block-ignore"))
return; return;

View File

@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Marking extends EcoEnchant { public class Marking extends EcoEnchant {
public Marking() { public Marking() {
@ -21,7 +22,7 @@ public class Marking extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
int ticks = ticksPerLevel * level; int ticks = ticksPerLevel * level;

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class NetherInfusion extends EcoEnchant { public class NetherInfusion extends EcoEnchant {
public NetherInfusion() { public NetherInfusion() {
super( super(
@ -17,7 +19,7 @@ public class NetherInfusion extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) if(!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER))
return; return;

View File

@ -7,6 +7,7 @@ import org.bukkit.World;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Netheric extends EcoEnchant { public class Netheric extends EcoEnchant {
public Netheric() { public Netheric() {
@ -19,7 +20,7 @@ public class Netheric extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER)) if(!attacker.getWorld().getEnvironment().equals(World.Environment.NETHER))
return; return;

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Nocturnal extends EcoEnchant { public class Nocturnal extends EcoEnchant {
public Nocturnal() { public Nocturnal() {
super( super(
@ -17,7 +19,7 @@ public class Nocturnal extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!attacker.getWorld().getEnvironment().equals(World.Environment.NORMAL)) if(!attacker.getWorld().getEnvironment().equals(World.Environment.NORMAL))
return; return;

View File

@ -7,6 +7,8 @@ import org.bukkit.Location;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Optics extends EcoEnchant { public class Optics extends EcoEnchant {
public Optics() { public Optics() {
super( super(
@ -18,7 +20,7 @@ public class Optics extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
Location land = arrow.getLocation(); Location land = arrow.getLocation();
Location source = attacker.getLocation(); Location source = attacker.getLocation();

View File

@ -7,6 +7,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.jetbrains.annotations.NotNull;
public class Oxygenate extends EcoEnchant { public class Oxygenate extends EcoEnchant {
public Oxygenate() { public Oxygenate() {
super( super(
@ -18,7 +20,7 @@ public class Oxygenate extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
if(player.getRemainingAir() == player.getMaximumAir()) return; if(player.getRemainingAir() == player.getMaximumAir()) return;
int oxygenLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "oxygen-per-level"); int oxygenLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "oxygen-per-level");

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Creeper;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Pacify extends EcoEnchant { public class Pacify extends EcoEnchant {
public Pacify() { public Pacify() {
@ -19,7 +20,7 @@ public class Pacify extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Creeper)) return; if(!(victim instanceof Creeper)) return;
double damage = event.getDamage(); double damage = event.getDamage();

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.Horse; import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Paladin extends EcoEnchant { public class Paladin extends EcoEnchant {
public Paladin() { public Paladin() {
super( super(
@ -17,7 +19,7 @@ public class Paladin extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(attacker.getVehicle() instanceof Horse)) return; if(!(attacker.getVehicle() instanceof Horse)) return;
double damage = event.getDamage(); double damage = event.getDamage();

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class Paralyze extends EcoEnchant { public class Paralyze extends EcoEnchant {
public Paralyze() { public Paralyze() {
@ -21,7 +22,7 @@ public class Paralyze extends EcoEnchant {
@Override @Override
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { public void onDeflect(@NotNull Player blocker, @NotNull LivingEntity attacker, int level, @NotNull EntityDamageByEntityEvent event) {
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))

View File

@ -7,6 +7,8 @@ import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Parasitic extends EcoEnchant { public class Parasitic extends EcoEnchant {
public Parasitic() { public Parasitic() {
super( super(
@ -18,7 +20,7 @@ public class Parasitic extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level");
double amountToHeal = level * multiplier; double amountToHeal = level * multiplier;
double newHealth = attacker.getHealth() + amountToHeal; double newHealth = attacker.getHealth() + amountToHeal;

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Phantasm extends EcoEnchant { public class Phantasm extends EcoEnchant {
public Phantasm() { public Phantasm() {
@ -20,7 +21,7 @@ public class Phantasm extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Zombie || victim instanceof Skeleton)) return; if(!(victim instanceof Zombie || victim instanceof Skeleton)) return;
double damage = event.getDamage(); double damage = event.getDamage();

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
@ -47,7 +48,7 @@ public class Plasmic extends EcoEnchant {
} }
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
EntityEquipment equipment = victim.getEquipment(); EntityEquipment equipment = victim.getEquipment();
if(equipment == null) return; if(equipment == null) return;

View File

@ -5,6 +5,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Protector extends EcoEnchant { public class Protector extends EcoEnchant {
public Protector() { public Protector() {
super( super(
@ -15,7 +17,7 @@ public class Protector extends EcoEnchant {
// START OF LISTENERS // START OF LISTENERS
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity uncastVictim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity uncastVictim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(uncastVictim instanceof Tameable)) return; if(!(uncastVictim instanceof Tameable)) return;
Tameable victim = (Tameable) uncastVictim; Tameable victim = (Tameable) uncastVictim;

View File

@ -5,6 +5,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Proximity extends EcoEnchant { public class Proximity extends EcoEnchant {
public Proximity() { public Proximity() {
super( super(
@ -16,7 +18,7 @@ public class Proximity extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
double distance = attacker.getLocation().distance(victim.getLocation()); double distance = attacker.getLocation().distance(victim.getLocation());
double decreaseAfter = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "when-closer-than-blocks"); double decreaseAfter = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "when-closer-than-blocks");

View File

@ -8,6 +8,8 @@ import org.bukkit.entity.Shulker;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.entity.Turtle; import org.bukkit.entity.Turtle;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Puncture extends EcoEnchant { public class Puncture extends EcoEnchant {
public Puncture() { public Puncture() {
super( super(
@ -19,7 +21,7 @@ public class Puncture extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Turtle || victim instanceof Shulker)) if(!(victim instanceof Turtle || victim instanceof Shulker))
return; return;

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Quadrilateralism extends EcoEnchant { public class Quadrilateralism extends EcoEnchant {
public Quadrilateralism() { public Quadrilateralism() {
@ -19,7 +20,7 @@ public class Quadrilateralism extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Slime)) if(!(victim instanceof Slime))
return; return;

View File

@ -9,6 +9,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class Radiance extends EcoEnchant { public class Radiance extends EcoEnchant {
public Radiance() { public Radiance() {
super( super(
@ -20,7 +22,7 @@ public class Radiance extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
double radius = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier"); double radius = level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "radius-multiplier");
int duration = level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level"); int duration = level * this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Monster;
import org.bukkit.entity.PigZombie; import org.bukkit.entity.PigZombie;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Rage extends EcoEnchant { public class Rage extends EcoEnchant {
public Rage() { public Rage() {
@ -24,7 +25,7 @@ public class Rage extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -6,6 +6,7 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.jetbrains.annotations.NotNull;
public class Rapid extends EcoEnchant { public class Rapid extends EcoEnchant {
public Rapid() { public Rapid() {
@ -18,7 +19,7 @@ public class Rapid extends EcoEnchant {
@Override @Override
public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { public void onBowShoot(@NotNull LivingEntity shooter, @NotNull Arrow arrow, int level, @NotNull EntityShootBowEvent event) {
double multiplier = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-faster-per-level") / 100) * level); double multiplier = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-faster-per-level") / 100) * level);
if (event.getForce() < multiplier) if (event.getForce() < multiplier)

View File

@ -5,6 +5,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
public class Reinforcement extends EcoEnchant { public class Reinforcement extends EcoEnchant {
public Reinforcement() { public Reinforcement() {
super( super(
@ -16,7 +18,7 @@ public class Reinforcement extends EcoEnchant {
@Override @Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) return; if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) return;
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level"); double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "reduction-per-level");

View File

@ -7,6 +7,8 @@ import org.bukkit.block.Block;
import org.bukkit.block.data.Ageable; import org.bukkit.block.data.Ageable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.jetbrains.annotations.NotNull;
public class Replenish extends EcoEnchant { public class Replenish extends EcoEnchant {
public Replenish() { public Replenish() {
super( super(
@ -18,7 +20,7 @@ public class Replenish extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
Material type = block.getType(); Material type = block.getType();
if(!(block.getBlockData() instanceof Ageable)) return; if(!(block.getBlockData() instanceof Ageable)) return;

View File

@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
public class Respirator extends EcoEnchant { public class Respirator extends EcoEnchant {
public Respirator() { public Respirator() {
@ -17,7 +18,7 @@ public class Respirator extends EcoEnchant {
@Override @Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
if(!event.getCause().equals(EntityDamageEvent.DamageCause.DRAGON_BREATH)) return; if(!event.getCause().equals(EntityDamageEvent.DamageCause.DRAGON_BREATH)) return;
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level"); double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level");

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Revenant extends EcoEnchant { public class Revenant extends EcoEnchant {
public Revenant() { public Revenant() {
@ -20,7 +21,7 @@ public class Revenant extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Zombie || victim instanceof Skeleton)) return; if(!(victim instanceof Zombie || victim instanceof Skeleton)) return;
double damage = event.getDamage(); double damage = event.getDamage();

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Serrated extends EcoEnchant { public class Serrated extends EcoEnchant {
public Serrated() { public Serrated() {
super( super(
@ -17,7 +19,7 @@ public class Serrated extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
double damage = event.getDamage(); double damage = event.getDamage();
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
double bonus = 1 + (multiplier * level); double bonus = 1 + (multiplier * level);

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Settle extends EcoEnchant { public class Settle extends EcoEnchant {
public Settle() { public Settle() {
@ -19,7 +20,7 @@ public class Settle extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Creeper)) return; if(!(victim instanceof Creeper)) return;
double damage = event.getDamage(); double damage = event.getDamage();

View File

@ -10,6 +10,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Sickening extends EcoEnchant { public class Sickening extends EcoEnchant {
public Sickening() { public Sickening() {
@ -22,7 +23,7 @@ public class Sickening extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Slaughter extends EcoEnchant { public class Slaughter extends EcoEnchant {
public Slaughter() { public Slaughter() {
@ -19,7 +20,7 @@ public class Slaughter extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(victim instanceof Monster) return; if(victim instanceof Monster) return;
double damage = event.getDamage(); double damage = event.getDamage();

View File

@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Stab extends EcoEnchant { public class Stab extends EcoEnchant {
public Stab() { public Stab() {
@ -17,7 +18,7 @@ public class Stab extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-base"); double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-base");
double perLevelDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level"); double perLevelDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level");
double damage = baseDamage + (level * perLevelDamage); double damage = baseDamage + (level * perLevelDamage);

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class Stalwart extends EcoEnchant { public class Stalwart extends EcoEnchant {
public Stalwart() { public Stalwart() {
@ -20,7 +21,7 @@ public class Stalwart extends EcoEnchant {
@Override @Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
if(!EnchantmentUtils.passedChance(this, level)) if(!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -12,6 +12,8 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class StoneSwitcher extends EcoEnchant { public class StoneSwitcher extends EcoEnchant {
public StoneSwitcher() { public StoneSwitcher() {
super( super(
@ -23,7 +25,7 @@ public class StoneSwitcher extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)
return; return;

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class StrayAspect extends EcoEnchant { public class StrayAspect extends EcoEnchant {
public StrayAspect() { public StrayAspect() {
@ -23,7 +24,7 @@ public class StrayAspect extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }

View File

@ -11,6 +11,8 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.jetbrains.annotations.NotNull;
public class Succession extends EcoEnchant { public class Succession extends EcoEnchant {
public Succession() { public Succession() {
super( super(
@ -22,7 +24,7 @@ public class Succession extends EcoEnchant {
@Override @Override
public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { public void onBowShoot(@NotNull LivingEntity shooter, @NotNull Arrow arrow, int level, @NotNull EntityShootBowEvent event) {
int number = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "extra-arrows"); int number = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "extra-arrows");
boolean fire = EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE); boolean fire = EnchantChecks.mainhand(shooter, Enchantment.ARROW_FIRE);

View File

@ -9,6 +9,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Supercritical extends EcoEnchant { public class Supercritical extends EcoEnchant {
public Supercritical() { public Supercritical() {
@ -21,7 +22,7 @@ public class Supercritical extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }

View File

@ -7,6 +7,8 @@ import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Sycophant extends EcoEnchant { public class Sycophant extends EcoEnchant {
public Sycophant() { public Sycophant() {
super( super(
@ -18,7 +20,7 @@ public class Sycophant extends EcoEnchant {
@Override @Override
public void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { public void onDeflect(@NotNull Player blocker, @NotNull LivingEntity attacker, int level, @NotNull EntityDamageByEntityEvent event) {
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level");
double amountToHeal = level * multiplier; double amountToHeal = level * multiplier;
double newHealth = attacker.getHealth() + amountToHeal; double newHealth = attacker.getHealth() + amountToHeal;

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Collection; import java.util.Collection;
public class Tectonic extends EcoEnchant { public class Tectonic extends EcoEnchant {
@ -21,7 +22,7 @@ public class Tectonic extends EcoEnchant {
@Override @Override
public void onFallDamage(LivingEntity faller, int level, EntityDamageEvent event) { public void onFallDamage(@NotNull LivingEntity faller, int level, @NotNull EntityDamageEvent event) {
if (!event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) if (!event.getCause().equals(EntityDamageEvent.DamageCause.FALL))
return; return;

View File

@ -10,6 +10,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Thor extends EcoEnchant { public class Thor extends EcoEnchant {
public Thor() { public Thor() {
@ -22,7 +23,7 @@ public class Thor extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Tornado extends EcoEnchant { public class Tornado extends EcoEnchant {
public Tornado() { public Tornado() {
super( super(
@ -17,7 +19,7 @@ public class Tornado extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
double baseVelocity = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-per-level"); double baseVelocity = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-per-level");
double yVelocity = baseVelocity * level; double yVelocity = baseVelocity * level;

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class Toxic extends EcoEnchant { public class Toxic extends EcoEnchant {
public Toxic() { public Toxic() {
@ -23,7 +24,7 @@ public class Toxic extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { if (attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }

View File

@ -12,6 +12,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -26,7 +27,7 @@ public class Transfuse extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)
return; return;

View File

@ -10,6 +10,8 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Tripleshot extends EcoEnchant { public class Tripleshot extends EcoEnchant {
public Tripleshot() { public Tripleshot() {
super( super(
@ -21,7 +23,7 @@ public class Tripleshot extends EcoEnchant {
@Override @Override
public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { public void onBowShoot(@NotNull LivingEntity shooter, @NotNull Arrow arrow, int level, @NotNull EntityShootBowEvent event) {
for (int i = -1; i < 2; i += 2) { for (int i = -1; i < 2; i += 2) {

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class VampireAspect extends EcoEnchant { public class VampireAspect extends EcoEnchant {
public VampireAspect() { public VampireAspect() {
@ -23,7 +24,7 @@ public class VampireAspect extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) { if(attacker instanceof Player && ProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown((Player) attacker) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) {
return; return;
} }

View File

@ -13,6 +13,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,7 +30,7 @@ public class Vein extends EcoEnchant {
@Override @Override
public void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { public void onBlockBreak(@NotNull Player player, @NotNull Block block, int level, @NotNull BlockBreakEvent event) {
if (block.hasMetadata("block-ignore")) if (block.hasMetadata("block-ignore"))
return; return;

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
public class Venom extends EcoEnchant { public class Venom extends EcoEnchant {
public Venom() { public Venom() {
@ -20,7 +21,7 @@ public class Venom extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -7,6 +7,7 @@ import org.bukkit.World;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Trident; import org.bukkit.entity.Trident;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class VoidAffinity extends EcoEnchant { public class VoidAffinity extends EcoEnchant {
public VoidAffinity() { public VoidAffinity() {
@ -19,7 +20,7 @@ public class VoidAffinity extends EcoEnchant {
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(!attacker.getWorld().getEnvironment().equals(World.Environment.THE_END)) if(!attacker.getWorld().getEnvironment().equals(World.Environment.THE_END))
return; return;

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
@ -38,7 +39,7 @@ public class Voltage extends EcoEnchant {
}; };
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
EntityEquipment equipment = victim.getEquipment(); EntityEquipment equipment = victim.getEquipment();
if(equipment == null) return; if(equipment == null) return;

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class WaterAffinity extends EcoEnchant { public class WaterAffinity extends EcoEnchant {
public WaterAffinity() { public WaterAffinity() {
super( super(
@ -17,7 +19,7 @@ public class WaterAffinity extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!attacker.getLocation().getBlock().getType().equals(Material.WATER)) if(!attacker.getLocation().getBlock().getType().equals(Material.WATER))
return; return;

View File

@ -8,6 +8,8 @@ import org.bukkit.entity.Enderman;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube; import org.bukkit.entity.MagmaCube;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class WaterAspect extends EcoEnchant { public class WaterAspect extends EcoEnchant {
public WaterAspect() { public WaterAspect() {
super( super(
@ -19,7 +21,7 @@ public class WaterAspect extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman)) if(!(victim instanceof Blaze || victim instanceof MagmaCube || victim instanceof Enderman))
return; return;

View File

@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public class Weakening extends EcoEnchant { public class Weakening extends EcoEnchant {
public Weakening() { public Weakening() {
@ -20,7 +21,7 @@ public class Weakening extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level"); int ticksPerLevel = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level");
int ticks = ticksPerLevel * level; int ticks = ticksPerLevel * level;

View File

@ -7,6 +7,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -21,7 +22,7 @@ public class Wound extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -8,6 +8,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Zeus extends EcoEnchant { public class Zeus extends EcoEnchant {
public Zeus() { public Zeus() {
@ -20,7 +21,7 @@ public class Zeus extends EcoEnchant {
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) if (!EnchantmentUtils.passedChance(this, level))
return; return;

View File

@ -9,6 +9,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.jetbrains.annotations.NotNull;
public class Harpoon extends EcoEnchant { public class Harpoon extends EcoEnchant {
public Harpoon() { public Harpoon() {
super( super(
@ -19,23 +21,34 @@ public class Harpoon extends EcoEnchant {
// START OF LISTENERS // START OF LISTENERS
@EventHandler @EventHandler
public void onFish(PlayerFishEvent event) { public void onFish(@NotNull final PlayerFishEvent event) {
if(!event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY)) if (!event.getState().equals(PlayerFishEvent.State.CAUGHT_ENTITY)) {
return; return;
}
if(!(event.getCaught() instanceof LivingEntity)) if (!(event.getCaught() instanceof LivingEntity)) {
return; return;
}
Player player = event.getPlayer(); Player player = event.getPlayer();
LivingEntity victim = (LivingEntity) event.getCaught(); LivingEntity victim = (LivingEntity) event.getCaught();
if(victim.hasMetadata("NPC")) return; if (victim.hasMetadata("NPC")) {
return;
}
if(!AntigriefManager.canInjure(player, victim)) return; if (!AntigriefManager.canInjure(player, victim)) {
return;
}
if (!EnchantChecks.mainhand(player, this)) return; if (!EnchantChecks.mainhand(player, this)) {
if(this.getDisabledWorlds().contains(player.getWorld())) return; return;
}
if (this.getDisabledWorlds().contains(player.getWorld())) {
return;
}
int level = EnchantChecks.getMainhandLevel(player, this); int level = EnchantChecks.getMainhandLevel(player, this);

View File

@ -6,6 +6,8 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class LifeSteal extends EcoEnchant { public class LifeSteal extends EcoEnchant {
public LifeSteal() { public LifeSteal() {
super( super(
@ -17,7 +19,7 @@ public class LifeSteal extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level"); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "health-per-level");
double amountToHeal = level * multiplier; double amountToHeal = level * multiplier;
double newHealth = attacker.getHealth() + amountToHeal; double newHealth = attacker.getHealth() + amountToHeal;

View File

@ -10,6 +10,8 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Pentashot extends EcoEnchant { public class Pentashot extends EcoEnchant {
public Pentashot() { public Pentashot() {
super( super(
@ -21,7 +23,7 @@ public class Pentashot extends EcoEnchant {
@Override @Override
public void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { public void onBowShoot(@NotNull LivingEntity shooter, @NotNull Arrow arrow, int level, @NotNull EntityShootBowEvent event) {
for (int i = -2; i <= 2; i += 1) { for (int i = -2; i <= 2; i += 1) {
if(i == 0) continue; if(i == 0) continue;

View File

@ -5,6 +5,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
public class Preservation extends EcoEnchant { public class Preservation extends EcoEnchant {
public Preservation() { public Preservation() {
super( super(
@ -16,7 +18,7 @@ public class Preservation extends EcoEnchant {
@Override @Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) return; if(event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) return;
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level"); double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level");

View File

@ -8,6 +8,7 @@ import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Razor extends EcoEnchant { public class Razor extends EcoEnchant {
public Razor() { public Razor() {
@ -20,7 +21,7 @@ public class Razor extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage"); double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage");
double extra = level*perLevelMultiplier + baseDamage; double extra = level*perLevelMultiplier + baseDamage;

View File

@ -6,6 +6,8 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
public class Spring extends EcoEnchant { public class Spring extends EcoEnchant {
public Spring() { public Spring() {
super( super(
@ -17,14 +19,14 @@ public class Spring extends EcoEnchant {
@Override @Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { public void onDamageWearingArmor(@NotNull LivingEntity victim, int level, @NotNull EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.FALL) { if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@Override @Override
public void onJump(Player player, int level, PlayerMoveEvent event) { public void onJump(@NotNull Player player, int level, @NotNull PlayerMoveEvent event) {
double multiplier = 0.5 + ((double) (level * level) / 4 - 0.2) / 3; double multiplier = 0.5 + ((double) (level * level) / 4 - 0.2) / 3;
player.setVelocity(player.getLocation().getDirection().multiply(multiplier).setY(multiplier)); player.setVelocity(player.getLocation().getDirection().multiply(multiplier).setY(multiplier));
} }

View File

@ -5,6 +5,8 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class Streamlining extends EcoEnchant { public class Streamlining extends EcoEnchant {
public Streamlining() { public Streamlining() {
super( super(
@ -16,7 +18,7 @@ public class Streamlining extends EcoEnchant {
@Override @Override
public void onArmorEquip(Player player, int level, ArmorEquipEvent event) { public void onArmorEquip(@NotNull Player player, int level, @NotNull ArmorEquipEvent event) {
if(level == 0) { if(level == 0) {
player.setWalkSpeed(0.2f); player.setWalkSpeed(0.2f);
return; return;

View File

@ -11,6 +11,7 @@ import org.bukkit.Location;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.jetbrains.annotations.NotNull;
public class Volatile extends EcoEnchant { public class Volatile extends EcoEnchant {
public Volatile() { public Volatile() {
@ -23,7 +24,7 @@ public class Volatile extends EcoEnchant {
@Override @Override
public void onMeleeAttack(LivingEntity uncastAttacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity uncastAttacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!(uncastAttacker instanceof Player)) return; if(!(uncastAttacker instanceof Player)) return;
Player attacker = (Player) uncastAttacker; Player attacker = (Player) uncastAttacker;

View File

@ -12,20 +12,22 @@ import org.bukkit.inventory.GrindstoneInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import java.util.Map; import java.util.Map;
public class GrindstoneListeners extends PluginDependent implements Listener { public class GrindstoneListeners extends PluginDependent implements Listener {
public GrindstoneListeners(AbstractEcoPlugin plugin) { public GrindstoneListeners(@NotNull final AbstractEcoPlugin plugin) {
super(plugin); super(plugin);
} }
@EventHandler @EventHandler
public void onGrindstone(InventoryClickEvent event) { public void onGrindstone(@NotNull final InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
if (player.getOpenInventory().getTopInventory().getType() != InventoryType.GRINDSTONE) if (player.getOpenInventory().getTopInventory().getType() != InventoryType.GRINDSTONE) {
return; return;
}
GrindstoneInventory inventory = (GrindstoneInventory) player.getOpenInventory().getTopInventory(); GrindstoneInventory inventory = (GrindstoneInventory) player.getOpenInventory().getTopInventory();
@ -39,7 +41,9 @@ public class GrindstoneListeners extends PluginDependent implements Listener {
if (toKeep.isEmpty()) { if (toKeep.isEmpty()) {
inventory.setItem(2, out); inventory.setItem(2, out);
} }
if (out == null) return; if (out == null) {
return;
}
ItemStack newOut = out.clone(); ItemStack newOut = out.clone();
if (newOut.getItemMeta() instanceof EnchantmentStorageMeta) { if (newOut.getItemMeta() instanceof EnchantmentStorageMeta) {

View File

@ -2,16 +2,20 @@ package com.willfp.ecoenchants.enchantments.support.merging.grindstone;
import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import lombok.experimental.UtilityClass;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@UtilityClass
public class GrindstoneMerge { public class GrindstoneMerge {
public static Map<Enchantment, Integer> doMerge(ItemStack top, ItemStack bottom) { public static Map<Enchantment, Integer> doMerge(@Nullable final ItemStack top,
@Nullable final ItemStack bottom) {
Map<Enchantment, Integer> bottomEnchants = new HashMap<>(); Map<Enchantment, Integer> bottomEnchants = new HashMap<>();
Map<Enchantment, Integer> topEnchants = new HashMap<>(); Map<Enchantment, Integer> topEnchants = new HashMap<>();
@ -36,17 +40,25 @@ public class GrindstoneMerge {
bottomEnchants.forEach(((enchantment, integer) -> { bottomEnchants.forEach(((enchantment, integer) -> {
if (EcoEnchants.getFromEnchantment(enchantment) != null) { if (EcoEnchants.getFromEnchantment(enchantment) != null) {
EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment);
if (!ecoEnchant.isGrindstoneable()) toKeep.putIfAbsent(enchantment, integer); if (!ecoEnchant.isGrindstoneable()) {
toKeep.putIfAbsent(enchantment, integer);
}
} else { } else {
if (enchantment.isCursed()) toKeep.putIfAbsent(enchantment, integer); if (enchantment.isCursed()) {
toKeep.putIfAbsent(enchantment, integer);
}
} }
})); }));
topEnchants.forEach(((enchantment, integer) -> { topEnchants.forEach(((enchantment, integer) -> {
if (EcoEnchants.getFromEnchantment(enchantment) != null) { if (EcoEnchants.getFromEnchantment(enchantment) != null) {
EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment); EcoEnchant ecoEnchant = EcoEnchants.getFromEnchantment(enchantment);
if (!ecoEnchant.isGrindstoneable()) toKeep.putIfAbsent(enchantment, integer); if (!ecoEnchant.isGrindstoneable()) {
toKeep.putIfAbsent(enchantment, integer);
}
} else { } else {
if (enchantment.isCursed()) toKeep.putIfAbsent(enchantment, integer); if (enchantment.isCursed()) {
toKeep.putIfAbsent(enchantment, integer);
}
} }
})); }));

View File

@ -14,47 +14,209 @@ import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
public interface Watcher { public interface Watcher {
default void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) {
/**
* Called when an entity shoots another entity with an arrow.
*
* @param attacker The shooter.
* @param victim The victim.
* @param arrow The arrow entity.
* @param level The level of the enchantment on the arrow.
* @param event The event that called this watcher.
*/
default void onArrowDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { /**
* Called when an entity damages another entity with a trident throw.
*
* @param attacker The shooter.
* @param victim The victim.
* @param trident The trident entity.
* @param level The level of the enchantment on the trident.
* @param event The event that called this watcher.
*/
default void onTridentDamage(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
@NotNull final Trident trident,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onJump(Player player, int level, PlayerMoveEvent event) { /**
* Called when a player jumps.
*
* @param player The player.
* @param level The level of the enchantment found on the player's armor.
* @param event The event that called this watcher.
*/
default void onJump(@NotNull final Player player,
final int level,
@NotNull final PlayerMoveEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { /**
* Called when an entity attacks another entity with a melee attack.
*
* @param attacker The attacker.
* @param victim The victim.
* @param level The level of the enchantment found on the attacker's weapon.
* @param event The event that called this watcher.
*/
default void onMeleeAttack(@NotNull final LivingEntity attacker,
@NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onBowShoot(LivingEntity shooter, Arrow arrow, int level, EntityShootBowEvent event) { /**
* Called when an entity shoots a bow.
*
* @param shooter The entity that shot the bow.
* @param arrow The arrow that was shot.
* @param level The level of the enchantment found on the bow.
* @param event The event that called this watcher.
*/
default void onBowShoot(@NotNull final LivingEntity shooter,
@NotNull final Arrow arrow,
final int level,
@NotNull final EntityShootBowEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onFallDamage(LivingEntity faller, int level, EntityDamageEvent event) { /**
* Called when an entity takes fall damage.
*
* @param faller The entity that took the fall damage.
* @param level The level of the enchantment found on the entity's armor.
* @param event The event that called this watcher.
*/
default void onFallDamage(@NotNull final LivingEntity faller,
final int level,
@NotNull final EntityDamageEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onArrowHit(LivingEntity shooter, int level, ProjectileHitEvent event) { /**
* Called when an arrow hits a block or entity.
*
* @param shooter The entity that shot the arrow.
* @param level The level of the enchantment found on the arrow.
* @param event The event that called this watcher.
*/
default void onArrowHit(@NotNull final LivingEntity shooter,
final int level,
@NotNull final ProjectileHitEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onTridentHit(LivingEntity shooter, int level, ProjectileHitEvent event) { /**
* Called when a trident hits a block or entity.
*
* @param shooter The entity that threw the trident.
* @param level The level of the enchantment found on the trident.
* @param event The event that called this watcher.
*/
default void onTridentHit(@NotNull final LivingEntity shooter,
final int level,
@NotNull final ProjectileHitEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onBlockBreak(Player player, Block block, int level, BlockBreakEvent event) { /**
* Called when a player breaks a block.
*
* @param player The player.
* @param block The block that was broken.
* @param level The level of the enchantment found on the player's main hand item.
* @param event The event that called this watcher.
*/
default void onBlockBreak(@NotNull final Player player,
@NotNull final Block block,
final int level,
@NotNull final BlockBreakEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) { /**
* Called when an entity takes damage wearing armor.
*
* @param victim The entity that took damage.
* @param level The level of the enchantment found on the entity's armor.
* @param event The event that called this watcher.
*/
default void onDamageWearingArmor(@NotNull final LivingEntity victim,
final int level,
@NotNull final EntityDamageEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onArmorEquip(Player player, int level, ArmorEquipEvent event) { /**
* Called when an entity puts on or takes off armor with an enchantment.
*
* @param player The player that equipped the armor.
* @param level The level of the enchantment found on the player's armor.
* @param event The event that called this watcher.
*/
default void onArmorEquip(@NotNull final Player player,
final int level,
@NotNull final ArmorEquipEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onDamageBlock(Player player, Block block, int level, BlockDamageEvent event) { /**
* Called when a player damages a block.
*
* @param player The player that damaged the block.
* @param block The damaged block.
* @param level The level of the enchantment found on the player's main hand.
* @param event The event that called this watcher.
*/
default void onDamageBlock(@NotNull final Player player,
@NotNull final Block block,
final int level,
@NotNull final BlockDamageEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onTridentLaunch(LivingEntity shooter, Trident trident, int level, ProjectileLaunchEvent event) { /**
* Called when an entity throws a trident.
*
* @param shooter The entity that threw the trident.
* @param trident The trident that was thrown.
* @param level The level of the enchantment found on the trident.
* @param event The event that called this watcher.
*/
default void onTridentLaunch(@NotNull final LivingEntity shooter,
@NotNull final Trident trident,
final int level,
@NotNull final ProjectileLaunchEvent event) {
// Empty default as enchantments only override required watchers.
} }
default void onDeflect(Player blocker, LivingEntity attacker, int level, EntityDamageByEntityEvent event) { /**
* Called when a player blocks an attack with a shield.
*
* @param blocker The player that blocked the attack.
* @param attacker The attacker.
* @param level The level of the enchantment found on the shield.
* @param event The event that called this watcher.
*/
default void onDeflect(@NotNull final Player blocker,
@NotNull final LivingEntity attacker,
final int level,
@NotNull final EntityDamageByEntityEvent event) {
// Empty default as enchantments only override required watchers.
} }
} }

View File

@ -14,7 +14,7 @@ public class HeatTreated extends BiomesEnchantment {
} }
@Override @Override
public boolean isValid(@NotNull Biome biome) { public boolean isValid(@NotNull final Biome biome) {
return Arrays.stream(new String[]{"desert", "badlands", "savanna"}).anyMatch(biome.name().toLowerCase()::contains); return Arrays.stream(new String[]{"desert", "badlands", "savanna"}).anyMatch(biome.name().toLowerCase()::contains);
} }
} }

View File

@ -13,7 +13,7 @@ public class Icelord extends BiomesEnchantment {
} }
@Override @Override
public boolean isValid(@NotNull Biome biome) { public boolean isValid(@NotNull final Biome biome) {
return Arrays.stream(new String[]{"snowy", "ice", "frozen"}).anyMatch(biome.name().toLowerCase()::contains); return Arrays.stream(new String[]{"snowy", "ice", "frozen"}).anyMatch(biome.name().toLowerCase()::contains);
} }
} }

View File

@ -23,6 +23,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
public abstract class SummoningEnchantment extends EcoEnchant { public abstract class SummoningEnchantment extends EcoEnchant {
private final SummoningType summoningType; private final SummoningType summoningType;
@ -36,21 +37,21 @@ public abstract class SummoningEnchantment extends EcoEnchant {
public abstract EntityType getEntity(); public abstract EntityType getEntity();
@Override @Override
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) { public void onMeleeAttack(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, int level, @NotNull EntityDamageByEntityEvent event) {
if(!summoningType.equals(SummoningType.MELEE)) return; if(!summoningType.equals(SummoningType.MELEE)) return;
doSpawn(attacker, victim, level); doSpawn(attacker, victim, level);
} }
@Override @Override
public void onArrowDamage(LivingEntity attacker, LivingEntity victim, Arrow arrow, int level, EntityDamageByEntityEvent event) { public void onArrowDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Arrow arrow, int level, @NotNull EntityDamageByEntityEvent event) {
if(!summoningType.equals(SummoningType.RANGED)) return; if(!summoningType.equals(SummoningType.RANGED)) return;
doSpawn(attacker, victim, level); doSpawn(attacker, victim, level);
} }
@Override @Override
public void onTridentDamage(LivingEntity attacker, LivingEntity victim, Trident trident, int level, EntityDamageByEntityEvent event) { public void onTridentDamage(@NotNull LivingEntity attacker, @NotNull LivingEntity victim, @NotNull Trident trident, int level, @NotNull EntityDamageByEntityEvent event) {
if(!summoningType.equals(SummoningType.TRIDENT)) return; if(!summoningType.equals(SummoningType.TRIDENT)) return;
doSpawn(attacker, victim, level); doSpawn(attacker, victim, level);