Some renaming and code moving to be more consistent

This commit is contained in:
Evenprime 2011-11-16 02:06:06 +01:00
parent e853eac486
commit cb2c3ceba6
9 changed files with 38 additions and 49 deletions

View File

@ -24,10 +24,9 @@ import cc.co.evenprime.bukkit.nocheat.events.BlockPlaceEventManager;
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
import cc.co.evenprime.bukkit.nocheat.events.FightEventManager;
import cc.co.evenprime.bukkit.nocheat.events.EventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerChatEventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerMoveEventManager;
import cc.co.evenprime.bukkit.nocheat.events.ChatEventManager;
import cc.co.evenprime.bukkit.nocheat.events.MovingEventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerTeleportEventManager;
import cc.co.evenprime.bukkit.nocheat.events.SwingEventManager;
import cc.co.evenprime.bukkit.nocheat.events.TimedEventManager;
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
import cc.co.evenprime.bukkit.nocheat.log.LogManager;
@ -99,13 +98,12 @@ public class NoCheat extends JavaPlugin {
eventManagers = new ArrayList<EventManager>(8); // Big enough
// Then set up the event listeners
eventManagers.add(new PlayerMoveEventManager(this));
eventManagers.add(new MovingEventManager(this));
eventManagers.add(new PlayerTeleportEventManager(this));
eventManagers.add(new PlayerChatEventManager(this));
eventManagers.add(new ChatEventManager(this));
eventManagers.add(new BlockBreakEventManager(this));
eventManagers.add(new BlockPlaceEventManager(this));
eventManagers.add(new FightEventManager(this));
eventManagers.add(new SwingEventManager(this));
TimedEventManager m = new TimedEventManager(this);
taskId = m.taskId; // There's a bukkit task, remember its id
eventManagers.add(m);

View File

@ -7,13 +7,14 @@ package cc.co.evenprime.bukkit.nocheat.data;
public class BlockBreakData extends Data {
public double reachVL = 0.0D;
public double directionVL = 0.0D;
public double directionVL = 0.0D;
public long directionLastViolationTime = 0;
public final SimpleLocation instaBrokenBlockLocation = new SimpleLocation();
public final SimpleLocation instaBrokenBlockLocation = new SimpleLocation();
public final SimpleLocation brokenBlockLocation = new SimpleLocation();
public final ExecutionHistory history = new ExecutionHistory();
public double noswingVL = 0.0D;
public double reachDistance;
public boolean armswung = true;
}

View File

@ -4,11 +4,12 @@ import net.minecraft.server.Entity;
public class FightData extends Data {
public double directionVL = 0;
public long directionLastViolationTime = 0;
public final ExecutionHistory history = new ExecutionHistory();
public double selfhitVL = 0;
public double noswingVL = 0.0D;
public Entity damagee;
public double directionVL = 0;
public long directionLastViolationTime = 0;
public final ExecutionHistory history = new ExecutionHistory();
public double selfhitVL = 0;
public double noswingVL = 0.0D;
public Entity damagee;
public boolean armswung = true;
}

View File

@ -8,6 +8,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
@ -42,6 +43,7 @@ public class BlockBreakEventManager extends EventManager {
registerListener(Event.Type.BLOCK_BREAK, Priority.Lowest, true, plugin.getPerformance(Type.BLOCKBREAK));
registerListener(Event.Type.BLOCK_DAMAGE, Priority.Monitor, true, plugin.getPerformance(Type.BLOCKDAMAGE));
registerListener(Event.Type.PLAYER_ANIMATION, Priority.Monitor, false, null);
}
@Override
@ -85,6 +87,11 @@ public class BlockBreakEventManager extends EventManager {
// direction check that are insta-breaks
data.instaBrokenBlockLocation.set(event.getBlock());
}
@Override
protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) {
plugin.getPlayer(event.getPlayer().getName()).getData().blockbreak.armswung = true;
}
public List<String> getActiveChecks(ConfigurationCache cc) {
LinkedList<String> s = new LinkedList<String>();

View File

@ -19,11 +19,11 @@ import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
import cc.co.evenprime.bukkit.nocheat.data.ChatData;
import cc.co.evenprime.bukkit.nocheat.debug.PerformanceManager.Type;
public class PlayerChatEventManager extends EventManager {
public class ChatEventManager extends EventManager {
private final List<ChatCheck> checks;
public PlayerChatEventManager(NoCheat plugin) {
public ChatEventManager(NoCheat plugin) {
super(plugin);

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
@ -35,6 +36,7 @@ public class FightEventManager extends EventManager {
this.checks.add(new SelfhitCheck(plugin));
registerListener(Event.Type.ENTITY_DAMAGE, Priority.Lowest, true, plugin.getPerformance(Type.FIGHT));
registerListener(Event.Type.PLAYER_ANIMATION, Priority.Monitor, false, null);
}
@Override
@ -68,6 +70,11 @@ public class FightEventManager extends EventManager {
if(cancelled)
event.setCancelled(cancelled);
}
@Override
protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) {
plugin.getPlayer(event.getPlayer().getName()).getData().fight.armswung = true;
}
public List<String> getActiveChecks(ConfigurationCache cc) {
LinkedList<String> s = new LinkedList<String>();

View File

@ -34,11 +34,11 @@ import cc.co.evenprime.bukkit.nocheat.debug.PerformanceManager.Type;
* evaluate the check results and decide what to
*
*/
public class PlayerMoveEventManager extends EventManager {
public class MovingEventManager extends EventManager {
private final List<MovingCheck> checks;
public PlayerMoveEventManager(NoCheat plugin) {
public MovingEventManager(NoCheat plugin) {
super(plugin);

View File

@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
/**
@ -40,10 +41,13 @@ public class PlayerTeleportEventManager extends EventManager {
if(!event.isCancelled())
return;
final MovingData data = plugin.getPlayer(event.getPlayer().getName()).getData().moving;
NoCheatPlayer player = plugin.getPlayer(event.getPlayer().getName());
final MovingData data = player.getData().moving;
if(data.teleportTo.isSet() && data.teleportTo.equals(event.getTo())) {
event.setCancelled(false);
if(player.getConfiguration().debug.overrideIdiocy) {
event.setCancelled(false);
}
}
}
}

View File

@ -1,29 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.events;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.player.PlayerAnimationEvent;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
/**
* The only place that listens to and modifies player_move events if necessary
*
* Get the event, decide which checks should work on it and in what order,
* evaluate the check results and decide what to
*
*/
public class SwingEventManager extends EventManager {
public SwingEventManager(NoCheat plugin) {
super(plugin);
registerListener(Event.Type.PLAYER_ANIMATION, Priority.Monitor, false, null);
}
@Override
protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) {
plugin.getPlayer(event.getPlayer().getName()).getData().armswung = true;
}
}