mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
update CM
This commit is contained in:
@@ -62,7 +62,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.Thatsmusic99</groupId>
|
<groupId>com.github.Thatsmusic99</groupId>
|
||||||
<artifactId>ConfigurationMaster</artifactId>
|
<artifactId>ConfigurationMaster</artifactId>
|
||||||
<version>v2.0.0-ALPHA-2</version>
|
<version>v2.0.0-ALPHA-3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+12
-12
@@ -27,7 +27,7 @@ public class ConfigCache {
|
|||||||
|
|
||||||
public boolean reloadConfig() {
|
public boolean reloadConfig() {
|
||||||
|
|
||||||
boolean firstLoad = createFiles();
|
createFiles();
|
||||||
config = ConfigFile.loadConfig(configFile);
|
config = ConfigFile.loadConfig(configFile);
|
||||||
|
|
||||||
config.addDefault("messages.prefix", "CommandWhitelist > ");
|
config.addDefault("messages.prefix", "CommandWhitelist > ");
|
||||||
@@ -45,17 +45,18 @@ public class ConfigCache {
|
|||||||
if (canDoProtocolLib)
|
if (canDoProtocolLib)
|
||||||
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
|
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
|
||||||
|
|
||||||
if (firstLoad) {
|
if (config.isNew()) {
|
||||||
List<String> exampleCommands = new ArrayList<>();
|
List<String> exampleCommands = new ArrayList<>();
|
||||||
exampleCommands.add("example");
|
exampleCommands.add("example");
|
||||||
List<String> exampleSubCommands = new ArrayList<>();
|
List<String> exampleSubCommands = new ArrayList<>();
|
||||||
exampleSubCommands.add("example of");
|
exampleSubCommands.add("example of");
|
||||||
|
|
||||||
config.addDefault("groups.example.commands", exampleCommands, "This is the WHITELIST of commands that players will be able to see/use in the group \"example\"");
|
config.addExample("groups.example.commands", exampleCommands, "This is the WHITELIST of commands that players will be able to see/use in the group \"example\"");
|
||||||
config.addDefault("groups.example.subcommands", exampleSubCommands, "This is the BLACKLIST of subcommands that players will NOT be able to see/use in the group \"example\"");
|
config.addExample("groups.example.subcommands", exampleSubCommands, "This is the BLACKLIST of subcommands that players will NOT be able to see/use in the group \"example\"");
|
||||||
config.addComment("groups.example", "All groups except from default require commandwhitelist.group.<group_name> permission\ncommandwhitelist.group.example in this case\n If you wish to leave the list empty, put \"commands: []\" or \"subcommands: []\"");
|
config.addComment("groups.example", "All groups except from default require commandwhitelist.group.<group_name> permission\ncommandwhitelist.group.example in this case\n If you wish to leave the list empty, put \"commands: []\" or \"subcommands: []\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.makeSectionLenient("groups");
|
||||||
List<String> defaultCommands = new ArrayList<>();
|
List<String> defaultCommands = new ArrayList<>();
|
||||||
defaultCommands.add("help");
|
defaultCommands.add("help");
|
||||||
defaultCommands.add("spawn");
|
defaultCommands.add("spawn");
|
||||||
@@ -102,20 +103,15 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createFiles() {
|
private void createFiles() {
|
||||||
boolean creatingFiles = false;
|
|
||||||
try {
|
try {
|
||||||
File parent = new File(configFile.getParent());
|
File parent = new File(configFile.getParent());
|
||||||
if (!parent.exists())
|
if (!parent.exists())
|
||||||
parent.mkdir();
|
parent.mkdir();
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists())
|
||||||
configFile.createNewFile();
|
configFile.createNewFile();
|
||||||
creatingFiles = true;
|
|
||||||
}
|
|
||||||
return creatingFiles;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +123,6 @@ public class ConfigCache {
|
|||||||
warn("CommandWhitelist - \"" + cmd + "\" is not a command. Loading it as \"" + cmdSplit[0] + "\".");
|
warn("CommandWhitelist - \"" + cmd + "\" is not a command. Loading it as \"" + cmdSplit[0] + "\".");
|
||||||
cmd = cmdSplit[0];
|
cmd = cmdSplit[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commands.contains(cmd)) continue;
|
if (commands.contains(cmd)) continue;
|
||||||
commands.add(cmd);
|
commands.add(cmd);
|
||||||
}
|
}
|
||||||
@@ -136,6 +131,11 @@ public class ConfigCache {
|
|||||||
return new CWGroup(id, commands, subCommands);
|
return new CWGroup(id, commands, subCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveCWGroup(String id, CWGroup group) {
|
||||||
|
config.set("groups." + id + ".", group.serialize());
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
public HashMap<String, CWGroup> getGroupList() {
|
public HashMap<String, CWGroup> getGroupList() {
|
||||||
return groupList;
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ public class CWCommand {
|
|||||||
if (cwGroup == null)
|
if (cwGroup == null)
|
||||||
return false;
|
return false;
|
||||||
cwGroup.addCommand(command);
|
cwGroup.addCommand(command);
|
||||||
configCache.reloadConfig();
|
configCache.saveCWGroup(group, cwGroup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ public class CWCommand {
|
|||||||
if (cwGroup == null)
|
if (cwGroup == null)
|
||||||
return false;
|
return false;
|
||||||
cwGroup.removeCommand(command);
|
cwGroup.removeCommand(command);
|
||||||
configCache.reloadConfig();
|
configCache.saveCWGroup(group, cwGroup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user