Start adding the Config Command

This commit is contained in:
fernferret 2011-10-10 11:31:22 -06:00
parent 73b42b5430
commit 1aad872333
4 changed files with 63 additions and 2 deletions

View File

@ -271,7 +271,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup the Debug option, we'll default to false because this option will not be in the default config.
GlobalDebug = this.configMV.getInt("debug", 0);
GlobalDebug = this.configMV.getInt("debug", 0);
this.messaging = new MVMessaging(this);
this.messaging.setCooldown(this.configMV.getInt("messagecooldown", 5000));
}
@ -308,6 +307,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.commandHandler.registerCommand(new ModifySetCommand(this));
this.commandHandler.registerCommand(new ModifyRemoveCommand(this));
this.commandHandler.registerCommand(new ModifyClearCommand(this));
this.commandHandler.registerCommand(new ConfigCommand(this));
// Misc Commands
this.commandHandler.registerCommand(new EnvironmentCommand(this));
this.commandHandler.registerCommand(new DebugCommand(this));

View File

@ -0,0 +1,56 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ConfigCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Configuration");
this.setCommandUsage("/mv config");
this.setArgRange(2, 2);
this.addKey("mv config");
this.addKey("mvconfig");
this.addKey("mv conf");
this.addKey("mvconf");
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown")) {
try {
this.plugin.getConfig().setProperty(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
this.plugin.loadConfigs();
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
}
} else {
if (ConfigProperty.valueOf(args.get(0).toLowerCase()) != null) {
try {
this.plugin.getConfig().setProperty(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(0)));
this.plugin.loadConfigs();
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
}
}
}
}
}

View File

@ -9,5 +9,6 @@ package com.onarandombox.MultiverseCore.enums;
/** Multiverse 2 */
public enum ConfigProperty {
messagecooldown, teleportcooldown, worldnameprefix, useworldaccess, disableautoheal, fakepvp, bedrespawn
messagecooldown, teleportcooldown, worldnameprefix, useworldaccess,
disableautoheal, fakepvp, bedrespawn, finalsayaccess
}

View File

@ -18,6 +18,10 @@ worldnameprefix: true
# If value is set to false, Multiverse will NOT enforce permissions
useworldaccess: false
# Should multiverse have the final say in world access? If set to false, Multiverse will only check access
# for itself and any MVPlugin.
finalsayaccess: true
# If you have a world(s) that has monsters = false, and you want to disable the built
# in autohealing, set this to true. This will have NO EFFECT if monsters = true for a given world.
disableautoheal: false