2012-04-26 23:36:43 +02:00
|
|
|
package fr.neatmonster.nocheatplus;
|
2012-04-05 18:24:39 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
|
|
|
import org.bukkit.plugin.PluginDescriptionFile;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
import fr.neatmonster.nocheatplus.checks.WorkaroundsListener;
|
|
|
|
import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakListener;
|
|
|
|
import fr.neatmonster.nocheatplus.checks.blockplace.BlockPlaceListener;
|
|
|
|
import fr.neatmonster.nocheatplus.checks.chat.ChatListener;
|
|
|
|
import fr.neatmonster.nocheatplus.checks.fight.FightListener;
|
|
|
|
import fr.neatmonster.nocheatplus.checks.inventory.InventoryListener;
|
|
|
|
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
|
|
|
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
|
|
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
|
|
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
|
|
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
|
|
|
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
2012-04-05 18:24:39 +02:00
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
public class NoCheatPlus extends JavaPlugin implements Listener {
|
|
|
|
public static NoCheatPlus instance = null;
|
2012-04-05 18:24:39 +02:00
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
public static boolean skipCheck() {
|
|
|
|
return instance.lagMeasureTask == null ? false : instance.lagMeasureTask.skipCheck();
|
2012-04-05 18:24:39 +02:00
|
|
|
}
|
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
private CommandHandler commandHandler;
|
|
|
|
private LagMeasureTask lagMeasureTask;
|
|
|
|
private List<Listener> listeners;
|
2012-04-05 18:24:39 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
|
|
|
|
|
|
|
final PluginDescriptionFile pdfFile = getDescription();
|
|
|
|
|
|
|
|
if (lagMeasureTask != null) {
|
|
|
|
lagMeasureTask.cancel();
|
|
|
|
lagMeasureTask = null;
|
|
|
|
}
|
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
ConfigManager.cleanup();
|
2012-04-05 18:24:39 +02:00
|
|
|
|
|
|
|
// Just to be sure nothing gets left out
|
|
|
|
getServer().getScheduler().cancelTasks(this);
|
|
|
|
|
|
|
|
commandHandler = null;
|
|
|
|
|
|
|
|
System.out.println("[NoCheatPlus] version [" + pdfFile.getVersion() + "] is disabled.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2012-04-26 23:36:43 +02:00
|
|
|
instance = this;
|
2012-04-05 18:24:39 +02:00
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
commandHandler = new CommandHandler();
|
2012-04-05 18:24:39 +02:00
|
|
|
// Then read the configuration files
|
2012-04-26 23:36:43 +02:00
|
|
|
ConfigManager.init();
|
2012-04-05 18:24:39 +02:00
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
listeners = new ArrayList<Listener>();
|
2012-04-05 18:24:39 +02:00
|
|
|
// Then set up the event listeners
|
2012-04-26 23:36:43 +02:00
|
|
|
listeners.add(new WorkaroundsListener());
|
|
|
|
listeners.add(new BlockBreakListener());
|
|
|
|
listeners.add(new BlockPlaceListener());
|
|
|
|
listeners.add(new ChatListener());
|
|
|
|
listeners.add(new FightListener());
|
|
|
|
listeners.add(new InventoryListener());
|
|
|
|
listeners.add(new MovingListener());
|
2012-04-05 18:24:39 +02:00
|
|
|
|
|
|
|
// Then set up a task to monitor server lag
|
|
|
|
if (lagMeasureTask == null) {
|
2012-04-26 23:36:43 +02:00
|
|
|
lagMeasureTask = new LagMeasureTask();
|
2012-04-05 18:24:39 +02:00
|
|
|
lagMeasureTask.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
// register all listeners
|
2012-04-26 23:36:43 +02:00
|
|
|
for (final Listener listener : listeners)
|
|
|
|
Bukkit.getPluginManager().registerEvents(listener, this);
|
2012-04-05 18:24:39 +02:00
|
|
|
|
|
|
|
Bukkit.getPluginManager().registerEvents(this, this);
|
|
|
|
|
2012-04-26 23:36:43 +02:00
|
|
|
getCommand("nocheatplus").setExecutor(commandHandler);
|
|
|
|
|
|
|
|
ConfigManager.writeInstructions();
|
2012-04-05 18:24:39 +02:00
|
|
|
|
|
|
|
// Tell the server admin that we finished loading NoCheatPlus now
|
|
|
|
System.out.println("[NoCheatPlus] version [" + getDescription().getVersion() + "] is enabled.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(
|
|
|
|
ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
|
|
public void onPlayerJoin(final PlayerJoinEvent event) {
|
|
|
|
final Player player = event.getPlayer();
|
2012-04-26 23:36:43 +02:00
|
|
|
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_ALLOWCLIENTMODS))
|
2012-04-05 22:17:41 +02:00
|
|
|
return;
|
2012-04-05 18:24:39 +02:00
|
|
|
String message = "";
|
|
|
|
// Disable Zombe's fly mod
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.ZOMBE_FLY))
|
2012-04-05 18:24:39 +02:00
|
|
|
message = message + "§f §f §1 §0 §2 §4";
|
2012-04-05 22:17:41 +02:00
|
|
|
// Disable Zombe's noclip
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.ZOMBE_NOCLIP))
|
2012-04-05 22:17:41 +02:00
|
|
|
message = message + "§f §f §4 §0 §9 §6";
|
2012-04-11 23:17:14 +02:00
|
|
|
// Disable Zombe's cheat
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.ZOMBE_CHEAT))
|
2012-04-05 18:24:39 +02:00
|
|
|
message = message + "§f §f §2 §0 §4 §8";
|
|
|
|
// Disable CJB's fly mod
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.CJB_FLY))
|
2012-04-05 18:24:39 +02:00
|
|
|
message = message + "§3 §9 §2 §0 §0 §1";
|
2012-04-05 22:17:41 +02:00
|
|
|
// Disable CJB's xray
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.CJB_XRAY))
|
2012-04-05 18:24:39 +02:00
|
|
|
message = message + "§3 §9 §2 §0 §0 §2";
|
2012-04-11 23:17:14 +02:00
|
|
|
// Disable CJB's radar
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.CJB_RADAR))
|
2012-04-05 18:24:39 +02:00
|
|
|
message = message + "§3 §9 §2 §0 §0 §3";
|
2012-04-05 22:17:41 +02:00
|
|
|
// Disable Rei's Minimap's cave mode
|
2012-05-08 18:49:17 +02:00
|
|
|
if (NCPPlayer.hasPermission(player, Permissions.REI_CAVE))
|
2012-04-05 22:17:41 +02:00
|
|
|
message = message + "§0§0§1§e§f";
|
|
|
|
// Disable Rei's Minimap's radar
|
2012-05-08 18:49:17 +02:00
|
|
|
if (NCPPlayer.hasPermission(player, Permissions.REI_RADAR))
|
2012-04-05 22:17:41 +02:00
|
|
|
message = message + "§0§0§2§3§4§5§6§7§e§f";
|
2012-04-11 23:17:14 +02:00
|
|
|
// Disable Minecraft AutoMap's ores
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.MINECRAFTAUTOMAP_ORES))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§0§1§f§e";
|
|
|
|
// Disable Minecraft AutoMap's cave mode
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.MINECRAFTAUTOMAP_CAVE))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§0§2§f§e";
|
|
|
|
// Disable Minecraft AutoMap's radar
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.MINECRAFTAUTOMAP_RADAR))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§0§3§4§5§6§7§8§f§e";
|
|
|
|
// Disable Smart Moving's climbing
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_CLIMBING))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§1§0§1§2§f§f";
|
|
|
|
// Disable Smart Moving's climbing
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_SWIMMING))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§1§3§4§f§f";
|
|
|
|
// Disable Smart Moving's climbing
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_CRAWLING))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§1§5§f§f";
|
|
|
|
// Disable Smart Moving's climbing
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_SLIDING))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§1§6§f§f";
|
|
|
|
// Disable Smart Moving's climbing
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_JUMPING))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§1§8§9§a§b§f§f";
|
|
|
|
// Disable Smart Moving's climbing
|
2012-05-08 18:49:17 +02:00
|
|
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_FLYING))
|
2012-04-11 23:17:14 +02:00
|
|
|
message = message + "§0§1§7§f§f";
|
2012-04-05 18:24:39 +02:00
|
|
|
player.sendMessage(message);
|
|
|
|
}
|
|
|
|
}
|