mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-27 09:51:32 +01:00
Display which checks are active in which world on startup
This commit is contained in:
parent
1480ebb3db
commit
0264eb97d5
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 2.02
|
||||
version: 2.03
|
||||
|
||||
permissions:
|
||||
|
||||
|
@ -1,14 +1,20 @@
|
||||
package cc.co.evenprime.bukkit.nocheat;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ActionManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.ConfigurationManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.events.BlockPlaceEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.EventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerChatEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerItemDropEventManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.events.PlayerInteractEventManager;
|
||||
@ -28,25 +34,19 @@ import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
*/
|
||||
public class NoCheat extends JavaPlugin {
|
||||
|
||||
private ConfigurationManager conf;
|
||||
private LogManager log;
|
||||
private DataManager data;
|
||||
private ConfigurationManager conf;
|
||||
private LogManager log;
|
||||
private DataManager data;
|
||||
|
||||
private PlayerMoveEventManager eventPlayerMoveManager;
|
||||
private PlayerTeleportEventManager eventPlayerTeleportManager;
|
||||
private BlockBreakEventManager eventBlockBreakManager;
|
||||
private BlockPlaceEventManager eventBlockPlaceManager;
|
||||
private PlayerInteractEventManager eventPlayerInteractManager;
|
||||
private PlayerItemDropEventManager eventPlayerItemDropManager;
|
||||
private PlayerChatEventManager eventPlayerChatManager;
|
||||
private List<EventManager> eventManagers = new LinkedList<EventManager>();
|
||||
|
||||
private int taskId = -1;
|
||||
private int ingameseconds = 0;
|
||||
private long lastIngamesecondTime = 0L;
|
||||
private long lastIngamesecondDuration = 0L;
|
||||
private boolean skipCheck = false;
|
||||
private int taskId = -1;
|
||||
private int ingameseconds = 0;
|
||||
private long lastIngamesecondTime = 0L;
|
||||
private long lastIngamesecondDuration = 0L;
|
||||
private boolean skipCheck = false;
|
||||
|
||||
private ActionManager action;
|
||||
private ActionManager action;
|
||||
|
||||
public NoCheat() {
|
||||
|
||||
@ -77,13 +77,13 @@ public class NoCheat extends JavaPlugin {
|
||||
// parse the nocheat.yml config file
|
||||
this.conf = new ConfigurationManager(this.getDataFolder().getPath(), action);
|
||||
|
||||
eventPlayerMoveManager = new PlayerMoveEventManager(this);
|
||||
eventPlayerTeleportManager = new PlayerTeleportEventManager(this);
|
||||
eventBlockBreakManager = new BlockBreakEventManager(this);
|
||||
eventBlockPlaceManager = new BlockPlaceEventManager(this);
|
||||
eventPlayerItemDropManager = new PlayerItemDropEventManager(this);
|
||||
eventPlayerInteractManager = new PlayerInteractEventManager(this);
|
||||
eventPlayerChatManager = new PlayerChatEventManager(this);
|
||||
eventManagers.add(new PlayerMoveEventManager(this));
|
||||
eventManagers.add(new PlayerTeleportEventManager(this));
|
||||
eventManagers.add(new PlayerItemDropEventManager(this));
|
||||
eventManagers.add(new PlayerInteractEventManager(this));
|
||||
eventManagers.add(new PlayerChatEventManager(this));
|
||||
eventManagers.add(new BlockBreakEventManager(this));
|
||||
eventManagers.add(new BlockPlaceEventManager(this));
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
|
||||
@ -107,6 +107,34 @@ public class NoCheat extends JavaPlugin {
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
log.logToConsole(LogLevel.LOW, "[NoCheat] Active Checks: ");
|
||||
|
||||
for(World world : this.getServer().getWorlds()) {
|
||||
|
||||
StringBuilder line = new StringBuilder(" ").append(world.getName()).append(": ");
|
||||
|
||||
int length = line.length();
|
||||
|
||||
ConfigurationCache cc = this.conf.getConfigurationCacheForWorld(world.getName());
|
||||
|
||||
for(EventManager em : eventManagers) {
|
||||
List<String> checks = em.getActiveChecks(cc);
|
||||
if(checks.size() > 0) {
|
||||
for(String active : em.getActiveChecks(cc)) {
|
||||
line.append(active).append(' ');
|
||||
}
|
||||
log.logToConsole(LogLevel.LOW, line.toString());
|
||||
|
||||
line = new StringBuilder(length);
|
||||
|
||||
for(int i = 0; i < length; i++) {
|
||||
line.append(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.logToConsole(LogLevel.LOW, "[NoCheat] version [" + pdfFile.getVersion() + "] is enabled.");
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class NoclipCheck {
|
||||
params.put(LogAction.LOCATION_TO, String.format(Locale.US, "%.2f,%.2f,%.2f", to.getX(), to.getY(), to.getZ()));
|
||||
params.put(LogAction.CHECK, "noclip");
|
||||
|
||||
boolean cancelled = action.executeActions(player, cc.moving.noclipActions, violationLevel, params, cc);
|
||||
/*boolean cancelled =*/ action.executeActions(player, cc.moving.noclipActions, violationLevel, params, cc);
|
||||
|
||||
// TODO: UNCOMMENT, WHEN THE CHECK WORKS RELIABLY
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -24,7 +27,7 @@ import cc.co.evenprime.bukkit.nocheat.data.BlockBreakData;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class BlockBreakEventManager extends BlockListener {
|
||||
public class BlockBreakEventManager extends BlockListener implements EventManager {
|
||||
|
||||
private final BlockBreakCheck blockBreakCheck;
|
||||
private final DataManager data;
|
||||
@ -57,10 +60,10 @@ public class BlockBreakEventManager extends BlockListener {
|
||||
if(cc.blockbreak.check && !player.hasPermission(Permissions.BLOCKBREAK)) {
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
|
||||
// Get the player-specific stored data that applies here
|
||||
final BlockBreakData data = this.data.getBlockBreakData(player);
|
||||
|
||||
|
||||
cancel = blockBreakCheck.check(player, event.getBlock(), data, cc);
|
||||
|
||||
if(cancel) {
|
||||
@ -68,7 +71,7 @@ public class BlockBreakEventManager extends BlockListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
@ -76,12 +79,37 @@ public class BlockBreakEventManager extends BlockListener {
|
||||
if(!event.isCancelled() && !event.getInstaBreak()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
// Get the player-specific stored data that applies here
|
||||
final BlockBreakData data = this.data.getBlockBreakData(player);
|
||||
|
||||
// Remember this location. We ignore block breaks in the block-break direction check that are insta-breaks
|
||||
|
||||
// Remember this location. We ignore block breaks in the block-break
|
||||
// direction check that are insta-breaks
|
||||
data.instaBrokeBlockLocation = event.getBlock().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(cc.blockbreak.check && cc.blockbreak.directionCheck)
|
||||
s.add("blockbreak.direction");
|
||||
if(cc.blockbreak.check && cc.blockbreak.reachCheck)
|
||||
s.add("blockbreak.reach");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(!(cc.blockbreak.check && cc.blockbreak.directionCheck))
|
||||
s.add("blockbreak.direction");
|
||||
if(!(cc.blockbreak.check && cc.blockbreak.reachCheck))
|
||||
s.add("blockbreak.reach");
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -23,7 +26,7 @@ import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class BlockPlaceEventManager extends BlockListener {
|
||||
public class BlockPlaceEventManager extends BlockListener implements EventManager {
|
||||
|
||||
private final MovingCheck movingCheck;
|
||||
private final BlockPlaceCheck blockPlaceCheck;
|
||||
@ -77,4 +80,28 @@ public class BlockPlaceEventManager extends BlockListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(cc.blockplace.check && cc.blockplace.onliquidCheck)
|
||||
s.add("blockplace.onliquid");
|
||||
if(cc.blockplace.check && cc.blockplace.reachCheck)
|
||||
s.add("blockplace.reach");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(!(cc.blockplace.check && cc.blockplace.onliquidCheck))
|
||||
s.add("blockplace.onliquid");
|
||||
if(!(cc.blockplace.check && cc.blockplace.reachCheck))
|
||||
s.add("blockplace.reach");
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
12
src/cc/co/evenprime/bukkit/nocheat/events/EventManager.java
Normal file
12
src/cc/co/evenprime/bukkit/nocheat/events/EventManager.java
Normal file
@ -0,0 +1,12 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
|
||||
|
||||
public interface EventManager {
|
||||
|
||||
public List<String> getActiveChecks(ConfigurationCache cc);
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc);
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -16,7 +19,12 @@ import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.ChatData;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
|
||||
public class PlayerChatEventManager extends PlayerListener {
|
||||
/**
|
||||
*
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerChatEventManager extends PlayerListener implements EventManager {
|
||||
|
||||
private final ChatCheck chatCheck;
|
||||
private final DataManager data;
|
||||
@ -59,4 +67,23 @@ public class PlayerChatEventManager extends PlayerListener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(cc.chat.check && cc.chat.spamCheck)
|
||||
s.add("chat.spam");
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(!(cc.chat.check && cc.chat.spamCheck))
|
||||
s.add("chat.spam");
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -21,7 +24,7 @@ import cc.co.evenprime.bukkit.nocheat.data.InteractData;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerInteractEventManager extends PlayerListener {
|
||||
public class PlayerInteractEventManager extends PlayerListener implements EventManager {
|
||||
|
||||
private final InteractCheck interactCheck;
|
||||
private final DataManager data;
|
||||
@ -65,4 +68,23 @@ public class PlayerInteractEventManager extends PlayerListener {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(cc.interact.check && cc.interact.durabilityCheck)
|
||||
s.add("interact.durability");
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(!(cc.interact.check && cc.interact.durabilityCheck))
|
||||
s.add("interact.durability");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
@ -8,9 +11,7 @@ import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.ConfigurationManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,7 +20,7 @@ import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerItemDropEventManager extends PlayerListener {
|
||||
public class PlayerItemDropEventManager extends PlayerListener implements EventManager {
|
||||
|
||||
public PlayerItemDropEventManager(NoCheat plugin) {
|
||||
|
||||
@ -36,4 +37,14 @@ public class PlayerItemDropEventManager extends PlayerListener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
return new LinkedList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
return new LinkedList<String>();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,7 +21,6 @@ import cc.co.evenprime.bukkit.nocheat.config.ConfigurationManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
|
||||
/**
|
||||
* The only place that listens to and modifies player_move events if necessary
|
||||
@ -29,17 +31,15 @@ import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerMoveEventManager extends PlayerListener {
|
||||
public class PlayerMoveEventManager extends PlayerListener implements EventManager {
|
||||
|
||||
private final MovingCheck movingCheck;
|
||||
|
||||
private final ConfigurationManager config;
|
||||
private final LogManager log;
|
||||
private final DataManager data;
|
||||
|
||||
public PlayerMoveEventManager(NoCheat plugin) {
|
||||
this.config = plugin.getConfigurationManager();
|
||||
this.log = plugin.getLogManager();
|
||||
this.data = plugin.getDataManager();
|
||||
|
||||
this.movingCheck = new MovingCheck(plugin);
|
||||
@ -119,4 +119,44 @@ public class PlayerMoveEventManager extends PlayerListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(cc.moving.check && cc.moving.flyingCheck)
|
||||
s.add("moving.flying");
|
||||
if(cc.moving.check && cc.moving.runningCheck)
|
||||
s.add("moving.running");
|
||||
if(cc.moving.check && cc.moving.runningCheck && cc.moving.swimmingCheck)
|
||||
s.add("moving.swimming");
|
||||
if(cc.moving.check && cc.moving.runningCheck && cc.moving.sneakingCheck)
|
||||
s.add("moving.sneaking");
|
||||
if(cc.moving.check && cc.moving.morePacketsCheck)
|
||||
s.add("moving.morepackets");
|
||||
if(cc.moving.check && cc.moving.noclipCheck)
|
||||
s.add("moving.noclip");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
||||
if(!(cc.moving.check && cc.moving.flyingCheck))
|
||||
s.add("moving.flying");
|
||||
if(!(cc.moving.check && cc.moving.runningCheck))
|
||||
s.add("moving.running");
|
||||
if(!(cc.moving.check && cc.moving.runningCheck && cc.moving.swimmingCheck))
|
||||
s.add("moving.running.swimming");
|
||||
if(!(cc.moving.check && cc.moving.runningCheck && cc.moving.sneakingCheck))
|
||||
s.add("moving.running.sneaking");
|
||||
if(!(cc.moving.check && cc.moving.morePacketsCheck))
|
||||
s.add("moving.morepackets");
|
||||
if(!(cc.moving.check && cc.moving.noclipCheck))
|
||||
s.add("moving.noclip");
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.events;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,9 +15,9 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.DataManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.MovingData;
|
||||
import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
|
||||
/**
|
||||
* Only place that listens to Player-teleport related events and dispatches them
|
||||
@ -23,14 +26,12 @@ import cc.co.evenprime.bukkit.nocheat.log.LogManager;
|
||||
* @author Evenprime
|
||||
*
|
||||
*/
|
||||
public class PlayerTeleportEventManager extends PlayerListener {
|
||||
public class PlayerTeleportEventManager extends PlayerListener implements EventManager {
|
||||
|
||||
private final LogManager log;
|
||||
private final DataManager data;
|
||||
|
||||
public PlayerTeleportEventManager(NoCheat plugin) {
|
||||
|
||||
this.log = plugin.getLogManager();
|
||||
this.data = plugin.getDataManager();
|
||||
|
||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||
@ -90,4 +91,14 @@ public class PlayerTeleportEventManager extends PlayerListener {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInactiveChecks(ConfigurationCache cc) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user