mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Silly IntelliJ!
This commit is contained in:
1 parent
77ab0062b8
commit
d87d140743
2 files changed
+210
-211
No files matched your search
+210
-210
@@ -1,210 +1,210 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.h31ix.anticheat;
|
package net.h31ix.anticheat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import net.h31ix.anticheat.config.Configuration;
|
import net.h31ix.anticheat.config.Configuration;
|
||||||
import net.h31ix.anticheat.event.*;
|
import net.h31ix.anticheat.event.*;
|
||||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||||
import net.h31ix.anticheat.manage.User;
|
import net.h31ix.anticheat.manage.User;
|
||||||
import net.h31ix.anticheat.update.Updater;
|
import net.h31ix.anticheat.update.Updater;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.h31ix.anticheat.util.Utilities;
|
||||||
import net.h31ix.anticheat.xray.XRayListener;
|
import net.h31ix.anticheat.xray.XRayListener;
|
||||||
import net.h31ix.anticheat.xray.XRayTracker;
|
import net.h31ix.anticheat.xray.XRayTracker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class AntiCheat extends JavaPlugin {
|
public class AntiCheat extends JavaPlugin {
|
||||||
|
|
||||||
private static AnticheatManager manager;
|
private static AnticheatManager manager;
|
||||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||||
private static boolean update = false;
|
private static boolean update = false;
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean developer;
|
private static boolean developer;
|
||||||
private static final long XRAY_TIME = 1200;
|
private static final long XRAY_TIME = 1200;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
manager = new AnticheatManager(this, getLogger());
|
manager = new AnticheatManager(this, getLogger());
|
||||||
eventList.add(new PlayerListener());
|
eventList.add(new PlayerListener());
|
||||||
eventList.add(new BlockListener());
|
eventList.add(new BlockListener());
|
||||||
eventList.add(new EntityListener());
|
eventList.add(new EntityListener());
|
||||||
eventList.add(new VehicleListener());
|
eventList.add(new VehicleListener());
|
||||||
eventList.add(new InventoryListener());
|
eventList.add(new InventoryListener());
|
||||||
// Order is important in some cases, don't screw with these unless needed, especially config
|
// Order is important in some cases, don't screw with these unless needed, especially config
|
||||||
setupConfig();
|
setupConfig();
|
||||||
// Xray must come before events
|
// Xray must come before events
|
||||||
setupXray();
|
setupXray();
|
||||||
setupEvents();
|
setupEvents();
|
||||||
setupCommands();
|
setupCommands();
|
||||||
setupUpdater();
|
setupUpdater();
|
||||||
restoreLevels();
|
restoreLevels();
|
||||||
// Check if NoCheatPlus is installed
|
// Check if NoCheatPlus is installed
|
||||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||||
getLogger().severe("You are also running NoCheatPlus!");
|
getLogger().severe("You are also running NoCheatPlus!");
|
||||||
getLogger().severe("NoCheatPlus has been known to conflict with AntiCheat's results and create false cheat detections.");
|
getLogger().severe("NoCheatPlus has been known to conflict with AntiCheat's results and create false cheat detections.");
|
||||||
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
|
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 40L);
|
}, 40L);
|
||||||
// End tests
|
// End tests
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Finished loading.");
|
getLogger().log(Level.INFO, "Finished loading.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for (User user : manager.getUserManager().getUsers()) {
|
for (User user : manager.getUserManager().getUsers()) {
|
||||||
config.getLevels().saveLevel(user.getName(), user.getLevel());
|
config.getLevels().saveLevel(user.getName(), user.getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
AnticheatManager.close();
|
AnticheatManager.close();
|
||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupXray() {
|
private void setupXray() {
|
||||||
final XRayTracker xtracker = manager.getXRayTracker();
|
final XRayTracker xtracker = manager.getXRayTracker();
|
||||||
if (config.getConfig().logXRayStats.getValue()) {
|
if (config.getConfig().logXRayStats.getValue()) {
|
||||||
eventList.add(new XRayListener());
|
eventList.add(new XRayListener());
|
||||||
if (config.getConfig().alertWhenXRayIsFound.getValue()) {
|
if (config.getConfig().alertWhenXRayIsFound.getValue()) {
|
||||||
getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name)) {
|
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name)) {
|
||||||
List<String> alert = new ArrayList<String>();
|
List<String> alert = new ArrayList<String>();
|
||||||
alert.add(ChatColor.YELLOW + "[ALERT] " + ChatColor.WHITE + name + ChatColor.YELLOW + " might be using xray.");
|
alert.add(ChatColor.YELLOW + "[ALERT] " + ChatColor.WHITE + name + ChatColor.YELLOW + " might be using xray.");
|
||||||
alert.add(ChatColor.YELLOW + "[ALERT] Please check their xray stats using " + ChatColor.WHITE + "/anticheat xray " + name + ChatColor.YELLOW + ".");
|
alert.add(ChatColor.YELLOW + "[ALERT] Please check their xray stats using " + ChatColor.WHITE + "/anticheat xray " + name + ChatColor.YELLOW + ".");
|
||||||
Utilities.alert(alert);
|
Utilities.alert(alert);
|
||||||
xtracker.logAlert(name);
|
xtracker.logAlert(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, XRAY_TIME, XRAY_TIME);
|
}, XRAY_TIME, XRAY_TIME);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Scheduled the XRay checker.");
|
getLogger().log(Level.INFO, "Scheduled the XRay checker.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupEvents() {
|
private void setupEvents() {
|
||||||
for (Listener listener : eventList) {
|
for (Listener listener : eventList) {
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
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());
|
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Registered commands.");
|
getLogger().log(Level.INFO, "Registered commands.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupUpdater() {
|
private void setupUpdater() {
|
||||||
if (config.getConfig().autoUpdate.getValue()) {
|
if (config.getConfig().autoUpdate.getValue()) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Checking for a new update...");
|
getLogger().log(Level.INFO, "Checking for a new update...");
|
||||||
}
|
}
|
||||||
Updater updater = new Updater(this, "anticheat", this.getFile(), Updater.UpdateType.DEFAULT, false);
|
Updater updater = new Updater(this, "anticheat", this.getFile(), Updater.UpdateType.DEFAULT, false);
|
||||||
update = updater.getResult() != Updater.UpdateResult.NO_UPDATE;
|
update = updater.getResult() != Updater.UpdateResult.NO_UPDATE;
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Update available: " + update);
|
getLogger().log(Level.INFO, "Update available: " + update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupConfig() {
|
private void setupConfig() {
|
||||||
config = manager.getConfiguration();
|
config = manager.getConfiguration();
|
||||||
verbose = config.getConfig().verboseStartup.getValue();
|
verbose = config.getConfig().verboseStartup.getValue();
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Setup the config.");
|
getLogger().log(Level.INFO, "Setup the config.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreLevels() {
|
private void restoreLevels() {
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
manager.getUserManager().addUser(new User(player.getName(), config.getLevels().getLevel(name)));
|
manager.getUserManager().addUser(new User(player.getName(), config.getLevels().getLevel(name)));
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
getLogger().log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
getLogger().log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AntiCheat getPlugin() {
|
public static AntiCheat getPlugin() {
|
||||||
return manager.getPlugin();
|
return manager.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnticheatManager getManager() {
|
public static AnticheatManager getManager() {
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUpdated() {
|
public static boolean isUpdated() {
|
||||||
return !update;
|
return !update;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
return manager.getPlugin().getDescription().getVersion();
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
eventList = null;
|
eventList = null;
|
||||||
manager = null;
|
manager = null;
|
||||||
config = null;
|
config = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean developerMode() {
|
public static boolean developerMode() {
|
||||||
return developer;
|
return developer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDeveloperMode(boolean b) {
|
public static void setDeveloperMode(boolean b) {
|
||||||
developer = b;
|
developer = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(final String string) {
|
public static void debugLog(final String string) {
|
||||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if(developer) {
|
if(developer) {
|
||||||
manager.log("[DEBUG] " + string);
|
manager.log("[DEBUG] " + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,4 +74,3 @@ public class Config extends ConfigurationFile {
|
|||||||
exemptedWorlds = new ConfigValue<List<String>>("Disable in");
|
exemptedWorlds = new ConfigValue<List<String>>("Disable in");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user