Verbose startup option added, also bread is food!

This commit is contained in:
Adam committed 2012-05-13 22:01:41 -04:00
1 parent a95f05d683
commit 447cf1e565
4 files changed
+54 -2

No files matched your search

@@ -27,6 +27,8 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
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.Logger;
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.xray.XRayListener; import net.h31ix.anticheat.xray.XRayListener;
@@ -39,13 +41,23 @@ public class Anticheat extends JavaPlugin
private final List<Listener> eventList = new ArrayList<Listener>(); private final List<Listener> eventList = new ArrayList<Listener>();
private static boolean update = false; private static boolean update = false;
private static final int BYTE_SIZE = 1024; private static final int BYTE_SIZE = 1024;
private static final Logger logger = Logger.getLogger("Minecraft");
private static boolean verbose;
@Override @Override
public void onDisable() public void onDisable()
{ {
if(update && AnticheatManager.CONFIGURATION.autoUpdate()) 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"); 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() public void onEnable()
{ {
plugin = this; plugin = this;
verbose = AnticheatManager.CONFIGURATION.verboseStartup();
checkForUpdate(); checkForUpdate();
if(!new File("plugins/AntiCheat/config.yml").exists()) if(!new File("plugins/AntiCheat/config.yml").exists())
{ {
if(verbose)
{
logger.log(Level.INFO,"[AC] Config file created");
}
saveDefaultConfig(); saveDefaultConfig();
} }
eventList.add(new PlayerListener()); eventList.add(new PlayerListener());
@@ -69,8 +86,17 @@ public class Anticheat extends JavaPlugin
for(Listener listener : eventList) for(Listener listener : eventList)
{ {
getServer().getPluginManager().registerEvents(listener, this); getServer().getPluginManager().registerEvents(listener, this);
if(verbose)
{
logger.log(Level.INFO,"[AC] Registered events for ".concat(listener.toString()));
}
} }
getCommand("anticheat").setExecutor(new CommandHandler()); 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) private void saveFile(String file, String url)
@@ -114,6 +140,10 @@ public class Anticheat extends JavaPlugin
private void checkForUpdate() private void checkForUpdate()
{ {
if(verbose)
{
logger.log(Level.INFO,"[AC] Checking for updates...");
}
URL url = null; URL url = null;
URLConnection urlConn = null; URLConnection urlConn = null;
InputStreamReader inStream = null; InputStreamReader inStream = null;
@@ -143,9 +173,17 @@ public class Anticheat extends JavaPlugin
if (!this.getDescription().getVersion().equalsIgnoreCase(v)) if (!this.getDescription().getVersion().equalsIgnoreCase(v))
{ {
update = true; update = true;
if(verbose)
{
logger.log(Level.INFO,"[AC] An update was found.");
}
} }
else else
{ {
if(verbose)
{
logger.log(Level.INFO,"[AC] No update found.");
}
update = false; update = false;
} }
} }
@@ -35,6 +35,7 @@ public class Configuration {
private boolean logConsole; private boolean logConsole;
private boolean logXRay; private boolean logXRay;
private boolean autoUpdate; private boolean autoUpdate;
private boolean verboseStartup;
private List<String> worlds = new ArrayList<String>(); private List<String> worlds = new ArrayList<String>();
public Configuration() public Configuration()
@@ -67,6 +68,11 @@ public class Configuration {
public boolean autoUpdate() public boolean autoUpdate()
{ {
return autoUpdate; return autoUpdate;
}
public boolean verboseStartup()
{
return verboseStartup;
} }
public final void load() public final void load()
@@ -103,6 +109,12 @@ public class Configuration {
save(); save();
} }
autoUpdate = config.getBoolean("System.Auto update"); 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) public String getResult(String event)
@@ -132,5 +144,5 @@ public class Configuration {
public boolean checkInWorld(World world) public boolean checkInWorld(World world)
{ {
return worlds.contains(world.getName()); return worlds.contains(world.getName());
} }
} }
@@ -110,6 +110,7 @@ public final class Utilities
FOOD.add(Material.GOLDEN_APPLE); FOOD.add(Material.GOLDEN_APPLE);
FOOD.add(Material.MELON); FOOD.add(Material.MELON);
FOOD.add(Material.COOKIE); FOOD.add(Material.COOKIE);
FOOD.add(Material.BREAD);
FOOD.add(Material.SPIDER_EYE); FOOD.add(Material.SPIDER_EYE);
FOOD.add(Material.ROTTEN_FLESH); FOOD.add(Material.ROTTEN_FLESH);
} }
+2 -1
View File
@@ -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. #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. #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 Auto update: true
Log to console: false Log to console: false
Verbose startup: false