mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
add full commands list dump command
This commit is contained in:
+31
@@ -1,5 +1,9 @@
|
||||
package eu.endermite.commandwhitelist.common;
|
||||
|
||||
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -63,4 +67,31 @@ public class CommandUtil {
|
||||
return parts[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps command list to a file
|
||||
*
|
||||
* @param serverCommands Commands to dump
|
||||
* @return True on successful file save
|
||||
*/
|
||||
public static boolean dumpAllBukkitCommands(ArrayList<String> serverCommands, File file) {
|
||||
try {
|
||||
File parent = new File(file.getParent());
|
||||
if (!parent.exists())
|
||||
parent.mkdir();
|
||||
if (!file.exists())
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ConfigFile dumpFile = ConfigFile.loadConfig(file);
|
||||
dumpFile.set("commands", serverCommands);
|
||||
try {
|
||||
dumpFile.save();
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -63,7 +63,7 @@ public class CWCommand {
|
||||
}
|
||||
|
||||
public enum CommandType {
|
||||
ADD, REMOVE, HELP, RELOAD
|
||||
ADD, REMOVE, HELP, RELOAD, DUMP
|
||||
}
|
||||
|
||||
public enum ImplementationType {
|
||||
@@ -88,6 +88,7 @@ public class CWCommand {
|
||||
if (adminPerm) {
|
||||
list.add("add");
|
||||
list.add("remove");
|
||||
list.add("dump");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -100,6 +101,8 @@ public class CWCommand {
|
||||
list.add("add");
|
||||
if ("remove".startsWith(args[0]) && adminPerm)
|
||||
list.add("remove");
|
||||
if ("dump".startsWith(args[0]) && adminPerm)
|
||||
list.add("dump");
|
||||
return list;
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove")) {
|
||||
|
||||
Reference in New Issue
Block a user