mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-02 08:40:01 +01:00
Further changes to logging and actions
This commit is contained in:
parent
6d9675cb6a
commit
7930bcb81d
@ -1,13 +1,15 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.log;
|
||||
package cc.co.evenprime.bukkit.nocheat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
/**
|
||||
* Somehow manage color codes in NoCheat
|
||||
*
|
||||
*/
|
||||
public class Colors {
|
||||
|
||||
|
||||
/**
|
||||
* Replace instances of &X with a color
|
||||
*
|
||||
@ -22,4 +24,19 @@ public class Colors {
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove instances of &X with a color
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public static String removeColors(String text) {
|
||||
|
||||
for(ChatColor c : ChatColor.values()) {
|
||||
text = text.replace("&" + c.getChar(), "");
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.WorkaroundsListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.blockbreak.BlockBreakCheckListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.blockplace.BlockPlaceCheckListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.chat.ChatCheckListener;
|
||||
@ -28,8 +29,6 @@ import cc.co.evenprime.bukkit.nocheat.config.Permissions;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.PlayerManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.debug.ActiveCheckPrinter;
|
||||
import cc.co.evenprime.bukkit.nocheat.debug.LagMeasureTask;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.WorkaroundsEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.NoCheatLogEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -83,7 +82,7 @@ public class NoCheat extends JavaPlugin implements Listener {
|
||||
eventManagers = new ArrayList<EventManager>(8); // Big enough
|
||||
// Then set up the event listeners
|
||||
eventManagers.add(new MovingCheckListener(this));
|
||||
eventManagers.add(new WorkaroundsEventManager(this));
|
||||
eventManagers.add(new WorkaroundsListener(this));
|
||||
eventManagers.add(new ChatCheckListener(this));
|
||||
eventManagers.add(new BlockBreakCheckListener(this));
|
||||
eventManagers.add(new BlockPlaceCheckListener(this));
|
||||
@ -197,18 +196,20 @@ public class NoCheat extends JavaPlugin implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void logEvent(NoCheatLogEvent event) {
|
||||
if(event.toConsole()) {
|
||||
System.out.println(event.getPrefix() + event.getMessage());
|
||||
// Console logs are not colored
|
||||
System.out.println(Colors.removeColors(event.getPrefix() + event.getMessage()));
|
||||
}
|
||||
if(event.toChat()) {
|
||||
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if(player.hasPermission(Permissions.ADMIN_CHATLOG)) {
|
||||
player.sendMessage(event.getPrefix() + event.getMessage());
|
||||
// Chat logs are potentially colored
|
||||
player.sendMessage(Colors.replaceColors(event.getPrefix() + event.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(event.toFile()) {
|
||||
fileLogger.info(event.getMessage());
|
||||
System.out.println("fileend");
|
||||
// File logs are not colored
|
||||
fileLogger.info(Colors.removeColors(event.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.log;
|
||||
package cc.co.evenprime.bukkit.nocheat;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -23,6 +23,10 @@ public class NoCheatLogEvent extends Event {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
@ -27,7 +27,5 @@ public interface NoCheatPlayer {
|
||||
|
||||
public boolean isCreative();
|
||||
|
||||
public void closeInventory();
|
||||
|
||||
public ExecutionHistory getExecutionHistory();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.actions.types;
|
||||
|
||||
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;
|
||||
|
||||
@ -11,11 +12,41 @@ import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
||||
*/
|
||||
public class ConsolecommandAction extends ActionWithParameters {
|
||||
|
||||
public ConsolecommandAction(String name, int delay, int repeat, String command) {
|
||||
private 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
|
||||
super(name, delay, repeat, command);
|
||||
}
|
||||
|
||||
public String getCommand(NoCheatPlayer player, Check check) {
|
||||
return super.getMessage(player, check);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of the action, with some modifications
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ 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.log.Colors;
|
||||
|
||||
/**
|
||||
* Print a message to various locations
|
||||
@ -17,16 +16,16 @@ public class LogAction extends ActionWithParameters {
|
||||
private boolean toFile = true;
|
||||
private String message;
|
||||
|
||||
public LogAction(String name, int delay, int repeat, String message) {
|
||||
public LogAction(String name, String message) {
|
||||
// Log messages may have color codes now
|
||||
super(name, delay, repeat, Colors.replaceColors(message));
|
||||
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
|
||||
super(name, delay, repeat, Colors.replaceColors(message));
|
||||
super(name, delay, repeat, message);
|
||||
this.toChat = toChat;
|
||||
this.toConsole = toConsole;
|
||||
this.toFile = toFile;
|
||||
@ -50,16 +49,30 @@ public class LogAction extends ActionWithParameters {
|
||||
|
||||
@Override
|
||||
public Action cloneWithProperties(String properties) {
|
||||
boolean toChat = properties.toLowerCase().contains("ch");
|
||||
boolean toFile = properties.toLowerCase().contains("fi");
|
||||
boolean toConsole = properties.toLowerCase().contains("co");
|
||||
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 = (toChat ? "ch," : "") + (toFile ? "fi," : "") + (toConsole ? "co," : "");
|
||||
if(props.length() > 0) {
|
||||
String props = delay + ":" + repeat + ":" + ((toChat ? "ch," : "") + (toFile ? "fi," : "") + (toConsole ? "co," : ""));
|
||||
if(props.endsWith(",")) {
|
||||
return props.substring(0, props.length() - 1);
|
||||
} else {
|
||||
return "";
|
||||
|
@ -9,7 +9,32 @@ import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
*/
|
||||
public class SpecialAction extends Action {
|
||||
|
||||
public SpecialAction(String name, String parameters) {
|
||||
super(name, 0, 0);
|
||||
}
|
||||
|
||||
public SpecialAction(String name, int delay, int repeat) {
|
||||
super(name, delay, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatLogEvent;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.NoCheatCommandSender;
|
||||
@ -15,7 +16,6 @@ import cc.co.evenprime.bukkit.nocheat.actions.types.DummyAction;
|
||||
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.ConfigurationCacheStore;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.NoCheatLogEvent;
|
||||
|
||||
public abstract class Check {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
package cc.co.evenprime.bukkit.nocheat.checks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -21,11 +21,11 @@ import cc.co.evenprime.bukkit.nocheat.config.ConfigurationCacheStore;
|
||||
* to relevant checks
|
||||
*
|
||||
*/
|
||||
public class WorkaroundsEventManager implements Listener, EventManager {
|
||||
public class WorkaroundsListener implements Listener, EventManager {
|
||||
|
||||
private final NoCheat plugin;
|
||||
|
||||
public WorkaroundsEventManager(NoCheat plugin) {
|
||||
public WorkaroundsListener(NoCheat plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
@ -65,6 +65,8 @@ public class MovingData implements DataItem {
|
||||
|
||||
public String checknamesuffix = "";
|
||||
|
||||
public int onIce = 0;
|
||||
|
||||
@Override
|
||||
public void clearCriticalData() {
|
||||
teleportTo.reset();
|
||||
|
@ -1,7 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks.moving;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
||||
@ -144,6 +145,14 @@ public class RunningCheck extends MovingCheck {
|
||||
|
||||
String suffix = null;
|
||||
|
||||
// Player on ice?
|
||||
Block b = player.getPlayer().getLocation().getBlock();
|
||||
if(b.getType() == Material.ICE || b.getRelative(0, -1, 0).getType() == Material.ICE) {
|
||||
data.onIce = 20;
|
||||
} else if(data.onIce > 0) {
|
||||
data.onIce--;
|
||||
}
|
||||
|
||||
if(cc.sneakingCheck && player.getPlayer().isSneaking() && !player.hasPermission(Permissions.MOVING_SNEAKING)) {
|
||||
limit = cc.sneakingSpeedLimit;
|
||||
suffix = "sneaking";
|
||||
@ -158,6 +167,10 @@ public class RunningCheck extends MovingCheck {
|
||||
suffix = "sprinting";
|
||||
}
|
||||
|
||||
if(data.onIce > 0) {
|
||||
limit *= 2.5;
|
||||
}
|
||||
|
||||
// Taken directly from Minecraft code, should work
|
||||
limit *= player.getSpeedAmplifier();
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.config;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.log.Colors;
|
||||
|
||||
/**
|
||||
* Configurations specific for logging. Every world gets one of these.
|
||||
@ -17,9 +16,9 @@ public class CCLogging {
|
||||
public CCLogging(Configuration data) {
|
||||
|
||||
active = data.getBoolean(Configuration.LOGGING_ACTIVE);
|
||||
prefix = Colors.replaceColors(data.getString(Configuration.LOGGING_PREFIX));
|
||||
prefix = data.getString(Configuration.LOGGING_PREFIX);
|
||||
toFile = data.getBoolean(Configuration.LOGGING_LOGTOFILE);
|
||||
toConsole = data.getBoolean(Configuration.LOGGING_LOGTOCONSOLE);
|
||||
toChat = data.getBoolean(Configuration.LOGGING_LOGTOCHAT);
|
||||
toChat = data.getBoolean(Configuration.LOGGING_LOGTOINGAMECHAT);
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ public abstract class Configuration {
|
||||
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("logtofile", LOGGING, DataType.BOOLEAN);
|
||||
public final static OptionNode LOGGING_LOGTOCONSOLE = new OptionNode("logtoconsole", LOGGING, DataType.BOOLEAN);
|
||||
public final static OptionNode LOGGING_LOGTOCHAT = new OptionNode("logtochat", LOGGING, DataType.BOOLEAN);
|
||||
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);
|
||||
|
@ -24,7 +24,7 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(LOGGING_FILENAME, "nocheat.log");
|
||||
setValue(LOGGING_LOGTOFILE, true);
|
||||
setValue(LOGGING_LOGTOCONSOLE, true);
|
||||
setValue(LOGGING_LOGTOCHAT, true);
|
||||
setValue(LOGGING_LOGTOINGAMECHAT, true);
|
||||
}
|
||||
|
||||
/*** DEBUG ***/
|
||||
@ -42,7 +42,7 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(INVENTORY_DROP_LIMIT, 100);
|
||||
|
||||
ActionList dropActionList = new ActionList();
|
||||
dropActionList.setActions(0, action.getActions("dropLog:co,ch,fi dropkick".split(" ")));
|
||||
dropActionList.setActions(0, action.getActions("dropLog:0:1:co,ch,fi dropkick".split(" ")));
|
||||
setValue(INVENTORY_DROP_ACTIONS, dropActionList);
|
||||
|
||||
}
|
||||
@ -66,16 +66,16 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(MOVING_RUNFLY_SWIMMINGSPEEDLIMIT, 18);
|
||||
|
||||
ActionList movingActionList = new ActionList();
|
||||
movingActionList.setActions(0, action.getActions("moveLogShort:fi moveCancel".split(" ")));
|
||||
movingActionList.setActions(100, action.getActions("moveLogShort:ch,fi moveCancel".split(" ")));
|
||||
movingActionList.setActions(400, action.getActions("moveLogLong:co,ch,fi moveCancel".split(" ")));
|
||||
movingActionList.setActions(0, action.getActions("moveLogShort:3:5:fi moveCancel".split(" ")));
|
||||
movingActionList.setActions(100, action.getActions("moveLogShort:0:5:ch,fi moveCancel".split(" ")));
|
||||
movingActionList.setActions(400, action.getActions("moveLogLong:0:5:co,ch,fi moveCancel".split(" ")));
|
||||
setValue(MOVING_RUNFLY_ACTIONS, movingActionList);
|
||||
|
||||
setValue(MOVING_RUNFLY_CHECKNOFALL, true);
|
||||
setValue(MOVING_RUNFLY_NOFALLMULTIPLIER, 200);
|
||||
|
||||
ActionList nofallActionList = new ActionList();
|
||||
nofallActionList.setActions(0, action.getActions("nofallLog:co,ch,fi nofallDamage".split(" ")));
|
||||
nofallActionList.setActions(0, action.getActions("nofallLog:0:5:co,ch,fi nofallDamage".split(" ")));
|
||||
setValue(MOVING_RUNFLY_NOFALLACTIONS, nofallActionList);
|
||||
|
||||
setValue(MOVING_RUNFLY_ALLOWLIMITEDFLYING, false);
|
||||
@ -84,17 +84,17 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(MOVING_RUNFLY_FLYINGHEIGHTLIMIT, 250);
|
||||
|
||||
ActionList flyingActionList = new ActionList();
|
||||
flyingActionList.setActions(0, action.getActions("moveLogShort:fi moveCancel".split(" ")));
|
||||
flyingActionList.setActions(100, action.getActions("moveLogShort:ch,fi moveCancel".split(" ")));
|
||||
flyingActionList.setActions(400, action.getActions("moveLogShort:co,ch,fi moveCancel".split(" ")));
|
||||
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:fi moveCancel".split(" ")));
|
||||
morepacketsActionList.setActions(30, action.getActions("morepackets:ch,fi moveCancel".split(" ")));
|
||||
morepacketsActionList.setActions(60, action.getActions("morepackets:co,ch,fi moveCancel".split(" ")));
|
||||
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);
|
||||
|
||||
}
|
||||
@ -107,7 +107,7 @@ public class DefaultConfiguration extends Configuration {
|
||||
|
||||
ActionList reachActionList = new ActionList();
|
||||
reachActionList.setActions(0, action.getActions("blockbreakCancel".split(" ")));
|
||||
reachActionList.setActions(5, action.getActions("reachLog:fi,ch blockbreakCancel".split(" ")));
|
||||
reachActionList.setActions(5, action.getActions("reachLog:0:2:fi,ch blockbreakCancel".split(" ")));
|
||||
setValue(BLOCKBREAK_REACH_ACTIONS, reachActionList);
|
||||
|
||||
setValue(BLOCKBREAK_DIRECTION_CHECK, true);
|
||||
@ -116,12 +116,12 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(BLOCKBREAK_DIRECTION_PENALTYTIME, 300);
|
||||
ActionList directionActionList = new ActionList();
|
||||
directionActionList.setActions(0, action.getActions("blockbreakCancel".split(" ")));
|
||||
directionActionList.setActions(10, action.getActions("directionLog:fi,co,ch blockbreakCancel".split(" ")));
|
||||
directionActionList.setActions(10, action.getActions("directionLog:0:5:fi,co,ch blockbreakCancel".split(" ")));
|
||||
setValue(BLOCKBREAK_DIRECTION_ACTIONS, directionActionList);
|
||||
|
||||
setValue(BLOCKBREAK_NOSWING_CHECK, true);
|
||||
ActionList noswingActionList = new ActionList();
|
||||
noswingActionList.setActions(0, action.getActions("noswingLog:fi,co,ch blockbreakCancel".split(" ")));
|
||||
noswingActionList.setActions(0, action.getActions("noswingLog:0:2:fi,co,ch blockbreakCancel".split(" ")));
|
||||
setValue(BLOCKBREAK_NOSWING_ACTIONS, noswingActionList);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class DefaultConfiguration extends Configuration {
|
||||
|
||||
ActionList reachActionList = new ActionList();
|
||||
reachActionList.setActions(0, action.getActions("blockplaceCancel".split(" ")));
|
||||
reachActionList.setActions(5, action.getActions("reachLog:fi,co,ch blockplaceCancel".split(" ")));
|
||||
reachActionList.setActions(5, action.getActions("reachLog:0:2:fi,co,ch blockplaceCancel".split(" ")));
|
||||
setValue(BLOCKPLACE_REACH_ACTIONS, reachActionList);
|
||||
|
||||
setValue(BLOCKPLACE_DIRECTION_CHECK, true);
|
||||
@ -141,7 +141,7 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(BLOCKPLACE_DIRECTION_PENALTYTIME, 100);
|
||||
ActionList directionActionList = new ActionList();
|
||||
directionActionList.setActions(0, action.getActions("blockplaceCancel".split(" ")));
|
||||
directionActionList.setActions(10, action.getActions("directionLog:fi,co,ch blockplaceCancel".split(" ")));
|
||||
directionActionList.setActions(10, action.getActions("directionLog:0:3:fi,co,ch blockplaceCancel".split(" ")));
|
||||
setValue(BLOCKPLACE_DIRECTION_ACTIONS, directionActionList);
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public class DefaultConfiguration extends Configuration {
|
||||
|
||||
setValue(CHAT_COLOR_CHECK, true);
|
||||
ActionList colorActionList = new ActionList();
|
||||
colorActionList.setActions(0, action.getActions("colorLog:fi,co,ch chatCancel".split(" ")));
|
||||
colorActionList.setActions(0, action.getActions("colorLog:0:1:fi,co,ch chatCancel".split(" ")));
|
||||
setValue(CHAT_COLOR_ACTIONS, colorActionList);
|
||||
|
||||
setValue(CHAT_SPAM_CHECK, true);
|
||||
@ -160,8 +160,8 @@ public class DefaultConfiguration extends Configuration {
|
||||
setValue(CHAT_SPAM_LIMIT, 5);
|
||||
|
||||
ActionList spamActionList = new ActionList();
|
||||
spamActionList.setActions(0, action.getActions("spamLog:fi,co,ch chatCancel".split(" ")));
|
||||
spamActionList.setActions(50, action.getActions("spamLog:fi,co,ch chatCancel spamkick".split(" ")));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -175,14 +175,14 @@ public class DefaultConfiguration extends Configuration {
|
||||
|
||||
ActionList directionActionList = new ActionList();
|
||||
directionActionList.setActions(0, action.getActions("fightCancel".split(" ")));
|
||||
directionActionList.setActions(5, action.getActions("fightDirectionLog:fi fightCancel".split(" ")));
|
||||
directionActionList.setActions(20, action.getActions("fightDirectionLog:fi,ch fightCancel".split(" ")));
|
||||
directionActionList.setActions(50, action.getActions("fightDirectionLog:fi,ch,co fightCancel".split(" ")));
|
||||
directionActionList.setActions(5, action.getActions("fightDirectionLog:3:5:fi fightCancel".split(" ")));
|
||||
directionActionList.setActions(20, action.getActions("fightDirectionLog:0:5:fi,ch fightCancel".split(" ")));
|
||||
directionActionList.setActions(50, action.getActions("fightDirectionLog:0:5:fi,ch,co fightCancel".split(" ")));
|
||||
setValue(FIGHT_DIRECTION_ACTIONS, directionActionList);
|
||||
|
||||
setValue(FIGHT_NOSWING_CHECK, true);
|
||||
ActionList noswingActionList = new ActionList();
|
||||
noswingActionList.setActions(0, action.getActions("noswingLog fightCancel".split(" ")));
|
||||
noswingActionList.setActions(0, action.getActions("noswingLog:0:5:fi,ch,co fightCancel".split(" ")));
|
||||
setValue(FIGHT_NOSWING_ACTIONS, noswingActionList);
|
||||
}
|
||||
}
|
||||
@ -242,21 +242,12 @@ public class DefaultConfiguration extends Configuration {
|
||||
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 moveLogLowShort 3 15 [player] failed [check]. VL [violations]");
|
||||
w(w, "log moveLogMedShort 0 15 [player] failed [check]. VL [violations]");
|
||||
w(w, "log moveLogHighShort 0 15 [player] failed [check]. VL [violations]");
|
||||
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 morepacketsLow 5 1 [player] failed [check]: Sent [packets] more packets than expected. Total violation level [violations].");
|
||||
w(w, "log morepacketsMed 0 1 [player] failed [check]: Sent [packets] more packets than expected. Total violation level [violations].");
|
||||
w(w, "log morepacketsHigh 0 1 [player] failed [check]: Sent [packets] more packets than expected. Total violation level [violations].");
|
||||
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 moveLogLowLong 3 15 [player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations].");
|
||||
w(w, "log moveLogMedLong 0 15 [player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations].");
|
||||
w(w, "log moveLogHighLong 0 15 [player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations].");
|
||||
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");
|
||||
|
@ -20,7 +20,7 @@ public class Explainations {
|
||||
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_LOGTOCHAT, "Should messages get logged to the ingame chat?");
|
||||
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.");
|
||||
|
@ -56,47 +56,25 @@ public class FlatFileAction {
|
||||
private Action parseLine(String line) {
|
||||
|
||||
// Split the line into some parts
|
||||
String parts[] = line.split("\\s+", 5);
|
||||
String parts[] = line.split("\\s+", 3);
|
||||
|
||||
// four pieces is the minimum we need, no matter what it is
|
||||
if(parts.length < 4) {
|
||||
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];
|
||||
|
||||
int delay = 0;
|
||||
try {
|
||||
delay = Integer.parseInt(parts[2]);
|
||||
} catch(Exception e) {
|
||||
throw new IllegalArgumentException("Couldn't parse third parameter of action " + name + " from file " + file.getName() + ". It is " + parts[2] + " but should be a number.");
|
||||
}
|
||||
|
||||
int repeat = 0;
|
||||
try {
|
||||
repeat = Integer.parseInt(parts[3]);
|
||||
} catch(Exception e) {
|
||||
throw new IllegalArgumentException("Couldn't parse fourth parameter of action " + name + " from file " + file.getName() + ". It is " + parts[2] + " but should be a number.");
|
||||
}
|
||||
String message = parts[2];
|
||||
|
||||
if(type.equalsIgnoreCase("log")) {
|
||||
// A log action, it seems
|
||||
if(parts.length < 5) {
|
||||
throw new IllegalArgumentException("Missing fifth parameter of action " + name + " from file " + file.getName() + ".");
|
||||
}
|
||||
|
||||
return new LogAction(name, delay, repeat, parts[4]);
|
||||
return new LogAction(name, message);
|
||||
} else if(type.equalsIgnoreCase("consolecommand")) {
|
||||
// A consolecommand action, it seems
|
||||
if(parts.length < 5) {
|
||||
throw new IllegalArgumentException("Missing fifth parameter of action " + name + " from file " + file.getName() + ".");
|
||||
}
|
||||
|
||||
return new ConsolecommandAction(name, delay, repeat, parts[4]);
|
||||
return new ConsolecommandAction(name, message);
|
||||
} else if(type.equalsIgnoreCase("special")) {
|
||||
// A "special" actions, it seems
|
||||
return new SpecialAction(name, delay, repeat);
|
||||
return new SpecialAction(name, message);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown action type " + type + " of action with name " + name + ".");
|
||||
}
|
||||
|
@ -7,10 +7,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.DummyAction;
|
||||
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;
|
||||
@ -99,22 +96,7 @@ public class FlatFileConfiguration extends Configuration {
|
||||
}
|
||||
int th = Integer.parseInt(treshold);
|
||||
|
||||
List<Action> actions = new LinkedList<Action>();
|
||||
|
||||
for(String name : value.split("\\s+")) {
|
||||
String nameParts[] = name.split(":", 2);
|
||||
Action a2 = action.getAction(nameParts[0]);
|
||||
if(a2 == null) {
|
||||
System.out.println("Nocheat: Action with name " + nameParts[0] + " isn't defined. You need to define it in your actions.txt file to make it work.");
|
||||
actions.add(new DummyAction(name, 0, 0));
|
||||
} else if(nameParts.length == 2) {
|
||||
actions.add(a2.cloneWithProperties(nameParts[1]));
|
||||
} else {
|
||||
actions.add(a2);
|
||||
}
|
||||
}
|
||||
|
||||
al.setActions(th, actions.toArray(new Action[actions.size()]));
|
||||
al.setActions(th, action.getActions(value.split("\\s+")));
|
||||
return al;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
|
||||
/**
|
||||
* Store amount of action executions for last 60 seconds
|
||||
* for various actions
|
||||
*
|
||||
*/
|
||||
public class ExecutionHistory {
|
||||
|
@ -4,8 +4,7 @@ import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* A class to store x,y,z triple data, instead of using bukkits Location
|
||||
* objects,
|
||||
* which can't be easily recycled
|
||||
* objects, which can't be easily recycled
|
||||
*
|
||||
*/
|
||||
public final class PreciseLocation {
|
||||
|
@ -97,10 +97,6 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
|
||||
return player.getGameMode() == GameMode.CREATIVE;
|
||||
}
|
||||
|
||||
public void closeInventory() {
|
||||
((CraftPlayer) this.player).getHandle().closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionHistory getExecutionHistory() {
|
||||
return history;
|
||||
|
Loading…
Reference in New Issue
Block a user