Removed deprecated methods and classes
This commit is contained in:
@@ -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<String> 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<AbstractCommand> getCommands() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* The commands to be registered.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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<EcoPlugin> implements CommandExecutor {
|
||||
/**
|
||||
* The name of the command
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Written out as a string for flexibility with subclasses.
|
||||
*/
|
||||
private final String permission;
|
||||
|
||||
/**
|
||||
* Should the command only be allowed to be executed by players?
|
||||
* <p>
|
||||
* In other worlds, only allowed to be executed by console.
|
||||
*/
|
||||
private final boolean playersOnly;
|
||||
|
||||
/**
|
||||
* Create a new command.
|
||||
* <p>
|
||||
* The command will not be registered until {@link this#register()} is called.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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[])}.
|
||||
* <p>
|
||||
* 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,
|
||||
* <p>
|
||||
* 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).
|
||||
* <p>
|
||||
* Unlike {@link this#onCommand(CommandSender, Command, String, String[])},
|
||||
* this does not return a value as the command <b>will</b> have been processed.
|
||||
*
|
||||
* @param sender The sender of the command
|
||||
* @param args The arguments of the command
|
||||
*/
|
||||
protected abstract void onExecute(CommandSender sender,
|
||||
List<String> args);
|
||||
}
|
||||
@@ -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[])}.
|
||||
* <p>
|
||||
* 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<String> 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).
|
||||
* <p>
|
||||
*
|
||||
* @param sender The sender of the command.
|
||||
* @param args The arguments of the command.
|
||||
* @return The list of tab-completions.
|
||||
*/
|
||||
public abstract List<String> onTab(@NotNull CommandSender sender,
|
||||
@NotNull List<String> args);
|
||||
}
|
||||
Reference in New Issue
Block a user