mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-16 04:31:22 +01:00
Code Quality improvements
This commit is contained in:
parent
f0f42a2035
commit
c3eb825381
@ -41,12 +41,11 @@ public class CommandEcodebug extends AbstractCommand {
|
||||
@NotNull final List<String> args) {
|
||||
if (!args.isEmpty() && args.get(0).equalsIgnoreCase("full")) {
|
||||
Bukkit.getLogger().info("--------------- BEGIN DEBUG ----------------");
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString());
|
||||
if (sender instanceof Player player) {
|
||||
player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand());
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString());
|
||||
Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand());
|
||||
Bukkit.getLogger().info("");
|
||||
}
|
||||
|
||||
@ -87,7 +86,7 @@ public class CommandEcodebug extends AbstractCommand {
|
||||
|
||||
List<Enchantment> uncached = Arrays.stream(Enchantment.values()).collect(Collectors.toList());
|
||||
uncached.removeAll(EnchantmentCache.getCache().values().stream().map(EnchantmentCache.CacheEntry::getEnchantment).collect(Collectors.toList()));
|
||||
Bukkit.getLogger().info("Uncached Enchantments: " + uncached.toString());
|
||||
Bukkit.getLogger().info("Uncached Enchantments: " + uncached);
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
List<Enchantment> brokenCache = Arrays.stream(Enchantment.values()).collect(Collectors.toList());
|
||||
@ -95,10 +94,10 @@ public class CommandEcodebug extends AbstractCommand {
|
||||
EnchantmentCache.getEntry(enchantment).getName().equalsIgnoreCase("null")
|
||||
|| EnchantmentCache.getEntry(enchantment).getRawName().equalsIgnoreCase("null")
|
||||
|| EnchantmentCache.getEntry(enchantment).getStringDescription().equalsIgnoreCase("null")));
|
||||
Bukkit.getLogger().info("Enchantments with broken cache: " + brokenCache.toString());
|
||||
Bukkit.getLogger().info("Enchantments with broken cache: " + brokenCache);
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
Bukkit.getLogger().info("Installed Plugins: " + Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()).toString());
|
||||
Bukkit.getLogger().info("Installed Plugins: " + Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()));
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
Set<EcoEnchant> withIssues = new HashSet<>();
|
||||
@ -110,12 +109,12 @@ public class CommandEcodebug extends AbstractCommand {
|
||||
withIssues.add(enchant);
|
||||
}
|
||||
});
|
||||
Bukkit.getLogger().info("Enchantments with evident issues: " + withIssues.toString());
|
||||
Bukkit.getLogger().info("Enchantments with evident issues: " + withIssues);
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
Bukkit.getLogger().info("Packets: " + ProtocolLibrary.getProtocolManager().getPacketListeners().stream()
|
||||
.filter(packetListener -> packetListener.getSendingWhitelist().getPriority().equals(ListenerPriority.MONITOR))
|
||||
.collect(Collectors.toList()).toString());
|
||||
.collect(Collectors.toList()));
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
Bukkit.getLogger().info("Server Information: ");
|
||||
@ -128,13 +127,12 @@ public class CommandEcodebug extends AbstractCommand {
|
||||
Bukkit.getLogger().info("Motd: " + Bukkit.getServer().getMotd());
|
||||
Bukkit.getLogger().info("--------------- END DEBUG ----------------");
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand().toString());
|
||||
if (sender instanceof Player player) {
|
||||
player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand());
|
||||
player.sendMessage("Lore: ");
|
||||
Bukkit.getLogger().info("");
|
||||
|
||||
Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString());
|
||||
Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand());
|
||||
Bukkit.getLogger().info("Lore: ");
|
||||
ItemMeta meta = player.getInventory().getItemInMainHand().getItemMeta();
|
||||
if (meta != null) {
|
||||
|
@ -225,11 +225,8 @@ public class EnchantDisplay extends DisplayModule {
|
||||
if (meta == null) {
|
||||
return new Object[]{false};
|
||||
}
|
||||
boolean hideEnchants = false;
|
||||
|
||||
if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||
hideEnchants = true;
|
||||
}
|
||||
boolean hideEnchants = meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
|
||||
if (meta.getPersistentDataContainer().has(legacyV, PersistentDataType.INTEGER)) {
|
||||
hideEnchants = false;
|
||||
|
@ -18,12 +18,10 @@ public class HungerCurse extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onHunger(@NotNull final FoodLevelChangeEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!EnchantChecks.helmet(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -25,10 +25,9 @@ public class Abrasion extends EcoEnchant {
|
||||
@NotNull final LivingEntity uncastVictim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(uncastVictim instanceof Player)) {
|
||||
if (!(uncastVictim instanceof Player victim)) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) uncastVictim;
|
||||
|
||||
if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) {
|
||||
return;
|
||||
|
@ -19,11 +19,10 @@ public class Aversion extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onEndermanTarget(@NotNull final EntityTargetLivingEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Enderman)) {
|
||||
if (!(event.getEntity() instanceof Enderman enderman)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Enderman enderman = (Enderman) event.getEntity();
|
||||
LivingEntity target = event.getTarget();
|
||||
|
||||
if (event.getReason() != EntityTargetEvent.TargetReason.CLOSEST_PLAYER) {
|
||||
|
@ -26,10 +26,9 @@ public class Corrosive extends EcoEnchant {
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(uncastVictim instanceof Player)) {
|
||||
if (!(uncastVictim instanceof Player victim)) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) uncastVictim;
|
||||
|
||||
ArrayList<ItemStack> armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents()));
|
||||
if (armor.isEmpty()) {
|
||||
|
@ -21,12 +21,10 @@ public class Defender extends EcoEnchant {
|
||||
@NotNull final Arrow arrow,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(victim instanceof Tameable)) {
|
||||
if (!(victim instanceof Tameable pet)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tameable pet = (Tameable) victim;
|
||||
|
||||
if (pet.getOwner() == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -36,16 +36,13 @@ public class Enderism extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onHit(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Arrow)) {
|
||||
if (!(event.getDamager() instanceof Arrow arrow)) {
|
||||
return;
|
||||
}
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) {
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
|
||||
assert player != null;
|
||||
if (!player.getWorld().getEnvironment().equals(World.Environment.THE_END)) {
|
||||
return;
|
||||
|
@ -31,22 +31,18 @@ public class Fetching extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getKiller() instanceof Wolf)) {
|
||||
if (!(event.getKiller() instanceof Wolf wolf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Wolf wolf = (Wolf) event.getKiller();
|
||||
|
||||
if (!wolf.isTamed() || wolf.getOwner() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(wolf.getOwner() instanceof Player)) {
|
||||
if (!(wolf.getOwner() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) wolf.getOwner();
|
||||
|
||||
if (!(EnchantChecks.helmet(player, this))) {
|
||||
return;
|
||||
}
|
||||
|
@ -22,17 +22,14 @@ public class Frozen extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onHurt(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof LivingEntity)) {
|
||||
if (!(event.getDamager() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
LivingEntity victim = (LivingEntity) event.getDamager();
|
||||
|
||||
final int points = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
|
||||
if (points == 0) {
|
||||
|
@ -21,17 +21,14 @@ public class Grit extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onGritHurt(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof Player)) {
|
||||
if (!(event.getDamager() instanceof Player attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
Player attacker = (Player) event.getDamager();
|
||||
|
||||
if (!AntigriefManager.canInjure(attacker, player)) {
|
||||
return;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class Ignite extends EcoEnchant {
|
||||
public void onArrowHit(@NotNull final LivingEntity uncastShooter,
|
||||
final int level,
|
||||
@NotNull final ProjectileHitEvent event) {
|
||||
if (!(uncastShooter instanceof Player)) {
|
||||
if (!(uncastShooter instanceof Player shooter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ public class Ignite extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Player shooter = (Player) uncastShooter;
|
||||
if (!AntigriefManager.canBreakBlock(shooter, event.getHitBlock())) {
|
||||
return;
|
||||
}
|
||||
|
@ -25,17 +25,14 @@ public class Incandescence extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof LivingEntity)) {
|
||||
if (!(event.getDamager() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
LivingEntity victim = (LivingEntity) event.getDamager();
|
||||
|
||||
int totalIncandescencePoints = EnchantChecks.getArmorPoints(player, this);
|
||||
|
||||
if (totalIncandescencePoints == 0) {
|
||||
|
@ -43,10 +43,9 @@ public class InfernalTouch extends EcoEnchant {
|
||||
Iterator<Recipe> iterator = Bukkit.recipeIterator();
|
||||
while (iterator.hasNext()) {
|
||||
Recipe recipe = iterator.next();
|
||||
if (!(recipe instanceof FurnaceRecipe)) {
|
||||
if (!(recipe instanceof FurnaceRecipe furnaceRecipe)) {
|
||||
continue;
|
||||
}
|
||||
FurnaceRecipe furnaceRecipe = (FurnaceRecipe) recipe;
|
||||
int xp = (int) Math.ceil(furnaceRecipe.getExperience());
|
||||
RECIPES.put(furnaceRecipe.getInput().getType(), new Pair<>(furnaceRecipe.getResult().getType(), xp));
|
||||
}
|
||||
|
@ -19,12 +19,10 @@ public class Invigoration extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onInvigorationHurt(@NotNull final EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (player.getHealth() > this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "below-health")) {
|
||||
return;
|
||||
}
|
||||
@ -45,12 +43,10 @@ public class Invigoration extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onInvigorationDamage(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Player)) {
|
||||
if (!(event.getDamager() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getDamager();
|
||||
|
||||
if (player.getHealth() > this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "below-health")) {
|
||||
return;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class LuckyCatch extends EcoEnchant {
|
||||
|
||||
Entity caught = event.getCaught();
|
||||
|
||||
if (!(caught instanceof Item)) {
|
||||
if (!(caught instanceof Item caughtItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,8 +48,6 @@ public class LuckyCatch extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Item caughtItem = (Item) caught;
|
||||
|
||||
caughtItem.getItemStack().setAmount(caughtItem.getItemStack().getAmount() * 2);
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,10 @@ public class Marking extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onHitWhileMarked(@NotNull final EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if (!victim.hasMetadata("marked")) {
|
||||
return;
|
||||
}
|
||||
|
@ -20,12 +20,10 @@ public class Marksman extends EcoEnchant {
|
||||
@EventHandler
|
||||
public void onMarksmanShoot(@NotNull final ProjectileLaunchEvent event) {
|
||||
|
||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,12 +26,11 @@ public class Necrotic extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof WitherSkeleton)) {
|
||||
if (!(event.getEntity() instanceof WitherSkeleton victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getEntity().getKiller();
|
||||
WitherSkeleton victim = (WitherSkeleton) event.getEntity();
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) {
|
||||
return;
|
||||
|
@ -18,7 +18,7 @@ public class Parry extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void parryHit(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -26,8 +26,6 @@ public class Parry extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -19,11 +19,10 @@ public class Protector extends EcoEnchant {
|
||||
@NotNull final LivingEntity uncastVictim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(uncastVictim instanceof Tameable)) {
|
||||
if (!(uncastVictim instanceof Tameable victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tameable victim = (Tameable) uncastVictim;
|
||||
if (victim.getOwner() == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -32,10 +32,9 @@ public class Radiance extends EcoEnchant {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(e instanceof LivingEntity)) {
|
||||
if (!(e instanceof LivingEntity entity)) {
|
||||
continue;
|
||||
}
|
||||
LivingEntity entity = (LivingEntity) e;
|
||||
|
||||
if (e.equals(attacker)) {
|
||||
continue;
|
||||
|
@ -20,11 +20,11 @@ public class Rebounding extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof LivingEntity)) {
|
||||
if (!(event.getDamager() instanceof LivingEntity attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -32,9 +32,6 @@ public class Rebounding extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
LivingEntity attacker = (LivingEntity) event.getDamager();
|
||||
|
||||
int level = EnchantChecks.getArmorPoints(victim, this);
|
||||
|
||||
if (level == 0) {
|
||||
|
@ -26,14 +26,12 @@ public class Reel extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
if (!(event.getCaught() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getCaught();
|
||||
|
||||
if (victim.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class Rejuvenation extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onRejuvenationHeal(@NotNull final EntityRegainHealthEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -26,8 +26,6 @@ public class Rejuvenation extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
int totalRejuvenationPoints = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
|
@ -23,7 +23,7 @@ public class Replenish extends EcoEnchant {
|
||||
@NotNull final BlockBreakEvent event) {
|
||||
Material type = block.getType();
|
||||
|
||||
if (!(block.getBlockData() instanceof Ageable)) {
|
||||
if (!(block.getBlockData() instanceof Ageable data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ public class Replenish extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Ageable data = (Ageable) block.getBlockData();
|
||||
if (data.getAge() != data.getMaximumAge()) {
|
||||
event.setDropItems(false);
|
||||
event.setExpToDrop(0);
|
||||
|
@ -18,12 +18,10 @@ public class Sating extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onSatingHunger(@NotNull final FoodLevelChangeEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!EnchantChecks.helmet(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -24,17 +24,14 @@ public class Shockwave extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onShoot(@NotNull final ProjectileLaunchEvent event) {
|
||||
if (!(event.getEntity() instanceof AbstractArrow)) {
|
||||
if (!(event.getEntity() instanceof AbstractArrow entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
AbstractArrow entity = (AbstractArrow) event.getEntity();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (entity instanceof Trident) {
|
||||
item = TridentUtils.getItemStack((Trident) entity);
|
||||
|
@ -24,7 +24,7 @@ public class ShotAssist extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) {
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,8 +36,6 @@ public class ShotAssist extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
|
||||
assert player != null;
|
||||
|
||||
int points = EnchantChecks.getArmorPoints(player, this, 0);
|
||||
|
@ -35,22 +35,18 @@ public class Spearfishing extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Trident)) {
|
||||
if (!(event.getEntity() instanceof Trident trident)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Trident trident = (Trident) event.getEntity();
|
||||
|
||||
if (!trident.getWorld().getBlockAt(trident.getLocation().add(0, 0.2, 0)).getType().equals(Material.WATER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
@ -24,14 +24,12 @@ public class Spiked extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
if (!(event.getCaught() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getCaught();
|
||||
|
||||
if (victim.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
|
@ -48,12 +48,10 @@ public class Splash extends EcoEnchant {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(victim instanceof LivingEntity)) {
|
||||
if (!(victim instanceof LivingEntity entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LivingEntity entity = (LivingEntity) victim;
|
||||
|
||||
if (victim.equals(shooter)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -18,12 +18,10 @@ public class Stamina extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onStaminaHunger(@NotNull final FoodLevelChangeEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!player.isSprinting()) {
|
||||
return;
|
||||
}
|
||||
|
@ -31,12 +31,10 @@ public class Weakening extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(@NotNull final EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if (!victim.hasMetadata("weak")) {
|
||||
return;
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ public class Aiming extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void aimingLaunch(@NotNull final ProjectileLaunchEvent event) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Arrow)) {
|
||||
if (!(event.getEntity() instanceof Arrow arrow)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,9 +42,6 @@ public class Aiming extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
Arrow arrow = (Arrow) event.getEntity();
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -25,10 +25,9 @@ public class Confusion extends EcoEnchant {
|
||||
@NotNull final LivingEntity uncastVictim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(uncastVictim instanceof Player)) {
|
||||
if (!(uncastVictim instanceof Player victim)) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) uncastVictim;
|
||||
|
||||
if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) {
|
||||
return;
|
||||
|
@ -24,14 +24,12 @@ public class Harpoon extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
if (!(event.getCaught() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getCaught();
|
||||
|
||||
if (victim.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
|
@ -25,12 +25,10 @@ public class Instability extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -22,12 +22,10 @@ public class Volatile extends EcoEnchant {
|
||||
@NotNull final LivingEntity victim,
|
||||
final int level,
|
||||
@NotNull final EntityDamageByEntityEvent event) {
|
||||
if (!(uncastAttacker instanceof Player)) {
|
||||
if (!(uncastAttacker instanceof Player attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player attacker = (Player) uncastAttacker;
|
||||
|
||||
if (!EnchantmentUtils.isFullyChargeIfRequired(this, attacker)) {
|
||||
return;
|
||||
}
|
||||
|
@ -144,10 +144,9 @@ public class EnchantmentRarity {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof EnchantmentRarity)) {
|
||||
if (!(o instanceof EnchantmentRarity that)) {
|
||||
return false;
|
||||
}
|
||||
EnchantmentRarity that = (EnchantmentRarity) o;
|
||||
return Objects.equals(getName(), that.getName());
|
||||
}
|
||||
|
||||
|
@ -228,10 +228,9 @@ public class EnchantmentType {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof EnchantmentType)) {
|
||||
if (!(o instanceof EnchantmentType that)) {
|
||||
return false;
|
||||
}
|
||||
EnchantmentType that = (EnchantmentType) o;
|
||||
return Objects.equals(getName(), that.getName());
|
||||
}
|
||||
|
||||
|
@ -220,8 +220,7 @@ public class AnvilMerge {
|
||||
|
||||
ItemStack output = left.clone();
|
||||
|
||||
if (output.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) output.getItemMeta();
|
||||
if (output.getItemMeta() instanceof EnchantmentStorageMeta meta) {
|
||||
meta.getStoredEnchants().forEach(((enchantment, integer) -> {
|
||||
meta.removeStoredEnchant(enchantment);
|
||||
}));
|
||||
|
@ -58,8 +58,7 @@ public class GrindstoneListeners extends PluginDependent implements Listener {
|
||||
}
|
||||
|
||||
ItemStack newOut = out.clone();
|
||||
if (newOut.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) newOut.getItemMeta();
|
||||
if (newOut.getItemMeta() instanceof EnchantmentStorageMeta meta) {
|
||||
toKeep.forEach(((enchantment, integer) -> {
|
||||
meta.addStoredEnchant(enchantment, integer, true);
|
||||
}));
|
||||
|
@ -207,8 +207,7 @@ public class EnchantingListeners extends PluginDependent implements Listener {
|
||||
if (item0 == null) {
|
||||
return;
|
||||
}
|
||||
if (item0.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item0.getItemMeta();
|
||||
if (item0.getItemMeta() instanceof EnchantmentStorageMeta meta) {
|
||||
for (Enchantment enchantment : meta.getStoredEnchants().keySet()) {
|
||||
meta.removeStoredEnchant(enchantment);
|
||||
}
|
||||
|
@ -57,11 +57,10 @@ public class LootPopulator extends BlockPopulator {
|
||||
|
||||
for (BlockState state : chunk.getTileEntities()) {
|
||||
Block block = state.getBlock();
|
||||
if (!(block.getState() instanceof Chest)) {
|
||||
if (!(block.getState() instanceof Chest chestState)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Chest chestState = (Chest) block.getState();
|
||||
Inventory inventory = chestState.getBlockInventory();
|
||||
|
||||
for (ItemStack item : inventory) {
|
||||
@ -148,8 +147,7 @@ public class LootPopulator extends BlockPopulator {
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getItemMeta() instanceof EnchantmentStorageMeta) {
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
|
||||
if (item.getItemMeta() instanceof EnchantmentStorageMeta meta) {
|
||||
toAdd.forEach(((enchantment, integer) -> meta.addStoredEnchant(enchantment, integer, false)));
|
||||
item.setItemMeta(meta);
|
||||
} else {
|
||||
|
@ -57,12 +57,10 @@ public class VillagerListeners extends PluginDependent implements Listener {
|
||||
float priceMultiplier = event.getRecipe().getPriceMultiplier();
|
||||
List<ItemStack> ingredients = event.getRecipe().getIngredients();
|
||||
|
||||
if (!(result.getItemMeta() instanceof EnchantmentStorageMeta)) {
|
||||
if (!(result.getItemMeta() instanceof EnchantmentStorageMeta meta)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) result.getItemMeta();
|
||||
|
||||
ArrayList<EcoEnchant> enchantments = new ArrayList<>(EcoEnchants.values());
|
||||
Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis
|
||||
|
||||
|
@ -116,11 +116,10 @@ public class EnchantChecks {
|
||||
}
|
||||
|
||||
MetadataValue enchantmentsMetaValue = arrow.getMetadata("shot-from").get(0);
|
||||
if (!(enchantmentsMetaValue.value() instanceof ItemStack)) {
|
||||
if (!(enchantmentsMetaValue.value() instanceof ItemStack shotFrom)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ItemStack shotFrom = (ItemStack) enchantmentsMetaValue.value();
|
||||
return getItemLevel(shotFrom, enchantment);
|
||||
}
|
||||
|
||||
@ -136,11 +135,10 @@ public class EnchantChecks {
|
||||
}
|
||||
|
||||
MetadataValue enchantmentsMetaValue = arrow.getMetadata("shot-from").get(0);
|
||||
if (!(enchantmentsMetaValue.value() instanceof ItemStack)) {
|
||||
if (!(enchantmentsMetaValue.value() instanceof ItemStack shotFrom)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
ItemStack shotFrom = (ItemStack) enchantmentsMetaValue.value();
|
||||
return getEnchantsOnItem(shotFrom);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemConversions extends PluginDependent implements Listener {
|
||||
/**
|
||||
@ -141,7 +140,7 @@ public class ItemConversions extends PluginDependent implements Listener {
|
||||
continue;
|
||||
}
|
||||
|
||||
String enchantName = lineSplit.stream().collect(Collectors.joining(" "));
|
||||
String enchantName = String.join(" ", lineSplit);
|
||||
enchant = EcoEnchants.getByName(enchantName);
|
||||
}
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof Arrow)) {
|
||||
if (!(event.getDamager() instanceof Arrow arrow)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -96,14 +96,10 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof LivingEntity)) {
|
||||
if (!(((Arrow) event.getDamager()).getShooter() instanceof LivingEntity attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity attacker = (LivingEntity) ((Arrow) event.getDamager()).getShooter();
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if (!allowOnNPC) {
|
||||
if (victim.hasMetadata("NPC")) {
|
||||
return;
|
||||
@ -146,11 +142,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof Trident)) {
|
||||
if (!(event.getDamager() instanceof Trident trident)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(((Trident) event.getDamager()).getShooter() instanceof LivingEntity)) {
|
||||
if (!(((Trident) event.getDamager()).getShooter() instanceof LivingEntity attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -158,7 +154,7 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -166,12 +162,8 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity attacker = (LivingEntity) ((Trident) event.getDamager()).getShooter();
|
||||
Trident trident = (Trident) event.getDamager();
|
||||
ItemStack item = TridentUtils.getItemStack(trident);
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if (!allowOnNPC) {
|
||||
if (victim.hasMetadata("NPC")) {
|
||||
return;
|
||||
@ -256,11 +248,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof LivingEntity)) {
|
||||
if (!(event.getDamager() instanceof LivingEntity attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -272,9 +264,6 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity attacker = (LivingEntity) event.getDamager();
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if (!allowOnNPC) {
|
||||
if (victim.hasMetadata("NPC")) {
|
||||
return;
|
||||
@ -402,12 +391,10 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
EnchantChecks.getEnchantsOnArmor(victim).forEach((enchant, level) -> {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -436,11 +423,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity().getShooter() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity().getShooter() instanceof LivingEntity shooter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Arrow)) {
|
||||
if (!(event.getEntity() instanceof Arrow arrow)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -448,9 +435,6 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Arrow arrow = (Arrow) event.getEntity();
|
||||
LivingEntity shooter = (LivingEntity) event.getEntity().getShooter();
|
||||
|
||||
EnchantChecks.getEnchantsOnArrow(arrow).forEach(((enchant, level) -> {
|
||||
if (!enchant.isEnabled()) {
|
||||
return;
|
||||
@ -475,7 +459,7 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity().getShooter() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity().getShooter() instanceof LivingEntity shooter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -483,13 +467,11 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Trident)) {
|
||||
if (!(event.getEntity() instanceof Trident trident)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Trident trident = (Trident) event.getEntity();
|
||||
ItemStack item = TridentUtils.getItemStack(trident);
|
||||
LivingEntity shooter = (LivingEntity) event.getEntity().getShooter();
|
||||
|
||||
EnchantChecks.getEnchantsOnItem(item).forEach((enchant, level) -> {
|
||||
if (!enchant.isEnabled()) {
|
||||
@ -554,12 +536,10 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
EnchantChecks.getEnchantsOnArmor(victim).forEach((enchant, level) -> {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -650,7 +630,7 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Trident)) {
|
||||
if (!(event.getEntity() instanceof Trident trident)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -658,7 +638,6 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Trident trident = (Trident) event.getEntity();
|
||||
LivingEntity shooter = (LivingEntity) trident.getShooter();
|
||||
ItemStack item = TridentUtils.getItemStack(trident);
|
||||
|
||||
@ -690,18 +669,14 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player blocker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof LivingEntity)) {
|
||||
if (!(event.getDamager() instanceof LivingEntity attacker)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player blocker = (Player) event.getEntity();
|
||||
|
||||
LivingEntity attacker = (LivingEntity) event.getDamager();
|
||||
|
||||
if (!blocker.isBlocking()) {
|
||||
return;
|
||||
}
|
||||
|
@ -35,12 +35,10 @@ public class Alchemy extends EcoEnchant {
|
||||
if (event.getNewEffect() == null) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
||||
if (!(event.getEntity() instanceof LivingEntity entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
||||
|
||||
if (entity.hasMetadata(event.getNewEffect().toString())) {
|
||||
return;
|
||||
}
|
||||
|
@ -31,12 +31,10 @@ public class Endershot extends EcoEnchant {
|
||||
if (event.getProjectile().getType() != EntityType.ARROW) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
if (!(event.getEntity() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
return;
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ public class Precision extends EcoEnchant {
|
||||
|
||||
@EventHandler
|
||||
public void aimingLaunch(@NotNull final ProjectileLaunchEvent event) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player)) {
|
||||
if (!(event.getEntity().getShooter() instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Trident)) {
|
||||
if (!(event.getEntity() instanceof Trident trident)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -43,9 +43,6 @@ public class Precision extends EcoEnchant {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
Trident trident = (Trident) event.getEntity();
|
||||
|
||||
ItemStack itemStack = TridentUtils.getItemStack(trident);
|
||||
if (!EnchantChecks.item(itemStack, this)) {
|
||||
return;
|
||||
|
@ -44,7 +44,7 @@ public class SprintArtifactsListener implements Listener {
|
||||
.filter(Objects::nonNull)
|
||||
.filter(enchantment -> enchantment.getType().equals(EnchantmentType.ARTIFACT))
|
||||
.findFirst();
|
||||
if (!matching.isPresent()) {
|
||||
if (matching.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Artifact artifact = (Artifact) matching.get();
|
||||
|
@ -112,12 +112,10 @@ public class Xray extends Spell {
|
||||
}
|
||||
|
||||
for (MetadataValue meta : block.getMetadata("xray-uuid")) {
|
||||
if (!(meta.value() instanceof UUID)) {
|
||||
if (!(meta.value() instanceof UUID uuid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UUID uuid = (UUID) meta.value();
|
||||
|
||||
assert uuid != null;
|
||||
|
||||
Entity entity = Bukkit.getServer().getEntity(uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user