implemented /ds saveconfig
This commit is contained in:
parent
4e4ebc58f8
commit
e15eb397da
@ -21,7 +21,7 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
static final String PERMISSION_OTHER = "discosheep.other";
|
||||
static final String PERMISSION_CHANGEPERIOD = "discosheep.changeperiod";
|
||||
static final String PERMISSION_CHANGEDEFAULTS = "discosheep.changedefaults";
|
||||
|
||||
static final String PERMISSION_SAVECONFIG = "discosheep.saveconfig";
|
||||
Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
|
||||
private BaaBaaBlockSheepEvents blockEvents = new BaaBaaBlockSheepEvents(this);
|
||||
FileConfiguration config;
|
||||
@ -68,6 +68,18 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
loadConfigFromDisk();
|
||||
}
|
||||
|
||||
void saveConfigToDisk() {
|
||||
if (config == null) {
|
||||
config = getConfig();
|
||||
}
|
||||
|
||||
config.set("default.sheep", DiscoParty.defaultSheep);
|
||||
config.set("default.radius", DiscoParty.defaultRadius);
|
||||
config.set("default.duration", toSeconds_i(DiscoParty.defaultDuration));
|
||||
config.set("default.period-ticks", DiscoParty.defaultPeriod);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.stopAllParties(); // or else the parties will continue FOREVER
|
||||
@ -203,8 +215,19 @@ public final class DiscoSheep extends JavaPlugin {
|
||||
if (sender.hasPermission(PERMISSION_CHANGEDEFAULTS)) {
|
||||
party.setDefaultsFromCurrent();
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_CHANGEDEFAULTS);
|
||||
}
|
||||
else return noPermsMessage(sender, PERMISSION_CHANGEDEFAULTS);
|
||||
}
|
||||
|
||||
boolean saveConfigCommand(CommandSender sender) {
|
||||
if (sender.hasPermission(PERMISSION_SAVECONFIG)) {
|
||||
saveConfigToDisk();
|
||||
return true;
|
||||
} else {
|
||||
return noPermsMessage(sender, PERMISSION_SAVECONFIG);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean noPermsMessage(CommandSender sender, String permission) {
|
||||
|
@ -78,6 +78,8 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||
return parent.helpCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
return parent.reloadCommand(sender);
|
||||
} else if (args[0].equalsIgnoreCase("save") || args[0].equalsIgnoreCase("saveconfig")) {
|
||||
return parent.saveConfigCommand(sender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,8 +152,7 @@ public class DiscoSheepCommandExecutor implements CommandExecutor {
|
||||
return parent.partyOtherCommand(parsePlayerList(args, 1), sender, mainParty);
|
||||
} else if (args[0].equalsIgnoreCase("defaults")) {
|
||||
return parent.setDefaultsCommand(sender, mainParty);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console).");
|
||||
return false;
|
||||
}
|
||||
|
@ -23,6 +23,14 @@ permissions:
|
||||
discosheep.other: true
|
||||
discosheep.changeperiod: true
|
||||
discosheep.changedefaults: true
|
||||
discosheep.admin:
|
||||
description: Suggested permissions for administrators
|
||||
default: op
|
||||
children:
|
||||
discosheep.stopall: true
|
||||
discosheep.reload: true
|
||||
discosheep.changedefaults: true
|
||||
discosheep.saveconfig: true
|
||||
discosheep.party:
|
||||
description: Allows a player to have a party of one
|
||||
default: op
|
||||
@ -49,4 +57,6 @@ permissions:
|
||||
discosheep.changedefaults:
|
||||
description: Allows a player to change the default settings
|
||||
default: op
|
||||
|
||||
discosheep.saveconfig:
|
||||
description: Allows a player to save the config with current values set in memory
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user