From 447cf1e56575054ea599190a18c70187d98dafb6 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 May 2012 22:01:41 -0400 Subject: [PATCH] Verbose startup option added, also bread is food! --- .../java/net/h31ix/anticheat/Anticheat.java | 38 +++++++++++++++++++ .../net/h31ix/anticheat/Configuration.java | 14 ++++++- .../net/h31ix/anticheat/manage/Utilities.java | 1 + src/main/resources/config.yml | 3 +- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java index c72999c..7cfe2ab 100644 --- a/src/main/java/net/h31ix/anticheat/Anticheat.java +++ b/src/main/java/net/h31ix/anticheat/Anticheat.java @@ -27,6 +27,8 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import net.h31ix.anticheat.event.*; import net.h31ix.anticheat.manage.AnticheatManager; import net.h31ix.anticheat.xray.XRayListener; @@ -39,13 +41,23 @@ public class Anticheat extends JavaPlugin private final List eventList = new ArrayList(); private static boolean update = false; private static final int BYTE_SIZE = 1024; + private static final Logger logger = Logger.getLogger("Minecraft"); + private static boolean verbose; @Override public void onDisable() { if(update && AnticheatManager.CONFIGURATION.autoUpdate()) { + if(verbose) + { + logger.log(Level.INFO,"[AC] Installing the new update..."); + } saveFile("plugins\\AntiCheat.jar", "http://dl.dropbox.com/u/38228324/AntiCheat.jar"); + if(verbose) + { + logger.log(Level.INFO,"[AC] New version of AntiCheat installed."); + } } } @@ -53,9 +65,14 @@ public class Anticheat extends JavaPlugin public void onEnable() { plugin = this; + verbose = AnticheatManager.CONFIGURATION.verboseStartup(); checkForUpdate(); if(!new File("plugins/AntiCheat/config.yml").exists()) { + if(verbose) + { + logger.log(Level.INFO,"[AC] Config file created"); + } saveDefaultConfig(); } eventList.add(new PlayerListener()); @@ -69,8 +86,17 @@ public class Anticheat extends JavaPlugin for(Listener listener : eventList) { getServer().getPluginManager().registerEvents(listener, this); + if(verbose) + { + logger.log(Level.INFO,"[AC] Registered events for ".concat(listener.toString())); + } } getCommand("anticheat").setExecutor(new CommandHandler()); + if(verbose) + { + logger.log(Level.INFO,"[AC] Registered commands"); + logger.log(Level.INFO,"[AC] Finished loading."); + } } private void saveFile(String file, String url) @@ -114,6 +140,10 @@ public class Anticheat extends JavaPlugin private void checkForUpdate() { + if(verbose) + { + logger.log(Level.INFO,"[AC] Checking for updates..."); + } URL url = null; URLConnection urlConn = null; InputStreamReader inStream = null; @@ -143,9 +173,17 @@ public class Anticheat extends JavaPlugin if (!this.getDescription().getVersion().equalsIgnoreCase(v)) { update = true; + if(verbose) + { + logger.log(Level.INFO,"[AC] An update was found."); + } } else { + if(verbose) + { + logger.log(Level.INFO,"[AC] No update found."); + } update = false; } } diff --git a/src/main/java/net/h31ix/anticheat/Configuration.java b/src/main/java/net/h31ix/anticheat/Configuration.java index 6ad7c19..31a29c4 100644 --- a/src/main/java/net/h31ix/anticheat/Configuration.java +++ b/src/main/java/net/h31ix/anticheat/Configuration.java @@ -35,6 +35,7 @@ public class Configuration { private boolean logConsole; private boolean logXRay; private boolean autoUpdate; + private boolean verboseStartup; private List worlds = new ArrayList(); public Configuration() @@ -67,6 +68,11 @@ public class Configuration { public boolean autoUpdate() { return autoUpdate; + } + + public boolean verboseStartup() + { + return verboseStartup; } public final void load() @@ -103,6 +109,12 @@ public class Configuration { save(); } autoUpdate = config.getBoolean("System.Auto update"); + if(config.getString("System.Verbose startup") == null) + { + config.set("System.Verbose startup", false); + save(); + } + verboseStartup = config.getBoolean("System.Verbose startup"); } public String getResult(String event) @@ -132,5 +144,5 @@ public class Configuration { public boolean checkInWorld(World world) { return worlds.contains(world.getName()); - } + } } diff --git a/src/main/java/net/h31ix/anticheat/manage/Utilities.java b/src/main/java/net/h31ix/anticheat/manage/Utilities.java index ae94ab9..39324c7 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/manage/Utilities.java @@ -110,6 +110,7 @@ public final class Utilities FOOD.add(Material.GOLDEN_APPLE); FOOD.add(Material.MELON); FOOD.add(Material.COOKIE); + FOOD.add(Material.BREAD); FOOD.add(Material.SPIDER_EYE); FOOD.add(Material.ROTTEN_FLESH); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 413cf40..8637127 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -14,4 +14,5 @@ System: #Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so. #AntiCheat will never bother you about updates if this is on, but if you turn it off you will have to manually update. Auto update: true - Log to console: false \ No newline at end of file + Log to console: false + Verbose startup: false \ No newline at end of file