mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-08 03:29:36 +01:00
Fixed behaviour of new checkops options (was inverted before)
Made speedhack check a bit less strict in case of server lag, and server lag measurement more useful. Made descriptions for options easier to use
This commit is contained in:
parent
65ed8d4da6
commit
7598cecdc9
@ -194,7 +194,7 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
|||||||
public void run() {
|
public void run() {
|
||||||
serverTicks += 10;
|
serverTicks += 10;
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
serverLagInMilliSeconds = (time - lastServerTime - 500)*2;
|
serverLagInMilliSeconds = Math.abs((time - lastServerTime - 500)*2);
|
||||||
lastServerTime = time;
|
lastServerTime = time;
|
||||||
}
|
}
|
||||||
}, 10, 10);
|
}, 10, 10);
|
||||||
@ -287,7 +287,8 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
|||||||
try {
|
try {
|
||||||
if(permissions == null) {
|
if(permissions == null) {
|
||||||
if(checkOPs) {
|
if(checkOPs) {
|
||||||
return true;
|
// OPs don't get special treatment
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return player.isOp();
|
return player.isOp();
|
||||||
|
@ -33,7 +33,7 @@ public class SpeedhackCheck extends Check {
|
|||||||
super(plugin, "speedhack", PermissionData.PERMISSION_SPEEDHACK, config);
|
super(plugin, "speedhack", PermissionData.PERMISSION_SPEEDHACK, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int violationsLimit = 2;
|
private static final int violationsLimit = 3;
|
||||||
|
|
||||||
// Limits for the speedhack check per second
|
// Limits for the speedhack check per second
|
||||||
private int limits[];
|
private int limits[];
|
||||||
@ -56,7 +56,7 @@ public class SpeedhackCheck extends Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// During world transfers many events of same location get sent, ignore them all
|
// During world transfers many events of same location get sent, ignore them all
|
||||||
if(event.getFrom().getX() == event.getTo().getX() && event.getFrom().getZ() == event.getTo().getZ() && event.getFrom().getY() == event.getTo().getY()) {
|
if(event.getFrom().equals(event.getTo())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ public class SpeedhackCheck extends Check {
|
|||||||
data.setBackPoint = event.getFrom();
|
data.setBackPoint = event.getFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plugin.getServerLag() > 200) {
|
if(plugin.getServerLag() > 150) {
|
||||||
// Any data would likely be unreliable with that lag
|
// Any data would likely be unreliable with that lag
|
||||||
resetData(data, event.getFrom(), ticks);
|
resetData(data, event.getFrom());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final int low = (limits[0]+1) / 2;
|
final int low = (limits[0]+1) / 2;
|
||||||
@ -91,8 +91,9 @@ public class SpeedhackCheck extends Check {
|
|||||||
if(data.eventsSinceLastCheck > high) level = 2;
|
if(data.eventsSinceLastCheck > high) level = 2;
|
||||||
else if(data.eventsSinceLastCheck > med) level = 1;
|
else if(data.eventsSinceLastCheck > med) level = 1;
|
||||||
else if(data.eventsSinceLastCheck > low) level = 0;
|
else if(data.eventsSinceLastCheck > low) level = 0;
|
||||||
else resetData(data, event.getFrom(), ticks);
|
else {
|
||||||
|
resetData(data, event.getFrom());
|
||||||
|
}
|
||||||
|
|
||||||
if(level >= 0) {
|
if(level >= 0) {
|
||||||
data.violationsInARowTotal++;
|
data.violationsInARowTotal++;
|
||||||
@ -112,18 +113,18 @@ public class SpeedhackCheck extends Check {
|
|||||||
else if(data.lastCheckTicks + 10 < ticks)
|
else if(data.lastCheckTicks + 10 < ticks)
|
||||||
{
|
{
|
||||||
// The player didn't move for the last 10 ticks
|
// The player didn't move for the last 10 ticks
|
||||||
resetData(data, event.getFrom(), ticks);
|
resetData(data, event.getFrom());
|
||||||
|
data.lastCheckTicks = ticks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void resetData(SpeedhackData data, Location l, int ticks) {
|
private static void resetData(SpeedhackData data, Location l) {
|
||||||
data.violationsInARow[0] = 0;
|
data.violationsInARow[0] = 0;
|
||||||
data.violationsInARow[1] = 0;
|
data.violationsInARow[1] = 0;
|
||||||
data.violationsInARow[2] = 0;
|
data.violationsInARow[2] = 0;
|
||||||
data.violationsInARowTotal = 0;
|
data.violationsInARowTotal = 0;
|
||||||
data.eventsSinceLastCheck = 0;
|
data.eventsSinceLastCheck = 0;
|
||||||
data.setBackPoint = l;
|
data.setBackPoint = l;
|
||||||
data.lastCheckTicks = ticks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void action(Action actions[], PlayerMoveEvent event, int violations, SpeedhackData data) {
|
private void action(Action actions[], PlayerMoveEvent event, int violations, SpeedhackData data) {
|
||||||
@ -202,10 +203,7 @@ public class SpeedhackCheck extends Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void teleported(PlayerTeleportEvent event) {
|
public void teleported(PlayerTeleportEvent event) {
|
||||||
|
|
||||||
SpeedhackData data = SpeedhackData.get(event.getPlayer());
|
SpeedhackData data = SpeedhackData.get(event.getPlayer());
|
||||||
|
resetData(data, event.getTo());
|
||||||
data.setBackPoint = event.getTo();
|
|
||||||
data.eventsSinceLastCheck = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,9 @@ public class BooleanOption extends ChildOption {
|
|||||||
|
|
||||||
private boolean value;
|
private boolean value;
|
||||||
|
|
||||||
public BooleanOption(String name, String parentName, boolean initialValue) {
|
public BooleanOption(String name, boolean initialValue) {
|
||||||
|
|
||||||
super(name, parentName);
|
super(name);
|
||||||
this.value = initialValue;
|
this.value = initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.wizard.gui.Explainations;
|
||||||
|
|
||||||
|
|
||||||
public abstract class ChildOption extends Option {
|
public abstract class ChildOption extends Option {
|
||||||
|
|
||||||
@ -8,9 +10,8 @@ public abstract class ChildOption extends Option {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4648294833934457776L;
|
private static final long serialVersionUID = -4648294833934457776L;
|
||||||
|
|
||||||
public ChildOption(String identifier, String parentIdentifier) {
|
public ChildOption(String identifier) {
|
||||||
|
super(identifier);
|
||||||
super(identifier, parentIdentifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -23,6 +24,6 @@ public abstract class ChildOption extends Option {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toDescriptionString(String prefix) {
|
public String toDescriptionString(String prefix) {
|
||||||
return prefix + getIdentifier() + ": \"" + getDescription().replace("\n", "\r\n" + prefix + "\t\t") + "\"\r\n";
|
return prefix + getIdentifier() + ": \"" + Explainations.get(getFullIdentifier()).replace("\n", "\r\n" + prefix + "\t\t") + "\"\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ public class CustomActionOption extends ChildOption {
|
|||||||
private String command;
|
private String command;
|
||||||
|
|
||||||
|
|
||||||
public CustomActionOption(String identifier, String parentName, String command) {
|
public CustomActionOption(String identifier, String command) {
|
||||||
|
|
||||||
super(identifier, parentName);
|
super(identifier);
|
||||||
|
|
||||||
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, String parentName, int initialValue) {
|
public IntegerOption(String name, int initialValue) {
|
||||||
|
|
||||||
super(name, parentName, String.valueOf(initialValue), 5);
|
super(name, String.valueOf(initialValue), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,9 +56,9 @@ public class LevelOption extends ChildOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LevelOption(String identifier, String parentName, LogLevel initialValue) {
|
public LevelOption(String identifier, LogLevel initialValue) {
|
||||||
|
|
||||||
super(identifier, parentName);
|
super(identifier);
|
||||||
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 parentName, String initialValue) {
|
public LongStringOption(String name, String initialValue) {
|
||||||
super(name, parentName, initialValue, 60);
|
super(name, 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 parentName, String initialValue) {
|
public MediumStringOption(String name, String initialValue) {
|
||||||
super(name, parentName, initialValue, 30);
|
super(name, initialValue, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,156 +67,156 @@ public class NoCheatConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
root = new ParentOption("", "", false);
|
root = new ParentOption("", false);
|
||||||
|
|
||||||
|
|
||||||
/*** LOGGING section ***/
|
/*** LOGGING section ***/
|
||||||
{
|
{
|
||||||
ParentOption loggingNode = new ParentOption("logging", root.getFullIdentifier(), false);
|
ParentOption loggingNode = new ParentOption("logging", false);
|
||||||
root.add(loggingNode);
|
root.add(loggingNode);
|
||||||
|
|
||||||
loggingNode.add(new MediumStringOption("filename", loggingNode.getFullIdentifier(),
|
loggingNode.add(new MediumStringOption("filename",
|
||||||
SimpleYaml.getString("logging.filename", "plugins/NoCheat/nocheat.log", yamlContent)));
|
SimpleYaml.getString("logging.filename", "plugins/NoCheat/nocheat.log", yamlContent)));
|
||||||
|
|
||||||
loggingNode.add(new LevelOption("logtofile", loggingNode.getFullIdentifier(),
|
loggingNode.add(new LevelOption("logtofile",
|
||||||
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.getFullIdentifier(),
|
loggingNode.add(new LevelOption("logtoconsole",
|
||||||
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.getFullIdentifier(),
|
loggingNode.add(new LevelOption("logtochat",
|
||||||
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.getFullIdentifier(),
|
loggingNode.add(new LevelOption("logtoirc",
|
||||||
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.getFullIdentifier(),
|
loggingNode.add(new ShortStringOption("logtoirctag",
|
||||||
SimpleYaml.getString("logging.logtoirctag", "nocheat", yamlContent)));
|
SimpleYaml.getString("logging.logtoirctag", "nocheat", yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** ACTIVE section ***/
|
/*** ACTIVE section ***/
|
||||||
{
|
{
|
||||||
ParentOption activeNode = new ParentOption("active", root.getFullIdentifier(), false);
|
ParentOption activeNode = new ParentOption("active", false);
|
||||||
root.add(activeNode);
|
root.add(activeNode);
|
||||||
|
|
||||||
activeNode.add(new BooleanOption("speedhack", activeNode.getFullIdentifier(),
|
activeNode.add(new BooleanOption("speedhack",
|
||||||
SimpleYaml.getBoolean("active.speedhack", true, yamlContent)));
|
SimpleYaml.getBoolean("active.speedhack", true, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("moving", activeNode.getFullIdentifier(),
|
activeNode.add(new BooleanOption("moving",
|
||||||
SimpleYaml.getBoolean("active.moving", true, yamlContent)));
|
SimpleYaml.getBoolean("active.moving", true, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("airbuild", activeNode.getFullIdentifier(),
|
activeNode.add(new BooleanOption("airbuild",
|
||||||
SimpleYaml.getBoolean("active.airbuild", false, yamlContent)));
|
SimpleYaml.getBoolean("active.airbuild", false, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("bedteleport", activeNode.getFullIdentifier(),
|
activeNode.add(new BooleanOption("bedteleport",
|
||||||
SimpleYaml.getBoolean("active.bedteleport", true, yamlContent)));
|
SimpleYaml.getBoolean("active.bedteleport", true, yamlContent)));
|
||||||
activeNode.add(new BooleanOption("bogusitems", activeNode.getFullIdentifier(),
|
activeNode.add(new BooleanOption("bogusitems",
|
||||||
SimpleYaml.getBoolean("active.bogusitems", false, yamlContent)));
|
SimpleYaml.getBoolean("active.bogusitems", false, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** SPEEDHACK section ***/
|
/*** SPEEDHACK section ***/
|
||||||
{
|
{
|
||||||
ParentOption speedhackNode = new ParentOption("speedhack", root.getFullIdentifier(), false);
|
ParentOption speedhackNode = new ParentOption("speedhack", false);
|
||||||
root.add(speedhackNode);
|
root.add(speedhackNode);
|
||||||
|
|
||||||
speedhackNode.add(new LongStringOption("logmessage", speedhackNode.getFullIdentifier(),
|
speedhackNode.add(new LongStringOption("logmessage",
|
||||||
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)));
|
||||||
|
|
||||||
speedhackNode.add(new BooleanOption("checkops", speedhackNode.getFullIdentifier(),
|
speedhackNode.add(new BooleanOption("checkops",
|
||||||
SimpleYaml.getBoolean("speedhack.checkops", false, yamlContent)));
|
SimpleYaml.getBoolean("speedhack.checkops", false, yamlContent)));
|
||||||
|
|
||||||
/*** SPEEDHACK LIMITS section ***/
|
/*** SPEEDHACK LIMITS section ***/
|
||||||
{
|
{
|
||||||
ParentOption speedhackLimitsNode = new ParentOption("limits", speedhackNode.getFullIdentifier(), false);
|
ParentOption speedhackLimitsNode = new ParentOption("limits", false);
|
||||||
speedhackNode.add(speedhackLimitsNode);
|
speedhackNode.add(speedhackLimitsNode);
|
||||||
|
|
||||||
speedhackLimitsNode.add(new IntegerOption("low", speedhackLimitsNode.getFullIdentifier(),
|
speedhackLimitsNode.add(new IntegerOption("low",
|
||||||
SimpleYaml.getInt("speedhack.limits.low", 22, yamlContent)));
|
SimpleYaml.getInt("speedhack.limits.low", 22, yamlContent)));
|
||||||
speedhackLimitsNode.add(new IntegerOption("med", speedhackLimitsNode.getFullIdentifier(),
|
speedhackLimitsNode.add(new IntegerOption("med",
|
||||||
SimpleYaml.getInt("speedhack.limits.med", 33, yamlContent)));
|
SimpleYaml.getInt("speedhack.limits.med", 33, yamlContent)));
|
||||||
speedhackLimitsNode.add(new IntegerOption("high", speedhackLimitsNode.getFullIdentifier(),
|
speedhackLimitsNode.add(new IntegerOption("high",
|
||||||
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", speedhackNode.getFullIdentifier(), false);
|
ParentOption speedhackActionNode = new ParentOption("action", false);
|
||||||
speedhackNode.add(speedhackActionNode);
|
speedhackNode.add(speedhackActionNode);
|
||||||
|
|
||||||
speedhackActionNode.add(new MediumStringOption("low", speedhackActionNode.getFullIdentifier(),
|
speedhackActionNode.add(new MediumStringOption("low",
|
||||||
SimpleYaml.getString("speedhack.action.low", "loglow cancel", yamlContent)));
|
SimpleYaml.getString("speedhack.action.low", "loglow cancel", yamlContent)));
|
||||||
speedhackActionNode.add(new MediumStringOption("med", speedhackActionNode.getFullIdentifier(),
|
speedhackActionNode.add(new MediumStringOption("med",
|
||||||
SimpleYaml.getString("speedhack.action.med", "logmed cancel", yamlContent)));
|
SimpleYaml.getString("speedhack.action.med", "logmed cancel", yamlContent)));
|
||||||
speedhackActionNode.add(new MediumStringOption("high", speedhackActionNode.getFullIdentifier(),
|
speedhackActionNode.add(new MediumStringOption("high",
|
||||||
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", root.getFullIdentifier(), false);
|
ParentOption movingNode = new ParentOption("moving", false);
|
||||||
root.add(movingNode);
|
root.add(movingNode);
|
||||||
|
|
||||||
movingNode.add(new LongStringOption("logmessage", movingNode.getFullIdentifier(),
|
movingNode.add(new LongStringOption("logmessage",
|
||||||
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)));
|
||||||
|
|
||||||
movingNode.add(new LongStringOption("summarymessage", movingNode.getFullIdentifier(),
|
movingNode.add(new LongStringOption("summarymessage",
|
||||||
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)));
|
||||||
|
|
||||||
movingNode.add(new BooleanOption("allowflying", movingNode.getFullIdentifier(),
|
movingNode.add(new BooleanOption("allowflying",
|
||||||
SimpleYaml.getBoolean("moving.allowflying", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.allowflying", false, yamlContent)));
|
||||||
movingNode.add(new BooleanOption("allowfakesneak", movingNode.getFullIdentifier(),
|
movingNode.add(new BooleanOption("allowfakesneak",
|
||||||
SimpleYaml.getBoolean("moving.allowfakesneak", true, yamlContent)));
|
SimpleYaml.getBoolean("moving.allowfakesneak", true, yamlContent)));
|
||||||
movingNode.add(new BooleanOption("allowfastswim", movingNode.getFullIdentifier(),
|
movingNode.add(new BooleanOption("allowfastswim",
|
||||||
SimpleYaml.getBoolean("moving.allowfastswim", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.allowfastswim", false, yamlContent)));
|
||||||
movingNode.add(new BooleanOption("waterelevators", movingNode.getFullIdentifier(),
|
movingNode.add(new BooleanOption("waterelevators",
|
||||||
SimpleYaml.getBoolean("moving.waterelevators", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.waterelevators", false, yamlContent)));
|
||||||
|
|
||||||
movingNode.add(new BooleanOption("checkops", movingNode.getFullIdentifier(),
|
movingNode.add(new BooleanOption("checkops",
|
||||||
SimpleYaml.getBoolean("moving.checkops", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.checkops", false, yamlContent)));
|
||||||
|
|
||||||
movingNode.add(new BooleanOption("enforceteleport", movingNode.getFullIdentifier(),
|
movingNode.add(new BooleanOption("enforceteleport",
|
||||||
SimpleYaml.getBoolean("moving.enforceteleport", false, yamlContent)));
|
SimpleYaml.getBoolean("moving.enforceteleport", false, yamlContent)));
|
||||||
|
|
||||||
/*** MOVING ACTION section ***/
|
/*** MOVING ACTION section ***/
|
||||||
{
|
{
|
||||||
ParentOption movingActionNode = new ParentOption("action", movingNode.getFullIdentifier(), false);
|
ParentOption movingActionNode = new ParentOption("action", false);
|
||||||
movingNode.add(movingActionNode);
|
movingNode.add(movingActionNode);
|
||||||
|
|
||||||
movingActionNode.add(new MediumStringOption("low", movingActionNode.getFullIdentifier(),
|
movingActionNode.add(new MediumStringOption("low",
|
||||||
SimpleYaml.getString("moving.action.low", "loglow cancel", yamlContent)));
|
SimpleYaml.getString("moving.action.low", "loglow cancel", yamlContent)));
|
||||||
movingActionNode.add(new MediumStringOption("med", movingActionNode.getFullIdentifier(),
|
movingActionNode.add(new MediumStringOption("med",
|
||||||
SimpleYaml.getString("moving.action.med", "logmed cancel", yamlContent)));
|
SimpleYaml.getString("moving.action.med", "logmed cancel", yamlContent)));
|
||||||
movingActionNode.add(new MediumStringOption("high", movingActionNode.getFullIdentifier(),
|
movingActionNode.add(new MediumStringOption("high",
|
||||||
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", root.getFullIdentifier(), false);
|
ParentOption airbuildNode = new ParentOption("airbuild", false);
|
||||||
root.add(airbuildNode);
|
root.add(airbuildNode);
|
||||||
|
|
||||||
airbuildNode.add(new BooleanOption("checkops", airbuildNode.getFullIdentifier(),
|
airbuildNode.add(new BooleanOption("checkops",
|
||||||
SimpleYaml.getBoolean("airbuild.checkops", false, yamlContent)));
|
SimpleYaml.getBoolean("airbuild.checkops", false, yamlContent)));
|
||||||
|
|
||||||
/*** AIRBUILD LIMITS section ***/
|
/*** AIRBUILD LIMITS section ***/
|
||||||
{
|
{
|
||||||
ParentOption airbuildLimitsNode = new ParentOption("limits", airbuildNode.getFullIdentifier(), false);
|
ParentOption airbuildLimitsNode = new ParentOption("limits", false);
|
||||||
airbuildNode.add(airbuildLimitsNode);
|
airbuildNode.add(airbuildLimitsNode);
|
||||||
|
|
||||||
airbuildLimitsNode.add(new IntegerOption("low", airbuildLimitsNode.getFullIdentifier(),
|
airbuildLimitsNode.add(new IntegerOption("low",
|
||||||
SimpleYaml.getInt("airbuild.limits.low", 1, yamlContent)));
|
SimpleYaml.getInt("airbuild.limits.low", 1, yamlContent)));
|
||||||
airbuildLimitsNode.add(new IntegerOption("med", airbuildLimitsNode.getFullIdentifier(),
|
airbuildLimitsNode.add(new IntegerOption("med",
|
||||||
SimpleYaml.getInt("airbuild.limits.med", 3, yamlContent)));
|
SimpleYaml.getInt("airbuild.limits.med", 3, yamlContent)));
|
||||||
airbuildLimitsNode.add(new IntegerOption("high", airbuildLimitsNode.getFullIdentifier(),
|
airbuildLimitsNode.add(new IntegerOption("high",
|
||||||
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", airbuildNode.getFullIdentifier(), false);
|
ParentOption airbuildActionNode = new ParentOption("action", false);
|
||||||
airbuildNode.add(airbuildActionNode);
|
airbuildNode.add(airbuildActionNode);
|
||||||
|
|
||||||
airbuildActionNode.add(new MediumStringOption("low", airbuildActionNode.getFullIdentifier(),
|
airbuildActionNode.add(new MediumStringOption("low",
|
||||||
SimpleYaml.getString("airbuild.action.low", "loglow cancel", yamlContent)));
|
SimpleYaml.getString("airbuild.action.low", "loglow cancel", yamlContent)));
|
||||||
airbuildActionNode.add(new MediumStringOption("med", airbuildActionNode.getFullIdentifier(),
|
airbuildActionNode.add(new MediumStringOption("med",
|
||||||
SimpleYaml.getString("airbuild.action.med", "logmed cancel", yamlContent)));
|
SimpleYaml.getString("airbuild.action.med", "logmed cancel", yamlContent)));
|
||||||
airbuildActionNode.add(new MediumStringOption("high", airbuildActionNode.getFullIdentifier(),
|
airbuildActionNode.add(new MediumStringOption("high",
|
||||||
SimpleYaml.getString("airbuild.action.high", "loghigh cancel", yamlContent)));
|
SimpleYaml.getString("airbuild.action.high", "loghigh cancel", yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,32 +225,32 @@ public class NoCheatConfiguration {
|
|||||||
|
|
||||||
/*** BEDTELEPORT section ***/
|
/*** BEDTELEPORT section ***/
|
||||||
{
|
{
|
||||||
ParentOption bedteleportNode = new ParentOption("bedteleport", root.getFullIdentifier(), false);
|
ParentOption bedteleportNode = new ParentOption("bedteleport", false);
|
||||||
root.add(bedteleportNode);
|
root.add(bedteleportNode);
|
||||||
|
|
||||||
bedteleportNode.add(new BooleanOption("checkops", bedteleportNode.getFullIdentifier(),
|
bedteleportNode.add(new BooleanOption("checkops",
|
||||||
SimpleYaml.getBoolean("bedteleport.checkops", false, yamlContent)));
|
SimpleYaml.getBoolean("bedteleport.checkops", false, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** BOGUSITEMS section ***/
|
/*** BOGUSITEMS section ***/
|
||||||
{
|
{
|
||||||
ParentOption bogusitemsNode = new ParentOption("bogusitems", root.getFullIdentifier(), false);
|
ParentOption bogusitemsNode = new ParentOption("bogusitems", false);
|
||||||
root.add(bogusitemsNode);
|
root.add(bogusitemsNode);
|
||||||
|
|
||||||
bogusitemsNode.add(new BooleanOption("checkops", bogusitemsNode.getFullIdentifier(),
|
bogusitemsNode.add(new BooleanOption("checkops",
|
||||||
SimpleYaml.getBoolean("bogusitems.checkops", false, yamlContent)));
|
SimpleYaml.getBoolean("bogusitems.checkops", false, yamlContent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** CUSTOMACTIONS section ***/
|
/*** CUSTOMACTIONS section ***/
|
||||||
{
|
{
|
||||||
ParentOption customActionsNode = new ParentOption("customactions", root.getFullIdentifier(), true);
|
ParentOption customActionsNode = new ParentOption("customactions", 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, customActionsNode.getFullIdentifier(), SimpleYaml.getString("customactions."+s, "unknown", yamlContent));
|
CustomActionOption o = new CustomActionOption(s, SimpleYaml.getString("customactions."+s, "unknown", yamlContent));
|
||||||
|
|
||||||
customActionsNode.add(o);
|
customActionsNode.add(o);
|
||||||
actionMap.put(s, o.getCustomActionValue());
|
actionMap.put(s, o.getCustomActionValue());
|
||||||
@ -258,7 +258,7 @@ public class NoCheatConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeConfigFile(configurationFile, this);
|
writeConfigFile(configurationFile, this);
|
||||||
writeDescriptionFile(descriptionsFile, this);
|
//writeDescriptionFile(descriptionsFile, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupFileLogger() {
|
public void setupFileLogger() {
|
||||||
|
@ -1,29 +1,24 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.wizard.gui.Explainations;
|
|
||||||
|
|
||||||
public abstract class Option {
|
public abstract class Option {
|
||||||
|
|
||||||
private final String identifier;
|
private final String identifier;
|
||||||
private final String parentIdentifier;
|
private Option parent;
|
||||||
private final String description;
|
|
||||||
|
|
||||||
public Option(String identifier, String parentIdentifier) {
|
public Option(String identifier) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
this.parentIdentifier = parentIdentifier;
|
|
||||||
this.description = Explainations.get(parentIdentifier == null || parentIdentifier.equals("") ? identifier : parentIdentifier + "." + identifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getIdentifier() {
|
public final String getIdentifier() {
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getDescription() {
|
public final void setParent(Option parent) {
|
||||||
return description;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getFullIdentifier() {
|
public final String getFullIdentifier() {
|
||||||
return (parentIdentifier == null || parentIdentifier == "") ? identifier : parentIdentifier + "." + identifier;
|
return (parent == null || parent.getFullIdentifier() == "") ? identifier : parent.getFullIdentifier() + "." + identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String toYAMLString(String prefix);
|
public abstract String toYAMLString(String prefix);
|
||||||
|
@ -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, String parentName, boolean editable) {
|
public ParentOption(String identifier, boolean editable) {
|
||||||
super(identifier, parentName);
|
super(identifier);
|
||||||
this.editable = editable;
|
this.editable = editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,14 +25,13 @@ public class ParentOption extends Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void add(Option option) {
|
public final void add(Option option) {
|
||||||
|
|
||||||
children.addLast(option);
|
children.addLast(option);
|
||||||
|
option.setParent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void remove(Option option) {
|
public final void remove(Option option) {
|
||||||
|
|
||||||
if(editable)
|
if(editable)
|
||||||
children.remove(option);
|
children.remove(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEditable() {
|
public boolean isEditable() {
|
||||||
|
@ -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 parentName, String initialValue) {
|
public ShortStringOption(String name, String initialValue) {
|
||||||
super(name, parentName, initialValue, 10);
|
super(name, 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 parentName, String initialValue, int preferredLength) {
|
public TextFieldOption(String name, String initialValue, int preferredLength) {
|
||||||
|
|
||||||
super(name, parentName);
|
super(name);
|
||||||
this.value = initialValue;
|
this.value = initialValue;
|
||||||
this.length = preferredLength;
|
this.length = preferredLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextFieldOption(String name, String parentName, String initialValue) {
|
public TextFieldOption(String name, String parentName, String initialValue) {
|
||||||
|
|
||||||
super(name, parentName);
|
super(name);
|
||||||
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(), option.getFullIdentifier(), "yourcommand [player]"));
|
option.add(new CustomActionOption(nameField.getText(), "yourcommand [player]"));
|
||||||
recreateContent();
|
recreateContent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user