mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Finished tidying up our Spout checking.
This commit is contained in:
parent
d09cd49f01
commit
d3b0da4186
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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()) {
|
||||
|
@ -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()) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user