Advertisement
Guest User

SnowGrow.java

a guest
Feb 11th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. package musaddict.snowgrow;
  2.  
  3. import java.io.File;
  4. import java.util.logging.Level;
  5. import java.util.logging.Logger;
  6.  
  7. import org.bukkit.plugin.PluginDescriptionFile;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. public class SnowGrow extends JavaPlugin {
  11.     public static PluginDescriptionFile info;
  12.     private static Logger log;
  13.     public static WorldData worldData;
  14.     private SnowGrowCommands commands;
  15.  
  16.     @Override
  17.     public void onEnable() {
  18.         info = getDescription();
  19.         log = Logger.getLogger("Minecraft");
  20.         getConfig().options().copyDefaults(true);
  21.         saveConfig();
  22.         worldData = new WorldData("plugins" + File.separator + info.getName());
  23.         commands = new SnowGrowCommands(this);
  24.  
  25.         Log("is enabled, version: " + info.getVersion());
  26.         Log("written by [Musaddict, Feed_Dante]");
  27.  
  28.         if (!worldData.loadWorldData())
  29.             SnowGrow.Log(Level.SEVERE, "Error loading world data");
  30.  
  31.         getCommand("snow").setExecutor(new SnowGrowCommands(this));
  32.  
  33.         getServer().getPluginManager().registerEvents(new AutoGrowListeners(this), this);
  34.     }
  35.  
  36.     public static void Log(String message) {
  37.         log.log(Level.INFO, "[" + info.getName() + "] " + message);
  38.     }
  39.  
  40.     public static void Log(Level logLevel, String message) {
  41.         log.log(logLevel, "[" + info.getName() + "] " + message);
  42.     }
  43.  
  44.     @Override
  45.     public void onDisable() {
  46.         for (String playerName : commands.playerSnow.keySet())
  47.             commands.new StopTasks(getServer().getPlayer(playerName), commands.playerSnow.get(playerName)).run();
  48.  
  49.         if (!worldData.saveWorldData())
  50.             SnowGrow.Log(Level.SEVERE, "Error saving world data");
  51.  
  52.         Log("was successfully disabled.");
  53.  
  54.         info = null;
  55.         log = null;
  56.         worldData = null;
  57.         commands = null;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement