diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 30d738afc..0ebcc7b1c 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -154,12 +154,10 @@ public class PlotSquared { public File styleFile; public File configFile; public File worldsFile; - public File commandsFile; public File translationFile; public YamlConfiguration style; public YamlConfiguration worlds; public YamlConfiguration storage; - public YamlConfiguration commands; // Temporary hold the plots/clusters before the worlds load public HashMap> clusters_tmp; public HashMap> plots_tmp; @@ -1796,23 +1794,6 @@ public class PlotSquared { } catch (IOException ignored) { PlotSquared.log("Failed to save storage.yml"); } - try { - this.commandsFile = new File(folder, "commands.yml"); - if (!this.commandsFile.exists() && !this.commandsFile.createNewFile()) { - PlotSquared.log( - "Could not the storage settings file, please create \"commands.yml\" manually."); - } - this.commands = YamlConfiguration.loadConfiguration(this.commandsFile); - } catch (IOException ignored) { - PlotSquared.log("Failed to save commands.yml"); - } - try { - this.style.save(this.styleFile); - this.commands.save(this.commandsFile); - } catch (IOException e) { - PlotSquared.log("Configuration file saving failed"); - e.printStackTrace(); - } return true; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java index 7238d4566..194fc48a4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -25,9 +25,7 @@ */ package com.plotsquared.core.command; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; -import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.util.MainUtil; @@ -40,7 +38,6 @@ import com.plotsquared.core.util.task.RunnableVal3; import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -190,36 +187,16 @@ public abstract class Command { this.permission = declaration.permission(); this.required = declaration.requiredType(); this.category = declaration.category(); + List aliasOptions = new ArrayList<>(); aliasOptions.add(this.id); aliasOptions.addAll(Arrays.asList(declaration.aliases())); - HashMap options = new HashMap<>(); - options.put("aliases", aliasOptions); - options.put("description", declaration.description()); - options.put("usage", declaration.usage()); - options.put("confirmation", declaration.confirmation()); - boolean set = false; - YamlConfiguration commands = - PlotSquared.get() == null ? new YamlConfiguration() : PlotSquared.get().commands; - for (Map.Entry entry : options.entrySet()) { - String key = this.getFullId() + "." + entry.getKey(); - if (!commands.contains(key)) { - commands.set(key, entry.getValue()); - set = true; - } - } - if (set && PlotSquared.get() != null) { - try { - commands.save(PlotSquared.get().commandsFile); - } catch (IOException e) { - e.printStackTrace(); - } - } - this.aliases = commands.getStringList(this.getFullId() + ".aliases"); - this.description = commands.getString(this.getFullId() + ".description"); - this.usage = commands.getString(this.getFullId() + ".usage"); - this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation"); + this.aliases = aliasOptions; + this.description = declaration.description(); + this.usage = declaration.usage(); + this.confirmation = declaration.confirmation(); + if (this.parent != null) { this.parent.register(this); }