Skip to content

Commit

Permalink
Added security.deop-everyone-on-join and security.block-in-game-op-co…
Browse files Browse the repository at this point in the history
…mmand.
  • Loading branch information
sk89q committed Nov 7, 2012
1 parent 7f108ce commit 5addfd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class ConfigurationManager {
public boolean activityHaltToggle = false;
public boolean autoGodMode;
public boolean usePlayerMove;
public boolean deopOnJoin;
public boolean blockInGameOp;
public Map<String, String> hostKeys = new HashMap<String, String>();

/**
Expand Down Expand Up @@ -148,6 +150,11 @@ public void load() {
usePlayerMove = config.getBoolean(
"use-player-move-event", true);

deopOnJoin = config.getBoolean(
"security.deop-everyone-on-join", false);
blockInGameOp = config.getBoolean(
"security.block-in-game-op-command", false);

hostKeys = new HashMap<String, String>();
Object hostKeysRaw = config.getProperty("host-keys");
if (hostKeysRaw == null || !(hostKeysRaw instanceof Map)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

import java.util.Iterator;
import java.util.Set;
import java.util.regex.Pattern;

import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;

Expand All @@ -55,6 +56,7 @@
*/
public class WorldGuardPlayerListener implements Listener {

private Pattern opPattern = Pattern.compile("^/op(?:\\s.*)?$", Pattern.CASE_INSENSITIVE);
private WorldGuardPlugin plugin;

/**
Expand Down Expand Up @@ -327,6 +329,10 @@ public void onPlayerLogin(PlayerLoginEvent event) {
return;
}
}

if (cfg.deopOnJoin) {
player.setOp(false);
}
}

@EventHandler
Expand Down Expand Up @@ -1119,5 +1125,13 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
return;
}
}

if (cfg.blockInGameOp) {
if (opPattern.matcher(event.getMessage()).matches()) {
player.sendMessage(ChatColor.RED + "/op can only be used in console (as set by a WG setting).");
event.setCancelled(true);
return;
}
}
}
}

0 comments on commit 5addfd8

Please sign in to comment.