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.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<Listener> eventList = new ArrayList<Listener>();
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;
}
}
@@ -35,6 +35,7 @@ public class Configuration {
private boolean logConsole;
private boolean logXRay;
private boolean autoUpdate;
private boolean verboseStartup;
private List<String> worlds = new ArrayList<String>();
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());
}
}
}
@@ -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);
}