diff --git a/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java b/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java index ff817984..5a9318ff 100644 --- a/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java +++ b/Extensions/Alchemy/src/main/java/com/willfp/ecoenchants/alchemy/Alchemy.java @@ -4,16 +4,12 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import com.willfp.ecoenchants.util.Logger; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityPotionEffectEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.potion.PotionEffect; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.stream.Collectors; public class Alchemy extends EcoEnchant { public Alchemy() { diff --git a/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java b/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java index 93b1199c..23015d27 100644 --- a/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java +++ b/Extensions/Effects/src/main/java/com/willfp/ecoenchants/effects/EffectsMain.java @@ -1,11 +1,7 @@ package com.willfp.ecoenchants.effects; import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.effects.enchants.JumpBoost; -import com.willfp.ecoenchants.effects.enchants.NightVision; -import com.willfp.ecoenchants.effects.enchants.Regeneration; -import com.willfp.ecoenchants.effects.enchants.Speed; -import com.willfp.ecoenchants.effects.enchants.WaterBreathing; +import com.willfp.ecoenchants.effects.enchants.*; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.extensions.Extension; import org.bukkit.Bukkit; diff --git a/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java b/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java index ffe6669b..923b553f 100644 --- a/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java +++ b/Extensions/Endershot/src/main/java/com/willfp/ecoenchants/endershot/Endershot.java @@ -8,7 +8,6 @@ import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.SoundCategory; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; diff --git a/Extensions/SprintArtifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java b/Extensions/SprintArtifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java index db7e6351..5e7d40e1 100644 --- a/Extensions/SprintArtifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java +++ b/Extensions/SprintArtifacts/src/main/java/com/willfp/ecoenchants/sprintartifacts/SprintArtifactsListener.java @@ -4,15 +4,12 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.itemtypes.Artifact; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.Location; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; import java.util.Objects; import java.util.Optional; diff --git a/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java b/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java index 4438fb01..453c284b 100644 --- a/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java +++ b/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningEnchantment.java @@ -11,12 +11,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.attribute.Attribute; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Mob; -import org.bukkit.entity.Player; -import org.bukkit.entity.Trident; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; diff --git a/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java b/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java index aa713edc..46479cb3 100644 --- a/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java +++ b/Extensions/Summoning/src/main/java/com/willfp/ecoenchants/summoning/SummoningMain.java @@ -3,11 +3,7 @@ package com.willfp.ecoenchants.summoning; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.extensions.Extension; -import com.willfp.ecoenchants.summoning.enchants.Crawler; -import com.willfp.ecoenchants.summoning.enchants.Firestorm; -import com.willfp.ecoenchants.summoning.enchants.Ghoul; -import com.willfp.ecoenchants.summoning.enchants.Metallic; -import com.willfp.ecoenchants.summoning.enchants.Mortality; +import com.willfp.ecoenchants.summoning.enchants.*; import org.bukkit.Bukkit; public class SummoningMain extends Extension { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java index 16f8a02a..338312d9 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/command/AbstractCommand.java @@ -7,6 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -15,7 +16,6 @@ public abstract class AbstractCommand implements CommandExecutor, Registerable { private final String name; private final String permission; private final boolean playersOnly; - private AbstractTabCompleter tabCompleter = null; protected AbstractCommand(String name, String permission, boolean playersOnly) { this.name = name; @@ -36,7 +36,7 @@ public abstract class AbstractCommand implements CommandExecutor, Registerable { } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNull String label, String[] args) { if(!command.getName().equalsIgnoreCase(name)) return false; if(playersOnly && !(sender instanceof Player)) { @@ -58,7 +58,7 @@ public abstract class AbstractCommand implements CommandExecutor, Registerable { public final void register() { Bukkit.getPluginCommand(name).setExecutor(this); - this.tabCompleter = this.getTab(); + AbstractTabCompleter tabCompleter = this.getTab(); if(tabCompleter != null) { Bukkit.getPluginCommand(name).setTabCompleter(tabCompleter); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java index 5f6e27ab..e7b90a8e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java @@ -5,7 +5,6 @@ import com.willfp.ecoenchants.command.AbstractCommand; import com.willfp.ecoenchants.display.EnchantmentCache; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import com.willfp.ecoenchants.extensions.loader.ExtensionLoader; import com.willfp.ecoenchants.util.Logger; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -14,11 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; @SuppressWarnings("unchecked") diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java index 76d14ad6..4ab9e6a2 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/ConfigManager.java @@ -1,10 +1,6 @@ package com.willfp.ecoenchants.config; -import com.willfp.ecoenchants.config.configs.Config; -import com.willfp.ecoenchants.config.configs.EnchantmentConfig; -import com.willfp.ecoenchants.config.configs.Lang; -import com.willfp.ecoenchants.config.configs.Rarity; -import com.willfp.ecoenchants.config.configs.Target; +import com.willfp.ecoenchants.config.configs.*; import java.util.HashMap; import java.util.HashSet; @@ -54,6 +50,7 @@ public class ConfigManager { * @param permissionName The permission name to match * @return The matching {@link EnchantmentConfig} */ + @SuppressWarnings("OptionalGetWithoutIsPresent") public static EnchantmentConfig getEnchantmentConfig(String permissionName) { return enchantmentConfigs.stream().filter(config -> config.getName().equalsIgnoreCase(permissionName)).findFirst().get(); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java index 6caffb04..5d8a49ff 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java @@ -6,13 +6,7 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; +import java.io.*; import java.nio.charset.StandardCharsets; /** @@ -27,7 +21,6 @@ public abstract class EnchantmentYamlConfig { private final JavaPlugin plugin = EcoEnchantsPlugin.getInstance(); private final Class source; private final EcoEnchant.EnchantmentType type; - private final File basedir = new File(this.plugin.getDataFolder(), "enchants/"); /** * Create new config yml @@ -41,6 +34,7 @@ public abstract class EnchantmentYamlConfig { this.source = plugin; this.type = type; + File basedir = new File(this.plugin.getDataFolder(), "enchants/"); if(!basedir.exists()) basedir.mkdirs(); File dir = new File(basedir, type.getName() + "/"); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java index 2fcb7f53..0141ec90 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/UpdatingYamlConfig.java @@ -5,11 +5,7 @@ import com.willfp.ecoenchants.util.Logger; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.nio.charset.StandardCharsets; public abstract class UpdatingYamlConfig { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index 6ed96bff..0e73762d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -16,11 +16,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java index 0df5e36d..7ec40f31 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/EnchantmentCache.java @@ -8,12 +8,7 @@ import com.willfp.ecoenchants.util.Logger; import org.apache.commons.lang.WordUtils; import org.bukkit.enchantments.Enchantment; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import java.util.*; @SuppressWarnings("deprecation") public class EnchantmentCache { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java index f616a0cf..5ee8f793 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketOpenWindowMerchant.java @@ -15,7 +15,6 @@ import java.lang.reflect.Modifier; import java.util.List; import java.util.stream.Collectors; -@SuppressWarnings("unchecked") public class PacketOpenWindowMerchant extends AbstractPacketAdapter { public PacketOpenWindowMerchant() { super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java index 8d2c47b2..b11baa1d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketSetSlot.java @@ -5,9 +5,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.willfp.ecoenchants.display.AbstractPacketAdapter; import com.willfp.ecoenchants.display.EnchantDisplay; import org.bukkit.inventory.ItemFlag; -import org.bukkit.persistence.PersistentDataType; -@SuppressWarnings("deprecation") public class PacketSetSlot extends AbstractPacketAdapter { public PacketSetSlot() { super(PacketType.Play.Server.SET_SLOT); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java index 01f7daae..e9e83d0e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/display/packets/PacketWindowItems.java @@ -5,9 +5,7 @@ import com.comphenix.protocol.events.PacketContainer; import com.willfp.ecoenchants.display.AbstractPacketAdapter; import com.willfp.ecoenchants.display.EnchantDisplay; import org.bukkit.inventory.ItemFlag; -import org.bukkit.persistence.PersistentDataType; -@SuppressWarnings("deprecation") public class PacketWindowItems extends AbstractPacketAdapter { public PacketWindowItems() { super(PacketType.Play.Server.WINDOW_ITEMS); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java index 994ed26d..a8992e20 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -23,6 +23,7 @@ import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; import java.util.*; @@ -70,7 +71,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist "Allows getting " + permissionName + " from an Enchanting Table", PermissionDefault.TRUE ); - permission.addParent(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*"), true); + permission.addParent(Objects.requireNonNull(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*")), true); Bukkit.getPluginManager().addPermission(permission); } @@ -345,7 +346,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist * @return The display name */ @Override - public String getName() { + public @NotNull String getName() { return name; } @@ -376,7 +377,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist */ @Override @Deprecated - public EnchantmentTarget getItemTarget() { + public @NotNull EnchantmentTarget getItemTarget() { return EnchantmentTarget.ALL; } @@ -407,7 +408,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist * @return If conflicts */ @Override - public boolean conflictsWith(Enchantment enchantment) { + public boolean conflictsWith(@NotNull Enchantment enchantment) { return conflicts.contains(enchantment); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java index 25719335..f154c65f 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -1,22 +1,10 @@ package com.willfp.ecoenchants.enchantments; import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.*; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.BreaklessnessCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.CallingCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.DecayCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.FragilityCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HarmlessnessCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HungerCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.InaccuracyCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.MisfortuneCurse; -import com.willfp.ecoenchants.enchantments.ecoenchants.curse.PermanenceCurse; +import com.willfp.ecoenchants.enchantments.ecoenchants.curse.*; import com.willfp.ecoenchants.enchantments.ecoenchants.normal.*; import com.willfp.ecoenchants.enchantments.ecoenchants.special.*; -import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Charge; -import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Dynamite; -import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile; -import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake; -import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize; +import com.willfp.ecoenchants.enchantments.ecoenchants.spell.*; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java index d61e666c..61627fde 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/curse/DecayCurse.java @@ -5,7 +5,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.Logger; import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java index 4d5a9ed5..5653c3b3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Abrasion.java @@ -30,7 +30,7 @@ public class Abrasion extends EcoEnchant { if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !notcharged) return; - ArrayList armor = new ArrayList(Arrays.asList(victim.getInventory().getArmorContents())); + ArrayList armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents())); if (armor.isEmpty()) return; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java index c8ff8c5a..2819c1bd 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Corrosive.java @@ -25,7 +25,7 @@ public class Corrosive extends EcoEnchant { if(!(uncastVictim instanceof Player)) return; Player victim = (Player) uncastVictim; - ArrayList armor = new ArrayList(Arrays.asList(victim.getInventory().getArmorContents())); + ArrayList armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents())); if (armor.isEmpty()) return; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java index 81e4248a..afd15f26 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/EnderSlayer.java @@ -17,7 +17,7 @@ public class EnderSlayer extends EcoEnchant { // START OF LISTENERS - private static Set endMobs = new HashSet() {{ + private static final Set endMobs = new HashSet() {{ add(EntityType.ENDERMITE); add(EntityType.ENDERMAN); add(EntityType.ENDER_DRAGON); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java index 99618100..b03357ac 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Fury.java @@ -5,11 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; import com.willfp.ecoenchants.nms.Cooldown; import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.entity.PigZombie; -import org.bukkit.entity.Player; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.util.Vector; public class Fury extends EcoEnchant { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java index 1cdbb26d..1bc7f5a5 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/InfernalTouch.java @@ -18,15 +18,7 @@ import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; public class InfernalTouch extends EcoEnchant { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java index 60efb1fa..1ea9e557 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Infuriate.java @@ -4,11 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.entity.PigZombie; -import org.bukkit.entity.Player; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.util.Vector; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java index 6830d52b..efa70308 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/LiquidShot.java @@ -2,11 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Blaze; -import org.bukkit.entity.Enderman; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; public class LiquidShot extends EcoEnchant { public LiquidShot() { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java index 4326c75c..71bc7bb0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rage.java @@ -4,11 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; import com.willfp.ecoenchants.util.VectorUtils; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.entity.PigZombie; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.util.Vector; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java index 30c73fcb..4b150a10 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Slicing.java @@ -22,7 +22,7 @@ public class Slicing extends EcoEnchant { // START OF LISTENERS - ArrayList entities = new ArrayList(); + private final ArrayList entities = new ArrayList<>(); @EventHandler public void onPlayerCollide(PlayerMoveEvent event) { @@ -49,11 +49,7 @@ public class Slicing extends EcoEnchant { victim.damage(level * damage, player); entities.add(victim); - Bukkit.getServer().getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), new Runnable() { - public void run() { - entities.remove(victim); - } - }, this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown")); + Bukkit.getServer().getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> entities.remove(victim), this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown")); if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage-elytra")) { DurabilityUtils.damageItem(player, player.getInventory().getChestplate(), 1, 38); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java index 3463c458..13f4d401 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Splash.java @@ -6,11 +6,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.nms.TridentStack; import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Trident; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java index 73879770..e37a201a 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java @@ -11,11 +11,7 @@ import com.willfp.ecoenchants.util.DropQueue; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Trident; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java index 687ddc50..b3d03c30 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -@SuppressWarnings("unchecked") +@SuppressWarnings({"unchecked", "unused"}) public class Aiming extends EcoEnchant { public Aiming() { super( diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java index ce54292d..88b1ccd0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Confusion.java @@ -34,7 +34,7 @@ public class Confusion extends EcoEnchant { if(!EnchantmentUtils.passedChance(this, level)) return; - List hotbar = new ArrayList(); + List hotbar = new ArrayList<>(); for (int i = 0; i < 9; i++) { hotbar.add(victim.getInventory().getItem(i)); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java index fba57940..56468fb6 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Frenzy.java @@ -29,8 +29,7 @@ public class Frenzy extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); int duration = (int) (level * 20 * this.getConfig().getDouble((EcoEnchants.CONFIG_LOCATION + "seconds-per-level"))); - int amplifier = level; - player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, duration, amplifier, true, true, true)); + player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, duration, level, true, true, true)); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java index b10f93ac..6295820e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Repairing.java @@ -5,7 +5,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.util.DurabilityUtils; -import com.willfp.ecoenchants.util.Logger; import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java index 8243856f..39276f5e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java @@ -10,11 +10,7 @@ import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; +import java.util.*; public class Soulbound extends EcoEnchant { public Soulbound() { super( diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java index 9d273b71..bb37d1ea 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Spring.java @@ -24,7 +24,7 @@ public class Spring extends EcoEnchant { @Override public void onJump(Player player, int level, 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)); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java index 7665be18..acb2f74b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Artifact.java @@ -54,7 +54,7 @@ public abstract class Artifact extends EcoEnchant { public Particle.DustOptions getDustOptions() { return null; - }; + } @EventHandler public void onBreak(BlockBreakEvent event) { @@ -144,7 +144,7 @@ public abstract class Artifact extends EcoEnchant { int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "particle-tick-delay"); - int noteColor = 0; + int noteColor; AtomicDouble color = new AtomicDouble(0); if(particle.equals(Particle.NOTE)) { noteColor = NumberUtils.randInt(0, 24); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java index 97255de5..1ae40f9b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/itemtypes/Spell.java @@ -17,12 +17,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import java.util.*; /** * Wrapper for Spell enchantments @@ -75,7 +70,7 @@ public abstract class Spell extends EcoEnchant { int level = EnchantChecks.getMainhandLevel(player, this); if(!cooldownTracker.containsKey(player.getUniqueId())) - cooldownTracker.put(player.getUniqueId(), new SpellRunnable(player, this)); + cooldownTracker.put(player.getUniqueId(), new SpellRunnable(this)); SpellRunnable runnable = cooldownTracker.get(player.getUniqueId()); runnable.setTask(() -> { @@ -101,7 +96,7 @@ public abstract class Spell extends EcoEnchant { public static int getCooldown(Spell spell, Player player) { if(!spell.cooldownTracker.containsKey(player.getUniqueId())) - spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(player, spell)); + spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(spell)); SpellRunnable runnable = spell.cooldownTracker.get(player.getUniqueId()); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java index 20f12eb8..4fc3d36c 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/meta/EnchantmentRarity.java @@ -145,7 +145,6 @@ public class EnchantmentRarity implements Registerable { public static void update() { Set raritiesNames = ConfigManager.getRarity().getRarities(); raritiesNames.forEach((rarity) -> { - String name = rarity; double probability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".table-probability"); int minimumLevel = ConfigManager.getRarity().getInt("rarities." + rarity + ".minimum-level"); double villagerProbability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".villager-probability"); @@ -155,7 +154,7 @@ public class EnchantmentRarity implements Registerable { customColor = StringUtils.translate(ConfigManager.getRarity().getString("rarities." + rarity + ".custom-color.color")); } - new EnchantmentRarity(name, probability, minimumLevel, villagerProbability, lootProbability, customColor).register(); + new EnchantmentRarity(rarity, probability, minimumLevel, villagerProbability, lootProbability, customColor).register(); }); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java index 0748296b..20fd8b3d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java @@ -4,7 +4,6 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.config.ConfigManager; import com.willfp.ecoenchants.integrations.anvilgui.AnvilGUIManager; import com.willfp.ecoenchants.nms.RepairCost; -import com.willfp.ecoenchants.util.Logger; import com.willfp.ecoenchants.util.NumberUtils; import com.willfp.ecoenchants.util.tuplets.Pair; import org.bukkit.Bukkit; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java index 24932f3e..08ca13b0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilMerge.java @@ -12,7 +12,6 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java index 0b212bd7..2963fd51 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/EnchantingListeners.java @@ -18,12 +18,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.scheduler.BukkitRunnable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; public class EnchantingListeners implements Listener { @@ -34,7 +29,7 @@ public class EnchantingListeners implements Listener { add(Material.SHEARS); add(Material.CARROT_ON_A_STICK); }}; - public static HashMap currentlyEnchantingSecondary = new HashMap<>(); + public static final HashMap currentlyEnchantingSecondary = new HashMap<>(); @EventHandler public void onPlayerLeave(PlayerQuitEvent event) { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java index 428fe7e2..4304b23f 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/obtaining/VillagerListeners.java @@ -14,11 +14,7 @@ import org.bukkit.inventory.MerchantRecipe; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; public class VillagerListeners implements Listener { @@ -66,7 +62,7 @@ public class VillagerListeners implements Listener { level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { int cost = event.getRecipe().getIngredients().get(0).getAmount(); - double enchantlevel1 = cost / 64; + double enchantlevel1 = (double) cost / 64; double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); @@ -147,7 +143,7 @@ public class VillagerListeners implements Listener { level = (int) Math.ceil(enchantlevel2 / enchantlevel3); } else { int cost = event.getRecipe().getIngredients().get(0).getAmount(); - double enchantlevel1 = cost / 64; + double enchantlevel1 = (double) cost / 64; double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1); double enchantlevel3 = 1 / (double) enchantment.getMaxLevel(); level = (int) Math.ceil(enchantlevel2 / enchantlevel3); diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java index 09263b5b..4ab989cb 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/SpellRunnable.java @@ -2,18 +2,13 @@ package com.willfp.ecoenchants.enchantments.util; import com.willfp.ecoenchants.enchantments.itemtypes.Spell; import com.willfp.ecoenchants.util.interfaces.Callable; -import org.bukkit.entity.Player; - -import java.util.UUID; public class SpellRunnable { - private final UUID player; private final Spell spell; private long endTime = 0; private Callable callable = () -> {}; - public SpellRunnable(Player player, Spell spell) { - this.player = player.getUniqueId(); + public SpellRunnable(Spell spell) { this.spell = spell; } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java index 5181d0cb..ebb44384 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/Watcher.java @@ -8,11 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Trident; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.player.PlayerMoveEvent; public interface Watcher { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java index 6f35febe..545d858b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java @@ -10,20 +10,12 @@ import com.willfp.ecoenchants.nms.TridentStack; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Trident; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java index adb14dbf..ede0b67e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorEquipEvent.java @@ -6,6 +6,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * @author Arnah @@ -34,7 +35,7 @@ public class ArmorEquipEvent extends PlayerEvent implements Cancellable { */ @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java index 3dbea915..4cf80e3f 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/armorequip/ArmorListener.java @@ -10,11 +10,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.*; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemBreakEvent; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java index 692f8427..c63cf15d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityEvent.java @@ -34,12 +34,12 @@ public class EntityDeathByEntityEvent extends Event { /** * The entity drops */ - private List drops; + private final List drops; /** * The xp to drop */ - private int xp; + private final int xp; /** * Create event based off parameters @@ -49,7 +49,7 @@ public class EntityDeathByEntityEvent extends Event { * @param xp The amount of xp to drop * @param deathEvent The associated {@link EntityDeathEvent} */ - public EntityDeathByEntityEvent(@NotNull LivingEntity victim, @NotNull Entity damager, @NotNull List drops, @NotNull int xp, @NotNull EntityDeathEvent deathEvent) { + public EntityDeathByEntityEvent(@NotNull LivingEntity victim, @NotNull Entity damager, @NotNull List drops, int xp, @NotNull EntityDeathEvent deathEvent) { this.victim = victim; this.damager = damager; this.drops = drops; @@ -99,7 +99,7 @@ public class EntityDeathByEntityEvent extends Event { } @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return HANDLERS; } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java index 87e20748..e87fa43b 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/entitydeathbyentity/EntityDeathByEntityListeners.java @@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicReference; public class EntityDeathByEntityListeners implements Listener { - Set events = new HashSet<>(); + final Set events = new HashSet<>(); @EventHandler(priority = EventPriority.HIGH) public void onEntityDamage(EntityDamageByEntityEvent event) { @@ -35,8 +35,7 @@ public class EntityDeathByEntityListeners implements Listener { new BukkitRunnable() { @Override public void run() { - if(events.contains(builtEvent)) - events.remove(builtEvent); + events.remove(builtEvent); } }.runTaskLater(EcoEnchantsPlugin.getInstance(), 1); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java index e7826fb1..90c5ec4d 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainBuilder.java @@ -6,7 +6,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.player.PlayerExpChangeEvent; class NaturalExpGainBuilder { - private LivingEntity victim = null; + private final LivingEntity victim = null; private boolean cancelled = false; private PlayerExpChangeEvent event; private Location loc; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java index 99f1bffb..8854d9b4 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainEvent.java @@ -34,7 +34,7 @@ public class NaturalExpGainEvent extends Event { } @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return HANDLERS; } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java index b1531043..672a823e 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/events/naturalexpgainevent/NaturalExpGainListeners.java @@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicReference; public class NaturalExpGainListeners implements Listener { - Set events = new HashSet<>(); + final Set events = new HashSet<>(); @EventHandler public void onExpChange(PlayerExpChangeEvent event) { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/extensions/loader/EcoExtensionLoader.java b/Plugin/src/main/java/com/willfp/ecoenchants/extensions/loader/EcoExtensionLoader.java index 531117b9..8847a704 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/extensions/loader/EcoExtensionLoader.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/extensions/loader/EcoExtensionLoader.java @@ -1,11 +1,8 @@ package com.willfp.ecoenchants.extensions.loader; import com.willfp.ecoenchants.EcoEnchantsPlugin; -import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.extensions.Extension; import com.willfp.ecoenchants.extensions.MalformedExtensionException; -import com.willfp.ecoenchants.util.Logger; -import com.willfp.ecoenchants.util.tuplets.Pair; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -15,8 +12,10 @@ import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * Class containing method to load extensions diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java index d2be0c4d..bd935dfa 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/antigrief/plugins/AntigriefFactionsUUID.java @@ -1,10 +1,6 @@ package com.willfp.ecoenchants.integrations.antigrief.plugins; -import com.massivecraft.factions.Board; -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Faction; +import com.massivecraft.factions.*; import com.massivecraft.factions.perms.PermissibleAction; import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper; import org.bukkit.Location; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java index 69b8c08c..2a6ae1dd 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/integrations/placeholder/plugins/PlaceholderIntegrationPAPI.java @@ -6,6 +6,7 @@ import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements PlaceholderIntegration { @Override @@ -19,22 +20,22 @@ public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements } @Override - public String getAuthor() { + public @NotNull String getAuthor() { return "Auxilor"; } @Override - public String getIdentifier() { + public @NotNull String getIdentifier() { return "ecoenchants"; } @Override - public String getVersion() { + public @NotNull String getVersion() { return EcoEnchantsPlugin.getInstance().getDescription().getVersion(); } @Override - public String onPlaceholderRequest(Player player, String identifier) { + public String onPlaceholderRequest(Player player, @NotNull String identifier) { return PlaceholderManager.getResult(player, identifier); } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/DropQueue.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/DropQueue.java index f4331f99..36c4c870 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/DropQueue.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/DropQueue.java @@ -2,11 +2,7 @@ package com.willfp.ecoenchants.util; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.entity.EntityType; import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Player; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/Loader.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/Loader.java index d4dac1af..07c98efc 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/Loader.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/Loader.java @@ -27,19 +27,13 @@ import com.willfp.ecoenchants.events.armorequip.ArmorListener; import com.willfp.ecoenchants.events.armorequip.DispenserArmorListener; import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityListeners; import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainListeners; -import com.willfp.ecoenchants.extensions.loader.ExtensionLoader; import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatAAC; import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatMatrix; import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatNCP; import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatSpartan; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefFactionsUUID; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefGriefPrevention; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefKingdoms; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefLands; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefTowny; -import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefWorldGuard; +import com.willfp.ecoenchants.integrations.antigrief.plugins.*; import com.willfp.ecoenchants.integrations.anvilgui.AnvilGUIManager; import com.willfp.ecoenchants.integrations.anvilgui.plugins.AnvilGUIImpl; import com.willfp.ecoenchants.integrations.essentials.EssentialsManager; @@ -50,11 +44,7 @@ import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager; import com.willfp.ecoenchants.integrations.placeholder.plugins.PlaceholderIntegrationPAPI; import com.willfp.ecoenchants.listeners.ArrowListeners; import com.willfp.ecoenchants.listeners.PlayerJoinListener; -import com.willfp.ecoenchants.nms.BlockBreak; -import com.willfp.ecoenchants.nms.Cooldown; -import com.willfp.ecoenchants.nms.OpenInventory; -import com.willfp.ecoenchants.nms.RepairCost; -import com.willfp.ecoenchants.nms.TridentStack; +import com.willfp.ecoenchants.nms.*; import com.willfp.ecoenchants.util.interfaces.Callable; import com.willfp.ecoenchants.util.interfaces.EcoRunnable; import com.willfp.ecoenchants.util.optional.Prerequisite; @@ -65,11 +55,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.generator.BlockPopulator; import org.bukkit.plugin.Plugin; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java index 2c003c13..bea5cb29 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/StringUtils.java @@ -12,20 +12,20 @@ import static net.md_5.bungee.api.ChatColor.COLOR_CHAR; public class StringUtils { public static String translate(String message, Player player) { message = PlaceholderManager.translatePlaceholders(message, player); - message = translateHexColorCodes("&#", "", message); + message = translateHexColorCodes(message); message = ChatColor.translateAlternateColorCodes('&', message); - return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes("&#", "", message)); + return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes(message)); } public static String translate(String message) { message = PlaceholderManager.translatePlaceholders(message, null); - message = translateHexColorCodes("&#", "", message); + message = translateHexColorCodes(message); message = ChatColor.translateAlternateColorCodes('&', message); - return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes("&#", "", message)); + return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes(message)); } - private static String translateHexColorCodes(String startTag, String endTag, String message) { - Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag); + private static String translateHexColorCodes(String message) { + Pattern hexPattern = Pattern.compile("&#" + "([A-Fa-f0-9]{6})" + ""); Matcher matcher = hexPattern.matcher(message); StringBuffer buffer = new StringBuffer(message.length() + 4 * 8); while(matcher.find()) { diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java index 23ac8877..287262ff 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/util/VectorShapes.java @@ -12,7 +12,7 @@ public class VectorShapes { * @return An array of {@link Vector}s */ public static Vector[] getCircle(int radius) { - ArrayList circleVecs = new ArrayList(); + ArrayList circleVecs = new ArrayList<>(); int xoffset = -radius; int zoffset = -radius; @@ -40,7 +40,7 @@ public class VectorShapes { * @return An array of {@link Vector}s */ public static Vector[] getSquare(int radius) { - ArrayList circleVecs = new ArrayList(); + ArrayList circleVecs = new ArrayList<>(); int xoffset = -radius; int zoffset = -radius; @@ -63,7 +63,7 @@ public class VectorShapes { * @return An array of {@link Vector}s */ public static Vector[] getCube(int radius) { - ArrayList cubeVecs = new ArrayList(); + ArrayList cubeVecs = new ArrayList<>(); int xoffset = -radius; int zoffset = -radius;