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

@ -34,10 +34,10 @@ v 1.3:
(for all worlds named in config.yml)
- Attempt to stop GM wiping groups/users yml's on a bad shut down.
- Added event handling to manage new world creation at runtime.
- Added the ability to handle unknown worlds at server start.
(GM will create the data files for any worlds it finds which are not in the config.yml)
- Added the ability to handle unknown worlds at server start.
(GM will create the data files for any worlds it finds which are not in the config.yml)
- Fix for Bukkit passing a null To location on a player Portaling
- Fixed manudelsub not correctly selecting the group to remove.
- Fixed manudelsub not correctly selecting the group to remove.
- Added two new permission nodes - groupmanager.notify.self & groupmanager.notify.other
These allow players/admins to be notified when players are moved between groups.
v 1.4:
@ -211,4 +211,5 @@ v 2.0:
- Negate 'groupmanager.noofflineperms' by default in the owner group.
- Add support for BukkitForge using 'overworld' as the main world name.
- 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'
# true will cause GroupManager to attempt name matching by default.
validate_toggle: true
# **********************************************************************************************************************************
# *** NOTE: Having this feature enabled, improper use of commandblocks will lead to undesireable permission changes, be alarmed! ***
# **********************************************************************************************************************************
allow_commandblocks: false
data:
save:
@ -39,4 +43,4 @@ settings:
# world4:
# - groups (World4 would use the groups.yml from world2, but it's own users.yml)
# world5:
# - world6 (this would cause world6 to mirror both files from world5)
# - world6 (this would cause world6 to mirror both files from world5)

View file

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

View file

@ -387,10 +387,12 @@ public class GroupManager extends JavaPlugin {
Group senderGroup = null;
User senderUser = null;
boolean isOpOverride = config.isOpOverride();
boolean isAllowCommandBlocks = config.isAllowCommandBlocks();
// PREVENT GM COMMANDS BEING USED ON COMMANDBLOCKS
if (sender instanceof BlockCommandSender) {
sender.sendMessage(ChatColor.RED + "GM Commands can not be called from CommandBlocks");
if (sender instanceof BlockCommandSender && !isAllowCommandBlocks) {
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;
}
@ -399,7 +401,7 @@ public class GroupManager extends JavaPlugin {
senderPlayer = (Player) sender;
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;
}