diff --git a/src/main/java/com/gmail/nossr50/database/Database.java b/src/main/java/com/gmail/nossr50/database/Database.java index 26ce333db..9bb7de207 100644 --- a/src/main/java/com/gmail/nossr50/database/Database.java +++ b/src/main/java/com/gmail/nossr50/database/Database.java @@ -18,7 +18,7 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.runnables.SQLReconnect; import com.gmail.nossr50.skills.SkillType; -import com.gmail.nossr50.spout.SpoutStuff; +import com.gmail.nossr50.spout.SpoutTools; import com.gmail.nossr50.spout.huds.SpoutHud; import com.gmail.nossr50.util.Users; @@ -577,7 +577,7 @@ public final class Database { Users.addUser(player); if (mcMMO.spoutEnabled) { - SpoutStuff.reloadSpoutPlayer(player); + SpoutTools.reloadSpoutPlayer(player); } } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 47586e5ea..12d1441cc 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -76,8 +76,8 @@ import com.gmail.nossr50.skills.swords.SwordsCommand; import com.gmail.nossr50.skills.taming.TamingCommand; import com.gmail.nossr50.skills.unarmed.UnarmedCommand; import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand; -import com.gmail.nossr50.spout.SpoutStart; -import com.gmail.nossr50.spout.SpoutStuff; +import com.gmail.nossr50.spout.SpoutConfig; +import com.gmail.nossr50.spout.SpoutTools; import com.gmail.nossr50.spout.commands.MchudCommand; import com.gmail.nossr50.spout.commands.XplockCommand; import com.gmail.nossr50.util.Anniversary; @@ -115,7 +115,7 @@ public class mcMMO extends JavaPlugin { private static String modDirectory; // Spout Check - public static boolean spoutEnabled; + public static boolean spoutEnabled = false; // XP Event Check private boolean xpEventEnabled = false; @@ -128,10 +128,15 @@ public class mcMMO extends JavaPlugin { p = this; setupFilePaths(); - if (p.getServer().getPluginManager().getPlugin("Spout") != null) { + // Check for Spout + if (getServer().getPluginManager().getPlugin("Spout") != null) { spoutEnabled = true; - SpoutStuff.preCacheFiles(); + SpoutConfig.getInstance(); + SpoutTools.setupSpoutConfigs(); + SpoutTools.registerCustomEvent(); + SpoutTools.preCacheFiles(); + SpoutTools.reloadSpoutPlayers(); // Handle spout players after a /reload } // Force the loading of config files @@ -203,8 +208,6 @@ public class mcMMO extends JavaPlugin { BukkitScheduler scheduler = getServer().getScheduler(); - // Schedule Spout Activation 1 second after start-up - scheduler.scheduleSyncDelayedTask(this, new SpoutStart(), 20); // Periodic save timer (Saves every 10 minutes by default) scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), 0, configInstance.getSaveInterval() * 1200); // Regen & Cooldown timer (Runs every second) diff --git a/src/main/java/com/gmail/nossr50/skills/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/SkillTools.java index b2d63dcbf..3c7648ee2 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillTools.java @@ -15,7 +15,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.spout.SpoutConfig; -import com.gmail.nossr50.spout.SpoutStuff; +import com.gmail.nossr50.spout.SpoutTools; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModChecks; import com.gmail.nossr50.util.Permissions; @@ -248,7 +248,7 @@ public class SkillTools { SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player); if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) { - SpoutStuff.levelUpNotification(skillType, spoutPlayer); + SpoutTools.levelUpNotification(skillType, spoutPlayer); /* Update custom titles */ if (SpoutConfig.getInstance().getShowPowerLevel()) { diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java index c48b40bf3..b0cb6aba3 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutListener.java @@ -33,7 +33,7 @@ public class SpoutListener implements Listener { PlayerProfile profile = mcMMOPlayer.getProfile(); //TODO: Add custom titles based on skills - if (SpoutStuff.showPowerLevel) { + if (SpoutTools.showPowerLevel) { spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", new Object[] {spoutPlayer.getName(), mcMMOPlayer.getPowerLevel()})); } @@ -82,7 +82,7 @@ public class SpoutListener implements Listener { return; } - if (event.getKey() == SpoutStuff.menuKey) { + if (event.getKey() == SpoutTools.menuKey) { SpoutHud spoutHud = Users.getProfile(spoutPlayer).getSpoutHud(); if (!spoutHud.isMenuOpened()) { diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutStart.java b/src/main/java/com/gmail/nossr50/spout/SpoutStart.java deleted file mode 100644 index ad9946232..000000000 --- a/src/main/java/com/gmail/nossr50/spout/SpoutStart.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.gmail.nossr50.spout; - -import com.gmail.nossr50.mcMMO; - -public class SpoutStart implements Runnable{ - - @Override - public void run() { - //Spout Stuff - if (mcMMO.spoutEnabled) { - SpoutConfig.getInstance(); - SpoutStuff.setupSpoutConfigs(); - SpoutStuff.registerCustomEvent(); - - //Handle spout players after a /reload - SpoutStuff.reloadSpoutPlayers(); - } - } -} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java b/src/main/java/com/gmail/nossr50/spout/SpoutTools.java similarity index 94% rename from src/main/java/com/gmail/nossr50/spout/SpoutStuff.java rename to src/main/java/com/gmail/nossr50/spout/SpoutTools.java index 4bfd931d2..9d34775d7 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutTools.java @@ -28,7 +28,7 @@ import com.gmail.nossr50.skills.SkillTools; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Users; -public class SpoutStuff { +public class SpoutTools { private static mcMMO plugin = mcMMO.p; static AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -57,6 +57,11 @@ public class SpoutStuff { try { File currentFile = new File(theFilePath + theFileName); + // No point in writing the file again if it already exists. + if (currentFile.exists()) { + return; + } + jar = new JarFile(mcMMO.mcmmo); JarEntry entry = jar.getJarEntry("resources/" + theFileName); is = jar.getInputStream(entry); @@ -595,11 +600,9 @@ public class SpoutStuff { } public static void preCacheFiles() { - if (mcMMO.spoutEnabled) { - extractFiles(); //Extract source materials - - FileManager FM = SpoutManager.getFileManager(); - FM.addToPreLoginCache(plugin, getFiles()); - } + extractFiles(); //Extract source materials + + FileManager FM = SpoutManager.getFileManager(); + FM.addToPreLoginCache(plugin, getFiles()); } }