Merge pull request #288 from necrodoom/patch-29

config option to allow GM commands in commandblocks
This commit is contained in:
ElgarL 2013-01-30 11:45:27 -08:00
commit 8afcd41ab2
4 changed files with 23 additions and 9 deletions

View File

@ -212,3 +212,4 @@ v 2.0:
- Add support for BukkitForge using 'overworld' as the main world name. - Add support for BukkitForge using 'overworld' as the main world name.
- Prevent '*' permissions granting the 'groupmanager.noofflineperms' permission. - Prevent '*' permissions granting the 'groupmanager.noofflineperms' permission.
- Added '/mancheckw <world>' to inspect which permission files a world is referencing. - Added '/mancheckw <world>' to inspect which permission files a world is referencing.
- Add config potion to set if GM commands should be allowed on CommnandBlocks.

View File

@ -7,6 +7,10 @@ settings:
# Default setting for 'mantoglevalidate' # Default setting for 'mantoglevalidate'
# true will cause GroupManager to attempt name matching by default. # true will cause GroupManager to attempt name matching by default.
validate_toggle: true validate_toggle: true
# **********************************************************************************************************************************
# *** NOTE: Having this feature enabled, improper use of commandblocks will lead to undesireable permission changes, be alarmed! ***
# **********************************************************************************************************************************
allow_commandblocks: false
data: data:
save: save:

View File

@ -22,6 +22,7 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
*/ */
public class GMConfiguration { public class GMConfiguration {
private boolean allowCommandBlocks = false;
private boolean opOverride = true; private boolean opOverride = true;
private boolean toggleValidate = true; private boolean toggleValidate = true;
private Integer saveInterval = 10; private Integer saveInterval = 10;
@ -40,6 +41,7 @@ public class GMConfiguration {
/* /*
* Set defaults * Set defaults
*/ */
allowCommandBlocks = false;
opOverride = true; opOverride = true;
toggleValidate = true; toggleValidate = true;
saveInterval = 10; saveInterval = 10;
@ -83,6 +85,7 @@ public class GMConfiguration {
try { try {
Map<String, Object> config = getElement("config", getElement("settings", GMconfig)); Map<String, Object> config = getElement("config", getElement("settings", GMconfig));
allowCommandBlocks = (Boolean) config.get("allow_commandblocks");
opOverride = (Boolean) config.get("opOverrides"); opOverride = (Boolean) config.get("opOverrides");
toggleValidate = (Boolean) config.get("validate_toggle"); toggleValidate = (Boolean) config.get("validate_toggle");
@ -142,6 +145,10 @@ public class GMConfiguration {
return (Map<String, Object>) map.get(element); return (Map<String, Object>) map.get(element);
} }
public boolean isAllowCommandBlocks() {
return allowCommandBlocks;
}
public boolean isOpOverride() { public boolean isOpOverride() {

View File

@ -387,10 +387,12 @@ public class GroupManager extends JavaPlugin {
Group senderGroup = null; Group senderGroup = null;
User senderUser = null; User senderUser = null;
boolean isOpOverride = config.isOpOverride(); boolean isOpOverride = config.isOpOverride();
boolean isAllowCommandBlocks = config.isAllowCommandBlocks();
// PREVENT GM COMMANDS BEING USED ON COMMANDBLOCKS // PREVENT GM COMMANDS BEING USED ON COMMANDBLOCKS
if (sender instanceof BlockCommandSender) { if (sender instanceof BlockCommandSender && !isAllowCommandBlocks) {
sender.sendMessage(ChatColor.RED + "GM Commands can not be called from CommandBlocks"); Block block = ((BlockCommandSender)sender).getBlock();
console.sendMessage(ChatColor.RED + "GM Commands can not be called from CommandBlock at location:" + ChatColor.GREEN + " " + block.getX + ", " + block.getY + ", " + block.getZ);
return true; return true;
} }
@ -399,7 +401,7 @@ public class GroupManager extends JavaPlugin {
senderPlayer = (Player) sender; senderPlayer = (Player) sender;
if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) { if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) {
sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. " + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + "" + ChatColor.RED + " and then try a '/manload'."); GroupManager.logger.warning(ChatColor.RED + "All commands are locked due to an error. " + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + "" + ChatColor.RED + " and then try a '/manload'.");
return true; return true;
} }