Remove commands.yml

This commit is contained in:
Alexander Söderberg 2020-07-08 13:40:55 +02:00 committed by Alexander Söderberg
parent 5004005c5a
commit 265c10ec1c
2 changed files with 6 additions and 48 deletions

View File

@ -154,12 +154,10 @@ public class PlotSquared {
public File styleFile; public File styleFile;
public File configFile; public File configFile;
public File worldsFile; public File worldsFile;
public File commandsFile;
public File translationFile; public File translationFile;
public YamlConfiguration style; public YamlConfiguration style;
public YamlConfiguration worlds; public YamlConfiguration worlds;
public YamlConfiguration storage; public YamlConfiguration storage;
public YamlConfiguration commands;
// Temporary hold the plots/clusters before the worlds load // Temporary hold the plots/clusters before the worlds load
public HashMap<String, Set<PlotCluster>> clusters_tmp; public HashMap<String, Set<PlotCluster>> clusters_tmp;
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp; public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
@ -1796,23 +1794,6 @@ public class PlotSquared {
} catch (IOException ignored) { } catch (IOException ignored) {
PlotSquared.log("Failed to save storage.yml"); 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; return true;
} }

View File

@ -25,9 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@ -40,7 +38,6 @@ import com.plotsquared.core.util.task.RunnableVal3;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@ -190,36 +187,16 @@ public abstract class Command {
this.permission = declaration.permission(); this.permission = declaration.permission();
this.required = declaration.requiredType(); this.required = declaration.requiredType();
this.category = declaration.category(); this.category = declaration.category();
List<String> aliasOptions = new ArrayList<>(); List<String> aliasOptions = new ArrayList<>();
aliasOptions.add(this.id); aliasOptions.add(this.id);
aliasOptions.addAll(Arrays.asList(declaration.aliases())); aliasOptions.addAll(Arrays.asList(declaration.aliases()));
HashMap<String, Object> 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<String, Object> 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 = aliasOptions;
} this.description = declaration.description();
this.aliases = commands.getStringList(this.getFullId() + ".aliases"); this.usage = declaration.usage();
this.description = commands.getString(this.getFullId() + ".description"); this.confirmation = declaration.confirmation();
this.usage = commands.getString(this.getFullId() + ".usage");
this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation");
if (this.parent != null) { if (this.parent != null) {
this.parent.register(this); this.parent.register(this);
} }