mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-02 08:40:01 +01:00
Use Bukkits YAML Configurations to store stuff
This commit is contained in:
parent
7930bcb81d
commit
c1d7e058dd
@ -9,7 +9,7 @@ package cc.co.evenprime.bukkit.nocheat.actions;
|
|||||||
public abstract class Action {
|
public abstract class Action {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delay in violations (only do if there were more than "delay" exceptions
|
* Delay in violations (only do if there were more than "delay" violations
|
||||||
* in last 60 seconds)
|
* in last 60 seconds)
|
||||||
*/
|
*/
|
||||||
public final int delay;
|
public final int delay;
|
||||||
@ -29,17 +29,4 @@ public abstract class Action {
|
|||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
this.repeat = repeat;
|
this.repeat = repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Make a copy of the action, with some modifications
|
|
||||||
* @param string
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Action cloneWithProperties(String string) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperties() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,12 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
import org.bukkit.permissions.ServerOperator;
|
import org.bukkit.permissions.ServerOperator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to execute commands of other plugins.
|
||||||
|
* It ignores any feedback of other plugins and claims to be
|
||||||
|
* OP when asked.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class NoCheatCommandSender extends PermissibleBase implements ConsoleCommandSender {
|
public class NoCheatCommandSender extends PermissibleBase implements ConsoleCommandSender {
|
||||||
|
|
||||||
private static final ServerOperator serverOperator = new ServerOperator() {
|
private static final ServerOperator serverOperator = new ServerOperator() {
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.actions;
|
package cc.co.evenprime.bukkit.nocheat.actions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some wildcards that are used in commands and log messages
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum ParameterName {
|
public enum ParameterName {
|
||||||
PLAYER("player"), LOCATION("location"), WORLD("world"), VIOLATIONS("violations"), MOVEDISTANCE("movedistance"), REACHDISTANCE("reachdistance"), FALLDISTANCE("falldistance"), LOCATION_TO("locationto"), CHECK("check"), PACKETS("packets"), TEXT("text"), PLACE_LOCATION("placelocation"), PLACE_AGAINST("placeagainst"), BLOCK_TYPE("blocktype");
|
PLAYER("player"), LOCATION("location"), WORLD("world"), VIOLATIONS("violations"), MOVEDISTANCE("movedistance"), REACHDISTANCE("reachdistance"), FALLDISTANCE("falldistance"), LOCATION_TO("locationto"), CHECK("check"), PACKETS("packets"), TEXT("text"), PLACE_LOCATION("placelocation"), PLACE_AGAINST("placeagainst"), BLOCK_TYPE("blocktype");
|
||||||
|
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||||
|
|
||||||
|
public class ActionFactory {
|
||||||
|
|
||||||
|
private static final Map<String, Object> lib = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
public ActionFactory(Map<String, Object> library) {
|
||||||
|
lib.putAll(library);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action createAction(String actionDefinition) {
|
||||||
|
|
||||||
|
actionDefinition = actionDefinition.toLowerCase();
|
||||||
|
|
||||||
|
if(actionDefinition.equals("cancel")) {
|
||||||
|
return new SpecialAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(actionDefinition.startsWith("log:")) {
|
||||||
|
return parseLogAction(actionDefinition.split(":", 2)[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(actionDefinition.startsWith("cmd:")) {
|
||||||
|
return parseCmdAction(actionDefinition.split(":", 2)[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("NoCheat doesn't understand action '" + actionDefinition + "' at all");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Action parseCmdAction(String definition) {
|
||||||
|
String[] parts = definition.split(":");
|
||||||
|
String name = parts[0];
|
||||||
|
Object command = lib.get(parts[0]);
|
||||||
|
int delay = 0;
|
||||||
|
int repeat = 1;
|
||||||
|
|
||||||
|
if(command == null) {
|
||||||
|
throw new IllegalArgumentException("NoCheat doesn't know command '" + name + "'. Have you forgotten to define it?");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parts.length > 1) {
|
||||||
|
try {
|
||||||
|
delay = Integer.parseInt(parts[1]);
|
||||||
|
repeat = Integer.parseInt(parts[2]);
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.out.println("NoCheat couldn't parse details of command '" + definition + "', will use default values instead.");
|
||||||
|
delay = 0;
|
||||||
|
repeat = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ConsolecommandAction(name, delay, repeat, command.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Action parseLogAction(String definition) {
|
||||||
|
String[] parts = definition.split(":");
|
||||||
|
String name = parts[0];
|
||||||
|
Object message = lib.get(parts[0]);
|
||||||
|
int delay = 0;
|
||||||
|
int repeat = 1;
|
||||||
|
boolean toConsole = true;
|
||||||
|
boolean toFile = true;
|
||||||
|
boolean toChat = true;
|
||||||
|
|
||||||
|
if(message == null) {
|
||||||
|
throw new IllegalArgumentException("NoCheat doesn't know log message '" + name + "'. Have you forgotten to define it?");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
delay = Integer.parseInt(parts[1]);
|
||||||
|
repeat = Integer.parseInt(parts[2]);
|
||||||
|
toConsole = parts[3].contains("c");
|
||||||
|
toChat = parts[3].contains("i");
|
||||||
|
toFile = parts[3].contains("f");
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.out.println("NoCheat couldn't parse details of log action '" + definition + "', will use default values instead.");
|
||||||
|
e.printStackTrace();
|
||||||
|
delay = 0;
|
||||||
|
repeat = 1;
|
||||||
|
toConsole = true;
|
||||||
|
toFile = true;
|
||||||
|
toChat = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new LogAction(name, delay, repeat, toChat, toConsole, toFile, message.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action[] createActions(String... definitions) {
|
||||||
|
List<Action> actions = new ArrayList<Action>();
|
||||||
|
|
||||||
|
for(String def : definitions) {
|
||||||
|
if(def.length() == 0)
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
actions.add(createAction(def));
|
||||||
|
} catch(IllegalArgumentException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
actions.add(new DummyAction(def));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return actions.toArray(new Action[actions.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionList createActionList(String definition) {
|
||||||
|
ActionList list = new ActionList();
|
||||||
|
|
||||||
|
boolean first = true;
|
||||||
|
|
||||||
|
for(String s : definition.split("vl>")) {
|
||||||
|
s = s.trim();
|
||||||
|
|
||||||
|
if(s.length() == 0) {
|
||||||
|
first = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] listEntry = s.split("\\s+", 2);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Integer vl;
|
||||||
|
String def;
|
||||||
|
if(first) {
|
||||||
|
first = false;
|
||||||
|
vl = 0;
|
||||||
|
def = listEntry[0];
|
||||||
|
} else {
|
||||||
|
vl = Integer.parseInt(listEntry[0]);
|
||||||
|
def = listEntry[1];
|
||||||
|
}
|
||||||
|
list.setActions(vl, createActions(def.split("\\s+")));
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.out.println("NoCheat couldn't parse action definition 'vl:" + s + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,10 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config.util;
|
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,7 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.actions;
|
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
||||||
|
|
||||||
public abstract class ActionWithParameters extends Action {
|
public abstract class ActionWithParameters extends Action {
|
@ -1,8 +1,6 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionWithParameters;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,14 +10,7 @@ import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
|||||||
*/
|
*/
|
||||||
public class ConsolecommandAction extends ActionWithParameters {
|
public class ConsolecommandAction extends ActionWithParameters {
|
||||||
|
|
||||||
private String command;
|
public ConsolecommandAction(String name, int delay, int repeat, String command) {
|
||||||
|
|
||||||
public ConsolecommandAction(String name, String command) {
|
|
||||||
super(name, 0, 1, command);
|
|
||||||
this.command = command;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ConsolecommandAction(String name, int delay, int repeat, String command) {
|
|
||||||
// Log messages may have color codes now
|
// Log messages may have color codes now
|
||||||
super(name, delay, repeat, command);
|
super(name, delay, repeat, command);
|
||||||
}
|
}
|
||||||
@ -28,25 +19,7 @@ public class ConsolecommandAction extends ActionWithParameters {
|
|||||||
return super.getMessage(player, check);
|
return super.getMessage(player, check);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String toString() {
|
||||||
* Make a copy of the action, with some modifications
|
return "cmd:" + name + ":" + delay + ":" + repeat;
|
||||||
* @param properties
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Action cloneWithProperties(String properties) {
|
|
||||||
String propertyFields[] = properties.split(":");
|
|
||||||
|
|
||||||
int delay = Integer.parseInt(propertyFields[0]);
|
|
||||||
int repeat = 5;
|
|
||||||
if(propertyFields.length > 1)
|
|
||||||
repeat = Integer.parseInt(propertyFields[1]);
|
|
||||||
|
|
||||||
return new ConsolecommandAction(name, delay, repeat, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProperties() {
|
|
||||||
return delay + ":" + repeat;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,20 @@ package cc.co.evenprime.bukkit.nocheat.actions.types;
|
|||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is only used to not lose config entries in case an action isn't defined
|
* If an action can't be parsed correctly, at least keep it
|
||||||
* correctly
|
* stored in this form
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DummyAction extends Action {
|
public class DummyAction extends Action {
|
||||||
|
|
||||||
public DummyAction(String name, int delay, int repeat) {
|
private String def;
|
||||||
super(name, delay, repeat);
|
|
||||||
|
public DummyAction(String def) {
|
||||||
|
super("dummyAction", 10000, 10000);
|
||||||
|
this.def = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionWithParameters;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a message to various locations
|
* Print a log message to various locations
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LogAction extends ActionWithParameters {
|
public class LogAction extends ActionWithParameters {
|
||||||
@ -14,16 +12,8 @@ public class LogAction extends ActionWithParameters {
|
|||||||
private boolean toChat = true;
|
private boolean toChat = true;
|
||||||
private boolean toConsole = true;
|
private boolean toConsole = true;
|
||||||
private boolean toFile = true;
|
private boolean toFile = true;
|
||||||
private String message;
|
|
||||||
|
|
||||||
public LogAction(String name, String message) {
|
public LogAction(String name, int delay, int repeat, boolean toChat, boolean toConsole, boolean toFile, String message) {
|
||||||
// Log messages may have color codes now
|
|
||||||
super(name, 0, 5, message);
|
|
||||||
this.message = message;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private LogAction(String name, int delay, int repeat, boolean toChat, boolean toConsole, boolean toFile, String message) {
|
|
||||||
// Log messages may have color codes now
|
// Log messages may have color codes now
|
||||||
super(name, delay, repeat, message);
|
super(name, delay, repeat, message);
|
||||||
this.toChat = toChat;
|
this.toChat = toChat;
|
||||||
@ -47,35 +37,7 @@ public class LogAction extends ActionWithParameters {
|
|||||||
return toFile;
|
return toFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String toString() {
|
||||||
public Action cloneWithProperties(String properties) {
|
return "log:" + name + ":" + delay + ":" + repeat + ":" + (toConsole ? "c" : "") + (toChat ? "i" : "") + (toFile ? "f" : "");
|
||||||
String propertyFields[] = properties.split(":");
|
|
||||||
|
|
||||||
int delay = Integer.parseInt(propertyFields[0]);
|
|
||||||
int repeat = 5;
|
|
||||||
if(propertyFields.length > 1)
|
|
||||||
repeat = Integer.parseInt(propertyFields[1]);
|
|
||||||
|
|
||||||
boolean toChat = false;
|
|
||||||
boolean toFile = false;
|
|
||||||
boolean toConsole = false;
|
|
||||||
|
|
||||||
if(propertyFields.length > 2) {
|
|
||||||
toChat = propertyFields[2].toLowerCase().contains("ch");
|
|
||||||
toFile = propertyFields[2].toLowerCase().contains("fi");
|
|
||||||
toConsole = propertyFields[2].toLowerCase().contains("co");
|
|
||||||
}
|
|
||||||
|
|
||||||
return new LogAction(name, delay, repeat, toChat, toConsole, toFile, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProperties() {
|
|
||||||
String props = delay + ":" + repeat + ":" + ((toChat ? "ch," : "") + (toFile ? "fi," : "") + (toConsole ? "co," : ""));
|
|
||||||
if(props.endsWith(",")) {
|
|
||||||
return props.substring(0, props.length() - 1);
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,32 +9,11 @@ import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
|||||||
*/
|
*/
|
||||||
public class SpecialAction extends Action {
|
public class SpecialAction extends Action {
|
||||||
|
|
||||||
public SpecialAction(String name, String parameters) {
|
public SpecialAction() {
|
||||||
super(name, 0, 0);
|
super("cancel", 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialAction(String name, int delay, int repeat) {
|
public String toString() {
|
||||||
super(name, delay, repeat);
|
return "cancel";
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make a copy of the action, with some modifications
|
|
||||||
* @param properties
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Action cloneWithProperties(String properties) {
|
|
||||||
String propertyFields[] = properties.split(":");
|
|
||||||
|
|
||||||
int delay = Integer.parseInt(propertyFields[0]);
|
|
||||||
int repeat = 5;
|
|
||||||
if(propertyFields.length > 1)
|
|
||||||
repeat = Integer.parseInt(propertyFields[1]);
|
|
||||||
|
|
||||||
return new SpecialAction(name, delay, repeat);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProperties() {
|
|
||||||
return delay + ":" + repeat;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,17 +59,14 @@ public class WorkaroundsListener implements Listener, EventManager {
|
|||||||
|
|
||||||
// Fix a common mistake that other developers make (cancelling move
|
// Fix a common mistake that other developers make (cancelling move
|
||||||
// events is crazy, rather set the target location to the from location)
|
// events is crazy, rather set the target location to the from location)
|
||||||
if(plugin.getPlayer(event.getPlayer()).getConfigurationStore().debug.overrideIdiocy) {
|
event.setCancelled(false);
|
||||||
event.setCancelled(false);
|
event.setTo(event.getFrom().clone());
|
||||||
event.setTo(event.getFrom().clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void toggleSprint(final PlayerToggleSprintEvent event) {
|
public void toggleSprint(final PlayerToggleSprintEvent event) {
|
||||||
if(event.isCancelled() && event.isSprinting()) {
|
if(event.isCancelled() && event.isSprinting()) {
|
||||||
if(plugin.getPlayer(event.getPlayer()).getConfigurationStore().debug.overrideIdiocy)
|
event.setCancelled(false);
|
||||||
event.setCancelled(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.blockbreak;
|
package cc.co.evenprime.bukkit.nocheat.checks.blockbreak;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
import cc.co.evenprime.bukkit.nocheat.config.ConfPaths;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurations specific for the "BlockBreak" checks
|
* Configurations specific for the "BlockBreak" checks
|
||||||
@ -12,7 +13,6 @@ import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
|||||||
public class BlockBreakConfig implements ConfigItem {
|
public class BlockBreakConfig implements ConfigItem {
|
||||||
|
|
||||||
public final boolean check;
|
public final boolean check;
|
||||||
public final boolean checkinstabreakblocks;
|
|
||||||
public final boolean reachCheck;
|
public final boolean reachCheck;
|
||||||
public final double reachDistance;
|
public final double reachDistance;
|
||||||
public final ActionList reachActions;
|
public final ActionList reachActions;
|
||||||
@ -23,19 +23,19 @@ public class BlockBreakConfig implements ConfigItem {
|
|||||||
public final boolean noswingCheck;
|
public final boolean noswingCheck;
|
||||||
public final ActionList noswingActions;
|
public final ActionList noswingActions;
|
||||||
|
|
||||||
public BlockBreakConfig(Configuration data) {
|
public BlockBreakConfig(NoCheatConfiguration data) {
|
||||||
|
|
||||||
check = data.getBoolean(Configuration.BLOCKBREAK_CHECK);
|
reachCheck = data.getBoolean(ConfPaths.BLOCKBREAK_REACH_CHECK);
|
||||||
reachCheck = data.getBoolean(Configuration.BLOCKBREAK_REACH_CHECK);
|
|
||||||
reachDistance = 535D / 100D;
|
reachDistance = 535D / 100D;
|
||||||
reachActions = data.getActionList(Configuration.BLOCKBREAK_REACH_ACTIONS);
|
reachActions = data.getActionList(ConfPaths.BLOCKBREAK_REACH_ACTIONS);
|
||||||
checkinstabreakblocks = data.getBoolean(Configuration.BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS);
|
directionCheck = data.getBoolean(ConfPaths.BLOCKBREAK_DIRECTION_CHECK);
|
||||||
directionCheck = data.getBoolean(Configuration.BLOCKBREAK_DIRECTION_CHECK);
|
directionPrecision = ((double) data.getInt(ConfPaths.BLOCKBREAK_DIRECTION_PRECISION)) / 100D;
|
||||||
directionPrecision = ((double) data.getInteger(Configuration.BLOCKBREAK_DIRECTION_PRECISION)) / 100D;
|
directionPenaltyTime = data.getInt(ConfPaths.BLOCKBREAK_DIRECTION_PENALTYTIME);
|
||||||
directionPenaltyTime = data.getInteger(Configuration.BLOCKBREAK_DIRECTION_PENALTYTIME);
|
directionActions = data.getActionList(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS);
|
||||||
directionActions = data.getActionList(Configuration.BLOCKBREAK_DIRECTION_ACTIONS);
|
noswingCheck = data.getBoolean(ConfPaths.BLOCKBREAK_NOSWING_CHECK);
|
||||||
noswingCheck = data.getBoolean(Configuration.BLOCKBREAK_NOSWING_CHECK);
|
noswingActions = data.getActionList(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS);
|
||||||
noswingActions = data.getActionList(Configuration.BLOCKBREAK_NOSWING_ACTIONS);
|
|
||||||
|
check = reachCheck || directionCheck || noswingCheck;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.blockbreak;
|
package cc.co.evenprime.bukkit.nocheat.checks.blockbreak;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
||||||
@ -24,12 +23,6 @@ public class DirectionCheck extends BlockBreakCheck {
|
|||||||
|
|
||||||
final SimpleLocation brokenBlock = data.brokenBlockLocation;
|
final SimpleLocation brokenBlock = data.brokenBlockLocation;
|
||||||
final boolean isInstaBreak = data.instaBrokenBlockLocation.equals(brokenBlock);
|
final boolean isInstaBreak = data.instaBrokenBlockLocation.equals(brokenBlock);
|
||||||
|
|
||||||
// If the block is instabreak and we don't check instabreak, return
|
|
||||||
if(isInstaBreak && !ccblockbreak.checkinstabreakblocks) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
double off = CheckUtil.directionCheck(player, brokenBlock.x + 0.5D, brokenBlock.y + 0.5D, brokenBlock.z + 0.5D, 1D, 1D, ccblockbreak.directionPrecision);
|
double off = CheckUtil.directionCheck(player, brokenBlock.x + 0.5D, brokenBlock.y + 0.5D, brokenBlock.z + 0.5D, 1D, 1D, ccblockbreak.directionPrecision);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.blockplace;
|
package cc.co.evenprime.bukkit.nocheat.checks.blockplace;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
import cc.co.evenprime.bukkit.nocheat.config.ConfPaths;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -20,18 +21,18 @@ public class BlockPlaceConfig implements ConfigItem {
|
|||||||
public final long directionPenaltyTime;
|
public final long directionPenaltyTime;
|
||||||
public final double directionPrecision;
|
public final double directionPrecision;
|
||||||
|
|
||||||
public BlockPlaceConfig(Configuration data) {
|
public BlockPlaceConfig(NoCheatConfiguration data) {
|
||||||
|
|
||||||
check = data.getBoolean(Configuration.BLOCKPLACE_CHECK);
|
reachCheck = data.getBoolean(ConfPaths.BLOCKPLACE_REACH_CHECK);
|
||||||
|
|
||||||
reachCheck = data.getBoolean(Configuration.BLOCKPLACE_REACH_CHECK);
|
|
||||||
reachDistance = 535D / 100D;
|
reachDistance = 535D / 100D;
|
||||||
reachActions = data.getActionList(Configuration.BLOCKPLACE_REACH_ACTIONS);
|
reachActions = data.getActionList(ConfPaths.BLOCKPLACE_REACH_ACTIONS);
|
||||||
|
|
||||||
directionCheck = data.getBoolean(Configuration.BLOCKPLACE_DIRECTION_CHECK);
|
directionCheck = data.getBoolean(ConfPaths.BLOCKPLACE_DIRECTION_CHECK);
|
||||||
directionPenaltyTime = data.getInteger(Configuration.BLOCKPLACE_DIRECTION_PENALTYTIME);
|
directionPenaltyTime = data.getInt(ConfPaths.BLOCKPLACE_DIRECTION_PENALTYTIME);
|
||||||
directionPrecision = ((double) data.getInteger(Configuration.BLOCKPLACE_DIRECTION_PRECISION)) / 100D;
|
directionPrecision = ((double) data.getInt(ConfPaths.BLOCKPLACE_DIRECTION_PRECISION)) / 100D;
|
||||||
directionActions = data.getActionList(Configuration.BLOCKPLACE_DIRECTION_ACTIONS);
|
directionActions = data.getActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS);
|
||||||
|
|
||||||
|
check = reachCheck || directionCheck;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,9 @@ package cc.co.evenprime.bukkit.nocheat.checks.chat;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
import cc.co.evenprime.bukkit.nocheat.config.ConfPaths;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
public class ChatConfig implements ConfigItem {
|
public class ChatConfig implements ConfigItem {
|
||||||
|
|
||||||
@ -17,16 +18,17 @@ public class ChatConfig implements ConfigItem {
|
|||||||
public final boolean colorCheck;
|
public final boolean colorCheck;
|
||||||
public final ActionList colorActions;
|
public final ActionList colorActions;
|
||||||
|
|
||||||
public ChatConfig(Configuration data) {
|
public ChatConfig(NoCheatConfiguration data) {
|
||||||
|
|
||||||
check = data.getBoolean(Configuration.CHAT_CHECK);
|
spamCheck = data.getBoolean(ConfPaths.CHAT_SPAM_CHECK);
|
||||||
spamCheck = data.getBoolean(Configuration.CHAT_SPAM_CHECK);
|
spamWhitelist = splitWhitelist(data.getString(ConfPaths.CHAT_SPAM_WHITELIST));
|
||||||
spamWhitelist = splitWhitelist(data.getString(Configuration.CHAT_SPAM_WHITELIST));
|
spamTimeframe = data.getInt(ConfPaths.CHAT_SPAM_TIMEFRAME);
|
||||||
spamTimeframe = data.getInteger(Configuration.CHAT_SPAM_TIMEFRAME);
|
spamLimit = data.getInt(ConfPaths.CHAT_SPAM_LIMIT);
|
||||||
spamLimit = data.getInteger(Configuration.CHAT_SPAM_LIMIT);
|
spamActions = data.getActionList(ConfPaths.CHAT_SPAM_ACTIONS);
|
||||||
spamActions = data.getActionList(Configuration.CHAT_SPAM_ACTIONS);
|
colorCheck = data.getBoolean(ConfPaths.CHAT_COLOR_CHECK);
|
||||||
colorCheck = data.getBoolean(Configuration.CHAT_COLOR_CHECK);
|
colorActions = data.getActionList(ConfPaths.CHAT_COLOR_ACTIONS);
|
||||||
colorActions = data.getActionList(Configuration.CHAT_COLOR_ACTIONS);
|
|
||||||
|
check = spamCheck || colorCheck;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.fight;
|
package cc.co.evenprime.bukkit.nocheat.checks.fight;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
import cc.co.evenprime.bukkit.nocheat.config.ConfPaths;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
public class FightConfig implements ConfigItem {
|
public class FightConfig implements ConfigItem {
|
||||||
|
|
||||||
@ -14,14 +15,15 @@ public class FightConfig implements ConfigItem {
|
|||||||
public final boolean noswingCheck;
|
public final boolean noswingCheck;
|
||||||
public final ActionList noswingActions;
|
public final ActionList noswingActions;
|
||||||
|
|
||||||
public FightConfig(Configuration data) {
|
public FightConfig(NoCheatConfiguration data) {
|
||||||
|
|
||||||
check = data.getBoolean(Configuration.FIGHT_CHECK);
|
directionCheck = data.getBoolean(ConfPaths.FIGHT_DIRECTION_CHECK);
|
||||||
directionCheck = data.getBoolean(Configuration.FIGHT_DIRECTION_CHECK);
|
directionPrecision = ((double) (data.getInt(ConfPaths.FIGHT_DIRECTION_PRECISION))) / 100D;
|
||||||
directionPrecision = ((double) (data.getInteger(Configuration.FIGHT_DIRECTION_PRECISION))) / 100D;
|
directionPenaltyTime = data.getInt(ConfPaths.FIGHT_DIRECTION_PENALTYTIME);
|
||||||
directionPenaltyTime = data.getInteger(Configuration.FIGHT_DIRECTION_PENALTYTIME);
|
directionActions = data.getActionList(ConfPaths.FIGHT_DIRECTION_ACTIONS);
|
||||||
directionActions = data.getActionList(Configuration.FIGHT_DIRECTION_ACTIONS);
|
noswingCheck = data.getBoolean(ConfPaths.FIGHT_NOSWING_CHECK);
|
||||||
noswingCheck = data.getBoolean(Configuration.FIGHT_NOSWING_CHECK);
|
noswingActions = data.getActionList(ConfPaths.FIGHT_NOSWING_ACTIONS);
|
||||||
noswingActions = data.getActionList(Configuration.FIGHT_NOSWING_ACTIONS);
|
|
||||||
|
check = directionCheck || noswingCheck;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.inventory;
|
package cc.co.evenprime.bukkit.nocheat.checks.inventory;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
import cc.co.evenprime.bukkit.nocheat.config.ConfPaths;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
public class InventoryConfig implements ConfigItem {
|
public class InventoryConfig implements ConfigItem {
|
||||||
|
|
||||||
@ -13,12 +14,13 @@ public class InventoryConfig implements ConfigItem {
|
|||||||
public final int dropLimit;
|
public final int dropLimit;
|
||||||
public final ActionList dropActions;
|
public final ActionList dropActions;
|
||||||
|
|
||||||
public InventoryConfig(Configuration data) {
|
public InventoryConfig(NoCheatConfiguration data) {
|
||||||
|
|
||||||
check = data.getBoolean(Configuration.INVENTORY_CHECK);
|
dropCheck = data.getBoolean(ConfPaths.INVENTORY_DROP_CHECK);
|
||||||
dropCheck = data.getBoolean(Configuration.INVENTORY_DROP_CHECK);
|
dropTimeFrame = data.getInt(ConfPaths.INVENTORY_DROP_TIMEFRAME);
|
||||||
dropTimeFrame = data.getInteger(Configuration.INVENTORY_DROP_TIMEFRAME);
|
dropLimit = data.getInt(ConfPaths.INVENTORY_DROP_LIMIT);
|
||||||
dropLimit = data.getInteger(Configuration.INVENTORY_DROP_LIMIT);
|
dropActions = data.getActionList(ConfPaths.INVENTORY_DROP_ACTIONS);
|
||||||
dropActions = data.getActionList(Configuration.INVENTORY_DROP_ACTIONS);
|
|
||||||
|
check = dropCheck;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,8 +203,6 @@ public class MovingCheckListener implements Listener, EventManager {
|
|||||||
|
|
||||||
if(!m.allowFlying) {
|
if(!m.allowFlying) {
|
||||||
s.add("moving.runfly");
|
s.add("moving.runfly");
|
||||||
if(m.swimmingCheck)
|
|
||||||
s.add("moving.swimming");
|
|
||||||
if(m.sneakingCheck)
|
if(m.sneakingCheck)
|
||||||
s.add("moving.sneaking");
|
s.add("moving.sneaking");
|
||||||
if(m.nofallCheck)
|
if(m.nofallCheck)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
import cc.co.evenprime.bukkit.nocheat.config.ConfPaths;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurations specific for the Move Checks. Every world gets one of these
|
* Configurations specific for the Move Checks. Every world gets one of these
|
||||||
@ -17,9 +18,7 @@ public class MovingConfig implements ConfigItem {
|
|||||||
public final boolean identifyCreativeMode;
|
public final boolean identifyCreativeMode;
|
||||||
public final double walkingSpeedLimit;
|
public final double walkingSpeedLimit;
|
||||||
public final double sprintingSpeedLimit;
|
public final double sprintingSpeedLimit;
|
||||||
public final boolean allowHungrySprinting;
|
|
||||||
public final double jumpheight;
|
public final double jumpheight;
|
||||||
public final boolean swimmingCheck;
|
|
||||||
public final double swimmingSpeedLimit;
|
public final double swimmingSpeedLimit;
|
||||||
public final boolean sneakingCheck;
|
public final boolean sneakingCheck;
|
||||||
public final double sneakingSpeedLimit;
|
public final double sneakingSpeedLimit;
|
||||||
@ -38,35 +37,34 @@ public class MovingConfig implements ConfigItem {
|
|||||||
|
|
||||||
public final double flyingHeightLimit;
|
public final double flyingHeightLimit;
|
||||||
|
|
||||||
public MovingConfig(Configuration data) {
|
public MovingConfig(NoCheatConfiguration data) {
|
||||||
|
|
||||||
check = data.getBoolean(Configuration.MOVING_CHECK);
|
identifyCreativeMode = data.getBoolean(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWINCREATIVE);
|
||||||
identifyCreativeMode = data.getBoolean(Configuration.MOVING_IDENTIFYCREATIVEMODE);
|
|
||||||
|
|
||||||
runflyCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECK);
|
runflyCheck = data.getBoolean(ConfPaths.MOVING_RUNFLY_CHECK);
|
||||||
walkingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_WALKINGSPEEDLIMIT)) / 100D;
|
walkingSpeedLimit = ((double) 22) / 100D;
|
||||||
sprintingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SPRINTINGSPEEDLIMIT)) / 100D;
|
sprintingSpeedLimit = ((double) 40) / 100D;
|
||||||
allowHungrySprinting = data.getBoolean(Configuration.MOVING_RUNFLY_ALLOWHUNGRYSPRINTING);
|
jumpheight = ((double) 135) / 100D;
|
||||||
jumpheight = ((double) data.getInteger(Configuration.MOVING_RUNFLY_JUMPHEIGHT)) / 100D;
|
actions = data.getActionList(ConfPaths.MOVING_RUNFLY_ACTIONS);
|
||||||
actions = data.getActionList(Configuration.MOVING_RUNFLY_ACTIONS);
|
|
||||||
|
|
||||||
swimmingCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECKSWIMMING);
|
swimmingSpeedLimit = ((double) 18) / 100D;
|
||||||
swimmingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SWIMMINGSPEEDLIMIT)) / 100D;
|
sneakingCheck = !data.getBoolean(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING);
|
||||||
sneakingCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECKSNEAKING);
|
sneakingSpeedLimit = ((double) 14) / 100D;
|
||||||
sneakingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SNEAKINGSPEEDLIMIT)) / 100D;
|
|
||||||
|
|
||||||
allowFlying = data.getBoolean(Configuration.MOVING_RUNFLY_ALLOWLIMITEDFLYING);
|
allowFlying = data.getBoolean(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS);
|
||||||
flyingSpeedLimitVertical = ((double) data.getInteger(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL)) / 100D;
|
flyingSpeedLimitVertical = ((double) data.getInt(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITVERTICAL)) / 100D;
|
||||||
flyingSpeedLimitHorizontal = ((double) data.getInteger(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL)) / 100D;
|
flyingSpeedLimitHorizontal = ((double) data.getInt(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITHORIZONTAL)) / 100D;
|
||||||
flyingHeightLimit = data.getInteger(Configuration.MOVING_RUNFLY_FLYINGHEIGHTLIMIT);
|
flyingHeightLimit = data.getInt(ConfPaths.MOVING_RUNFLY_FLYING_HEIGHTLIMIT);
|
||||||
flyingActions = data.getActionList(Configuration.MOVING_RUNFLY_FLYINGACTIONS);
|
flyingActions = data.getActionList(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS);
|
||||||
|
|
||||||
nofallCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECKNOFALL);
|
nofallCheck = data.getBoolean(ConfPaths.MOVING_RUNFLY_CHECKNOFALL);
|
||||||
nofallMultiplier = ((float) data.getInteger(Configuration.MOVING_RUNFLY_NOFALLMULTIPLIER)) / 100F;
|
nofallMultiplier = ((float) 200) / 100F;
|
||||||
nofallActions = data.getActionList(Configuration.MOVING_RUNFLY_NOFALLACTIONS);
|
nofallActions = data.getActionList(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS);
|
||||||
|
|
||||||
morePacketsCheck = data.getBoolean(Configuration.MOVING_MOREPACKETS_CHECK);
|
morePacketsCheck = data.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
|
||||||
morePacketsActions = data.getActionList(Configuration.MOVING_MOREPACKETS_ACTIONS);
|
morePacketsActions = data.getActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS);
|
||||||
|
|
||||||
|
check = runflyCheck || morePacketsCheck;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
|
|
||||||
// A player is considered sprinting if the flag is set and if he has
|
// A player is considered sprinting if the flag is set and if he has
|
||||||
// enough food level (configurable)
|
// enough food level (configurable)
|
||||||
final boolean sprinting = player.isSprinting() && (player.getPlayer().getFoodLevel() > 5 || cc.allowHungrySprinting);
|
final boolean sprinting = player.isSprinting() && (player.getPlayer().getFoodLevel() > 5);
|
||||||
|
|
||||||
double limit = 0.0D;
|
double limit = 0.0D;
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
if(cc.sneakingCheck && player.getPlayer().isSneaking() && !player.hasPermission(Permissions.MOVING_SNEAKING)) {
|
if(cc.sneakingCheck && player.getPlayer().isSneaking() && !player.hasPermission(Permissions.MOVING_SNEAKING)) {
|
||||||
limit = cc.sneakingSpeedLimit;
|
limit = cc.sneakingSpeedLimit;
|
||||||
suffix = "sneaking";
|
suffix = "sneaking";
|
||||||
} else if(cc.swimmingCheck && isSwimming && !player.hasPermission(Permissions.MOVING_SWIMMING)) {
|
} else if(isSwimming) {
|
||||||
limit = cc.swimmingSpeedLimit;
|
limit = cc.swimmingSpeedLimit;
|
||||||
suffix = "swimming";
|
suffix = "swimming";
|
||||||
} else if(!sprinting) {
|
} else if(!sprinting) {
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
|
||||||
|
|
||||||
public class CCDebug {
|
|
||||||
|
|
||||||
public final boolean showchecks;
|
|
||||||
public final boolean overrideIdiocy;
|
|
||||||
|
|
||||||
public CCDebug(Configuration data) {
|
|
||||||
|
|
||||||
showchecks = data.getBoolean(Configuration.DEBUG_SHOWACTIVECHECKS);
|
|
||||||
overrideIdiocy = data.getBoolean(Configuration.DEBUG_COMPATIBILITY);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurations specific for logging. Every world gets one of these.
|
* Configurations specific for logging. Every world gets one of these.
|
||||||
*
|
*
|
||||||
@ -8,17 +7,19 @@ package cc.co.evenprime.bukkit.nocheat.config;
|
|||||||
public class CCLogging {
|
public class CCLogging {
|
||||||
|
|
||||||
public final boolean active;
|
public final boolean active;
|
||||||
|
public final boolean showactivechecks;
|
||||||
public final boolean toFile;
|
public final boolean toFile;
|
||||||
public final boolean toConsole;
|
public final boolean toConsole;
|
||||||
public final boolean toChat;
|
public final boolean toChat;
|
||||||
public final String prefix;
|
public final String prefix;
|
||||||
|
|
||||||
public CCLogging(Configuration data) {
|
public CCLogging(NoCheatConfiguration data) {
|
||||||
|
|
||||||
active = data.getBoolean(Configuration.LOGGING_ACTIVE);
|
active = data.getBoolean(ConfPaths.LOGGING_ACTIVE);
|
||||||
prefix = data.getString(Configuration.LOGGING_PREFIX);
|
showactivechecks = data.getBoolean(ConfPaths.LOGGING_SHOWACTIVECHECKS);
|
||||||
toFile = data.getBoolean(Configuration.LOGGING_LOGTOFILE);
|
prefix = data.getString(ConfPaths.LOGGING_PREFIX);
|
||||||
toConsole = data.getBoolean(Configuration.LOGGING_LOGTOCONSOLE);
|
toFile = data.getBoolean(ConfPaths.LOGGING_LOGTOFILE);
|
||||||
toChat = data.getBoolean(Configuration.LOGGING_LOGTOINGAMECHAT);
|
toConsole = data.getBoolean(ConfPaths.LOGGING_LOGTOCONSOLE);
|
||||||
|
toChat = data.getBoolean(ConfPaths.LOGGING_LOGTOINGAMECHAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
101
src/cc/co/evenprime/bukkit/nocheat/config/ConfPaths.java
Normal file
101
src/cc/co/evenprime/bukkit/nocheat/config/ConfPaths.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paths for the configuration options
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ConfPaths {
|
||||||
|
|
||||||
|
private final static String LOGGING = "logging.";
|
||||||
|
public final static String LOGGING_ACTIVE = LOGGING + "active";
|
||||||
|
public final static String LOGGING_PREFIX = LOGGING + "prefix";
|
||||||
|
public final static String LOGGING_FILENAME = LOGGING + "filename";
|
||||||
|
public final static String LOGGING_LOGTOFILE = LOGGING + "file";
|
||||||
|
public final static String LOGGING_LOGTOCONSOLE = LOGGING + "console";
|
||||||
|
public final static String LOGGING_LOGTOINGAMECHAT = LOGGING + "ingamechat";
|
||||||
|
public final static String LOGGING_SHOWACTIVECHECKS = LOGGING + "showactivechecks";
|
||||||
|
|
||||||
|
private final static String INVENTORY_DROP = "inventory.drop.";
|
||||||
|
public final static String INVENTORY_DROP_CHECK = INVENTORY_DROP + "active";
|
||||||
|
public final static String INVENTORY_DROP_TIMEFRAME = INVENTORY_DROP + "time";
|
||||||
|
public final static String INVENTORY_DROP_LIMIT = INVENTORY_DROP + "limit";
|
||||||
|
public final static String INVENTORY_DROP_ACTIONS = INVENTORY_DROP + "actions";
|
||||||
|
|
||||||
|
private final static String MOVING = "moving.";
|
||||||
|
|
||||||
|
private final static String MOVING_RUNFLY = MOVING + "runfly.";
|
||||||
|
public final static String MOVING_RUNFLY_CHECK = MOVING_RUNFLY + "active";
|
||||||
|
public final static String MOVING_RUNFLY_ALLOWFASTSNEAKING = MOVING_RUNFLY + "allowfastsneaking";
|
||||||
|
public final static String MOVING_RUNFLY_ACTIONS = MOVING_RUNFLY + "actions";
|
||||||
|
|
||||||
|
public final static String MOVING_RUNFLY_CHECKNOFALL = MOVING_RUNFLY + "checknofall";
|
||||||
|
public final static String MOVING_RUNFLY_NOFALLACTIONS = MOVING_RUNFLY + "nofallactions";
|
||||||
|
|
||||||
|
public final static String MOVING_RUNFLY_FLYING = MOVING_RUNFLY + "flying.";
|
||||||
|
public final static String MOVING_RUNFLY_FLYING_ALLOWALWAYS = MOVING_RUNFLY_FLYING + "allowflyingalways";
|
||||||
|
public final static String MOVING_RUNFLY_FLYING_ALLOWINCREATIVE = MOVING_RUNFLY_FLYING + "allowflyingincreative";
|
||||||
|
public final static String MOVING_RUNFLY_FLYING_SPEEDLIMITVERTICAL = MOVING_RUNFLY_FLYING + "flyingspeedlimitvertical";
|
||||||
|
public final static String MOVING_RUNFLY_FLYING_SPEEDLIMITHORIZONTAL = MOVING_RUNFLY_FLYING + "flyingspeedlimithorizontal";
|
||||||
|
public final static String MOVING_RUNFLY_FLYING_HEIGHTLIMIT = MOVING_RUNFLY_FLYING + "flyingheightlimit";
|
||||||
|
public final static String MOVING_RUNFLY_FLYING_ACTIONS = MOVING_RUNFLY_FLYING + "actions";
|
||||||
|
|
||||||
|
private final static String MOVING_MOREPACKETS = MOVING + "morepackets.";
|
||||||
|
public final static String MOVING_MOREPACKETS_CHECK = MOVING_MOREPACKETS + "active";
|
||||||
|
public final static String MOVING_MOREPACKETS_ACTIONS = MOVING_MOREPACKETS + "actions";
|
||||||
|
|
||||||
|
private final static String BLOCKBREAK = "blockbreak.";
|
||||||
|
|
||||||
|
private final static String BLOCKBREAK_REACH = BLOCKBREAK + "reach.";
|
||||||
|
public final static String BLOCKBREAK_REACH_CHECK = BLOCKBREAK_REACH + "active";
|
||||||
|
public final static String BLOCKBREAK_REACH_ACTIONS = BLOCKBREAK_REACH + "actions";
|
||||||
|
|
||||||
|
private final static String BLOCKBREAK_DIRECTION = BLOCKBREAK + "direction.";
|
||||||
|
public final static String BLOCKBREAK_DIRECTION_CHECK = BLOCKBREAK_DIRECTION + "active";
|
||||||
|
public final static String BLOCKBREAK_DIRECTION_PRECISION = BLOCKBREAK_DIRECTION + "precision";
|
||||||
|
public final static String BLOCKBREAK_DIRECTION_PENALTYTIME = BLOCKBREAK_DIRECTION + "penaltytime";
|
||||||
|
public final static String BLOCKBREAK_DIRECTION_ACTIONS = BLOCKBREAK_DIRECTION + "actions";
|
||||||
|
|
||||||
|
private final static String BLOCKBREAK_NOSWING = BLOCKBREAK + "noswing.";
|
||||||
|
public static final String BLOCKBREAK_NOSWING_CHECK = BLOCKBREAK_NOSWING + "active";
|
||||||
|
public static final String BLOCKBREAK_NOSWING_ACTIONS = BLOCKBREAK_NOSWING + "actions";
|
||||||
|
|
||||||
|
private final static String BLOCKPLACE = "blockplace.";
|
||||||
|
|
||||||
|
private final static String BLOCKPLACE_REACH = BLOCKPLACE + "reach.";
|
||||||
|
public final static String BLOCKPLACE_REACH_CHECK = BLOCKPLACE_REACH + "active";
|
||||||
|
public final static String BLOCKPLACE_REACH_ACTIONS = BLOCKPLACE_REACH + "actions";
|
||||||
|
|
||||||
|
private final static String BLOCKPLACE_DIRECTION = BLOCKPLACE + "direction.";
|
||||||
|
public final static String BLOCKPLACE_DIRECTION_CHECK = BLOCKPLACE_DIRECTION + "active";
|
||||||
|
public final static String BLOCKPLACE_DIRECTION_PRECISION = BLOCKPLACE_DIRECTION + "precision";
|
||||||
|
public final static String BLOCKPLACE_DIRECTION_PENALTYTIME = BLOCKPLACE_DIRECTION + "penaltytime";
|
||||||
|
public final static String BLOCKPLACE_DIRECTION_ACTIONS = BLOCKPLACE_DIRECTION + "actions";
|
||||||
|
|
||||||
|
private final static String CHAT = "chat.";
|
||||||
|
|
||||||
|
private final static String CHAT_COLOR = CHAT + "color.";
|
||||||
|
public final static String CHAT_COLOR_CHECK = CHAT_COLOR + "active";
|
||||||
|
public final static String CHAT_COLOR_ACTIONS = CHAT_COLOR + "actions";
|
||||||
|
|
||||||
|
private final static String CHAT_SPAM = CHAT + "spam.";
|
||||||
|
public final static String CHAT_SPAM_CHECK = CHAT_SPAM + "active";
|
||||||
|
public final static String CHAT_SPAM_WHITELIST = CHAT_SPAM + "whitelist";
|
||||||
|
public final static String CHAT_SPAM_TIMEFRAME = CHAT_SPAM + "timeframe";
|
||||||
|
public final static String CHAT_SPAM_LIMIT = CHAT_SPAM + "limit";
|
||||||
|
public final static String CHAT_SPAM_ACTIONS = CHAT_SPAM + "actions";
|
||||||
|
|
||||||
|
private final static String FIGHT = "fight.";
|
||||||
|
|
||||||
|
private final static String FIGHT_DIRECTION = FIGHT + "direction.";
|
||||||
|
public final static String FIGHT_DIRECTION_CHECK = FIGHT_DIRECTION + "active";
|
||||||
|
public final static String FIGHT_DIRECTION_PRECISION = FIGHT_DIRECTION + "precision";
|
||||||
|
public final static String FIGHT_DIRECTION_PENALTYTIME = FIGHT_DIRECTION + "penaltytime";
|
||||||
|
public final static String FIGHT_DIRECTION_ACTIONS = FIGHT_DIRECTION + "actions";
|
||||||
|
|
||||||
|
private final static String FIGHT_NOSWING = FIGHT + "noswing.";
|
||||||
|
public final static String FIGHT_NOSWING_CHECK = FIGHT_NOSWING + "active";
|
||||||
|
public final static String FIGHT_NOSWING_ACTIONS = FIGHT_NOSWING + "actions";
|
||||||
|
|
||||||
|
public final static String STRINGS = "strings";
|
||||||
|
|
||||||
|
}
|
@ -1,242 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode.DataType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class describes a basic configuration for NoCheat. NoCheats
|
|
||||||
* configuration
|
|
||||||
* is based on String,String pairs, and this class provides some convenience
|
|
||||||
* methods
|
|
||||||
* to retrieve and store more complex datatypes based on strings.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class Configuration {
|
|
||||||
|
|
||||||
protected final static OptionNode ROOT = new OptionNode(null, null, DataType.PARENT);
|
|
||||||
|
|
||||||
private final static OptionNode LOGGING = new OptionNode("logging", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode LOGGING_ACTIVE = new OptionNode("active", LOGGING, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode LOGGING_PREFIX = new OptionNode("prefix", LOGGING, DataType.STRING);
|
|
||||||
public final static OptionNode LOGGING_FILENAME = new OptionNode("filename", LOGGING, DataType.STRING);
|
|
||||||
public final static OptionNode LOGGING_LOGTOFILE = new OptionNode("file", LOGGING, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode LOGGING_LOGTOCONSOLE = new OptionNode("console", LOGGING, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode LOGGING_LOGTOINGAMECHAT = new OptionNode("ingamechat", LOGGING, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode DEBUG = new OptionNode("debug", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode DEBUG_SHOWACTIVECHECKS = new OptionNode("showactivechecks", DEBUG, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode DEBUG_COMPATIBILITY = new OptionNode("compatibility", DEBUG, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode INVENTORY = new OptionNode("inventory", ROOT, DataType.PARENT);
|
|
||||||
public static final OptionNode INVENTORY_CHECK = new OptionNode("check", INVENTORY, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode INVENTORY_DROP = new OptionNode("drop", INVENTORY, DataType.PARENT);
|
|
||||||
public final static OptionNode INVENTORY_DROP_CHECK = new OptionNode("check", INVENTORY_DROP, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode INVENTORY_DROP_TIMEFRAME = new OptionNode("timeframe", INVENTORY_DROP, DataType.INTEGER);
|
|
||||||
public final static OptionNode INVENTORY_DROP_LIMIT = new OptionNode("limit", INVENTORY_DROP, DataType.INTEGER);
|
|
||||||
public final static OptionNode INVENTORY_DROP_ACTIONS = new OptionNode("actions", INVENTORY_DROP, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode MOVING = new OptionNode("moving", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode MOVING_CHECK = new OptionNode("check", MOVING, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_IDENTIFYCREATIVEMODE = new OptionNode("identifycreativemode", MOVING, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode MOVING_RUNFLY = new OptionNode("runfly", MOVING, DataType.PARENT);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_CHECK = new OptionNode("check", MOVING_RUNFLY, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_WALKINGSPEEDLIMIT = new OptionNode("walkingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_SPRINTINGSPEEDLIMIT = new OptionNode("sprintingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_ALLOWHUNGRYSPRINTING = new OptionNode("allowhungrysprinting", MOVING_RUNFLY, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_JUMPHEIGHT = new OptionNode("jumpheight", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_CHECKSNEAKING = new OptionNode("checksneaking", MOVING_RUNFLY, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_SNEAKINGSPEEDLIMIT = new OptionNode("sneakingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_CHECKSWIMMING = new OptionNode("checkswimming", MOVING_RUNFLY, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_SWIMMINGSPEEDLIMIT = new OptionNode("swimmingspeedlimit", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_ACTIONS = new OptionNode("actions", MOVING_RUNFLY, DataType.ACTIONLIST);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_CHECKNOFALL = new OptionNode("checknofall", MOVING_RUNFLY, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_NOFALLMULTIPLIER = new OptionNode("nofallmultiplier", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_NOFALLACTIONS = new OptionNode("nofallactions", MOVING_RUNFLY, DataType.ACTIONLIST);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_ALLOWLIMITEDFLYING = new OptionNode("allowlimitedflying", MOVING_RUNFLY, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL = new OptionNode("flyingspeedlimitvertical", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL = new OptionNode("flyingspeedlimithorizontal", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_FLYINGHEIGHTLIMIT = new OptionNode("flyingheightlimit", MOVING_RUNFLY, DataType.INTEGER);
|
|
||||||
public final static OptionNode MOVING_RUNFLY_FLYINGACTIONS = new OptionNode("flyingactions", MOVING_RUNFLY, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode MOVING_MOREPACKETS = new OptionNode("morepackets", MOVING, DataType.PARENT);
|
|
||||||
public final static OptionNode MOVING_MOREPACKETS_CHECK = new OptionNode("check", MOVING_MOREPACKETS, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode MOVING_MOREPACKETS_ACTIONS = new OptionNode("actions", MOVING_MOREPACKETS, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKBREAK = new OptionNode("blockbreak", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode BLOCKBREAK_CHECK = new OptionNode("check", BLOCKBREAK, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKBREAK_REACH = new OptionNode("reach", BLOCKBREAK, DataType.PARENT);
|
|
||||||
public final static OptionNode BLOCKBREAK_REACH_CHECK = new OptionNode("check", BLOCKBREAK_REACH, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode BLOCKBREAK_REACH_ACTIONS = new OptionNode("actions", BLOCKBREAK_REACH, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKBREAK_DIRECTION = new OptionNode("direction", BLOCKBREAK, DataType.PARENT);
|
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_CHECK = new OptionNode("check", BLOCKBREAK_DIRECTION, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS = new OptionNode("checkinstabreakblocks", BLOCKBREAK_DIRECTION, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_PRECISION = new OptionNode("precision", BLOCKBREAK_DIRECTION, DataType.INTEGER);
|
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_PENALTYTIME = new OptionNode("penaltytime", BLOCKBREAK_DIRECTION, DataType.INTEGER);
|
|
||||||
public final static OptionNode BLOCKBREAK_DIRECTION_ACTIONS = new OptionNode("actions", BLOCKBREAK_DIRECTION, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKBREAK_NOSWING = new OptionNode("noswing", BLOCKBREAK, DataType.PARENT);
|
|
||||||
public static final OptionNode BLOCKBREAK_NOSWING_CHECK = new OptionNode("check", BLOCKBREAK_NOSWING, DataType.BOOLEAN);
|
|
||||||
public static final OptionNode BLOCKBREAK_NOSWING_ACTIONS = new OptionNode("actions", BLOCKBREAK_NOSWING, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKPLACE = new OptionNode("blockplace", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode BLOCKPLACE_CHECK = new OptionNode("check", BLOCKPLACE, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKPLACE_REACH = new OptionNode("reach", BLOCKPLACE, DataType.PARENT);
|
|
||||||
public final static OptionNode BLOCKPLACE_REACH_CHECK = new OptionNode("check", BLOCKPLACE_REACH, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode BLOCKPLACE_REACH_ACTIONS = new OptionNode("actions", BLOCKPLACE_REACH, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode BLOCKPLACE_DIRECTION = new OptionNode("direction", BLOCKPLACE, DataType.PARENT);
|
|
||||||
public final static OptionNode BLOCKPLACE_DIRECTION_CHECK = new OptionNode("check", BLOCKPLACE_DIRECTION, DataType.BOOLEAN); ;
|
|
||||||
public final static OptionNode BLOCKPLACE_DIRECTION_PENALTYTIME = new OptionNode("penaltytime", BLOCKPLACE_DIRECTION, DataType.INTEGER);
|
|
||||||
public final static OptionNode BLOCKPLACE_DIRECTION_PRECISION = new OptionNode("precision", BLOCKPLACE_DIRECTION, DataType.INTEGER);
|
|
||||||
public final static OptionNode BLOCKPLACE_DIRECTION_ACTIONS = new OptionNode("actions", BLOCKPLACE_DIRECTION, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode CHAT = new OptionNode("chat", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode CHAT_CHECK = new OptionNode("check", CHAT, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode CHAT_COLOR = new OptionNode("color", CHAT, DataType.PARENT);
|
|
||||||
public final static OptionNode CHAT_COLOR_CHECK = new OptionNode("check", CHAT_COLOR, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode CHAT_COLOR_ACTIONS = new OptionNode("actions", CHAT_COLOR, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode CHAT_SPAM = new OptionNode("spam", CHAT, DataType.PARENT);
|
|
||||||
public final static OptionNode CHAT_SPAM_CHECK = new OptionNode("check", CHAT_SPAM, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode CHAT_SPAM_WHITELIST = new OptionNode("whitelist", CHAT_SPAM, DataType.STRING);
|
|
||||||
public final static OptionNode CHAT_SPAM_TIMEFRAME = new OptionNode("timeframe", CHAT_SPAM, DataType.INTEGER);
|
|
||||||
public final static OptionNode CHAT_SPAM_LIMIT = new OptionNode("limit", CHAT_SPAM, DataType.INTEGER);
|
|
||||||
public final static OptionNode CHAT_SPAM_ACTIONS = new OptionNode("actions", CHAT_SPAM, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode FIGHT = new OptionNode("fight", ROOT, DataType.PARENT);
|
|
||||||
public final static OptionNode FIGHT_CHECK = new OptionNode("check", FIGHT, DataType.BOOLEAN);
|
|
||||||
|
|
||||||
private final static OptionNode FIGHT_DIRECTION = new OptionNode("direction", FIGHT, DataType.PARENT);
|
|
||||||
public final static OptionNode FIGHT_DIRECTION_CHECK = new OptionNode("check", FIGHT_DIRECTION, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode FIGHT_DIRECTION_PRECISION = new OptionNode("precision", FIGHT_DIRECTION, DataType.INTEGER);
|
|
||||||
public final static OptionNode FIGHT_DIRECTION_PENALTYTIME = new OptionNode("penaltytime", FIGHT_DIRECTION, DataType.INTEGER);
|
|
||||||
public final static OptionNode FIGHT_DIRECTION_ACTIONS = new OptionNode("actions", FIGHT_DIRECTION, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final static OptionNode FIGHT_NOSWING = new OptionNode("noswing", FIGHT, DataType.PARENT);
|
|
||||||
public final static OptionNode FIGHT_NOSWING_CHECK = new OptionNode("check", FIGHT_NOSWING, DataType.BOOLEAN);
|
|
||||||
public final static OptionNode FIGHT_NOSWING_ACTIONS = new OptionNode("actions", FIGHT_NOSWING, DataType.ACTIONLIST);
|
|
||||||
|
|
||||||
private final Map<OptionNode, Object> values;
|
|
||||||
private final Configuration defaults;
|
|
||||||
|
|
||||||
public Configuration(Configuration defaults, boolean copyDefaults) {
|
|
||||||
|
|
||||||
this.values = new HashMap<OptionNode, Object>();
|
|
||||||
this.defaults = defaults;
|
|
||||||
|
|
||||||
if(defaults != null && copyDefaults) {
|
|
||||||
deepCopy(defaults, ROOT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deepCopy(Configuration defaults, OptionNode root) {
|
|
||||||
|
|
||||||
if(root.isLeaf()) {
|
|
||||||
this.set(root, defaults.getRecursive(root));
|
|
||||||
} else {
|
|
||||||
for(OptionNode child : root.getChildren()) {
|
|
||||||
deepCopy(defaults, child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBoolean(OptionNode id) {
|
|
||||||
if(id.getType() != DataType.BOOLEAN) {
|
|
||||||
throw new IllegalArgumentException(id + " is no boolean value!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Boolean) getRecursive(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getString(OptionNode id) {
|
|
||||||
if(id.getType() != DataType.STRING) {
|
|
||||||
throw new IllegalArgumentException(id + " is no string value!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (String) getRecursive(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInteger(OptionNode id) {
|
|
||||||
if(id.getType() != DataType.INTEGER) {
|
|
||||||
throw new IllegalArgumentException(id + " is no integer value!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Integer) getRecursive(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionList getActionList(OptionNode id) {
|
|
||||||
|
|
||||||
if(id.getType() != DataType.ACTIONLIST) {
|
|
||||||
throw new IllegalArgumentException(id + " is no actionlist value!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ActionList) getRecursive(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(OptionNode id, Integer value) {
|
|
||||||
if(id.getType() != DataType.INTEGER) {
|
|
||||||
throw new IllegalArgumentException(id + " is no integer value!");
|
|
||||||
}
|
|
||||||
set(id, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(OptionNode id, Boolean value) {
|
|
||||||
if(id.getType() != DataType.BOOLEAN) {
|
|
||||||
throw new IllegalArgumentException(id + " is no boolean value!");
|
|
||||||
}
|
|
||||||
set(id, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(OptionNode id, String value) {
|
|
||||||
if(id.getType() != DataType.STRING) {
|
|
||||||
throw new IllegalArgumentException(id + " is no string value!");
|
|
||||||
}
|
|
||||||
set(id, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(OptionNode id, ActionList value) {
|
|
||||||
if(id.getType() != DataType.ACTIONLIST) {
|
|
||||||
throw new IllegalArgumentException(id + " is no actionlist value!");
|
|
||||||
}
|
|
||||||
set(id, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void set(OptionNode id, Object value) {
|
|
||||||
if(value == null) {
|
|
||||||
this.values.remove(id);
|
|
||||||
} else {
|
|
||||||
this.values.put(id, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Object getRecursive(OptionNode id) {
|
|
||||||
Object o = get(id);
|
|
||||||
|
|
||||||
if(o != null) {
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defaults != null) {
|
|
||||||
return defaults.getRecursive(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Configuration getDefaults() {
|
|
||||||
return defaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Object get(OptionNode id) {
|
|
||||||
return this.values.get(id);
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,20 +12,18 @@ import cc.co.evenprime.bukkit.nocheat.ConfigItem;
|
|||||||
public class ConfigurationCacheStore {
|
public class ConfigurationCacheStore {
|
||||||
|
|
||||||
public final CCLogging logging;
|
public final CCLogging logging;
|
||||||
public final CCDebug debug;
|
|
||||||
|
|
||||||
private final Map<String, ConfigItem> configMap = new HashMap<String, ConfigItem>();
|
private final Map<String, ConfigItem> configMap = new HashMap<String, ConfigItem>();
|
||||||
|
|
||||||
private final Configuration data;
|
private final NoCheatConfiguration data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a config cache and populate it with the data of a
|
* Instantiate a config cache and populate it with the data of a
|
||||||
* Config tree (and its parent tree)
|
* Config tree (and its parent tree)
|
||||||
*/
|
*/
|
||||||
public ConfigurationCacheStore(Configuration data) {
|
public ConfigurationCacheStore(NoCheatConfiguration data) {
|
||||||
|
|
||||||
logging = new CCLogging(data);
|
logging = new CCLogging(data);
|
||||||
debug = new CCDebug(data);
|
|
||||||
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
@ -40,7 +38,7 @@ public class ConfigurationCacheStore {
|
|||||||
configMap.put(id, config);
|
configMap.put(id, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration getConfiguration() {
|
public NoCheatConfiguration getConfiguration() {
|
||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -15,7 +14,6 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Central location for everything that's described in the configuration file(s)
|
* Central location for everything that's described in the configuration file(s)
|
||||||
@ -23,16 +21,12 @@ import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
|||||||
*/
|
*/
|
||||||
public class ConfigurationManager {
|
public class ConfigurationManager {
|
||||||
|
|
||||||
private final static String configFileName = "config.txt";
|
private final static String configFileName = "config.yml";
|
||||||
private final static String actionFileName = "actions.txt";
|
|
||||||
private final static String defaultActionFileName = "default_actions.txt";
|
|
||||||
|
|
||||||
private final Map<String, ConfigurationCacheStore> worldnameToConfigCacheMap = new HashMap<String, ConfigurationCacheStore>();
|
private final Map<String, ConfigurationCacheStore> worldnameToConfigCacheMap = new HashMap<String, ConfigurationCacheStore>();
|
||||||
|
|
||||||
private final Configuration defaultConfig;
|
|
||||||
|
|
||||||
private FileHandler fileHandler;
|
private FileHandler fileHandler;
|
||||||
private NoCheat plugin;
|
private NoCheat plugin;
|
||||||
|
|
||||||
private static class LogFileFormatter extends Formatter {
|
private static class LogFileFormatter extends Formatter {
|
||||||
|
|
||||||
@ -64,81 +58,51 @@ public class ConfigurationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our personal logger
|
|
||||||
// private final static String loggerName = "cc.co.evenprime.nocheat";
|
|
||||||
// public final Logger logger = Logger.getLogger(loggerName);
|
|
||||||
|
|
||||||
public ConfigurationManager(NoCheat plugin, File rootConfigFolder) {
|
public ConfigurationManager(NoCheat plugin, File rootConfigFolder) {
|
||||||
|
|
||||||
ActionMapper actionMapper = new ActionMapper();
|
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
// Parse actions file
|
|
||||||
initializeActions(rootConfigFolder, actionMapper);
|
|
||||||
|
|
||||||
// Create a default configuration
|
|
||||||
defaultConfig = new DefaultConfiguration(actionMapper);
|
|
||||||
|
|
||||||
// Setup the real configuration
|
// Setup the real configuration
|
||||||
initializeConfig(rootConfigFolder, actionMapper);
|
initializeConfig(rootConfigFolder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeActions(File rootConfigFolder, ActionMapper actionManager) {
|
|
||||||
|
|
||||||
File defaultActionsFile = new File(rootConfigFolder, defaultActionFileName);
|
|
||||||
|
|
||||||
// Write the current default action file into the target folder
|
|
||||||
DefaultConfiguration.writeDefaultActionFile(defaultActionsFile);
|
|
||||||
|
|
||||||
// now parse that file again
|
|
||||||
FlatFileAction parser = new FlatFileAction(defaultActionsFile);
|
|
||||||
parser.read(actionManager);
|
|
||||||
|
|
||||||
// Check if the "custom" action file exists, if not, create one
|
|
||||||
File customActionsFile = new File(rootConfigFolder, actionFileName);
|
|
||||||
if(!customActionsFile.exists()) {
|
|
||||||
DefaultConfiguration.writeActionFile(customActionsFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser = new FlatFileAction(customActionsFile);
|
|
||||||
parser.read(actionManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the configuration file and assign either standard values or whatever
|
* Read the configuration file and assign either standard values or whatever
|
||||||
* is declared in the file
|
* is declared in the file
|
||||||
*
|
*
|
||||||
* @param configurationFile
|
* @param configurationFile
|
||||||
*/
|
*/
|
||||||
private void initializeConfig(File rootConfigFolder, ActionMapper action) {
|
private void initializeConfig(File rootConfigFolder) {
|
||||||
|
|
||||||
// First try to obtain and parse the global config file
|
// First try to obtain and parse the global config file
|
||||||
FlatFileConfiguration root;
|
NoCheatConfiguration root = new NoCheatConfiguration();
|
||||||
File globalConfigFile = getGlobalConfigFile(rootConfigFolder);
|
root.setDefaults(new DefaultConfiguration());
|
||||||
|
root.options().copyDefaults(true);
|
||||||
|
|
||||||
root = new FlatFileConfiguration(defaultConfig, true, globalConfigFile);
|
File globalConfigFile = getGlobalConfigFile(rootConfigFolder);
|
||||||
|
|
||||||
if(globalConfigFile.exists()) {
|
if(globalConfigFile.exists()) {
|
||||||
try {
|
try {
|
||||||
root.load(action);
|
root.load(globalConfigFile);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
root.save();
|
root.save(globalConfigFile);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
root.regenerateActionLists();
|
||||||
|
|
||||||
// Create a corresponding Configuration Cache
|
// Create a corresponding Configuration Cache
|
||||||
// put the global config on the config map
|
// put the global config on the config map
|
||||||
worldnameToConfigCacheMap.put(null, new ConfigurationCacheStore(root));
|
worldnameToConfigCacheMap.put(null, new ConfigurationCacheStore(root));
|
||||||
|
|
||||||
plugin.setFileLogger(setupFileLogger(new File(rootConfigFolder, root.getString(DefaultConfiguration.LOGGING_FILENAME))));
|
plugin.setFileLogger(setupFileLogger(new File(rootConfigFolder, root.getString(ConfPaths.LOGGING_FILENAME))));
|
||||||
|
|
||||||
// Try to find world-specific config files
|
// Try to find world-specific config files
|
||||||
Map<String, File> worldFiles = getWorldSpecificConfigFiles(rootConfigFolder);
|
Map<String, File> worldFiles = getWorldSpecificConfigFiles(rootConfigFolder);
|
||||||
@ -147,20 +111,23 @@ public class ConfigurationManager {
|
|||||||
|
|
||||||
File worldConfigFile = worldEntry.getValue();
|
File worldConfigFile = worldEntry.getValue();
|
||||||
|
|
||||||
FlatFileConfiguration world = new FlatFileConfiguration(root, false, worldConfigFile);
|
NoCheatConfiguration world = new NoCheatConfiguration();
|
||||||
|
world.setDefaults(root);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
world.load(action);
|
world.load(worldConfigFile);
|
||||||
|
|
||||||
worldnameToConfigCacheMap.put(worldEntry.getKey(), new ConfigurationCacheStore(world));
|
worldnameToConfigCacheMap.put(worldEntry.getKey(), new ConfigurationCacheStore(world));
|
||||||
|
|
||||||
// write the config file back to disk immediately
|
// write the config file back to disk immediately
|
||||||
world.save();
|
world.save(worldConfigFile);
|
||||||
|
|
||||||
} catch(IOException e) {
|
} catch(Exception e) {
|
||||||
System.out.println("NoCheat: Couldn't load world-specific config for " + worldEntry.getKey());
|
System.out.println("NoCheat: Couldn't load world-specific config for " + worldEntry.getKey());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.regenerateActionLists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,308 +1,162 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The place where the structure of the configuration tree is defined, the
|
* These are the default settings for NoCheat. They will be used
|
||||||
* default settings are defined, the default files are defined.
|
* in addition to/in replacement of configurations given in the
|
||||||
|
* config.yml file
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DefaultConfiguration extends Configuration {
|
public class DefaultConfiguration extends NoCheatConfiguration {
|
||||||
|
|
||||||
public DefaultConfiguration(ActionMapper action) {
|
public DefaultConfiguration() {
|
||||||
super(null, false);
|
|
||||||
|
|
||||||
/*** LOGGING ***/
|
set(ConfPaths.STRINGS + ".drop", "[player] failed [check]: Tried to drop more items than allowed. VL [violations]");
|
||||||
{
|
set(ConfPaths.STRINGS + ".moveshort", "[player] failed [check]. VL [violations]");
|
||||||
setValue(LOGGING_ACTIVE, true);
|
set(ConfPaths.STRINGS + ".movelong", "[player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations]");
|
||||||
setValue(LOGGING_PREFIX, "&4NC&f: ");
|
set(ConfPaths.STRINGS + ".nofall", "[player] failed [check]: tried to avoid fall damage for ~[falldistance] blocks. VL [violations]");
|
||||||
setValue(LOGGING_FILENAME, "nocheat.log");
|
set(ConfPaths.STRINGS + ".morepackets", "[player] failed [check]: Sent [packets] more packets than expected. Total violation level [violations]");
|
||||||
setValue(LOGGING_LOGTOFILE, true);
|
set(ConfPaths.STRINGS + ".bbreach", "[player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations]");
|
||||||
setValue(LOGGING_LOGTOCONSOLE, true);
|
set(ConfPaths.STRINGS + ".bbdirection", "[player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
||||||
setValue(LOGGING_LOGTOINGAMECHAT, true);
|
set(ConfPaths.STRINGS + ".bbnoswing", "[player] failed [check]: Didn't swing arm. VL [violations]");
|
||||||
}
|
set(ConfPaths.STRINGS + ".bpreach", "[player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations]");
|
||||||
|
set(ConfPaths.STRINGS + ".bpdirection", "[player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
||||||
|
set(ConfPaths.STRINGS + ".color", "[player] failed [check]: Sent colored chat message '[text]'. VL [violations]");
|
||||||
|
set(ConfPaths.STRINGS + ".spam", "[player] failed [check]: Last sent message '[text]'. VL [violations]");
|
||||||
|
set(ConfPaths.STRINGS + ".fdirection", "[player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
||||||
|
set(ConfPaths.STRINGS + ".fnoswing", "[player] failed [check]: Didn't swing arm. VL [violations]");
|
||||||
|
set(ConfPaths.STRINGS + ".kick", "kick [player]");
|
||||||
|
|
||||||
/*** DEBUG ***/
|
// Update internal factory based on all the new entries to the "actions" section
|
||||||
{
|
regenerateActionLists();
|
||||||
setValue(DEBUG_SHOWACTIVECHECKS, false);
|
|
||||||
setValue(DEBUG_COMPATIBILITY, true);
|
/** LOGGING **/
|
||||||
}
|
set(ConfPaths.LOGGING_ACTIVE, true);
|
||||||
|
set(ConfPaths.LOGGING_SHOWACTIVECHECKS, false);
|
||||||
|
set(ConfPaths.LOGGING_PREFIX, "&4NC&f: ");
|
||||||
|
set(ConfPaths.LOGGING_FILENAME, "nocheat.log");
|
||||||
|
set(ConfPaths.LOGGING_LOGTOFILE, true);
|
||||||
|
set(ConfPaths.LOGGING_LOGTOCONSOLE, true);
|
||||||
|
set(ConfPaths.LOGGING_LOGTOINGAMECHAT, true);
|
||||||
|
|
||||||
/*** INVENTORY ***/
|
/*** INVENTORY ***/
|
||||||
{
|
set(ConfPaths.INVENTORY_DROP_CHECK, true);
|
||||||
setValue(INVENTORY_CHECK, true);
|
set(ConfPaths.INVENTORY_DROP_TIMEFRAME, 20);
|
||||||
|
set(ConfPaths.INVENTORY_DROP_LIMIT, 100);
|
||||||
|
|
||||||
setValue(INVENTORY_DROP_CHECK, true);
|
ActionList dropActionList = new ActionList();
|
||||||
setValue(INVENTORY_DROP_TIMEFRAME, 20);
|
dropActionList.setActions(0, createActions("log:drop:0:1:cif", "cmd:kick"));
|
||||||
setValue(INVENTORY_DROP_LIMIT, 100);
|
set(ConfPaths.INVENTORY_DROP_ACTIONS, dropActionList);
|
||||||
|
|
||||||
ActionList dropActionList = new ActionList();
|
|
||||||
dropActionList.setActions(0, action.getActions("dropLog:0:1:co,ch,fi dropkick".split(" ")));
|
|
||||||
setValue(INVENTORY_DROP_ACTIONS, dropActionList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** MOVING ***/
|
/*** MOVING ***/
|
||||||
{
|
set(ConfPaths.MOVING_RUNFLY_CHECK, true);
|
||||||
setValue(MOVING_CHECK, true);
|
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING, false);
|
||||||
setValue(MOVING_IDENTIFYCREATIVEMODE, true);
|
|
||||||
|
|
||||||
setValue(MOVING_RUNFLY_CHECK, true);
|
ActionList movingActionList = new ActionList();
|
||||||
|
movingActionList.setActions(0, createActions("log:moveshort:3:5:f", "cancel"));
|
||||||
|
movingActionList.setActions(100, createActions("log:moveshort:0:5:if", "cancel"));
|
||||||
|
movingActionList.setActions(400, createActions("log:movelong:0:5:cif", "cancel"));
|
||||||
|
set(ConfPaths.MOVING_RUNFLY_ACTIONS, movingActionList);
|
||||||
|
|
||||||
setValue(MOVING_RUNFLY_WALKINGSPEEDLIMIT, 22);
|
set(ConfPaths.MOVING_RUNFLY_CHECKNOFALL, true);
|
||||||
setValue(MOVING_RUNFLY_SPRINTINGSPEEDLIMIT, 40);
|
|
||||||
setValue(MOVING_RUNFLY_ALLOWHUNGRYSPRINTING, false);
|
|
||||||
setValue(MOVING_RUNFLY_JUMPHEIGHT, 135);
|
|
||||||
|
|
||||||
setValue(MOVING_RUNFLY_CHECKSNEAKING, true);
|
ActionList nofallActionList = new ActionList();
|
||||||
setValue(MOVING_RUNFLY_SNEAKINGSPEEDLIMIT, 14);
|
nofallActionList.setActions(0, createActions("log:nofall:0:5:cif", "cancel"));
|
||||||
|
set(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS, nofallActionList);
|
||||||
|
|
||||||
setValue(MOVING_RUNFLY_CHECKSWIMMING, true);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS, false);
|
||||||
setValue(MOVING_RUNFLY_SWIMMINGSPEEDLIMIT, 18);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWINCREATIVE, true);
|
||||||
|
set(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITHORIZONTAL, 60);
|
||||||
|
set(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITVERTICAL, 100);
|
||||||
|
set(ConfPaths.MOVING_RUNFLY_FLYING_HEIGHTLIMIT, 250);
|
||||||
|
|
||||||
ActionList movingActionList = new ActionList();
|
ActionList flyingActionList = new ActionList();
|
||||||
movingActionList.setActions(0, action.getActions("moveLogShort:3:5:fi moveCancel".split(" ")));
|
flyingActionList.setActions(0, createActions("log:moveShort:3:5:f", "cancel"));
|
||||||
movingActionList.setActions(100, action.getActions("moveLogShort:0:5:ch,fi moveCancel".split(" ")));
|
flyingActionList.setActions(100, createActions("log:moveShort:0:5:if", "cancel"));
|
||||||
movingActionList.setActions(400, action.getActions("moveLogLong:0:5:co,ch,fi moveCancel".split(" ")));
|
flyingActionList.setActions(400, createActions("log:moveLong:0:5:cif", "cancel"));
|
||||||
setValue(MOVING_RUNFLY_ACTIONS, movingActionList);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS, flyingActionList);
|
||||||
|
|
||||||
setValue(MOVING_RUNFLY_CHECKNOFALL, true);
|
set(ConfPaths.MOVING_MOREPACKETS_CHECK, true);
|
||||||
setValue(MOVING_RUNFLY_NOFALLMULTIPLIER, 200);
|
|
||||||
|
|
||||||
ActionList nofallActionList = new ActionList();
|
ActionList morepacketsActionList = new ActionList();
|
||||||
nofallActionList.setActions(0, action.getActions("nofallLog:0:5:co,ch,fi nofallDamage".split(" ")));
|
morepacketsActionList.setActions(0, createActions("log:morepackets:3:2:f", "cancel"));
|
||||||
setValue(MOVING_RUNFLY_NOFALLACTIONS, nofallActionList);
|
morepacketsActionList.setActions(30, createActions("log:morepackets:0:2:if", "cancel"));
|
||||||
|
morepacketsActionList.setActions(60, createActions("log:morepackets:0:2:cif", "cancel"));
|
||||||
setValue(MOVING_RUNFLY_ALLOWLIMITEDFLYING, false);
|
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, morepacketsActionList);
|
||||||
setValue(MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL, 100);
|
|
||||||
setValue(MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL, 60);
|
|
||||||
setValue(MOVING_RUNFLY_FLYINGHEIGHTLIMIT, 250);
|
|
||||||
|
|
||||||
ActionList flyingActionList = new ActionList();
|
|
||||||
flyingActionList.setActions(0, action.getActions("moveLogShort:3:5:fi moveCancel".split(" ")));
|
|
||||||
flyingActionList.setActions(100, action.getActions("moveLogShort:0:5:ch,fi moveCancel".split(" ")));
|
|
||||||
flyingActionList.setActions(400, action.getActions("moveLogShort:0:5:co,ch,fi moveCancel".split(" ")));
|
|
||||||
setValue(MOVING_RUNFLY_FLYINGACTIONS, flyingActionList);
|
|
||||||
|
|
||||||
setValue(MOVING_MOREPACKETS_CHECK, true);
|
|
||||||
|
|
||||||
ActionList morepacketsActionList = new ActionList();
|
|
||||||
morepacketsActionList.setActions(0, action.getActions("morepackets:3:2:fi moveCancel".split(" ")));
|
|
||||||
morepacketsActionList.setActions(30, action.getActions("morepackets:0:2:ch,fi moveCancel".split(" ")));
|
|
||||||
morepacketsActionList.setActions(60, action.getActions("morepackets:0:2:co,ch,fi moveCancel".split(" ")));
|
|
||||||
setValue(MOVING_MOREPACKETS_ACTIONS, morepacketsActionList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** BLOCKBREAK ***/
|
/*** BLOCKBREAK ***/
|
||||||
{
|
|
||||||
setValue(BLOCKBREAK_CHECK, true);
|
|
||||||
|
|
||||||
setValue(BLOCKBREAK_REACH_CHECK, true);
|
set(ConfPaths.BLOCKBREAK_REACH_CHECK, true);
|
||||||
|
|
||||||
ActionList reachActionList = new ActionList();
|
ActionList breakreachActionList = new ActionList();
|
||||||
reachActionList.setActions(0, action.getActions("blockbreakCancel".split(" ")));
|
breakreachActionList.setActions(0, createActions("cancel"));
|
||||||
reachActionList.setActions(5, action.getActions("reachLog:0:2:fi,ch blockbreakCancel".split(" ")));
|
breakreachActionList.setActions(5, createActions("log:bbreach:0:2:if", "cancel"));
|
||||||
setValue(BLOCKBREAK_REACH_ACTIONS, reachActionList);
|
set(ConfPaths.BLOCKBREAK_REACH_ACTIONS, breakreachActionList);
|
||||||
|
|
||||||
setValue(BLOCKBREAK_DIRECTION_CHECK, true);
|
set(ConfPaths.BLOCKBREAK_DIRECTION_CHECK, true);
|
||||||
setValue(BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS, true);
|
set(ConfPaths.BLOCKBREAK_DIRECTION_PRECISION, 50);
|
||||||
setValue(BLOCKBREAK_DIRECTION_PRECISION, 50);
|
set(ConfPaths.BLOCKBREAK_DIRECTION_PENALTYTIME, 300);
|
||||||
setValue(BLOCKBREAK_DIRECTION_PENALTYTIME, 300);
|
ActionList breakdirectionActionList = new ActionList();
|
||||||
ActionList directionActionList = new ActionList();
|
breakdirectionActionList.setActions(0, createActions("cancel"));
|
||||||
directionActionList.setActions(0, action.getActions("blockbreakCancel".split(" ")));
|
breakdirectionActionList.setActions(10, createActions("log:bbdirection:0:5:cif", "cancel"));
|
||||||
directionActionList.setActions(10, action.getActions("directionLog:0:5:fi,co,ch blockbreakCancel".split(" ")));
|
set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, breakdirectionActionList);
|
||||||
setValue(BLOCKBREAK_DIRECTION_ACTIONS, directionActionList);
|
|
||||||
|
|
||||||
setValue(BLOCKBREAK_NOSWING_CHECK, true);
|
set(ConfPaths.BLOCKBREAK_NOSWING_CHECK, true);
|
||||||
ActionList noswingActionList = new ActionList();
|
ActionList breaknoswingActionList = new ActionList();
|
||||||
noswingActionList.setActions(0, action.getActions("noswingLog:0:2:fi,co,ch blockbreakCancel".split(" ")));
|
breaknoswingActionList.setActions(0, createActions("log:bbnoswing:0:2:cif", "cancel"));
|
||||||
setValue(BLOCKBREAK_NOSWING_ACTIONS, noswingActionList);
|
set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, breaknoswingActionList);
|
||||||
}
|
|
||||||
|
|
||||||
/*** BLOCKPLACE ***/
|
/*** BLOCKPLACE ***/
|
||||||
{
|
|
||||||
setValue(BLOCKPLACE_CHECK, true);
|
|
||||||
|
|
||||||
setValue(BLOCKPLACE_REACH_CHECK, true);
|
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
|
||||||
|
|
||||||
ActionList reachActionList = new ActionList();
|
ActionList placereachActionList = new ActionList();
|
||||||
reachActionList.setActions(0, action.getActions("blockplaceCancel".split(" ")));
|
placereachActionList.setActions(0, createActions("cancel"));
|
||||||
reachActionList.setActions(5, action.getActions("reachLog:0:2:fi,co,ch blockplaceCancel".split(" ")));
|
placereachActionList.setActions(5, createActions("log:bpreach:0:2:cif", "cancel"));
|
||||||
setValue(BLOCKPLACE_REACH_ACTIONS, reachActionList);
|
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, placereachActionList);
|
||||||
|
|
||||||
setValue(BLOCKPLACE_DIRECTION_CHECK, true);
|
set(ConfPaths.BLOCKPLACE_DIRECTION_CHECK, true);
|
||||||
setValue(BLOCKPLACE_DIRECTION_PRECISION, 75);
|
set(ConfPaths.BLOCKPLACE_DIRECTION_PRECISION, 75);
|
||||||
setValue(BLOCKPLACE_DIRECTION_PENALTYTIME, 100);
|
set(ConfPaths.BLOCKPLACE_DIRECTION_PENALTYTIME, 100);
|
||||||
ActionList directionActionList = new ActionList();
|
ActionList placedirectionActionList = new ActionList();
|
||||||
directionActionList.setActions(0, action.getActions("blockplaceCancel".split(" ")));
|
placedirectionActionList.setActions(0, createActions("cancel"));
|
||||||
directionActionList.setActions(10, action.getActions("directionLog:0:3:fi,co,ch blockplaceCancel".split(" ")));
|
placedirectionActionList.setActions(10, createActions("log:bpdirection:0:3:cif", "cancel"));
|
||||||
setValue(BLOCKPLACE_DIRECTION_ACTIONS, directionActionList);
|
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, placedirectionActionList);
|
||||||
}
|
|
||||||
|
|
||||||
/*** CHAT ***/
|
/*** CHAT ***/
|
||||||
{
|
set(ConfPaths.CHAT_COLOR_CHECK, true);
|
||||||
setValue(CHAT_CHECK, true);
|
ActionList colorActionList = new ActionList();
|
||||||
|
colorActionList.setActions(0, createActions("log:color:0:1:cif", "cancel"));
|
||||||
|
set(ConfPaths.CHAT_COLOR_ACTIONS, colorActionList);
|
||||||
|
|
||||||
setValue(CHAT_COLOR_CHECK, true);
|
set(ConfPaths.CHAT_SPAM_CHECK, true);
|
||||||
ActionList colorActionList = new ActionList();
|
set(ConfPaths.CHAT_SPAM_WHITELIST, "");
|
||||||
colorActionList.setActions(0, action.getActions("colorLog:0:1:fi,co,ch chatCancel".split(" ")));
|
set(ConfPaths.CHAT_SPAM_TIMEFRAME, 5);
|
||||||
setValue(CHAT_COLOR_ACTIONS, colorActionList);
|
set(ConfPaths.CHAT_SPAM_LIMIT, 5);
|
||||||
|
|
||||||
setValue(CHAT_SPAM_CHECK, true);
|
ActionList spamActionList = new ActionList();
|
||||||
setValue(CHAT_SPAM_WHITELIST, "");
|
spamActionList.setActions(0, createActions("log:spam:0:5:cif", "cancel"));
|
||||||
setValue(CHAT_SPAM_TIMEFRAME, 5);
|
spamActionList.setActions(50, createActions("log:spam:0:5:cif", "cancel", "cmd:kick"));
|
||||||
setValue(CHAT_SPAM_LIMIT, 5);
|
set(ConfPaths.CHAT_SPAM_ACTIONS, spamActionList);
|
||||||
|
|
||||||
ActionList spamActionList = new ActionList();
|
|
||||||
spamActionList.setActions(0, action.getActions("spamLog:0:5:fi,co,ch chatCancel".split(" ")));
|
|
||||||
spamActionList.setActions(50, action.getActions("spamLog:0:5:fi,co,ch chatCancel spamkick".split(" ")));
|
|
||||||
setValue(CHAT_SPAM_ACTIONS, spamActionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** FIGHT ***/
|
/*** FIGHT ***/
|
||||||
{
|
|
||||||
setValue(FIGHT_CHECK, true);
|
|
||||||
|
|
||||||
setValue(FIGHT_DIRECTION_CHECK, true);
|
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
|
||||||
setValue(FIGHT_DIRECTION_PRECISION, 75);
|
set(ConfPaths.FIGHT_DIRECTION_PRECISION, 75);
|
||||||
setValue(FIGHT_DIRECTION_PENALTYTIME, 500);
|
set(ConfPaths.FIGHT_DIRECTION_PENALTYTIME, 500);
|
||||||
|
|
||||||
ActionList directionActionList = new ActionList();
|
ActionList directionActionList = new ActionList();
|
||||||
directionActionList.setActions(0, action.getActions("fightCancel".split(" ")));
|
directionActionList.setActions(0, createActions("cancel"));
|
||||||
directionActionList.setActions(5, action.getActions("fightDirectionLog:3:5:fi fightCancel".split(" ")));
|
directionActionList.setActions(5, createActions("log:fdirection:3:5:f", "cancel"));
|
||||||
directionActionList.setActions(20, action.getActions("fightDirectionLog:0:5:fi,ch fightCancel".split(" ")));
|
directionActionList.setActions(20, createActions("log:fdirection:0:5:cf", "cancel"));
|
||||||
directionActionList.setActions(50, action.getActions("fightDirectionLog:0:5:fi,ch,co fightCancel".split(" ")));
|
directionActionList.setActions(50, createActions("log:fdirection:0:5:cif", "cancel"));
|
||||||
setValue(FIGHT_DIRECTION_ACTIONS, directionActionList);
|
set(ConfPaths.FIGHT_DIRECTION_ACTIONS, directionActionList);
|
||||||
|
|
||||||
setValue(FIGHT_NOSWING_CHECK, true);
|
set(ConfPaths.FIGHT_NOSWING_CHECK, true);
|
||||||
ActionList noswingActionList = new ActionList();
|
ActionList fightnoswingActionList = new ActionList();
|
||||||
noswingActionList.setActions(0, action.getActions("noswingLog:0:5:fi,ch,co fightCancel".split(" ")));
|
fightnoswingActionList.setActions(0, createActions("log:fnoswing:0:5:cif", "cancel"));
|
||||||
setValue(FIGHT_NOSWING_ACTIONS, noswingActionList);
|
set(ConfPaths.FIGHT_NOSWING_ACTIONS, fightnoswingActionList);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeActionFile(File file) {
|
|
||||||
BufferedWriter w;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(!file.exists()) {
|
|
||||||
try {
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
file.createNewFile();
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
w = new BufferedWriter(new FileWriter(file));
|
|
||||||
|
|
||||||
w(w, "# This file contains the definitions of your personal actions for NoCheat.");
|
|
||||||
w(w, "# Look at the file default_actions.txt for inspiration on how it works.");
|
|
||||||
w(w, "");
|
|
||||||
w.flush();
|
|
||||||
w.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeDefaultActionFile(File file) {
|
|
||||||
|
|
||||||
BufferedWriter w;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(!file.exists()) {
|
|
||||||
try {
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
file.createNewFile();
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
w = new BufferedWriter(new FileWriter(file));
|
|
||||||
|
|
||||||
w(w, "# This file contains the definitions of the default actions of NoCheat.");
|
|
||||||
w(w, "# DO NOT EDIT THIS FILE DIRECTLY. If you want to change any of these, copy");
|
|
||||||
w(w, "# them to your \"actions.txt\" file and modify them there. If an action with");
|
|
||||||
w(w, "# the same name exists here and in your file, yours will be used.");
|
|
||||||
w(w, "#");
|
|
||||||
w(w, "# LOG Actions: They will print messages in your log file, console, chat, ...");
|
|
||||||
w(w, "# - They start with the word 'log'");
|
|
||||||
w(w, "# - Then comes their name. That name is used in the config file to identify them");
|
|
||||||
w(w, "# - Then comes the 'delay', that is how often has this action to be called before it really gets executed");
|
|
||||||
w(w, "# - Then comes the 'repeat', that is how many seconds have to be between two executions of the action");
|
|
||||||
w(w, "# - Then comes the 'message', depending on where the action is used, different keywords in [ ] may be used");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# Gives a very short log message of the violation, only containing name, violation type and total violation value, at most once every 15 seconds, only if more than 3 violations happened within the last minute (low) and immediatly (med,high)");
|
|
||||||
w(w, "log moveLogShort 0 5 [player] failed [check]. VL [violations]");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# Gives a log message of the violation, only containing name, violation type and total violation value, at most once every second, only if more than 5 violations happened within the last minute (low) and immediatly (med,high)");
|
|
||||||
w(w, "log morepackets 0 1 [player] failed [check]: Sent [packets] more packets than expected. Total violation level [violations].");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# Gives a lengthy log message of the violation, containing name, location, violation type and total violation, at most once every 15 seconds, only if more than 3 violations happened within the last minute (low) and immediatly (med,high)");
|
|
||||||
w(w, "log moveLogLong 0 5 [player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations].");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# Some other log messages that are limited a bit by default, to avoid too extreme spam");
|
|
||||||
w(w, "log reachLog 0 5 [player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations]");
|
|
||||||
w(w, "log directionLog 2 5 [player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
|
||||||
w(w, "log spamLog 0 5 [player] failed [check]: Last sent message \"[text]\". VL [violations]");
|
|
||||||
w(w, "log nofallLog 0 5 [player] failed [check]: tried to avoid fall damage for ~[falldistance] blocks. VL [violations]");
|
|
||||||
w(w, "log noswingLog 2 5 [player] failed [check]: Didn't swing arm. VL [violations]");
|
|
||||||
w(w, "log colorLog 0 5 [player] failed [check]: Sent colored chat message \"[text]\". VL [violations]");
|
|
||||||
w(w, "log dropLog 0 5 [player] failed [check]: Tried to drop more items than allowed. VL [violations]");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# Some log messages related to fighting, displaying the same text, but with different level (Info, Warning, Severe)");
|
|
||||||
w(w, "log fightDirectionLogLow 0 5 [player] failed [check]: tried to attack out of sight entity. Total violation level so far [violations].");
|
|
||||||
w(w, "log fightDirectionLog 0 5 [player] failed [check]: tried to attack out of sight entity. Total violation level so far [violations].");
|
|
||||||
w(w, "log fightDirectionLogHigh 0 5 [player] failed [check]: tried to attack out of sight entity. Total violation level so far [violations].");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "log fightSelfhitlog 0 1 med [player] failed [check]: tried to attack himself. Total violation level so far [violations].");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# SPECIAL Actions: They will do something check dependant, usually cancel an event.");
|
|
||||||
w(w, "# - They start with the word 'special'");
|
|
||||||
w(w, "# - Then comes their name. That name is used in the config file to identify them");
|
|
||||||
w(w, "# - Then comes the 'delay', that is how often has this action to be called before it really gets executed");
|
|
||||||
w(w, "# - Then comes the 'repeat', that is how many seconds have to be between two executions of the action");
|
|
||||||
w(w, "# - Then come further instructions, if necessary");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# Cancels the event in case of an violation. Always. No delay. These are equivalent. The different names are just for better readability");
|
|
||||||
w(w, "special moveCancel 0 0");
|
|
||||||
w(w, "special blockbreakCancel 0 0");
|
|
||||||
w(w, "special blockplaceCancel 0 0");
|
|
||||||
w(w, "special spamCancel 0 0");
|
|
||||||
w(w, "special chatCancel 0 0");
|
|
||||||
w(w, "special nofallDamage 0 0");
|
|
||||||
w(w, "special fightCancel 0 0");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# CONSOLECOMMAND Actions: They will execute a command as if it were typed into the console.");
|
|
||||||
w(w, "# - They start with the word 'consolecommand'");
|
|
||||||
w(w, "# - Then comes their name. That name is used in the config file to identify them");
|
|
||||||
w(w, "# - Then comes the 'delay', that is how often has this action to be called before it really gets executed");
|
|
||||||
w(w, "# - Then comes the 'repeat', that is how many seconds have to be between two executions of the action");
|
|
||||||
w(w, "# - Then comes the command. You can use the same [ ] that you use for log actions. You'll most likely want to use [player] at some point.");
|
|
||||||
w(w, "");
|
|
||||||
w(w, "# E.g. Kick a player");
|
|
||||||
w(w, "consolecommand kick 0 1 kick [player]");
|
|
||||||
w(w, "consolecommand spamkick 0 1 kick [player]");
|
|
||||||
w(w, "consolecommand dropKick 0 1 kick [player]");
|
|
||||||
w.flush();
|
|
||||||
w.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void w(BufferedWriter writer, String text) throws IOException {
|
|
||||||
writer.write(text);
|
|
||||||
writer.newLine();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Textual explainations of options, will be displayed at the end of the
|
|
||||||
* config.txt file
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class Explainations {
|
|
||||||
|
|
||||||
private static final Map<OptionNode, String> explainations = new HashMap<OptionNode, String>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
|
|
||||||
set(Configuration.LOGGING_ACTIVE, "Should NoCheat related messages get logged at all. Some messages may still appear, e.g. error\n messages, even if this option is deactivated");
|
|
||||||
|
|
||||||
set(Configuration.LOGGING_PREFIX, "The short text that appears in front of messages by NoCheat. Color codes are &0-&9 and &A-&F");
|
|
||||||
set(Configuration.LOGGING_FILENAME, "Where logs that go to the logfile are stored. You can have different files for different worlds.");
|
|
||||||
set(Configuration.LOGGING_LOGTOFILE, "Should messages get logged to the specified logfile?");
|
|
||||||
set(Configuration.LOGGING_LOGTOINGAMECHAT, "Should messages get logged to the ingame chat?");
|
|
||||||
set(Configuration.LOGGING_LOGTOCONSOLE, "Should messages get logged to the server console?");
|
|
||||||
|
|
||||||
set(Configuration.DEBUG_SHOWACTIVECHECKS, "Print to the console an overview of all checks that are enabled when NoCheat gets loaded.");
|
|
||||||
set(Configuration.DEBUG_COMPATIBILITY, "Do some voodoo to fix common mistakes of other plugins which interfere with NoCheat.");
|
|
||||||
|
|
||||||
set(Configuration.INVENTORY_CHECK, "If true, do various checks on Inventory related things.");
|
|
||||||
set(Configuration.INVENTORY_DROP_CHECK, "If true, prevent players from dropping too many items in a short timeframe to reduce lag");
|
|
||||||
set(Configuration.INVENTORY_DROP_TIMEFRAME, "Over how many seconds should item drops be counted.");
|
|
||||||
set(Configuration.INVENTORY_DROP_LIMIT, "How many seperate items should the player be allowed to drop during that timeframe");
|
|
||||||
set(Configuration.INVENTORY_DROP_ACTIONS, "What should be done if a player drops more items than that.\nUnit is item drops above the limit.");
|
|
||||||
|
|
||||||
set(Configuration.MOVING_CHECK, "If true, do various checks on PlayerMove events.");
|
|
||||||
set(Configuration.MOVING_IDENTIFYCREATIVEMODE, "If true, NoCheat will automatically identify if players are in creative mode and will allow them to fly, avoid fall damage etc.");
|
|
||||||
|
|
||||||
set(Configuration.MOVING_RUNFLY_CHECK, "If true, check if a player is walking/sprinting/sneaking/swimming too fast/high.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_WALKINGSPEEDLIMIT, "Set the speed limit for moving horizontal under 'normal' conditions.\nUnit is 1/100 of a block, default is 22.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_SPRINTINGSPEEDLIMIT, "Set the speed limit for moving horizontal while sprinting.\nUnit is 1/100 of a block, default is 40.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_ALLOWHUNGRYSPRINTING, "Should players with a food level of less than 6 be allowed to use the builtin sprint-function?");
|
|
||||||
set(Configuration.MOVING_RUNFLY_JUMPHEIGHT, "Set how high a player is allowed to jump.\nUnit is 1/100 of a block, default is 135.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_CHECKSWIMMING, "Use a seperate speed limit for swimming players.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_SWIMMINGSPEEDLIMIT, "Set the speed limit for moving horizontal while in water.\nUnit is 1/100 of a block, default is 18");
|
|
||||||
set(Configuration.MOVING_RUNFLY_CHECKSNEAKING, "Use a seperate speed limit for sneaking players.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_SNEAKINGSPEEDLIMIT, "Set the speed limit for moving horizontal while sneaking.\nUnit is 1/100 of a block, default is 14");
|
|
||||||
set(Configuration.MOVING_RUNFLY_ACTIONS, "What should be done if a player moves faster than the speed limit(s) or jumps higher than allowed.\nUnits are in 1/100 of a block above the limit.");
|
|
||||||
|
|
||||||
set(Configuration.MOVING_RUNFLY_CHECKNOFALL, "If true, check if a player is avoiding fall damage by using a nofall hack. EXPERIMENTAL! Feedback is appreciated.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_NOFALLMULTIPLIER, "How many percent falldamage should be dealt to the player.\nNoCheat will almost always underestimate fall damage, using a value bigger than 100 is advised.\nUnit is percent of the estimated original fall damage, default is 200.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_NOFALLACTIONS, "What should be done if a player is detected as avoiding fall damage.\nUnit is number of blocks the player fell down.");
|
|
||||||
|
|
||||||
set(Configuration.MOVING_RUNFLY_ALLOWLIMITEDFLYING, "If true, instead of doing the above checks for walking/sprinting/swimming/sneaking,\nallow flying and only limit the flying speed.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITVERTICAL, "Set the speed limit for moving vertical while flying.\nUnit is 1/100 of a block, default is 100.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_FLYINGSPEEDLIMITHORIZONTAL, "Set the speed limit for moving horizontal while flying.\nUnit is 1/100 of a block, default is 60.");
|
|
||||||
set(Configuration.MOVING_RUNFLY_FLYINGHEIGHTLIMIT, "Set the absolute height limit that a player may go to when flying.\nUnit is number of blocks, default is 500");
|
|
||||||
set(Configuration.MOVING_RUNFLY_FLYINGACTIONS, "What should be done if a player flies faster than the speed limit(s). \nUnits are in 1/100 of a block above the speedlimit.");
|
|
||||||
|
|
||||||
set(Configuration.MOVING_MOREPACKETS_CHECK, "If true, check if a player is sending too many 'move-packets' per second. In a normal game, the player won't send more than 22 packets per second.");
|
|
||||||
set(Configuration.MOVING_MOREPACKETS_ACTIONS, "What should be done if a player sends more 'move-packets' than normal.\nUnits are packets per second above the limit.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKBREAK_CHECK, "If true, do various checks on BlockBreak events.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKBREAK_REACH_CHECK, "If true, check if a player is breaking blocks that are too far away.");
|
|
||||||
set(Configuration.BLOCKBREAK_REACH_ACTIONS, "What should be done if a player is breaking blocks that are too far away.\nUnit is number of break(attempt)s beyond the limit.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKBREAK_DIRECTION_CHECK, "If true, check if a player is looking at the block that he's breaking.");
|
|
||||||
set(Configuration.BLOCKBREAK_DIRECTION_CHECKINSTABREAKBLOCKS, "If true, NoCheat will also check for direction for Instant-Breaking blocks.\nTHIS WILL CAUSE FALSE POSITIVES, when a player keeps his mouse button pressed and moves the mouse fast over the screen.");
|
|
||||||
set(Configuration.BLOCKBREAK_DIRECTION_PRECISION, "Define how precise a player has to hit blocks when mining. Lower values mean more precision, higher values less precision.");
|
|
||||||
set(Configuration.BLOCKBREAK_DIRECTION_PENALTYTIME, "Define how long after a failed attempt to dig a player will be disallowed to break another block. \nUnit is milliseconds, default is 300.");
|
|
||||||
set(Configuration.BLOCKBREAK_DIRECTION_ACTIONS, "What should be done if a player is breaking blocks that are not in his line of sight.\nUnit is the combined distance in blocks between where the player looked vs. where the block was.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKBREAK_NOSWING_CHECK, "If true, check if a player swung his arm before breaking a block, which he should have done.");
|
|
||||||
set(Configuration.BLOCKBREAK_NOSWING_ACTIONS, "What should be done if a player didn't swing his arm.\nUnit is number of blockbreaking without armswinging.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKPLACE_CHECK, "If true, do various checks on BlockPlace events.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKPLACE_REACH_CHECK, "If true, check if a player is placing blocks at locations too far away.");
|
|
||||||
set(Configuration.BLOCKPLACE_REACH_ACTIONS, "What should be done if a player is placing blocks that are too far away.\nUnit is number of place(attempt)s beyond the limit.");
|
|
||||||
|
|
||||||
set(Configuration.BLOCKPLACE_DIRECTION_CHECK, "If true, check if a player is looking at the block that he's placing.");
|
|
||||||
set(Configuration.BLOCKPLACE_DIRECTION_PRECISION, "Define how precise a player has to be when placing blocks. Lower values mean more precision, higher values less precision. Default 75.");
|
|
||||||
set(Configuration.BLOCKPLACE_DIRECTION_PENALTYTIME, "Define how long after a failed attempt to place blocks a player will be disallowed to place another block. \nUnit is milliseconds, default is 100.");
|
|
||||||
set(Configuration.BLOCKPLACE_DIRECTION_ACTIONS, "What should be done if a player is placing blocks that are not in his line of sight.\nUnit is the combined distance in blocks between where the player looked vs. where the block was.");
|
|
||||||
|
|
||||||
set(Configuration.CHAT_CHECK, "If true, do various checks on PlayerChat events.");
|
|
||||||
|
|
||||||
set(Configuration.CHAT_COLOR_CHECK, "If true, check if a message sent by the player contains color codes.");
|
|
||||||
set(Configuration.CHAT_COLOR_ACTIONS, "What should be done if a player is trying to send colored messages.\n\"cancel\" means in this case that the color codes get removed from the message.\nUnit is number of colored chat messages sent by the player.");
|
|
||||||
set(Configuration.CHAT_SPAM_CHECK, "If true, check if a player is spamming the chat.");
|
|
||||||
set(Configuration.CHAT_SPAM_WHITELIST, "A list of messages that should be ignored by the spam check, seperated by ','. All messages/commands starting with one of these will be let through.");
|
|
||||||
set(Configuration.CHAT_SPAM_TIMEFRAME, "Over what timeframe (in seconds) should the messages be counted?\nWhen the time is over, counting starts at 0 again.");
|
|
||||||
set(Configuration.CHAT_SPAM_LIMIT, "How many messages per timeframe may the player send without it counting as spamming?");
|
|
||||||
set(Configuration.CHAT_SPAM_ACTIONS, "What should be done if a player is trying to spam the chat.\nUnit is number of chat messages above the limit you declared above.");
|
|
||||||
|
|
||||||
set(Configuration.FIGHT_CHECK, "If true, do various checks on Events related to fighting.");
|
|
||||||
set(Configuration.FIGHT_DIRECTION_CHECK, "If true, check if a player is really looking at enemies that he attacks.");
|
|
||||||
set(Configuration.FIGHT_DIRECTION_PRECISION, "Set how precise the check should be. If you experience the check to be too zealous, increase this value. \nIf you want to make it tighter, reduce this value. Default is 100.");
|
|
||||||
set(Configuration.FIGHT_DIRECTION_PENALTYTIME, "If a player fails the check, he will be unable to attack for this amount of time (in milliseconds), default is 500.");
|
|
||||||
set(Configuration.FIGHT_DIRECTION_ACTIONS, "What should be done if a player attacks entities that are not in his field of view.\nUnit is sqare root of the distance in blocks between where the enemy was and where the player looked.");
|
|
||||||
|
|
||||||
set(Configuration.FIGHT_NOSWING_CHECK, "If true, check if a player swung his arm before attacking, which he should have done.");
|
|
||||||
set(Configuration.FIGHT_NOSWING_ACTIONS, "What should be done if a player didn't swing his arm.\nUnit is number of attacks without armswinging.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void set(OptionNode id, String text) {
|
|
||||||
explainations.put(id, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String get(OptionNode id) {
|
|
||||||
String result = explainations.get(id);
|
|
||||||
|
|
||||||
if(result == null) {
|
|
||||||
System.out.println("Missing description for " + id.getName());
|
|
||||||
result = "No description available";
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.types.SpecialAction;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
|
||||||
|
|
||||||
public class FlatFileAction {
|
|
||||||
|
|
||||||
private final File file;
|
|
||||||
|
|
||||||
public FlatFileAction(File file) {
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void read(ActionMapper mapper) {
|
|
||||||
|
|
||||||
List<Action> actions = new ArrayList<Action>();
|
|
||||||
|
|
||||||
BufferedReader reader;
|
|
||||||
try {
|
|
||||||
reader = new BufferedReader(new FileReader(file));
|
|
||||||
String line = null;
|
|
||||||
while((line = reader.readLine()) != null) {
|
|
||||||
try {
|
|
||||||
if(line.trim().length() > 0 && !line.startsWith("#")) {
|
|
||||||
actions.add(parseLine(line));
|
|
||||||
}
|
|
||||||
} catch(IllegalArgumentException e) {
|
|
||||||
System.out.println("NoCheat: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
} catch(FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Action a : actions) {
|
|
||||||
mapper.addAction(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Action parseLine(String line) {
|
|
||||||
|
|
||||||
// Split the line into some parts
|
|
||||||
String parts[] = line.split("\\s+", 3);
|
|
||||||
|
|
||||||
// four pieces is the minimum we need, no matter what it is
|
|
||||||
if(parts.length < 3) {
|
|
||||||
throw new IllegalArgumentException("The line " + line + " of the file " + file.getName() + " is malformed. It has not enough parts.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String type = parts[0];
|
|
||||||
String name = parts[1];
|
|
||||||
String message = parts[2];
|
|
||||||
|
|
||||||
if(type.equalsIgnoreCase("log")) {
|
|
||||||
// A log action, it seems
|
|
||||||
return new LogAction(name, message);
|
|
||||||
} else if(type.equalsIgnoreCase("consolecommand")) {
|
|
||||||
// A consolecommand action, it seems
|
|
||||||
return new ConsolecommandAction(name, message);
|
|
||||||
} else if(type.equalsIgnoreCase("special")) {
|
|
||||||
return new SpecialAction(name, message);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Unknown action type " + type + " of action with name " + name + ".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,282 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.ActionMapper;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.config.util.OptionNode;
|
|
||||||
|
|
||||||
public class FlatFileConfiguration extends Configuration {
|
|
||||||
|
|
||||||
private final File file;
|
|
||||||
|
|
||||||
public FlatFileConfiguration(Configuration defaults, boolean copyDefaults, File file) {
|
|
||||||
super(defaults, copyDefaults);
|
|
||||||
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load(ActionMapper action) throws IOException {
|
|
||||||
|
|
||||||
if(!file.exists()) {
|
|
||||||
if(file.getParentFile() != null)
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
if(file.createNewFile())
|
|
||||||
save();
|
|
||||||
else
|
|
||||||
throw new IOException("Cannot load \"" + file.getPath() + "\": File can not be created!");
|
|
||||||
}
|
|
||||||
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
|
|
||||||
|
|
||||||
String line = null;
|
|
||||||
|
|
||||||
while((line = r.readLine()) != null) {
|
|
||||||
parse(line, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
r.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parse(String line, ActionMapper action) throws IOException {
|
|
||||||
|
|
||||||
line = line.trim();
|
|
||||||
|
|
||||||
// Is it a key/value pair?
|
|
||||||
if(line.startsWith("#") || !line.contains("=")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String pair[] = line.split("=", 2);
|
|
||||||
|
|
||||||
String key = pair[0].trim();
|
|
||||||
String value = pair[1].trim();
|
|
||||||
|
|
||||||
// Find out which option we have in front of us
|
|
||||||
OptionNode node = getOptionNodeForString(ROOT, key);
|
|
||||||
|
|
||||||
if(node == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (node.getType()) {
|
|
||||||
case ACTIONLIST:
|
|
||||||
this.set(node, parseActionList(node, key, removeQuotationMarks(value), action));
|
|
||||||
break;
|
|
||||||
case STRING:
|
|
||||||
this.set(node, removeQuotationMarks(value));
|
|
||||||
break;
|
|
||||||
case INTEGER:
|
|
||||||
this.set(node, Integer.valueOf(removeQuotationMarks(value)));
|
|
||||||
break;
|
|
||||||
case BOOLEAN:
|
|
||||||
this.set(node, Boolean.valueOf(removeQuotationMarks(value)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown node type " + node.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ActionList parseActionList(OptionNode node, String key, String value, ActionMapper action) {
|
|
||||||
|
|
||||||
String[] s = key.split("\\.");
|
|
||||||
String treshold = s[s.length - 1];
|
|
||||||
|
|
||||||
// See if we already got that actionlist created
|
|
||||||
ActionList al = (ActionList) this.get(node);
|
|
||||||
|
|
||||||
if(al == null || al == this.getDefaults().getRecursive(node)) {
|
|
||||||
al = new ActionList();
|
|
||||||
}
|
|
||||||
int th = Integer.parseInt(treshold);
|
|
||||||
|
|
||||||
al.setActions(th, action.getActions(value.split("\\s+")));
|
|
||||||
return al;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OptionNode getOptionNodeForString(OptionNode root, String key) {
|
|
||||||
String parts[] = key.split("\\.", 2);
|
|
||||||
|
|
||||||
for(OptionNode node : root.getChildren()) {
|
|
||||||
// Found the correct node?
|
|
||||||
if(node.getName().equals(parts[0])) {
|
|
||||||
if(node.isLeaf()) {
|
|
||||||
return node;
|
|
||||||
} else {
|
|
||||||
return getOptionNodeForString(node, parts[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(!file.exists()) {
|
|
||||||
if(file.getParentFile() != null)
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
if(!file.createNewFile())
|
|
||||||
throw new IOException("Cannot save to \"" + file.getPath() + "\" : File can not be created!");
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferedWriter w = new BufferedWriter(new FileWriter(file));
|
|
||||||
|
|
||||||
w.write("# Want to know what these options do? Read at the end of this file.");
|
|
||||||
w.newLine();
|
|
||||||
|
|
||||||
saveRecursive(w, ROOT);
|
|
||||||
|
|
||||||
w.newLine();
|
|
||||||
w.newLine();
|
|
||||||
|
|
||||||
saveDescriptionsRecursive(w, ROOT);
|
|
||||||
|
|
||||||
w.flush();
|
|
||||||
w.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveDescriptionsRecursive(BufferedWriter w, OptionNode node) throws IOException {
|
|
||||||
if(!node.isLeaf()) {
|
|
||||||
for(OptionNode o : node.getChildren()) {
|
|
||||||
saveDescriptionsRecursive(w, o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save a leaf node, if it's really stored here
|
|
||||||
Object object = this.get(node);
|
|
||||||
|
|
||||||
if(object == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the full id of the node
|
|
||||||
String id = node.getName();
|
|
||||||
OptionNode i = node;
|
|
||||||
|
|
||||||
while((i = i.getParent()) != null && i.getName() != null && i.getName().length() > 0) {
|
|
||||||
id = i.getName() + "." + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
w.newLine();
|
|
||||||
w.newLine();
|
|
||||||
w.write("# " + id + ":");
|
|
||||||
w.newLine();
|
|
||||||
w.write("#");
|
|
||||||
w.newLine();
|
|
||||||
|
|
||||||
String[] explainationLines = Explainations.get(node).split("\n");
|
|
||||||
|
|
||||||
for(String line : explainationLines) {
|
|
||||||
w.write("# " + line);
|
|
||||||
w.newLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveRecursive(BufferedWriter w, OptionNode node) throws IOException {
|
|
||||||
|
|
||||||
if(!node.isLeaf()) {
|
|
||||||
|
|
||||||
for(OptionNode o : node.getChildren()) {
|
|
||||||
|
|
||||||
if(node == ROOT) {
|
|
||||||
w.newLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
saveRecursive(w, o);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
saveLeaf(w, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveLeaf(BufferedWriter w, OptionNode node) throws IOException {
|
|
||||||
// Save a leaf node, if it's really stored here
|
|
||||||
Object object = this.get(node);
|
|
||||||
|
|
||||||
if(object == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get the full id of the node
|
|
||||||
String id = node.getName();
|
|
||||||
OptionNode i = node;
|
|
||||||
|
|
||||||
while((i = i.getParent()) != null && i.getName() != null && i.getName().length() > 0) {
|
|
||||||
id = i.getName() + "." + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (node.getType()) {
|
|
||||||
case ACTIONLIST:
|
|
||||||
saveActionList(w, id, (ActionList) object);
|
|
||||||
break;
|
|
||||||
case STRING:
|
|
||||||
saveString(w, id, (String) object);
|
|
||||||
break;
|
|
||||||
case INTEGER:
|
|
||||||
saveValue(w, id, object.toString());
|
|
||||||
break;
|
|
||||||
case LOGLEVEL:
|
|
||||||
saveValue(w, id, object.toString());
|
|
||||||
break;
|
|
||||||
case BOOLEAN:
|
|
||||||
saveValue(w, id, object.toString());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown node type " + node.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveActionList(BufferedWriter w, String id, ActionList actionList) throws IOException {
|
|
||||||
for(Integer treshold : actionList.getTresholds()) {
|
|
||||||
StringBuilder s = new StringBuilder("");
|
|
||||||
for(Action s2 : actionList.getActions(treshold)) {
|
|
||||||
s.append(" ").append(s2.name);
|
|
||||||
if(s2.getProperties() != null) {
|
|
||||||
s.append(":").append(s2.getProperties());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
saveValue(w, id + "." + treshold, s.toString().trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveString(BufferedWriter w, String id, String value) throws IOException {
|
|
||||||
saveValue(w, id, addQuotationMarks(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveValue(BufferedWriter w, String id, String value) throws IOException {
|
|
||||||
w.write(id + " = " + value);
|
|
||||||
w.newLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String removeQuotationMarks(String s) {
|
|
||||||
|
|
||||||
s = s.trim();
|
|
||||||
|
|
||||||
if(s.startsWith("\"") && s.endsWith("\"")) {
|
|
||||||
return s.substring(1, s.length() - 1);
|
|
||||||
} else if(s.startsWith("\'") && s.endsWith("\'")) {
|
|
||||||
return s.substring(1, s.length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String addQuotationMarks(String s) {
|
|
||||||
|
|
||||||
return "\"" + s + "\"";
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,77 @@
|
|||||||
|
package cc.co.evenprime.bukkit.nocheat.config;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import org.bukkit.configuration.MemorySection;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionFactory;
|
||||||
|
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||||
|
|
||||||
|
public class NoCheatConfiguration extends YamlConfiguration {
|
||||||
|
|
||||||
|
private ActionFactory factory;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String saveToString() {
|
||||||
|
// Some reflection wizardry to avoid having a lot of
|
||||||
|
// linebreaks in the yml file
|
||||||
|
try {
|
||||||
|
Field op;
|
||||||
|
op = YamlConfiguration.class.getDeclaredField("yamlOptions");
|
||||||
|
op.setAccessible(true);
|
||||||
|
DumperOptions options = (DumperOptions) op.get(this);
|
||||||
|
options.setWidth(200);
|
||||||
|
} catch(Exception e) {}
|
||||||
|
|
||||||
|
return super.saveToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do this after reading new data
|
||||||
|
*/
|
||||||
|
public void regenerateActionLists() {
|
||||||
|
factory = new ActionFactory(((MemorySection) this.get(ConfPaths.STRINGS)).getValues(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience method to get action lists from the config
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ActionList getActionList(String path) {
|
||||||
|
|
||||||
|
String value = this.getString(path);
|
||||||
|
return factory.createActionList(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create actions from some string representations
|
||||||
|
* @param definitions
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Action[] createActions(String... definitions) {
|
||||||
|
|
||||||
|
return factory.createActions(definitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Savely store ActionLists back into the yml file
|
||||||
|
* @param path
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
public void set(String path, ActionList list) {
|
||||||
|
String string = "";
|
||||||
|
|
||||||
|
for(int treshold : list.getTresholds()) {
|
||||||
|
if(treshold > 0) {
|
||||||
|
string += " vl>" + treshold;
|
||||||
|
}
|
||||||
|
for(Action action : list.getActions(treshold)) {
|
||||||
|
string += " " + action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set(path, string.trim());
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,6 @@ public class Permissions {
|
|||||||
public final static String MOVING = CHECKS + ".moving";
|
public final static String MOVING = CHECKS + ".moving";
|
||||||
public final static String MOVING_RUNFLY = MOVING + ".runfly";
|
public final static String MOVING_RUNFLY = MOVING + ".runfly";
|
||||||
public final static String MOVING_SNEAKING = MOVING + ".sneaking";
|
public final static String MOVING_SNEAKING = MOVING + ".sneaking";
|
||||||
public final static String MOVING_SWIMMING = MOVING + ".swimming";
|
|
||||||
public final static String MOVING_FLYING = MOVING + ".flying";
|
public final static String MOVING_FLYING = MOVING + ".flying";
|
||||||
public final static String MOVING_NOFALL = MOVING + ".nofall";
|
public final static String MOVING_NOFALL = MOVING + ".nofall";
|
||||||
public final static String MOVING_MOREPACKETS = MOVING + ".morepackets";
|
public final static String MOVING_MOREPACKETS = MOVING + ".morepackets";
|
||||||
@ -29,7 +28,6 @@ public class Permissions {
|
|||||||
|
|
||||||
public final static String CHAT = CHECKS + ".chat";
|
public final static String CHAT = CHECKS + ".chat";
|
||||||
public final static String CHAT_SPAM = CHAT + ".spam";
|
public final static String CHAT_SPAM = CHAT + ".spam";
|
||||||
public static final String CHAT_EMPTY = CHAT + ".empty";
|
|
||||||
public static final String CHAT_COLOR = CHAT + ".color";
|
public static final String CHAT_COLOR = CHAT + ".color";
|
||||||
|
|
||||||
public static final String FIGHT = CHECKS + ".fight";
|
public static final String FIGHT = CHECKS + ".fight";
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config.util;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ActionMapper {
|
|
||||||
|
|
||||||
private final Map<String, Action> actions;
|
|
||||||
|
|
||||||
public ActionMapper() {
|
|
||||||
this.actions = new HashMap<String, Action>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAction(Action action) {
|
|
||||||
|
|
||||||
this.actions.put(action.name.toLowerCase(), action);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action[] getActions(String[] actionNames) {
|
|
||||||
Action[] result = new Action[actionNames.length];
|
|
||||||
|
|
||||||
for(int i = 0; i < actionNames.length; i++) {
|
|
||||||
String actionParts[] = actionNames[i].toLowerCase().split(":", 2);
|
|
||||||
result[i] = this.actions.get(actionParts[0]);
|
|
||||||
if(actionParts.length == 2)
|
|
||||||
result[i] = result[i].cloneWithProperties(actionParts[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action getAction(String actionName) {
|
|
||||||
|
|
||||||
return this.actions.get(actionName.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.config.util;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class OptionNode {
|
|
||||||
|
|
||||||
public enum DataType {
|
|
||||||
PARENT, STRING, BOOLEAN, INTEGER, LOGLEVEL, ACTIONLIST
|
|
||||||
};
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final List<OptionNode> children;
|
|
||||||
private final OptionNode parent;
|
|
||||||
private final DataType type;
|
|
||||||
|
|
||||||
public OptionNode(String name, OptionNode parent, DataType type) {
|
|
||||||
this.name = name;
|
|
||||||
if(type == DataType.PARENT) {
|
|
||||||
this.children = new LinkedList<OptionNode>();
|
|
||||||
} else {
|
|
||||||
this.children = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parent != null) {
|
|
||||||
parent.addChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parent = parent;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addChild(OptionNode node) {
|
|
||||||
if(this.type != DataType.PARENT) {
|
|
||||||
throw new IllegalArgumentException("Can't a child to a leaf node.");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.children.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLeaf() {
|
|
||||||
return this.type != DataType.PARENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OptionNode> getChildren() {
|
|
||||||
return this.children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OptionNode getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,7 @@ public class ActiveCheckPrinter {
|
|||||||
|
|
||||||
ConfigurationCacheStore cc = plugin.getConfig(world);
|
ConfigurationCacheStore cc = plugin.getConfig(world);
|
||||||
|
|
||||||
if(!cc.debug.showchecks)
|
if(!cc.logging.showactivechecks)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(EventManager em : eventManagers) {
|
for(EventManager em : eventManagers) {
|
||||||
|
Loading…
Reference in New Issue
Block a user