Removed command singletons

This commit is contained in:
Auxilor 2020-09-22 07:19:18 +01:00
parent 057fbeb24e
commit 3a43d9395d
6 changed files with 9 additions and 40 deletions

View File

@ -10,8 +10,6 @@ import java.util.Arrays;
import java.util.List;
public abstract class AbstractCommand implements CommandExecutor {
protected static AbstractCommand instance;
private final String name;
private final String permission;
private final boolean playersOnly;
@ -20,10 +18,9 @@ public abstract class AbstractCommand implements CommandExecutor {
this.name = name;
this.permission = permission;
this.playersOnly = playersOnly;
instance = this;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!command.getName().equalsIgnoreCase(name)) return false;

View File

@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
public final class CommandEcodebug extends AbstractCommand {
private CommandEcodebug() {
public CommandEcodebug() {
super("ecodebug", "ecoenchants.ecodebug", true);
}
@ -37,11 +37,4 @@ public final class CommandEcodebug extends AbstractCommand {
Bukkit.getLogger().info("--------------- END DEBUG ----------------");
}
public static AbstractCommand getInstance() {
if(instance == null) {
instance = new CommandEcodebug();
}
return instance;
}
}

View File

@ -14,7 +14,7 @@ import org.bukkit.event.HandlerList;
import java.util.List;
public final class CommandEcoreload extends AbstractCommand {
private CommandEcoreload() {
public CommandEcoreload() {
super("ecoreload", "ecoenchants.reload", false);
}
@ -41,11 +41,4 @@ public final class CommandEcoreload extends AbstractCommand {
}, 1);
}));
}
public static AbstractCommand getInstance() {
if(instance == null) {
instance = new CommandEcoreload();
}
return instance;
}
}

View File

@ -12,7 +12,7 @@ import org.bukkit.persistence.PersistentDataType;
import java.util.List;
public final class CommandEcoskip extends AbstractCommand {
private CommandEcoskip() {
public CommandEcoskip() {
super("ecoskip", "ecoenchants.skip", true);
}
@ -33,11 +33,4 @@ public final class CommandEcoskip extends AbstractCommand {
}
item.setItemMeta(meta);
}
public static AbstractCommand getInstance() {
if(instance == null) {
instance = new CommandEcoskip();
}
return instance;
}
}

View File

@ -16,7 +16,7 @@ import java.util.List;
import java.util.Set;
public final class CommandEnchantinfo extends AbstractCommand {
private CommandEnchantinfo() {
public CommandEnchantinfo() {
super("enchantinfo", "ecoenchants.enchantinfo", false);
}
@ -136,11 +136,4 @@ public final class CommandEnchantinfo extends AbstractCommand {
sender.sendMessage(string);
}));
}
public static AbstractCommand getInstance() {
if(instance == null) {
instance = new CommandEnchantinfo();
}
return instance;
}
}

View File

@ -380,10 +380,10 @@ public class Loader {
*/
Bukkit.getLogger().info("Loading Commands...");
Bukkit.getPluginCommand("ecoreload").setExecutor(CommandEcoreload.getInstance());
Bukkit.getPluginCommand("ecodebug").setExecutor(CommandEcodebug.getInstance());
Bukkit.getPluginCommand("enchantinfo").setExecutor(CommandEnchantinfo.getInstance());
Bukkit.getPluginCommand("ecoskip").setExecutor(CommandEcoskip.getInstance());
Bukkit.getPluginCommand("ecoreload").setExecutor(new CommandEcoreload());
Bukkit.getPluginCommand("ecodebug").setExecutor(new CommandEcodebug());
Bukkit.getPluginCommand("enchantinfo").setExecutor(new CommandEnchantinfo());
Bukkit.getPluginCommand("ecoskip").setExecutor(new CommandEcoskip());
Bukkit.getLogger().info("");
/*