mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Clean up
This commit is contained in:
1 parent
6706a97097
commit
c3ef3ca560
4 files changed
+65
-64
No files matched your search
@@ -44,17 +44,17 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Anticheat extends JavaPlugin {
|
||||
private static AnticheatManager manager;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static boolean update = false;
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static Metrics metrics;
|
||||
private static final long XRAY_TIME = 1200;
|
||||
public static final String SPY_METADATA = "ac-spydata";
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
private static AnticheatManager manager;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static boolean update = false;
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static Metrics metrics;
|
||||
private static final long XRAY_TIME = 1200;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
manager = new AnticheatManager(this, getLogger());
|
||||
eventList.add(new PlayerListener());
|
||||
eventList.add(new BlockListener());
|
||||
@@ -84,10 +84,10 @@ public class Anticheat extends JavaPlugin {
|
||||
if (verbose) {
|
||||
getLogger().log(Level.INFO, "Finished loading.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
AnticheatManager.close();
|
||||
for (User user : manager.getUserManager().getUsers()) {
|
||||
config.saveLevel(user.getName(), user.getLevel());
|
||||
@@ -95,9 +95,9 @@ public class Anticheat extends JavaPlugin {
|
||||
config.saveLevels();
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private boolean save(InputStream in, File file) {
|
||||
}
|
||||
|
||||
private boolean save(InputStream in, File file) {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
@@ -118,9 +118,9 @@ public class Anticheat extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setupXray() {
|
||||
}
|
||||
|
||||
private void setupXray() {
|
||||
final XRayTracker xtracker = manager.getXRayTracker();
|
||||
if (config.logXRay()) {
|
||||
eventList.add(new XRayListener());
|
||||
@@ -146,25 +146,25 @@ public class Anticheat extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupEvents() {
|
||||
}
|
||||
|
||||
private void setupEvents() {
|
||||
for (Listener listener : eventList) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
if (verbose) {
|
||||
getLogger().log(Level.INFO, "Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
if (verbose) {
|
||||
getLogger().log(Level.INFO, "Registered commands.");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupUpdater() {
|
||||
}
|
||||
|
||||
private void setupUpdater() {
|
||||
if (config.autoUpdate()) {
|
||||
if (verbose) {
|
||||
getLogger().log(Level.INFO, "Checking for a new update...");
|
||||
@@ -175,9 +175,9 @@ public class Anticheat extends JavaPlugin {
|
||||
getLogger().log(Level.INFO, "Update available: " + update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
try {
|
||||
metrics = new Metrics(this);
|
||||
final EventListener listener = new EventListener();
|
||||
@@ -209,9 +209,9 @@ public class Anticheat extends JavaPlugin {
|
||||
getLogger().log(Level.INFO, "Metrics started.");
|
||||
}
|
||||
} catch (IOException ex) {}
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
config = manager.getConfiguration();
|
||||
checkConfigs();
|
||||
config.load();
|
||||
@@ -219,9 +219,9 @@ public class Anticheat extends JavaPlugin {
|
||||
if (verbose) {
|
||||
getLogger().log(Level.INFO, "Setup the config.");
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreLevels() {
|
||||
}
|
||||
|
||||
private void restoreLevels() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
String name = player.getName();
|
||||
manager.getUserManager().addUser(new User(player.getName(), config.getLevel(name)));
|
||||
@@ -229,37 +229,37 @@ public class Anticheat extends JavaPlugin {
|
||||
getLogger().log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkConfigs() {
|
||||
}
|
||||
|
||||
public void checkConfigs() {
|
||||
save(getResource("config.yml"), new File(getDataFolder() + "/config.yml"));
|
||||
save(getResource("lang.yml"), new File(getDataFolder() + "/lang.yml"));
|
||||
save(getResource("magic.yml"), new File(getDataFolder() + "/magic.yml"));
|
||||
if(save(getResource("events.yml"), new File(getDataFolder() + "/events.yml"))) {
|
||||
config.setUpdateEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin() {
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin() {
|
||||
return manager.getPlugin();
|
||||
}
|
||||
|
||||
public static AnticheatManager getManager() {
|
||||
}
|
||||
|
||||
public static AnticheatManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static boolean isUpdated() {
|
||||
}
|
||||
|
||||
public static boolean isUpdated() {
|
||||
return !update;
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
eventList = null;
|
||||
manager = null;
|
||||
config = null;
|
||||
metrics = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,10 +160,10 @@ public class CommandHandler implements CommandExecutor {
|
||||
p.hidePlayer(sender);
|
||||
}
|
||||
}
|
||||
if (!sender.hasMetadata(Anticheat.SPY_METADATA)) // Maintain ORIGINAL location and other data
|
||||
if (!sender.hasMetadata(Utilities.SPY_METADATA)) // Maintain ORIGINAL location and other data
|
||||
{
|
||||
SpyState state = new SpyState(sender.getAllowFlight(), sender.isFlying(), sender.getLocation());
|
||||
sender.setMetadata(Anticheat.SPY_METADATA, new FixedMetadataValue(Anticheat.getPlugin(), state));
|
||||
sender.setMetadata(Utilities.SPY_METADATA, new FixedMetadataValue(Anticheat.getPlugin(), state));
|
||||
}
|
||||
sender.setAllowFlight(true);
|
||||
sender.setFlying(true);
|
||||
@@ -176,12 +176,12 @@ public class CommandHandler implements CommandExecutor {
|
||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||
}
|
||||
} else {
|
||||
if (sender.hasMetadata(Anticheat.SPY_METADATA)) {
|
||||
SpyState state = ((SpyState) sender.getMetadata(Anticheat.SPY_METADATA).get(0).value());
|
||||
if (sender.hasMetadata(Utilities.SPY_METADATA)) {
|
||||
SpyState state = ((SpyState) sender.getMetadata(Utilities.SPY_METADATA).get(0).value());
|
||||
sender.setAllowFlight(state.getAllowFlight());
|
||||
sender.setFlying(state.getFlying());
|
||||
sender.teleport(state.getLocation());
|
||||
sender.removeMetadata(Anticheat.SPY_METADATA, Anticheat.getPlugin());
|
||||
sender.removeMetadata(Utilities.SPY_METADATA, Anticheat.getPlugin());
|
||||
for (Player p : cs.getServer().getOnlinePlayers()) {
|
||||
p.showPlayer(sender);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ public class PlayerListener extends EventListener {
|
||||
} else {
|
||||
getUserManager().addUserFromFile(player.getName());
|
||||
}
|
||||
if (player.hasMetadata(Anticheat.SPY_METADATA)) {
|
||||
if (player.hasMetadata(Utilities.SPY_METADATA)) {
|
||||
for (Player p : player.getServer().getOnlinePlayers()) {
|
||||
if (!Permission.SYSTEM_SPY.get(p)) {
|
||||
p.hidePlayer(player);
|
||||
|
||||
@@ -44,6 +44,7 @@ public final class Utilities {
|
||||
private static final List<Material> SHOVELS = new ArrayList<Material>();
|
||||
private static final List<Material> ANY = new ArrayList<Material>();
|
||||
private static final Map<Material, Material> COMBO = new HashMap<Material, Material>();
|
||||
public static final String SPY_METADATA = "ac-spydata";
|
||||
|
||||
/**
|
||||
* Send a hack level alert to players and console
|
||||
|
||||
Reference in new issue
Block a user