From 610081dab4de10445ff07c63161e013fd18961e3 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 14 Jul 2021 13:41:45 +0200 Subject: [PATCH] Removed deprecated methods and classes --- .../java/com/willfp/eco/core/EcoPlugin.java | 68 +------- .../com/willfp/eco/core/Prerequisite.java | 9 - .../eco/core/command/AbstractCommand.java | 156 ------------------ .../core/command/AbstractTabCompleter.java | 66 -------- 4 files changed, 1 insertion(+), 298 deletions(-) delete mode 100644 eco-api/src/main/java/com/willfp/eco/core/command/AbstractCommand.java delete mode 100644 eco-api/src/main/java/com/willfp/eco/core/command/AbstractTabCompleter.java diff --git a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java index e649196a..74931e66 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java +++ b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java @@ -1,6 +1,5 @@ package com.willfp.eco.core; -import com.willfp.eco.core.command.AbstractCommand; import com.willfp.eco.core.command.impl.PluginCommand; import com.willfp.eco.core.config.ConfigHandler; import com.willfp.eco.core.config.base.ConfigYml; @@ -36,22 +35,12 @@ import java.util.Set; import java.util.logging.Logger; import java.util.stream.Collectors; -@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"}) public abstract class EcoPlugin extends JavaPlugin { /** * Loaded eco plugins. */ public static final List LOADED_ECO_PLUGINS = new ArrayList<>(); - /** - * The name of the plugin. - * - * @deprecated Pointless, use getName instead. - */ - @Getter - @Deprecated - private final String pluginName; - /** * The spigot resource ID of the plugin. */ @@ -251,49 +240,6 @@ public abstract class EcoPlugin extends JavaPlugin { @NotNull final String proxyPackage, @NotNull final String color, final boolean supportingExtensions) { - this("", resourceId, bStatsId, proxyPackage, color, supportingExtensions); - } - - /** - * Create a new plugin. - * - * @param pluginName The name of the plugin. - * @param resourceId The spigot resource ID for the plugin. - * @param bStatsId The bStats resource ID for the plugin. - * @param proxyPackage The package where proxy implementations are stored. - * @param color The color of the plugin (used in messages, such as &a, &b) - * @deprecated pluginName is redundant. - */ - @Deprecated - @SuppressWarnings("unused") - protected EcoPlugin(@NotNull final String pluginName, - final int resourceId, - final int bStatsId, - @NotNull final String proxyPackage, - @NotNull final String color) { - this(pluginName, resourceId, bStatsId, proxyPackage, color, false); - } - - /** - * Create a new plugin. - * - * @param pluginName The name of the plugin. - * @param resourceId The spigot resource ID for the plugin. - * @param bStatsId The bStats resource ID for the plugin. - * @param proxyPackage The package where proxy implementations are stored. - * @param color The color of the plugin (used in messages, such as &a, &b) - * @param supportingExtensions If the plugin supports extensions. - * @deprecated pluginName is redundant. - */ - @Deprecated - @SuppressWarnings("unused") - protected EcoPlugin(@NotNull final String pluginName, - final int resourceId, - final int bStatsId, - @NotNull final String proxyPackage, - @NotNull final String color, - final boolean supportingExtensions) { - this.pluginName = this.getName(); this.resourceId = resourceId; this.bStatsId = bStatsId; this.proxyPackage = proxyPackage; @@ -382,7 +328,6 @@ public abstract class EcoPlugin extends JavaPlugin { this.getListeners().forEach(listener -> this.getEventManager().registerListener(listener)); - this.getCommands().forEach(AbstractCommand::register); this.getPluginCommands().forEach(PluginCommand::register); this.getScheduler().runLater(this::afterLoad, 1); @@ -466,7 +411,7 @@ public abstract class EcoPlugin extends JavaPlugin { this.reload(); - this.getLogger().info("Loaded " + this.color + this.pluginName); + this.getLogger().info("Loaded " + this.color + this.getName()); } /** @@ -538,17 +483,6 @@ public abstract class EcoPlugin extends JavaPlugin { return new ArrayList<>(); } - /** - * The commands to be registered. - * - * @return A list of commands. - * @deprecated Use {@link this#getPluginCommands()} instead. - */ - @Deprecated - public List getCommands() { - return new ArrayList<>(); - } - /** * The commands to be registered. * diff --git a/eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java b/eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java index b59274f3..d53af350 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java +++ b/eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java @@ -24,15 +24,6 @@ public class Prerequisite { "Requires server to be running paper (or a fork)" ); - /** - * Requires the server to be running 1.17. - */ - @Deprecated - public static final Prerequisite v1_17 = new Prerequisite( - () -> ProxyConstants.NMS_VERSION.contains("17"), - "Requires server to be running 1.17+" - ); - /** * Requires the server to be running 1.17. */ diff --git a/eco-api/src/main/java/com/willfp/eco/core/command/AbstractCommand.java b/eco-api/src/main/java/com/willfp/eco/core/command/AbstractCommand.java deleted file mode 100644 index 697f9d7d..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/command/AbstractCommand.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.willfp.eco.core.command; - -import com.willfp.eco.core.PluginDependent; -import com.willfp.eco.core.EcoPlugin; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.PluginCommand; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.List; - -@Deprecated -@SuppressWarnings("DeprecatedIsStillUsed") -public abstract class AbstractCommand extends PluginDependent implements CommandExecutor { - /** - * The name of the command - *

- * i.e. the name used on execution, for example /enchantinfo would have the name enchantinfo. - */ - private final String name; - - /** - * The permission required to execute the command. - *

- * Written out as a string for flexibility with subclasses. - */ - private final String permission; - - /** - * Should the command only be allowed to be executed by players? - *

- * In other worlds, only allowed to be executed by console. - */ - private final boolean playersOnly; - - /** - * Create a new command. - *

- * The command will not be registered until {@link this#register()} is called. - *

- * The name cannot be the same as an existing command as this will conflict. - * - * @param plugin The owning {@link EcoPlugin}. - * @param name The name used in execution. - * @param permission The permission required to execute the command. - * @param playersOnly If only players should be able to execute this command. - */ - protected AbstractCommand(@NotNull final EcoPlugin plugin, - @NotNull final String name, - @NotNull final String permission, - final boolean playersOnly) { - super(plugin); - this.name = name; - this.permission = permission; - this.playersOnly = playersOnly; - } - - /** - * Get the {@link AbstractTabCompleter} associated with this command. - *

- * Implementations of {@link AbstractCommand} do not have to override this method: - * null represents no associated tab-completer. - * - * @return The associated {@link AbstractTabCompleter}, or null if none associated. - */ - public @Nullable AbstractTabCompleter getTab() { - return null; - } - - /** - * Get the name of the permission required to execute this command. - * - * @return The name of the permission. - */ - public String getPermission() { - return this.permission; - } - - /** - * Get the name of the command used in execution. - * - * @return The command name. - */ - public String getName() { - return this.name; - } - - /** - * Internal implementation used to clean up boilerplate. - * Used for parity with {@link CommandExecutor#onCommand(CommandSender, Command, String, String[])}. - *

- * Calls {@link this#onExecute(CommandSender, List)}. - * - * @param sender The executor of the command. - * @param command The bukkit command. - * @param label The name of the executed command. - * @param args The arguments of the command (anything after the physical command name) - * @return If the command was processed by the linked {@link EcoPlugin} - */ - @Override - public final boolean onCommand(@NotNull final CommandSender sender, - @NotNull final Command command, - @NotNull final String label, - @NotNull final String[] args) { - if (!command.getName().equalsIgnoreCase(name)) { - return false; - } - - if (playersOnly && !(sender instanceof Player)) { - sender.sendMessage(this.getPlugin().getLangYml().getMessage("not-player")); - return true; - } - - if (!sender.hasPermission(permission) && sender instanceof Player) { - sender.sendMessage(this.getPlugin().getLangYml().getNoPermission()); - return true; - } - - onExecute(sender, Arrays.asList(args)); - - return true; - } - - /** - * Registers the command with the server, - *

- * Requires the command name to exist, defined in plugin.yml. - */ - public final void register() { - PluginCommand command = Bukkit.getPluginCommand(name); - assert command != null; - command.setExecutor(this); - - AbstractTabCompleter tabCompleter = this.getTab(); - if (tabCompleter != null) { - command.setTabCompleter(tabCompleter); - } - } - - /** - * The code for the execution of the command (The actual functionality). - *

- * Unlike {@link this#onCommand(CommandSender, Command, String, String[])}, - * this does not return a value as the command will have been processed. - * - * @param sender The sender of the command - * @param args The arguments of the command - */ - protected abstract void onExecute(CommandSender sender, - List args); -} diff --git a/eco-api/src/main/java/com/willfp/eco/core/command/AbstractTabCompleter.java b/eco-api/src/main/java/com/willfp/eco/core/command/AbstractTabCompleter.java deleted file mode 100644 index 357ee69d..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/command/AbstractTabCompleter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.willfp.eco.core.command; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.List; - -@Deprecated -public abstract class AbstractTabCompleter implements TabCompleter { - /** - * The {@link AbstractCommand} that is tab-completed. - */ - private final AbstractCommand command; - - /** - * Create a tab-completer for a specified {@link AbstractCommand}. - * - * @param command The command to tab-complete. - */ - protected AbstractTabCompleter(@NotNull final AbstractCommand command) { - this.command = command; - } - - /** - * Internal implementation used to clean up boilerplate. - * Used for parity with {@link TabCompleter#onTabComplete(CommandSender, Command, String, String[])}. - *

- * Calls {@link this#onTab(CommandSender, List)}. - * - * @param sender The executor of the command. - * @param command The bukkit command. - * @param label The name of the executed command. - * @param args The arguments of the command (anything after the physical command name). - * @return The list of tab-completions. - */ - @Override - public @Nullable List onTabComplete(@NotNull final CommandSender sender, - @NotNull final Command command, - @NotNull final String label, - @NotNull final String[] args) { - if (!command.getName().equalsIgnoreCase(this.command.getName())) { - return null; - } - - if (!sender.hasPermission(this.command.getPermission())) { - return null; - } - - return onTab(sender, Arrays.asList(args)); - } - - /** - * The code for the tab-completion of the command (The actual functionality). - *

- * - * @param sender The sender of the command. - * @param args The arguments of the command. - * @return The list of tab-completions. - */ - public abstract List onTab(@NotNull CommandSender sender, - @NotNull List args); -}