Some bugfixes

This commit is contained in:
Evenprime 2012-01-29 23:26:27 +01:00
parent c1d7e058dd
commit c83bbd999b
18 changed files with 139 additions and 195 deletions

View File

@ -13,6 +13,7 @@ public class NoCheatLogEvent extends Event {
private boolean toConsole, toChat, toFile;
public NoCheatLogEvent(String prefix, String message, boolean toConsole, boolean toChat, boolean toFile) {
this.prefix = prefix;
this.message = message;
this.toConsole = toConsole;
this.toChat = toChat;
@ -62,8 +63,4 @@ public class NoCheatLogEvent extends Event {
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -9,7 +9,7 @@ import cc.co.evenprime.bukkit.nocheat.actions.Action;
*/
public class DummyAction extends Action {
private String def;
private final String def;
public DummyAction(String def) {
super("dummyAction", 10000, 10000);

View File

@ -9,9 +9,9 @@ import cc.co.evenprime.bukkit.nocheat.checks.Check;
*/
public class LogAction extends ActionWithParameters {
private boolean toChat = true;
private boolean toConsole = true;
private boolean toFile = true;
private final boolean toChat;
private final boolean toConsole;
private final boolean toFile;
public LogAction(String name, int delay, int repeat, boolean toChat, boolean toConsole, boolean toFile, String message) {
// Log messages may have color codes now

View File

@ -1,7 +1,6 @@
package cc.co.evenprime.bukkit.nocheat.checks.blockbreak;
import java.util.Locale;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;

View File

@ -17,7 +17,7 @@ import cc.co.evenprime.bukkit.nocheat.config.Permissions;
public class ChatCheckListener implements Listener, EventManager {
private final List<ChatCheck> checks;
private NoCheat plugin;
private final NoCheat plugin;
public ChatCheckListener(NoCheat plugin) {

View File

@ -21,7 +21,7 @@ import cc.co.evenprime.bukkit.nocheat.config.Permissions;
public class FightCheckListener implements Listener, EventManager {
private final List<FightCheck> checks;
private NoCheat plugin;
private final NoCheat plugin;
public FightCheckListener(NoCheat plugin) {
@ -37,10 +37,15 @@ public class FightCheckListener implements Listener, EventManager {
if(event.isCancelled() || !(event instanceof EntityDamageByEntityEvent))
return;
if(event.getCause() == DamageCause.ENTITY_ATTACK) {
normalDamage((EntityDamageByEntityEvent) event);
} else if(event.getCause() == DamageCause.CUSTOM) {
customDamage((EntityDamageByEntityEvent) event);
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if(!(e.getDamager() instanceof Player)) {
return;
}
if(e.getCause() == DamageCause.ENTITY_ATTACK) {
normalDamage(e);
} else if(e.getCause() == DamageCause.CUSTOM) {
customDamage(e);
}
}

View File

@ -9,9 +9,6 @@ public class FightData implements DataItem {
public double directionVL = 0.0D;
public double directionTotalVL = 0.0D;
public int directionFailed = 0;
public double selfhitVL = 0.0D;
public double selfhitTotalVL = 0.0D;
public int selfhitFailed = 0;
public double noswingVL = 0.0D;
public double noswingTotalVL = 0.0D;
public int noswingFailed = 0;
@ -25,10 +22,8 @@ public class FightData implements DataItem {
@Override
public void collectData(Map<String, Object> map) {
map.put("fight.direction.vl", (int) directionTotalVL);
map.put("fight.selfhit.vl", (int) selfhitTotalVL);
map.put("fight.noswing.vl", (int) noswingTotalVL);
map.put("fight.direction.failed", directionFailed);
map.put("fight.selfhit.failed", selfhitFailed);
map.put("fight.noswing.failed", noswingFailed);
}

View File

@ -94,7 +94,7 @@ public class MovingCheckListener implements Listener, EventManager {
}
@EventHandler(priority = EventPriority.LOWEST)
protected void handlePlayerMoveEvent(final PlayerMoveEvent event) {
protected void move(final PlayerMoveEvent event) {
if(event.isCancelled())
return;
@ -171,7 +171,7 @@ public class MovingCheckListener implements Listener, EventManager {
}
@EventHandler(priority = EventPriority.MONITOR)
protected void handlePlayerVelocityEvent(final PlayerVelocityEvent event) {
protected void velocity(final PlayerVelocityEvent event) {
if(event.isCancelled())
return;
final MovingData data = MovingCheck.getData(plugin.getPlayer(event.getPlayer()).getDataStore());

View File

@ -1,10 +1,15 @@
package cc.co.evenprime.bukkit.nocheat.actions.types;
package cc.co.evenprime.bukkit.nocheat.config;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cc.co.evenprime.bukkit.nocheat.actions.Action;
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction;
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;
public class ActionFactory {
@ -121,16 +126,15 @@ public class ActionFactory {
continue;
}
String[] listEntry = s.split("\\s+", 2);
try {
Integer vl;
String def;
if(first) {
first = false;
vl = 0;
def = listEntry[0];
def = s;
} else {
String[] listEntry = s.split("\\s+", 2);
vl = Integer.parseInt(listEntry[0]);
def = listEntry[1];
}

View File

@ -15,13 +15,14 @@ public abstract class ConfPaths {
public final static String LOGGING_LOGTOINGAMECHAT = LOGGING + "ingamechat";
public final static String LOGGING_SHOWACTIVECHECKS = LOGGING + "showactivechecks";
private final static String INVENTORY_DROP = "inventory.drop.";
private final static String CHECKS = "checks.";
private final static String INVENTORY_DROP = CHECKS + "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 = CHECKS + "moving.";
private final static String MOVING_RUNFLY = MOVING + "runfly.";
public final static String MOVING_RUNFLY_CHECK = MOVING_RUNFLY + "active";
@ -31,7 +32,7 @@ public abstract class ConfPaths {
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.";
private 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";
@ -43,7 +44,7 @@ public abstract class ConfPaths {
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 = CHECKS + "blockbreak.";
private final static String BLOCKBREAK_REACH = BLOCKBREAK + "reach.";
public final static String BLOCKBREAK_REACH_CHECK = BLOCKBREAK_REACH + "active";
@ -59,7 +60,7 @@ public abstract class ConfPaths {
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 = CHECKS + "blockplace.";
private final static String BLOCKPLACE_REACH = BLOCKPLACE + "reach.";
public final static String BLOCKPLACE_REACH_CHECK = BLOCKPLACE_REACH + "active";
@ -71,7 +72,7 @@ public abstract class ConfPaths {
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 = CHECKS + "chat.";
private final static String CHAT_COLOR = CHAT + "color.";
public final static String CHAT_COLOR_CHECK = CHAT_COLOR + "active";
@ -84,7 +85,7 @@ public abstract class ConfPaths {
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 = CHECKS + "fight.";
private final static String FIGHT_DIRECTION = FIGHT + "direction.";
public final static String FIGHT_DIRECTION_CHECK = FIGHT_DIRECTION + "active";

View File

@ -11,7 +11,7 @@ import cc.co.evenprime.bukkit.nocheat.ConfigItem;
*/
public class ConfigurationCacheStore {
public final CCLogging logging;
public final LoggingConfig logging;
private final Map<String, ConfigItem> configMap = new HashMap<String, ConfigItem>();
@ -23,7 +23,7 @@ public class ConfigurationCacheStore {
*/
public ConfigurationCacheStore(NoCheatConfiguration data) {
logging = new CCLogging(data);
logging = new LoggingConfig(data);
this.data = data;
}

View File

@ -26,7 +26,7 @@ public class ConfigurationManager {
private final Map<String, ConfigurationCacheStore> worldnameToConfigCacheMap = new HashMap<String, ConfigurationCacheStore>();
private FileHandler fileHandler;
private NoCheat plugin;
private final NoCheat plugin;
private static class LogFileFormatter extends Formatter {
@ -79,6 +79,7 @@ public class ConfigurationManager {
NoCheatConfiguration root = new NoCheatConfiguration();
root.setDefaults(new DefaultConfiguration());
root.options().copyDefaults(true);
root.options().copyHeader(true);
File globalConfigFile = getGlobalConfigFile(rootConfigFolder);

View File

@ -1,6 +1,5 @@
package cc.co.evenprime.bukkit.nocheat.config;
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
/**
* These are the default settings for NoCheat. They will be used
@ -12,6 +11,84 @@ public class DefaultConfiguration extends NoCheatConfiguration {
public DefaultConfiguration() {
this.options().header("Main configuration file for NoCheat.");
/** 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 ***/
set(ConfPaths.INVENTORY_DROP_CHECK, true);
set(ConfPaths.INVENTORY_DROP_TIMEFRAME, 20);
set(ConfPaths.INVENTORY_DROP_LIMIT, 100);
set(ConfPaths.INVENTORY_DROP_ACTIONS, "log:drop:0:1:cif cmd:kick");
/*** MOVING ***/
set(ConfPaths.MOVING_RUNFLY_CHECK, true);
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING, false);
set(ConfPaths.MOVING_RUNFLY_ACTIONS, "log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
set(ConfPaths.MOVING_RUNFLY_CHECKNOFALL, true);
set(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS, "log:nofall:0:5:cif cancel");
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS, false);
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);
set(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS, "log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
set(ConfPaths.MOVING_MOREPACKETS_CHECK, true);
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, "log:morepackets:3:2:f cancel vl>30 log:morepackets:0:2:if cancel vl>60 log:morepackets:0:2:cif cancel");
/*** BLOCKBREAK ***/
set(ConfPaths.BLOCKBREAK_REACH_CHECK, true);
set(ConfPaths.BLOCKBREAK_REACH_ACTIONS, "cancel vl>5 log:bbreach:0:2:if cancel");
set(ConfPaths.BLOCKBREAK_DIRECTION_CHECK, true);
set(ConfPaths.BLOCKBREAK_DIRECTION_PRECISION, 50);
set(ConfPaths.BLOCKBREAK_DIRECTION_PENALTYTIME, 300);
set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, "cancel vl>10 log:bbdirection:0:5:cif cancel");
set(ConfPaths.BLOCKBREAK_NOSWING_CHECK, true);
set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, "log:bbnoswing:0:2:cif cancel");
/*** BLOCKPLACE ***/
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, "cancel vl>5 log:bpreach:0:2:cif cancel");
set(ConfPaths.BLOCKPLACE_DIRECTION_CHECK, true);
set(ConfPaths.BLOCKPLACE_DIRECTION_PRECISION, 75);
set(ConfPaths.BLOCKPLACE_DIRECTION_PENALTYTIME, 100);
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, "cancel vl>10 log:bpdirection:0:3:cif cancel");
/*** CHAT ***/
set(ConfPaths.CHAT_COLOR_CHECK, true);
set(ConfPaths.CHAT_COLOR_ACTIONS, "log:color:0:1:cif cancel");
set(ConfPaths.CHAT_SPAM_CHECK, true);
set(ConfPaths.CHAT_SPAM_WHITELIST, "");
set(ConfPaths.CHAT_SPAM_TIMEFRAME, 5);
set(ConfPaths.CHAT_SPAM_LIMIT, 5);
set(ConfPaths.CHAT_SPAM_ACTIONS, "log:spam:0:5:cif cancel vl>50 log:spam:0:5:cif cancel cmd:kick");
/*** FIGHT ***/
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
set(ConfPaths.FIGHT_DIRECTION_PRECISION, 75);
set(ConfPaths.FIGHT_DIRECTION_PENALTYTIME, 500);
set(ConfPaths.FIGHT_DIRECTION_ACTIONS, "cancel vl>5 log:fdirection:3:5:f cancel vl>20 log:fdirection:0:5:cf cancel vl>50 log:fdirection:0:5:cif cancel");
set(ConfPaths.FIGHT_NOSWING_CHECK, true);
set(ConfPaths.FIGHT_NOSWING_ACTIONS, "log:fnoswing:0:5:cif cancel");
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]");
set(ConfPaths.STRINGS + ".movelong", "[player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations]");
@ -30,133 +107,5 @@ public class DefaultConfiguration extends NoCheatConfiguration {
// Update internal factory based on all the new entries to the "actions" section
regenerateActionLists();
/** 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 ***/
set(ConfPaths.INVENTORY_DROP_CHECK, true);
set(ConfPaths.INVENTORY_DROP_TIMEFRAME, 20);
set(ConfPaths.INVENTORY_DROP_LIMIT, 100);
ActionList dropActionList = new ActionList();
dropActionList.setActions(0, createActions("log:drop:0:1:cif", "cmd:kick"));
set(ConfPaths.INVENTORY_DROP_ACTIONS, dropActionList);
/*** MOVING ***/
set(ConfPaths.MOVING_RUNFLY_CHECK, true);
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING, false);
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);
set(ConfPaths.MOVING_RUNFLY_CHECKNOFALL, true);
ActionList nofallActionList = new ActionList();
nofallActionList.setActions(0, createActions("log:nofall:0:5:cif", "cancel"));
set(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS, nofallActionList);
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS, false);
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 flyingActionList = new ActionList();
flyingActionList.setActions(0, createActions("log:moveShort:3:5:f", "cancel"));
flyingActionList.setActions(100, createActions("log:moveShort:0:5:if", "cancel"));
flyingActionList.setActions(400, createActions("log:moveLong:0:5:cif", "cancel"));
set(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS, flyingActionList);
set(ConfPaths.MOVING_MOREPACKETS_CHECK, true);
ActionList morepacketsActionList = new ActionList();
morepacketsActionList.setActions(0, createActions("log:morepackets:3:2:f", "cancel"));
morepacketsActionList.setActions(30, createActions("log:morepackets:0:2:if", "cancel"));
morepacketsActionList.setActions(60, createActions("log:morepackets:0:2:cif", "cancel"));
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, morepacketsActionList);
/*** BLOCKBREAK ***/
set(ConfPaths.BLOCKBREAK_REACH_CHECK, true);
ActionList breakreachActionList = new ActionList();
breakreachActionList.setActions(0, createActions("cancel"));
breakreachActionList.setActions(5, createActions("log:bbreach:0:2:if", "cancel"));
set(ConfPaths.BLOCKBREAK_REACH_ACTIONS, breakreachActionList);
set(ConfPaths.BLOCKBREAK_DIRECTION_CHECK, true);
set(ConfPaths.BLOCKBREAK_DIRECTION_PRECISION, 50);
set(ConfPaths.BLOCKBREAK_DIRECTION_PENALTYTIME, 300);
ActionList breakdirectionActionList = new ActionList();
breakdirectionActionList.setActions(0, createActions("cancel"));
breakdirectionActionList.setActions(10, createActions("log:bbdirection:0:5:cif", "cancel"));
set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, breakdirectionActionList);
set(ConfPaths.BLOCKBREAK_NOSWING_CHECK, true);
ActionList breaknoswingActionList = new ActionList();
breaknoswingActionList.setActions(0, createActions("log:bbnoswing:0:2:cif", "cancel"));
set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, breaknoswingActionList);
/*** BLOCKPLACE ***/
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
ActionList placereachActionList = new ActionList();
placereachActionList.setActions(0, createActions("cancel"));
placereachActionList.setActions(5, createActions("log:bpreach:0:2:cif", "cancel"));
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, placereachActionList);
set(ConfPaths.BLOCKPLACE_DIRECTION_CHECK, true);
set(ConfPaths.BLOCKPLACE_DIRECTION_PRECISION, 75);
set(ConfPaths.BLOCKPLACE_DIRECTION_PENALTYTIME, 100);
ActionList placedirectionActionList = new ActionList();
placedirectionActionList.setActions(0, createActions("cancel"));
placedirectionActionList.setActions(10, createActions("log:bpdirection:0:3:cif", "cancel"));
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, placedirectionActionList);
/*** CHAT ***/
set(ConfPaths.CHAT_COLOR_CHECK, true);
ActionList colorActionList = new ActionList();
colorActionList.setActions(0, createActions("log:color:0:1:cif", "cancel"));
set(ConfPaths.CHAT_COLOR_ACTIONS, colorActionList);
set(ConfPaths.CHAT_SPAM_CHECK, true);
set(ConfPaths.CHAT_SPAM_WHITELIST, "");
set(ConfPaths.CHAT_SPAM_TIMEFRAME, 5);
set(ConfPaths.CHAT_SPAM_LIMIT, 5);
ActionList spamActionList = new ActionList();
spamActionList.setActions(0, createActions("log:spam:0:5:cif", "cancel"));
spamActionList.setActions(50, createActions("log:spam:0:5:cif", "cancel", "cmd:kick"));
set(ConfPaths.CHAT_SPAM_ACTIONS, spamActionList);
/*** FIGHT ***/
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
set(ConfPaths.FIGHT_DIRECTION_PRECISION, 75);
set(ConfPaths.FIGHT_DIRECTION_PENALTYTIME, 500);
ActionList directionActionList = new ActionList();
directionActionList.setActions(0, createActions("cancel"));
directionActionList.setActions(5, createActions("log:fdirection:3:5:f", "cancel"));
directionActionList.setActions(20, createActions("log:fdirection:0:5:cf", "cancel"));
directionActionList.setActions(50, createActions("log:fdirection:0:5:cif", "cancel"));
set(ConfPaths.FIGHT_DIRECTION_ACTIONS, directionActionList);
set(ConfPaths.FIGHT_NOSWING_CHECK, true);
ActionList fightnoswingActionList = new ActionList();
fightnoswingActionList.setActions(0, createActions("log:fnoswing:0:5:cif", "cancel"));
set(ConfPaths.FIGHT_NOSWING_ACTIONS, fightnoswingActionList);
}
}

View File

@ -4,7 +4,7 @@ package cc.co.evenprime.bukkit.nocheat.config;
* Configurations specific for logging. Every world gets one of these.
*
*/
public class CCLogging {
public class LoggingConfig {
public final boolean active;
public final boolean showactivechecks;
@ -13,7 +13,7 @@ public class CCLogging {
public final boolean toChat;
public final String prefix;
public CCLogging(NoCheatConfiguration data) {
public LoggingConfig(NoCheatConfiguration data) {
active = data.getBoolean(ConfPaths.LOGGING_ACTIVE);
showactivechecks = data.getBoolean(ConfPaths.LOGGING_SHOWACTIVECHECKS);

View File

@ -5,7 +5,6 @@ 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 {
@ -45,33 +44,23 @@ public class NoCheatConfiguration extends YamlConfiguration {
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 = "";
StringBuffer string = new StringBuffer();
for(int treshold : list.getTresholds()) {
if(treshold > 0) {
string += " vl>" + treshold;
string.append(" vl>").append(treshold);
}
for(Action action : list.getActions(treshold)) {
string += " " + action;
string.append(" ").append(action);
}
}
set(path, string.trim());
set(path, string.toString().trim());
}
}

View File

@ -34,9 +34,6 @@ public class Permissions {
public static final String FIGHT_DIRECTION = FIGHT + ".direction";
public static final String FIGHT_NOSWING = FIGHT + ".noswing";
public static final String TIMED = CHECKS + ".timed";
public static final String TIMED_GODMODE = TIMED + ".godmode";
public final static String ADMIN_CHATLOG = ADMIN + ".chatlog";
public static final String ADMIN_COMMANDS = ADMIN + ".commands";

View File

@ -19,11 +19,13 @@ public final class SimpleLocation {
reset();
}
public final boolean equals(Block block) {
return block.getX() == x && block.getY() == y && block.getZ() == z;
}
@Override
public final boolean equals(Object object) {
if(!(object instanceof SimpleLocation))
return false;
SimpleLocation simpleLocation = (SimpleLocation) object;
public final boolean equals(SimpleLocation simpleLocation) {
if(!isSet() && !simpleLocation.isSet())
return true;
else if(!isSet() || !simpleLocation.isSet())
@ -32,6 +34,11 @@ public final class SimpleLocation {
return simpleLocation.x == x && simpleLocation.y == y && simpleLocation.z == z;
}
@Override
public final int hashCode() {
return x * 1000000 + y * 1000 + z;
}
public final void set(Block block) {
x = block.getX();
y = block.getY();

View File

@ -13,12 +13,12 @@ import cc.co.evenprime.bukkit.nocheat.data.ExecutionHistory;
public class NoCheatPlayerImpl implements NoCheatPlayer {
protected Player player;
protected final NoCheat plugin;
protected final DataStore data;
protected ConfigurationCacheStore config;
protected long lastUsedTime;
protected final ExecutionHistory history;
private Player player;
private final NoCheat plugin;
private final DataStore data;
private ConfigurationCacheStore config;
private long lastUsedTime;
private final ExecutionHistory history;
public NoCheatPlayerImpl(Player player, NoCheat plugin) {