mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 11:57:59 +01:00
"Help" buttons for GUI configuration program
Started implementing additional options for: - forcing checks of OPs (in case Permissions plugin is not available) - enforcing teleports initialized by NoCheat to be successful (overriding cancels of other plugins)
This commit is contained in:
parent
2fa4beb656
commit
1de43ec782
@ -59,10 +59,10 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
|||||||
private long serverLagInMilliSeconds = 0;
|
private long serverLagInMilliSeconds = 0;
|
||||||
private long lastServerTime = 0;
|
private long lastServerTime = 0;
|
||||||
|
|
||||||
// Permissions 2.x, if available
|
// Permissions, if available
|
||||||
private PermissionHandler permissions;
|
private PermissionHandler permissions;
|
||||||
|
|
||||||
// CraftIRC 2.x, if available
|
// CraftIRC, if available
|
||||||
private CraftIRC irc;
|
private CraftIRC irc;
|
||||||
private boolean allowFlightSet;
|
private boolean allowFlightSet;
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
|||||||
private void logToChat(Level l, String message) {
|
private void logToChat(Level l, String message) {
|
||||||
if(chatLevel.intValue() <= l.intValue()) {
|
if(chatLevel.intValue() <= l.intValue()) {
|
||||||
for(Player player : getServer().getOnlinePlayers()) {
|
for(Player player : getServer().getOnlinePlayers()) {
|
||||||
if(hasPermission(player, PermissionData.PERMISSION_NOTIFY)) {
|
if(hasPermission(player, PermissionData.PERMISSION_NOTIFY, false)) {
|
||||||
player.sendMessage("["+l.getName()+"] " + message);
|
player.sendMessage("["+l.getName()+"] " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,13 +280,19 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean hasPermission(Player player, int permission) {
|
public boolean hasPermission(Player player, int permission, boolean checkOPs) {
|
||||||
|
|
||||||
if(player == null) return false;
|
if(player == null) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(permissions == null)
|
if(permissions == null) {
|
||||||
return player.isOp();
|
if(checkOPs) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return player.isOp();
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
PermissionData data = PermissionData.get(player);
|
PermissionData data = PermissionData.get(player);
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
@ -375,11 +381,11 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
|||||||
s = s + (!c.isActive() ? c.getName() + "* " : (c.skipCheck(p) ? c.getName() + " " : ""));
|
s = s + (!c.isActive() ? c.getName() + "* " : (c.skipCheck(p) ? c.getName() + " " : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
s = s + (!movingCheck.isActive() || movingCheck.allowFlying ? "flying* " : (hasPermission(p, PermissionData.PERMISSION_FLYING) ? "flying " : ""));
|
s = s + (!movingCheck.isActive() || movingCheck.allowFlying ? "flying* " : (hasPermission(p, PermissionData.PERMISSION_FLYING, movingCheck.checkOPs) ? "flying " : ""));
|
||||||
s = s + (!movingCheck.isActive() || movingCheck.allowFakeSneak ? "fakesneak* " : (hasPermission(p, PermissionData.PERMISSION_FAKESNEAK) ? "fakesneak " : ""));
|
s = s + (!movingCheck.isActive() || movingCheck.allowFakeSneak ? "fakesneak* " : (hasPermission(p, PermissionData.PERMISSION_FAKESNEAK, movingCheck.checkOPs) ? "fakesneak " : ""));
|
||||||
s = s + (!movingCheck.isActive() || movingCheck.allowFastSwim ? "fastswim* " : (hasPermission(p, PermissionData.PERMISSION_FASTSWIM) ? "fastswim " : ""));
|
s = s + (!movingCheck.isActive() || movingCheck.allowFastSwim ? "fastswim* " : (hasPermission(p, PermissionData.PERMISSION_FASTSWIM, movingCheck.checkOPs) ? "fastswim " : ""));
|
||||||
|
|
||||||
s = s + (hasPermission(p, PermissionData.PERMISSION_NOTIFY) ? "notify " : "");
|
s = s + (hasPermission(p, PermissionData.PERMISSION_NOTIFY, false) ? "notify " : "");
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package cc.co.evenprime.bukkit.nocheat.checks;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.ConfigurationException;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
@ -19,17 +20,26 @@ public abstract class Check {
|
|||||||
private String name;
|
private String name;
|
||||||
protected NoCheat plugin;
|
protected NoCheat plugin;
|
||||||
|
|
||||||
|
// Should OPs be checked if Permissions plugin is not available?
|
||||||
|
protected boolean checkOPs = false;
|
||||||
|
|
||||||
protected Check(NoCheat plugin, String name, int permission, NoCheatConfiguration config) {
|
protected Check(NoCheat plugin, String name, int permission, NoCheatConfiguration config) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
|
try {
|
||||||
|
checkOPs = config.getBooleanValue(name + ".checkops");
|
||||||
|
} catch (ConfigurationException e) {
|
||||||
|
checkOPs = false;
|
||||||
|
}
|
||||||
|
|
||||||
configure(config);
|
configure(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean skipCheck(Player player) {
|
public boolean skipCheck(Player player) {
|
||||||
// Should we check at all?
|
// Should we check at all?
|
||||||
return !active || plugin.hasPermission(player, permission);
|
return !active || plugin.hasPermission(player, permission, checkOPs);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void configure(NoCheatConfiguration config);
|
protected abstract void configure(NoCheatConfiguration config);
|
||||||
|
@ -62,7 +62,7 @@ public class MovingCheck extends Check {
|
|||||||
public boolean allowFlying;
|
public boolean allowFlying;
|
||||||
public boolean allowFakeSneak;
|
public boolean allowFakeSneak;
|
||||||
public boolean allowFastSwim;
|
public boolean allowFastSwim;
|
||||||
|
public boolean checkOPs;
|
||||||
|
|
||||||
private boolean waterElevators;
|
private boolean waterElevators;
|
||||||
|
|
||||||
@ -74,6 +74,10 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
public long statisticTotalEvents = 1; // Prevent accidental division by 0 at some point
|
public long statisticTotalEvents = 1; // Prevent accidental division by 0 at some point
|
||||||
|
|
||||||
|
private boolean enforceTeleport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final double magic = 0.30000001192092896D;
|
private static final double magic = 0.30000001192092896D;
|
||||||
private static final double magic2 = 0.69999998807907103D;
|
private static final double magic2 = 0.69999998807907103D;
|
||||||
|
|
||||||
@ -101,15 +105,13 @@ public class MovingCheck extends Check {
|
|||||||
// Get the two locations of the event
|
// Get the two locations of the event
|
||||||
final Location to = event.getTo();
|
final Location to = event.getTo();
|
||||||
|
|
||||||
// the from location of the event may be different from the location the player
|
// use our self-defined from-location, instead of the one from the event
|
||||||
// actually was - choose appropriately
|
Location from = data.lastLocation;
|
||||||
Location from = data.teleportTo != null ? data.teleportTo : event.getFrom();
|
|
||||||
data.teleportTo = null;
|
|
||||||
|
|
||||||
|
|
||||||
updateVelocity(player.getVelocity(), data);
|
updateVelocity(player.getVelocity(), data);
|
||||||
|
|
||||||
if(shouldBeIgnored(player, data, from, to)) {
|
// event.getFrom() is intentional here
|
||||||
|
if(shouldBeIgnored(player, data, event.getFrom(), to)) {
|
||||||
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
statisticElapsedTimeNano += System.nanoTime() - startTime;
|
||||||
statisticTotalEvents++;
|
statisticTotalEvents++;
|
||||||
return;
|
return;
|
||||||
@ -180,7 +182,7 @@ public class MovingCheck extends Check {
|
|||||||
{
|
{
|
||||||
final Location l;
|
final Location l;
|
||||||
|
|
||||||
final boolean canFly = allowFlying || plugin.hasPermission(player, PermissionData.PERMISSION_FLYING);
|
final boolean canFly = allowFlying || plugin.hasPermission(player, PermissionData.PERMISSION_FLYING, checkOPs);
|
||||||
|
|
||||||
if(data.setBackPoint == null || canFly)
|
if(data.setBackPoint == null || canFly)
|
||||||
l = from;
|
l = from;
|
||||||
@ -257,7 +259,7 @@ public class MovingCheck extends Check {
|
|||||||
int violationLevelSneaking = -1;
|
int violationLevelSneaking = -1;
|
||||||
|
|
||||||
// Maybe the player is allowed to sneak faster than usual?
|
// Maybe the player is allowed to sneak faster than usual?
|
||||||
final boolean canFakeSneak = allowFakeSneak || plugin.hasPermission(player, PermissionData.PERMISSION_FAKESNEAK);
|
final boolean canFakeSneak = allowFakeSneak || plugin.hasPermission(player, PermissionData.PERMISSION_FAKESNEAK, checkOPs);
|
||||||
|
|
||||||
if(!canFakeSneak) {
|
if(!canFakeSneak) {
|
||||||
|
|
||||||
@ -297,7 +299,7 @@ public class MovingCheck extends Check {
|
|||||||
int violationLevelSwimming = -1;
|
int violationLevelSwimming = -1;
|
||||||
|
|
||||||
// Maybe the player is allowed to swim faster than usual?
|
// Maybe the player is allowed to swim faster than usual?
|
||||||
final boolean canFastSwim = allowFastSwim || plugin.hasPermission(player, PermissionData.PERMISSION_FASTSWIM);
|
final boolean canFastSwim = allowFastSwim || plugin.hasPermission(player, PermissionData.PERMISSION_FASTSWIM, checkOPs);
|
||||||
|
|
||||||
if(!canFastSwim) {
|
if(!canFastSwim) {
|
||||||
|
|
||||||
@ -454,14 +456,20 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
if(data.respawned) data.respawned = false;
|
if(data.respawned) data.respawned = false;
|
||||||
|
|
||||||
|
// We can enforce a teleport, if that flag is explicitly set
|
||||||
|
if(event.isCancelled() && enforceTeleport && event.getTo().equals(data.teleportTo)) {
|
||||||
|
event.setCancelled(false);
|
||||||
|
}
|
||||||
|
|
||||||
if(!event.isCancelled()) {
|
if(!event.isCancelled()) {
|
||||||
data.lastLocation = event.getTo();
|
data.lastLocation = event.getTo();
|
||||||
data.teleportTo = event.getTo();
|
|
||||||
data.jumpPhase = 0;
|
data.jumpPhase = 0;
|
||||||
data.setBackPoint = event.getTo();
|
data.setBackPoint = event.getTo();
|
||||||
|
|
||||||
data.worldChanged = !event.getFrom().getWorld().getName().equals(event.getTo().getWorld().getName());
|
data.worldChanged = !event.getFrom().getWorld().getName().equals(event.getTo().getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.teleportTo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -567,6 +575,7 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
Location t = new Location(data.setBackPoint.getWorld(), data.setBackPoint.getX(), y, data.setBackPoint.getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
Location t = new Location(data.setBackPoint.getWorld(), data.setBackPoint.getX(), y, data.setBackPoint.getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
||||||
|
|
||||||
|
data.teleportTo = t;
|
||||||
// Only reset player and cancel event if teleport is successful
|
// Only reset player and cancel event if teleport is successful
|
||||||
if(event.getPlayer().teleport(t)) {
|
if(event.getPlayer().teleport(t)) {
|
||||||
|
|
||||||
@ -576,6 +585,8 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.teleportTo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -721,6 +732,9 @@ public class MovingCheck extends Check {
|
|||||||
actions[2] = config.getActionValue("moving.action.high");
|
actions[2] = config.getActionValue("moving.action.high");
|
||||||
|
|
||||||
setActive(config.getBooleanValue("active.moving"));
|
setActive(config.getBooleanValue("active.moving"));
|
||||||
|
|
||||||
|
enforceTeleport = config.getBooleanValue("moving.enforceteleport");
|
||||||
|
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
setActive(false);
|
setActive(false);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -10,9 +10,9 @@ public class BooleanOption extends ChildOption {
|
|||||||
|
|
||||||
private boolean value;
|
private boolean value;
|
||||||
|
|
||||||
public BooleanOption(String name, boolean initialValue) {
|
public BooleanOption(String name, String parentName, boolean initialValue) {
|
||||||
|
|
||||||
super(name);
|
super(name, parentName);
|
||||||
this.value = initialValue;
|
this.value = initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ public abstract class ChildOption extends Option {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4648294833934457776L;
|
private static final long serialVersionUID = -4648294833934457776L;
|
||||||
|
|
||||||
public ChildOption(String identifier) {
|
public ChildOption(String identifier, String parentIdentifier) {
|
||||||
|
|
||||||
super(identifier);
|
super(identifier, parentIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ public class CustomActionOption extends ChildOption {
|
|||||||
private String command;
|
private String command;
|
||||||
|
|
||||||
|
|
||||||
public CustomActionOption(String identifier, String command) {
|
public CustomActionOption(String identifier, String parentName, String command) {
|
||||||
|
|
||||||
super(identifier);
|
super(identifier, parentName);
|
||||||
|
|
||||||
this.parseCommand(command);
|
this.parseCommand(command);
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ public class IntegerOption extends TextFieldOption {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 2258827414736580449L;
|
private static final long serialVersionUID = 2258827414736580449L;
|
||||||
|
|
||||||
public IntegerOption(String name, int initialValue) {
|
public IntegerOption(String name, String parentName, int initialValue) {
|
||||||
|
|
||||||
super(name, String.valueOf(initialValue), 5);
|
super(name, parentName, String.valueOf(initialValue), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,9 +56,9 @@ public class LevelOption extends ChildOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LevelOption(String identifier, LogLevel initialValue) {
|
public LevelOption(String identifier, String parentName, LogLevel initialValue) {
|
||||||
|
|
||||||
super(identifier);
|
super(identifier, parentName);
|
||||||
this.option = initialValue;
|
this.option = initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ public class LongStringOption extends TextFieldOption {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 2258827414736580449L;
|
private static final long serialVersionUID = 2258827414736580449L;
|
||||||
|
|
||||||
public LongStringOption(String name, String initialValue) {
|
public LongStringOption(String name, String parentName, String initialValue) {
|
||||||
super(name, initialValue, 60);
|
super(name, parentName, initialValue, 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ public class MediumStringOption extends TextFieldOption {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 2258827414736580449L;
|
private static final long serialVersionUID = 2258827414736580449L;
|
||||||
|
|
||||||
public MediumStringOption(String name, String initialValue) {
|
public MediumStringOption(String name, String parentName, String initialValue) {
|
||||||
super(name, initialValue, 30);
|
super(name, parentName, initialValue, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,176 +66,196 @@ public class NoCheatConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
root = new ParentOption("", false);
|
root = new ParentOption("", "", false);
|
||||||
|
|
||||||
|
|
||||||
/*** LOGGING section ***/
|
/*** LOGGING section ***/
|
||||||
{
|
{
|
||||||
ParentOption loggingNode = new ParentOption("logging", false);
|
ParentOption loggingNode = new ParentOption("logging", root.getFullIdentifier(), false);
|
||||||
root.add(loggingNode);
|
root.add(loggingNode);
|
||||||
|
|
||||||
loggingNode.add(new MediumStringOption("filename",
|
loggingNode.add(new MediumStringOption("filename", loggingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("logging.filename", "plugins/NoCheat/nocheat.log", yamlContent)));
|
SimpleYaml.getString("logging.filename", "plugins/NoCheat/nocheat.log", yamlContent)));
|
||||||
|
|
||||||
loggingNode.add(new LevelOption("logtofile",
|
loggingNode.add(new LevelOption("logtofile", loggingNode.getFullIdentifier(),
|
||||||
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtofile", LogLevel.LOW.asString(), yamlContent))));
|
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtofile", LogLevel.LOW.asString(), yamlContent))));
|
||||||
loggingNode.add(new LevelOption("logtoconsole",
|
loggingNode.add(new LevelOption("logtoconsole", loggingNode.getFullIdentifier(),
|
||||||
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtoconsole", LogLevel.HIGH.asString(), yamlContent))));
|
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtoconsole", LogLevel.HIGH.asString(), yamlContent))));
|
||||||
loggingNode.add(new LevelOption("logtochat",
|
loggingNode.add(new LevelOption("logtochat", loggingNode.getFullIdentifier(),
|
||||||
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtochat", LogLevel.MED.asString(), yamlContent))));
|
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtochat", LogLevel.MED.asString(), yamlContent))));
|
||||||
loggingNode.add(new LevelOption("logtoirc",
|
loggingNode.add(new LevelOption("logtoirc", loggingNode.getFullIdentifier(),
|
||||||
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtoirc", LogLevel.MED.asString(), yamlContent))));
|
LogLevel.getLogLevelFromString(SimpleYaml.getString("logging.logtoirc", LogLevel.MED.asString(), yamlContent))));
|
||||||
|
|
||||||
loggingNode.add(new ShortStringOption("logtoirctag",
|
loggingNode.add(new ShortStringOption("logtoirctag", loggingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("logging.logtoirctag", "nocheat", yamlContent)));
|
SimpleYaml.getString("logging.logtoirctag", "nocheat", yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** ACTIVE section ***/
|
/*** ACTIVE section ***/
|
||||||
{
|
{
|
||||||
ParentOption activeNode = new ParentOption("active", false);
|
ParentOption activeNode = new ParentOption("active", root.getFullIdentifier(), false);
|
||||||
root.add(activeNode);
|
root.add(activeNode);
|
||||||
|
|
||||||
activeNode.add(new BooleanOption("speedhack",
|
activeNode.add(new BooleanOption("speedhack", activeNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("active.speedhack", true, yamlContent)));
|
SimpleYaml.getBoolean("active.speedhack", true, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("moving",
|
activeNode.add(new BooleanOption("moving", activeNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("active.moving", true, yamlContent)));
|
SimpleYaml.getBoolean("active.moving", true, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("airbuild",
|
activeNode.add(new BooleanOption("airbuild", activeNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("active.airbuild", false, yamlContent)));
|
SimpleYaml.getBoolean("active.airbuild", false, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("bedteleport",
|
activeNode.add(new BooleanOption("bedteleport", activeNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("active.bedteleport", true, yamlContent)));
|
SimpleYaml.getBoolean("active.bedteleport", true, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("bogusitems",
|
activeNode.add(new BooleanOption("bogusitems", activeNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("active.bogusitems", false, yamlContent)));
|
SimpleYaml.getBoolean("active.bogusitems", false, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** SPEEDHACK section ***/
|
/*** SPEEDHACK section ***/
|
||||||
{
|
{
|
||||||
ParentOption speedhackNode = new ParentOption("speedhack", false);
|
ParentOption speedhackNode = new ParentOption("speedhack", root.getFullIdentifier(), false);
|
||||||
root.add(speedhackNode);
|
root.add(speedhackNode);
|
||||||
|
|
||||||
speedhackNode.add(new LongStringOption("logmessage",
|
speedhackNode.add(new LongStringOption("logmessage", speedhackNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("speedhack.logmessage", "[player] sent [events] move events, but only [limit] were allowed. Speedhack?", yamlContent).
|
SimpleYaml.getString("speedhack.logmessage", "[player] sent [events] move events, but only [limit] were allowed. Speedhack?", yamlContent).
|
||||||
replace("[player]", "%1$s").replace("[events]", "%2$d").replace("[limit]", "%3$d")));
|
replace("[player]", "%1$s").replace("[events]", "%2$d").replace("[limit]", "%3$d")));
|
||||||
|
|
||||||
|
speedhackNode.add(new BooleanOption("checkops", speedhackNode.getFullIdentifier(),
|
||||||
|
SimpleYaml.getBoolean("speedhack.checkops", false, yamlContent)));
|
||||||
|
|
||||||
/*** SPEEDHACK LIMITS section ***/
|
/*** SPEEDHACK LIMITS section ***/
|
||||||
{
|
{
|
||||||
ParentOption speedhackLimitsNode = new ParentOption("limits", false);
|
ParentOption speedhackLimitsNode = new ParentOption("limits", speedhackNode.getFullIdentifier(), false);
|
||||||
speedhackNode.add(speedhackLimitsNode);
|
speedhackNode.add(speedhackLimitsNode);
|
||||||
|
|
||||||
speedhackLimitsNode.add(new IntegerOption("low",
|
speedhackLimitsNode.add(new IntegerOption("low", speedhackLimitsNode.getFullIdentifier(),
|
||||||
SimpleYaml.getInt("speedhack.limits.low", 22, yamlContent)));
|
SimpleYaml.getInt("speedhack.limits.low", 22, yamlContent)));
|
||||||
speedhackLimitsNode.add(new IntegerOption("med",
|
speedhackLimitsNode.add(new IntegerOption("med", speedhackLimitsNode.getFullIdentifier(),
|
||||||
SimpleYaml.getInt("speedhack.limits.med", 33, yamlContent)));
|
SimpleYaml.getInt("speedhack.limits.med", 33, yamlContent)));
|
||||||
speedhackLimitsNode.add(new IntegerOption("high",
|
speedhackLimitsNode.add(new IntegerOption("high", speedhackLimitsNode.getFullIdentifier(),
|
||||||
SimpleYaml.getInt("speedhack.limits.high", 44, yamlContent)));
|
SimpleYaml.getInt("speedhack.limits.high", 44, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** SPEEDHACK ACTIONS section ***/
|
/*** SPEEDHACK ACTIONS section ***/
|
||||||
{
|
{
|
||||||
ParentOption speedhackActionNode = new ParentOption("action", false);
|
ParentOption speedhackActionNode = new ParentOption("action", speedhackNode.getFullIdentifier(), false);
|
||||||
speedhackNode.add(speedhackActionNode);
|
speedhackNode.add(speedhackActionNode);
|
||||||
|
|
||||||
speedhackActionNode.add(new MediumStringOption("low",
|
speedhackActionNode.add(new MediumStringOption("low", speedhackActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("speedhack.action.low", "loglow cancel", yamlContent)));
|
SimpleYaml.getString("speedhack.action.low", "loglow cancel", yamlContent)));
|
||||||
speedhackActionNode.add(new MediumStringOption("med",
|
speedhackActionNode.add(new MediumStringOption("med", speedhackActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("speedhack.action.med", "logmed cancel", yamlContent)));
|
SimpleYaml.getString("speedhack.action.med", "logmed cancel", yamlContent)));
|
||||||
speedhackActionNode.add(new MediumStringOption("high",
|
speedhackActionNode.add(new MediumStringOption("high", speedhackActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("speedhack.action.high", "loghigh cancel", yamlContent)));
|
SimpleYaml.getString("speedhack.action.high", "loghigh cancel", yamlContent)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** MOVING section ***/
|
/*** MOVING section ***/
|
||||||
{
|
{
|
||||||
ParentOption movingNode = new ParentOption("moving", false);
|
ParentOption movingNode = new ParentOption("moving", root.getFullIdentifier(), false);
|
||||||
root.add(movingNode);
|
root.add(movingNode);
|
||||||
|
|
||||||
movingNode.add(new LongStringOption("logmessage",
|
movingNode.add(new LongStringOption("logmessage", movingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("moving.logmessage", "Moving violation: [player] from [world] [from] to [to] distance [distance]", yamlContent).
|
SimpleYaml.getString("moving.logmessage", "Moving violation: [player] from [world] [from] to [to] distance [distance]", yamlContent).
|
||||||
replace("[player]", "%1$s").replace("[world]", "%2$s").
|
replace("[player]", "%1$s").replace("[world]", "%2$s").
|
||||||
replace("[from]", "(%4$.1f, %5$.1f, %6$.1f)").
|
replace("[from]", "(%4$.1f, %5$.1f, %6$.1f)").
|
||||||
replace("[to]", "(%7$.1f, %8$.1f, %9$.1f)").
|
replace("[to]", "(%7$.1f, %8$.1f, %9$.1f)").
|
||||||
replace("[distance]", "(%10$.1f, %11$.1f, %12$.1f)")));
|
replace("[distance]", "(%10$.1f, %11$.1f, %12$.1f)")));
|
||||||
|
|
||||||
movingNode.add(new LongStringOption("summarymessage",
|
movingNode.add(new LongStringOption("summarymessage", movingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("moving.summarymessage", "Moving summary of last ~[timeframe] seconds: [player] total Violations: [violations]", yamlContent).
|
SimpleYaml.getString("moving.summarymessage", "Moving summary of last ~[timeframe] seconds: [player] total Violations: [violations]", yamlContent).
|
||||||
replace("[timeframe]", "%2$d").replace("[player]", "%1$s").
|
replace("[timeframe]", "%2$d").replace("[player]", "%1$s").
|
||||||
replace("[violations]", "(%3$d,%4$d,%5$d)")));
|
replace("[violations]", "(%3$d,%4$d,%5$d)")));
|
||||||
movingNode.add(new BooleanOption("allowflying",
|
movingNode.add(new BooleanOption("allowflying", movingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("moving.allowflying", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.allowflying", false, yamlContent)));
|
||||||
movingNode.add(new BooleanOption("allowfakesneak",
|
movingNode.add(new BooleanOption("allowfakesneak", movingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("moving.allowfakesneak", true, yamlContent)));
|
SimpleYaml.getBoolean("moving.allowfakesneak", true, yamlContent)));
|
||||||
movingNode.add(new BooleanOption("allowfastswim",
|
movingNode.add(new BooleanOption("allowfastswim", movingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("moving.allowfastswim", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.allowfastswim", false, yamlContent)));
|
||||||
movingNode.add(new BooleanOption("waterelevators",
|
movingNode.add(new BooleanOption("waterelevators", movingNode.getFullIdentifier(),
|
||||||
SimpleYaml.getBoolean("moving.waterelevators", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.waterelevators", false, yamlContent)));
|
||||||
|
|
||||||
|
movingNode.add(new BooleanOption("checkops", movingNode.getFullIdentifier(),
|
||||||
|
SimpleYaml.getBoolean("moving.checkops", false, yamlContent)));
|
||||||
|
|
||||||
|
movingNode.add(new BooleanOption("enforceteleport", movingNode.getFullIdentifier(),
|
||||||
|
SimpleYaml.getBoolean("moving.enforceteleport", false, yamlContent)));
|
||||||
|
|
||||||
/*** MOVING ACTION section ***/
|
/*** MOVING ACTION section ***/
|
||||||
{
|
{
|
||||||
ParentOption movingActionNode = new ParentOption("action", false);
|
ParentOption movingActionNode = new ParentOption("action", movingNode.getFullIdentifier(), false);
|
||||||
movingNode.add(movingActionNode);
|
movingNode.add(movingActionNode);
|
||||||
|
|
||||||
movingActionNode.add(new MediumStringOption("low",
|
movingActionNode.add(new MediumStringOption("low", movingActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("moving.action.low", "loglow cancel", yamlContent)));
|
SimpleYaml.getString("moving.action.low", "loglow cancel", yamlContent)));
|
||||||
movingActionNode.add(new MediumStringOption("med",
|
movingActionNode.add(new MediumStringOption("med", movingActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("moving.action.med", "logmed cancel", yamlContent)));
|
SimpleYaml.getString("moving.action.med", "logmed cancel", yamlContent)));
|
||||||
movingActionNode.add(new MediumStringOption("high",
|
movingActionNode.add(new MediumStringOption("high", movingActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("moving.action.high", "loghigh cancel", yamlContent)));
|
SimpleYaml.getString("moving.action.high", "loghigh cancel", yamlContent)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** AIRBUILD section ***/
|
/*** AIRBUILD section ***/
|
||||||
{
|
{
|
||||||
ParentOption airbuildNode = new ParentOption("airbuild", false);
|
ParentOption airbuildNode = new ParentOption("airbuild", root.getFullIdentifier(), false);
|
||||||
root.add(airbuildNode);
|
root.add(airbuildNode);
|
||||||
|
|
||||||
|
airbuildNode.add(new BooleanOption("checkops", airbuildNode.getFullIdentifier(),
|
||||||
|
SimpleYaml.getBoolean("airbuild.checkops", false, yamlContent)));
|
||||||
|
|
||||||
/*** AIRBUILD LIMITS section ***/
|
/*** AIRBUILD LIMITS section ***/
|
||||||
{
|
{
|
||||||
ParentOption airbuildLimitsNode = new ParentOption("limits", false);
|
ParentOption airbuildLimitsNode = new ParentOption("limits", airbuildNode.getFullIdentifier(), false);
|
||||||
airbuildNode.add(airbuildLimitsNode);
|
airbuildNode.add(airbuildLimitsNode);
|
||||||
|
|
||||||
airbuildLimitsNode.add(new IntegerOption("low",
|
airbuildLimitsNode.add(new IntegerOption("low", airbuildLimitsNode.getFullIdentifier(),
|
||||||
SimpleYaml.getInt("airbuild.limits.low", 1, yamlContent)));
|
SimpleYaml.getInt("airbuild.limits.low", 1, yamlContent)));
|
||||||
airbuildLimitsNode.add(new IntegerOption("med",
|
airbuildLimitsNode.add(new IntegerOption("med", airbuildLimitsNode.getFullIdentifier(),
|
||||||
SimpleYaml.getInt("airbuild.limits.med", 3, yamlContent)));
|
SimpleYaml.getInt("airbuild.limits.med", 3, yamlContent)));
|
||||||
airbuildLimitsNode.add(new IntegerOption("high",
|
airbuildLimitsNode.add(new IntegerOption("high", airbuildLimitsNode.getFullIdentifier(),
|
||||||
SimpleYaml.getInt("airbuild.limits.high", 10, yamlContent)));
|
SimpleYaml.getInt("airbuild.limits.high", 10, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** AIRBUILD ACTION section ***/
|
/*** AIRBUILD ACTION section ***/
|
||||||
{
|
{
|
||||||
ParentOption airbuildActionNode = new ParentOption("action", false);
|
ParentOption airbuildActionNode = new ParentOption("action", airbuildNode.getFullIdentifier(), false);
|
||||||
airbuildNode.add(airbuildActionNode);
|
airbuildNode.add(airbuildActionNode);
|
||||||
|
|
||||||
airbuildActionNode.add(new MediumStringOption("low",
|
airbuildActionNode.add(new MediumStringOption("low", airbuildActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("airbuild.action.low", "loglow cancel", yamlContent)));
|
SimpleYaml.getString("airbuild.action.low", "loglow cancel", yamlContent)));
|
||||||
airbuildActionNode.add(new MediumStringOption("med",
|
airbuildActionNode.add(new MediumStringOption("med", airbuildActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("airbuild.action.med", "logmed cancel", yamlContent)));
|
SimpleYaml.getString("airbuild.action.med", "logmed cancel", yamlContent)));
|
||||||
airbuildActionNode.add(new MediumStringOption("high",
|
airbuildActionNode.add(new MediumStringOption("high", airbuildActionNode.getFullIdentifier(),
|
||||||
SimpleYaml.getString("airbuild.action.high", "loghigh cancel", yamlContent)));
|
SimpleYaml.getString("airbuild.action.high", "loghigh cancel", yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** BEDTELEPORT section ***/
|
/*** BEDTELEPORT section ***/
|
||||||
{
|
{
|
||||||
ParentOption bedteleportNode = new ParentOption("bedteleport", false);
|
ParentOption bedteleportNode = new ParentOption("bedteleport", root.getFullIdentifier(), false);
|
||||||
root.add(bedteleportNode);
|
root.add(bedteleportNode);
|
||||||
|
|
||||||
|
bedteleportNode.add(new BooleanOption("checkops", bedteleportNode.getFullIdentifier(),
|
||||||
|
SimpleYaml.getBoolean("bedteleport.checkops", false, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** BOGUSITEMS section ***/
|
/*** BOGUSITEMS section ***/
|
||||||
{
|
{
|
||||||
ParentOption bogusitemsNode = new ParentOption("bogusitems", false);
|
ParentOption bogusitemsNode = new ParentOption("bogusitems", root.getFullIdentifier(), false);
|
||||||
root.add(bogusitemsNode);
|
root.add(bogusitemsNode);
|
||||||
|
|
||||||
|
bogusitemsNode.add(new BooleanOption("checkops", bogusitemsNode.getFullIdentifier(),
|
||||||
|
SimpleYaml.getBoolean("bogusitems.checkops", false, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** CUSTOMACTIONS section ***/
|
/*** CUSTOMACTIONS section ***/
|
||||||
{
|
{
|
||||||
ParentOption customActionsNode = new ParentOption("customactions", true);
|
ParentOption customActionsNode = new ParentOption("customactions", root.getFullIdentifier(), true);
|
||||||
root.add(customActionsNode);
|
root.add(customActionsNode);
|
||||||
|
|
||||||
Set<String> customs = SimpleYaml.getKeys("customactions", yamlContent);
|
Set<String> customs = SimpleYaml.getKeys("customactions", yamlContent);
|
||||||
|
|
||||||
for(String s : customs) {
|
for(String s : customs) {
|
||||||
|
|
||||||
CustomActionOption o = new CustomActionOption(s, SimpleYaml.getString("customactions."+s, "unknown", yamlContent));
|
CustomActionOption o = new CustomActionOption(s, customActionsNode.getFullIdentifier(), SimpleYaml.getString("customactions."+s, "unknown", yamlContent));
|
||||||
|
|
||||||
customActionsNode.add(o);
|
customActionsNode.add(o);
|
||||||
actionMap.put(s, o.getCustomActionValue());
|
actionMap.put(s, o.getCustomActionValue());
|
||||||
|
@ -4,15 +4,21 @@ package cc.co.evenprime.bukkit.nocheat.config;
|
|||||||
public abstract class Option {
|
public abstract class Option {
|
||||||
|
|
||||||
private final String identifier;
|
private final String identifier;
|
||||||
|
private final String parentIdentifier;
|
||||||
|
|
||||||
public Option(String identifier) {
|
public Option(String identifier, String parentIdentifier) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
|
this.parentIdentifier = parentIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFullIdentifier() {
|
||||||
|
return (parentIdentifier == null || parentIdentifier == "") ? identifier : parentIdentifier + "." + identifier;
|
||||||
|
}
|
||||||
|
|
||||||
public String toYAMLString(String prefix) {
|
public String toYAMLString(String prefix) {
|
||||||
return prefix + "\r\n";
|
return prefix + "\r\n";
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ public class ParentOption extends Option {
|
|||||||
private LinkedList<Option> children = new LinkedList<Option>();
|
private LinkedList<Option> children = new LinkedList<Option>();
|
||||||
private boolean editable;
|
private boolean editable;
|
||||||
|
|
||||||
public ParentOption(String identifier, boolean editable) {
|
public ParentOption(String identifier, String parentName, boolean editable) {
|
||||||
super(identifier);
|
super(identifier, parentName);
|
||||||
this.editable = editable;
|
this.editable = editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ public class ShortStringOption extends TextFieldOption {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 2258827414736580449L;
|
private static final long serialVersionUID = 2258827414736580449L;
|
||||||
|
|
||||||
public ShortStringOption(String name, String initialValue) {
|
public ShortStringOption(String name, String parentName, String initialValue) {
|
||||||
super(name, initialValue, 10);
|
super(name, parentName, initialValue, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ public abstract class TextFieldOption extends ChildOption {
|
|||||||
private String value;
|
private String value;
|
||||||
private int length = -1;
|
private int length = -1;
|
||||||
|
|
||||||
public TextFieldOption(String name, String initialValue, int preferredLength) {
|
public TextFieldOption(String name, String parentName, String initialValue, int preferredLength) {
|
||||||
|
|
||||||
super(name);
|
super(name, parentName);
|
||||||
this.value = initialValue;
|
this.value = initialValue;
|
||||||
this.length = preferredLength;
|
this.length = preferredLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextFieldOption(String name, String initialValue) {
|
public TextFieldOption(String name, String parentName, String initialValue) {
|
||||||
|
|
||||||
super(name);
|
super(name, parentName);
|
||||||
this.value = initialValue;
|
this.value = initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class ParentOptionGui extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
option.add(new CustomActionOption(nameField.getText(), "yourcommand [player]"));
|
option.add(new CustomActionOption(nameField.getText(), option.getFullIdentifier(), "yourcommand [player]"));
|
||||||
recreateContent();
|
recreateContent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -155,13 +155,13 @@ public class ParentOptionGui extends JPanel {
|
|||||||
JComponent tmp = ChildOptionGuiFactory.create((ChildOption)child);
|
JComponent tmp = ChildOptionGuiFactory.create((ChildOption)child);
|
||||||
|
|
||||||
this.add(tmp, c);
|
this.add(tmp, c);
|
||||||
/*
|
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
c.gridy = line;
|
c.gridy = line;
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
c.anchor = GridBagConstraints.CENTER;
|
c.anchor = GridBagConstraints.CENTER;
|
||||||
c.ipadx = 0;
|
c.ipadx = 0;
|
||||||
c.insets = new Insets(0, 5, 0, 5);
|
c.insets = new Insets(0, 15, 0, 5);
|
||||||
c.weightx = 0;
|
c.weightx = 0;
|
||||||
|
|
||||||
JButton help = new JButton("?");
|
JButton help = new JButton("?");
|
||||||
@ -171,14 +171,14 @@ public class ParentOptionGui extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, "get help", "help is here", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, Explainations.get(((ChildOption)child).getFullIdentifier()), "Description", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
help.setMargin(new Insets(0, 0, 0, 0));
|
help.setMargin(new Insets(0, 0, 0, 0));
|
||||||
this.add(help, c);*/
|
this.add(help, c);
|
||||||
|
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
c.gridy = line;
|
c.gridy = line;
|
||||||
@ -187,7 +187,6 @@ public class ParentOptionGui extends JPanel {
|
|||||||
c.ipadx = 5;
|
c.ipadx = 5;
|
||||||
c.weightx = 1;
|
c.weightx = 1;
|
||||||
|
|
||||||
|
|
||||||
this.add(Box.createHorizontalGlue(), c);
|
this.add(Box.createHorizontalGlue(), c);
|
||||||
|
|
||||||
if(this.option.isEditable()) {
|
if(this.option.isEditable()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user