Deactivate dropCheck for now, as it faces an unsolvable problem

This commit is contained in:
Evenprime 2011-12-23 22:14:44 +01:00
parent bc9869a68f
commit 9735f3fac1
9 changed files with 44 additions and 21 deletions

View File

@ -26,4 +26,6 @@ public interface NoCheatPlayer {
public float getSpeedAmplifier(); public float getSpeedAmplifier();
public boolean isCreative(); public boolean isCreative();
public void closeInventory();
} }

View File

@ -4,11 +4,25 @@ import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissibleBase; import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.ServerOperator;
public class NoCheatCommandSender extends PermissibleBase implements CommandSender { public class NoCheatCommandSender extends PermissibleBase implements CommandSender {
private static final ServerOperator serverOperator = new ServerOperator() {
@Override
public boolean isOp() {
return true;
}
@Override
public void setOp(boolean value) {
//
}
};
public NoCheatCommandSender() { public NoCheatCommandSender() {
super(null); super(serverOperator);
} }
@Override @Override
@ -18,8 +32,7 @@ public class NoCheatCommandSender extends PermissibleBase implements CommandSend
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
// We don't want to receive messages, as we can't do anything with them // We don't want messages
// anyway
} }
@Override @Override

View File

@ -76,6 +76,7 @@ public abstract class Check {
try { try {
command = action.getCommand(player, check); command = action.getCommand(player, check);
System.out.println("Going to execute command "+command);
plugin.getServer().dispatchCommand(noCheatCommandSender, command); plugin.getServer().dispatchCommand(noCheatCommandSender, command);
} catch(CommandException e) { } catch(CommandException e) {
System.out.println("[NoCheat] failed to execute the command '" + command + "': " + e.getMessage() + ", please check if everything is setup correct. "); System.out.println("[NoCheat] failed to execute the command '" + command + "': " + e.getMessage() + ", please check if everything is setup correct. ");

View File

@ -21,6 +21,7 @@ public class CCInventory implements ConfigItem {
dropTimeFrame = data.getInteger(Configuration.INVENTORY_DROP_TIMEFRAME); dropTimeFrame = data.getInteger(Configuration.INVENTORY_DROP_TIMEFRAME);
dropLimit = data.getInteger(Configuration.INVENTORY_DROP_LIMIT); dropLimit = data.getInteger(Configuration.INVENTORY_DROP_LIMIT);
dropActions = data.getActionList(Configuration.INVENTORY_DROP_ACTIONS); dropActions = data.getActionList(Configuration.INVENTORY_DROP_ACTIONS);
closebeforeteleports = data.getBoolean(Configuration.INVENTORY_PREVENTITEMDUPE); closebeforeteleports = data.getBoolean(Configuration.INVENTORY_PREVENTITEMDUPE);
} }
} }

View File

@ -7,12 +7,12 @@ import cc.co.evenprime.bukkit.nocheat.data.ExecutionHistory;
public class InventoryData implements DataItem { public class InventoryData implements DataItem {
public int dropVL = 0; public int dropVL = 0;
public double dropTotalVL = 0; public double dropTotalVL = 0;
public int dropFailed = 0; public int dropFailed = 0;
public long dropLastTime; public long dropLastTime;
public int dropCount; public int dropCount;
public final ExecutionHistory history = new ExecutionHistory(); public final ExecutionHistory history = new ExecutionHistory();
@Override @Override
public void collectData(Map<String, Object> map) { public void collectData(Map<String, Object> map) {

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Priority;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
@ -14,7 +13,6 @@ 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.config.ConfigurationCacheStore; import cc.co.evenprime.bukkit.nocheat.config.ConfigurationCacheStore;
import cc.co.evenprime.bukkit.nocheat.config.Permissions; import cc.co.evenprime.bukkit.nocheat.config.Permissions;
import cc.co.evenprime.bukkit.nocheat.debug.PerformanceManager.EventType;
import cc.co.evenprime.bukkit.nocheat.events.EventManagerImpl; import cc.co.evenprime.bukkit.nocheat.events.EventManagerImpl;
public class InventoryEventManager extends EventManagerImpl { public class InventoryEventManager extends EventManagerImpl {
@ -25,18 +23,20 @@ public class InventoryEventManager extends EventManagerImpl {
super(plugin); super(plugin);
this.checks = new ArrayList<InventoryCheck>(1); this.checks = new ArrayList<InventoryCheck>(1);
this.checks.add(new DropCheck(plugin));
// Don't use this check now, it's buggy
//this.checks.add(new DropCheck(plugin));
registerListener(Event.Type.PLAYER_DROP_ITEM, Priority.Lowest, true, plugin.getPerformance(EventType.INVENTORY)); //registerListener(Event.Type.PLAYER_DROP_ITEM, Priority.Lowest, true, plugin.getPerformance(EventType.INVENTORY));
registerListener(Event.Type.PLAYER_TELEPORT, Priority.Monitor, true, null); registerListener(Event.Type.PLAYER_TELEPORT, Priority.Monitor, true, null);
} }
@Override @Override
protected void handlePlayerTeleportEvent(final PlayerTeleportEvent event, final Priority priority) { protected void handlePlayerTeleportEvent(final PlayerTeleportEvent event, final Priority priority) {
CraftPlayer player = (CraftPlayer) event.getPlayer(); NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
if(InventoryCheck.getConfig(plugin.getPlayer(player).getConfigurationStore()).closebeforeteleports && event.getTo() != null && !(event.getTo().getWorld().equals(player.getWorld()))) { if(InventoryCheck.getConfig(player.getConfigurationStore()).closebeforeteleports && event.getTo() != null && !(event.getTo().getWorld().equals(player.getPlayer().getWorld()))) {
player.getHandle().closeInventory(); player.closeInventory();
} }
} }
@ -62,15 +62,15 @@ public class InventoryEventManager extends EventManagerImpl {
} }
if(cancelled) if(cancelled)
event.setCancelled(cancelled); event.setCancelled(true);
} }
public List<String> getActiveChecks(ConfigurationCacheStore cc) { public List<String> getActiveChecks(ConfigurationCacheStore cc) {
LinkedList<String> s = new LinkedList<String>(); LinkedList<String> s = new LinkedList<String>();
CCInventory i = InventoryCheck.getConfig(cc); /*CCInventory i = InventoryCheck.getConfig(cc);
if(i.check && i.dropCheck) if(i.check && i.dropCheck)
s.add("inventory.dropCheck"); s.add("inventory.dropCheck");*/
return s; return s;
} }
} }

View File

@ -20,6 +20,8 @@ public abstract class Configuration {
protected final static OptionNode ROOT = new OptionNode(null, null, DataType.PARENT); protected final static OptionNode ROOT = new OptionNode(null, null, DataType.PARENT);
protected final static OptionNode INACTIVE = new OptionNode(null, null, DataType.PARENT);
private final static OptionNode LOGGING = new OptionNode("logging", ROOT, 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_ACTIVE = new OptionNode("active", LOGGING, DataType.BOOLEAN);
public final static OptionNode LOGGING_PREFIX = new OptionNode("prefix", LOGGING, DataType.STRING); public final static OptionNode LOGGING_PREFIX = new OptionNode("prefix", LOGGING, DataType.STRING);
@ -34,9 +36,9 @@ public abstract class Configuration {
private final static OptionNode INVENTORY = new OptionNode("inventory", ROOT, DataType.PARENT); private final static OptionNode INVENTORY = new OptionNode("inventory", ROOT, DataType.PARENT);
public final static OptionNode INVENTORY_PREVENTITEMDUPE = new OptionNode("preventitemdupe", INVENTORY, DataType.BOOLEAN); public final static OptionNode INVENTORY_PREVENTITEMDUPE = new OptionNode("preventitemdupe", INVENTORY, DataType.BOOLEAN);
public static final OptionNode INVENTORY_CHECK = new OptionNode("check", INVENTORY, DataType.BOOLEAN); public static final OptionNode INVENTORY_CHECK = new OptionNode("check", INACTIVE, DataType.BOOLEAN);
private final static OptionNode INVENTORY_DROP = new OptionNode("drop", INVENTORY, DataType.PARENT); private final static OptionNode INVENTORY_DROP = new OptionNode("drop", INACTIVE, DataType.PARENT);
public final static OptionNode INVENTORY_DROP_CHECK = new OptionNode("check", INVENTORY_DROP, DataType.BOOLEAN); 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_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_LIMIT = new OptionNode("limit", INVENTORY_DROP, DataType.INTEGER);

View File

@ -37,8 +37,8 @@ public class DefaultConfiguration extends Configuration {
/*** INVENTORY ***/ /*** INVENTORY ***/
{ {
setValue(INVENTORY_CHECK, true);
setValue(INVENTORY_PREVENTITEMDUPE, true); setValue(INVENTORY_PREVENTITEMDUPE, true);
/*setValue(INVENTORY_CHECK, true);
setValue(INVENTORY_DROP_CHECK, true); setValue(INVENTORY_DROP_CHECK, true);
setValue(INVENTORY_DROP_TIMEFRAME, 20); setValue(INVENTORY_DROP_TIMEFRAME, 20);
@ -47,7 +47,7 @@ public class DefaultConfiguration extends Configuration {
ActionList dropActionList = new ActionList(); ActionList dropActionList = new ActionList();
dropActionList.setActions(0, action.getActions("dropLog dropCancel".split(" "))); dropActionList.setActions(0, action.getActions("dropLog dropCancel".split(" ")));
dropActionList.setActions(500, action.getActions("dropLog dropCancel dropkick".split(" "))); dropActionList.setActions(500, action.getActions("dropLog dropCancel dropkick".split(" ")));
setValue(INVENTORY_DROP_ACTIONS, dropActionList); setValue(INVENTORY_DROP_ACTIONS, dropActionList);*/
} }
/*** MOVING ***/ /*** MOVING ***/

View File

@ -95,4 +95,8 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
public boolean isCreative() { public boolean isCreative() {
return player.getGameMode() == GameMode.CREATIVE; return player.getGameMode() == GameMode.CREATIVE;
} }
public void closeInventory() {
((CraftPlayer) this.player).getHandle().closeInventory();
}
} }