// Path: src/com/github/jamesnorris/ablockalypse/Ablockalypse.java
// public class Ablockalypse extends JavaPlugin {
//     private static Ablockalypse instance;
//     private static DataContainer data = new DataContainer();
//     private static MainThread mainThread;
//     private static External external;
//     private static BaseCommand commandInstance;
//     private static Tracker tracker;
// 
//     public static BaseCommand getBaseCommandInstance() {
//         return commandInstance;
//     }
// 
//     public static DataContainer getData() {
//         return data;
//     }
// 
//     public static External getExternal() {
//         return external;
//     }
// 
//     public static Ablockalypse getInstance() {
//         return instance;
//     }
// 
//     public static MainThread getMainThread() {
//         return mainThread;
//     }
// 
//     public static Tracker getTracker() {
//         return tracker;
//     }
// 
//     // Kills the plugin.
//     protected static void kill() {
//         Ablockalypse.instance.setEnabled(false);
//     }
// 
//     @Override public void onDisable() {
//         for (Game game : data.getObjectsOfType(Game.class)) {
//             game.organizeObjects();
//             PermanentAspect.save(game, external.getSavedDataFile(game.getName(), true));
//             if ((Boolean) Setting.PRINT_STORAGE_DATA_TO_FILE.getSetting()) {
//                 try {
//                     PermanentAspect.printData(game);
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//             game.remove(false);
//         }
//         for (PlayerState state : PlayerJoin.toLoad) {
//             PlayerQuit.playerSaves.put(state.getPlayer().getPlayer(), state);
//         }
//         for (Player player : PlayerQuit.playerSaves.keySet()) {
//             PlayerState state = PlayerQuit.playerSaves.get(player);
//             PermanentAspect.save(state, external.getSavedPlayerDataFile(player, true));
//         }
//         mainThread.cancel();
//     }
// 
//     @SuppressWarnings("unchecked") @Override public void onEnable() {
//         Ablockalypse.instance = this;
//         external = new External(this);
//         tracker = new Tracker("Ablockalypse", getDescription().getVersion(), "https://github.com/JamesNorris/Ablockalypse/issues", (Integer) Setting.MAX_FATALITY.getSetting());
//         commandInstance = new BaseCommand();
//         register();
//         initServerThreads(false);
//         try {
//             for (File file : external.getSavedDataFolder().listFiles()) {
//                 if (file != null && !file.isDirectory()) {
//                     Map<String, Object> save = (Map<String, Object>) External.load(file);
//                     PermanentAspect.load(Game.class, save);
//                 }
//             }
//             for (File file : external.getSavedPlayerDataFolder().listFiles()) {
//                 if (file != null && !file.isDirectory()) {
//                     Map<String, Object> save = (Map<String, Object>) External.load(file);
//                     PlayerJoin.toLoad.add((PlayerState) PermanentAspect.load(PlayerState.class, save));
//                     file.delete();
//                 }
//             }
//         } catch (EOFException e) {
//             // nothing, the file is empty and no data was saved
//         } catch (IOException e) {
//             e.printStackTrace();
//         } catch (ClassNotFoundException e) {
//             e.printStackTrace();
//         }
//         mainThread.run();// starts the main thread, which was told not to autorun earlier. Done to prevent NPEs with loading saves and running threads.
//     }
// 
//     protected void initServerThreads(boolean startMain) {
//         mainThread = new MainThread(startMain);
//         new ServerBarrierActionTask(true);
//         new ServerMobSpawnPreventionTask(360, (Boolean) Setting.CLEAR_MOBS.getSetting());
//         new ServerHellhoundActionTask(20, true);
//         new ServerTeleporterActionTask(20, true);
//     }
// 
//     protected void register() {
//         PluginManager pm = getServer().getPluginManager();
//         /* EVENTS */
//         for (Listener listener : new Listener[] {new EntityDamage(), new PlayerDeath(), new PlayerInteract(),
//                 new SignChange(), new EntityDeath(), new PlayerPickupItem(), new ProjectileHit(), new PlayerMove(),
//                 new EntityBreakDoor(), new PlayerTeleport(), new PlayerQuit(), new EntityTarget(), new PlayerRespawn(),
//                 new EntityExplode(), new EntityDamageByEntity(), new PlayerJoin(), new BlockBreak(),
//                 new PlayerDropItem(), new PlayerKick(), new BlockPlace(), new BlockRedstone(), new PlayerToggleSneak()}) {
//             pm.registerEvents(listener, instance);
//         }
//         /* COMMANDS */
//         instance.getCommand("za").setExecutor(commandInstance);
//     }
// }


import org.bukkit.Bukkit;
import com.github.jamesnorris.ablockalypse.Ablockalypse;
package com.github.jamesnorris.ablockalypse.threading;



public class MainThread {
    private int id = -1, interval = 1;

    public MainThread(boolean autorun) {
        if (autorun) {
            run();
        }
    }

    public synchronized void cancel() {
        Bukkit.getScheduler().cancelTask(id);
// Path: src/com/github/jamesnorris/ablockalypse/Ablockalypse.java
// public class Ablockalypse extends JavaPlugin {
//     private static Ablockalypse instance;
//     private static DataContainer data = new DataContainer();
//     private static MainThread mainThread;
//     private static External external;
//     private static BaseCommand commandInstance;
//     private static Tracker tracker;
// 
//     public static BaseCommand getBaseCommandInstance() {
//         return commandInstance;
//     }
// 
//     public static DataContainer getData() {
//         return data;
//     }
// 
//     public static External getExternal() {
//         return external;
//     }
// 
//     public static Ablockalypse getInstance() {
//         return instance;
//     }
// 
//     public static MainThread getMainThread() {
//         return mainThread;
//     }
// 
//     public static Tracker getTracker() {
//         return tracker;
//     }
// 
//     // Kills the plugin.
//     protected static void kill() {
//         Ablockalypse.instance.setEnabled(false);
//     }
// 
//     @Override public void onDisable() {
//         for (Game game : data.getObjectsOfType(Game.class)) {
//             game.organizeObjects();
//             PermanentAspect.save(game, external.getSavedDataFile(game.getName(), true));
//             if ((Boolean) Setting.PRINT_STORAGE_DATA_TO_FILE.getSetting()) {
//                 try {
//                     PermanentAspect.printData(game);
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//             game.remove(false);
//         }
//         for (PlayerState state : PlayerJoin.toLoad) {
//             PlayerQuit.playerSaves.put(state.getPlayer().getPlayer(), state);
//         }
//         for (Player player : PlayerQuit.playerSaves.keySet()) {
//             PlayerState state = PlayerQuit.playerSaves.get(player);
//             PermanentAspect.save(state, external.getSavedPlayerDataFile(player, true));
//         }
//         mainThread.cancel();
//     }
// 
//     @SuppressWarnings("unchecked") @Override public void onEnable() {
//         Ablockalypse.instance = this;
//         external = new External(this);
//         tracker = new Tracker("Ablockalypse", getDescription().getVersion(), "https://github.com/JamesNorris/Ablockalypse/issues", (Integer) Setting.MAX_FATALITY.getSetting());
//         commandInstance = new BaseCommand();
//         register();
//         initServerThreads(false);
//         try {
//             for (File file : external.getSavedDataFolder().listFiles()) {
//                 if (file != null && !file.isDirectory()) {
//                     Map<String, Object> save = (Map<String, Object>) External.load(file);
//                     PermanentAspect.load(Game.class, save);
//                 }
//             }
//             for (File file : external.getSavedPlayerDataFolder().listFiles()) {
//                 if (file != null && !file.isDirectory()) {
//                     Map<String, Object> save = (Map<String, Object>) External.load(file);
//                     PlayerJoin.toLoad.add((PlayerState) PermanentAspect.load(PlayerState.class, save));
//                     file.delete();
//                 }
//             }
//         } catch (EOFException e) {
//             // nothing, the file is empty and no data was saved
//         } catch (IOException e) {
//             e.printStackTrace();
//         } catch (ClassNotFoundException e) {
//             e.printStackTrace();
//         }
//         mainThread.run();// starts the main thread, which was told not to autorun earlier. Done to prevent NPEs with loading saves and running threads.
//     }
// 
//     protected void initServerThreads(boolean startMain) {
//         mainThread = new MainThread(startMain);
//         new ServerBarrierActionTask(true);
//         new ServerMobSpawnPreventionTask(360, (Boolean) Setting.CLEAR_MOBS.getSetting());
//         new ServerHellhoundActionTask(20, true);
//         new ServerTeleporterActionTask(20, true);
//     }
// 
//     protected void register() {
//         PluginManager pm = getServer().getPluginManager();
//         /* EVENTS */
//         for (Listener listener : new Listener[] {new EntityDamage(), new PlayerDeath(), new PlayerInteract(),
//                 new SignChange(), new EntityDeath(), new PlayerPickupItem(), new ProjectileHit(), new PlayerMove(),
//                 new EntityBreakDoor(), new PlayerTeleport(), new PlayerQuit(), new EntityTarget(), new PlayerRespawn(),
//                 new EntityExplode(), new EntityDamageByEntity(), new PlayerJoin(), new BlockBreak(),
//                 new PlayerDropItem(), new PlayerKick(), new BlockPlace(), new BlockRedstone(), new PlayerToggleSneak()}) {
//             pm.registerEvents(listener, instance);
//         }
//         /* COMMANDS */
//         instance.getCommand("za").setExecutor(commandInstance);
//     }
// }


// Path: src/com/github/jamesnorris/ablockalypse/threading/MainThread.java
import org.bukkit.Bukkit;
import com.github.jamesnorris.ablockalypse.Ablockalypse;

package com.github.jamesnorris.ablockalypse.threading;



public class MainThread {
    private int id = -1, interval = 1;

    public MainThread(boolean autorun) {
        if (autorun) {
            run();
        }
    }

    public synchronized void cancel() {
        Bukkit.getScheduler().cancelTask(id);
        id = -1;