Spout support cleanup

This commit is contained in:
TfT_02 2014-02-15 16:37:06 +01:00
parent fe17906047
commit e380ef440b
4 changed files with 18 additions and 16 deletions

View File

@ -975,6 +975,14 @@ public class McMMOPlayer {
profile.resetCooldowns();
}
public McMMOHud getSpoutHud() {
return profile.getSpoutHud();
}
public void setSpoutHud(McMMOHud spoutHud) {
profile.setSpoutHud(spoutHud);
}
public FixedMetadataValue getPlayerMetadata() {
return playerMetadata;
}

View File

@ -39,7 +39,7 @@ public class SpoutListener implements Listener {
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel()));
}
mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
mcMMOPlayer.setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
}
/**
@ -66,7 +66,7 @@ public class SpoutListener implements Listener {
if (event.getScreen() instanceof McMMOMenu) {
SpoutPlayer spoutPlayer = event.getPlayer();
UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud().onMenuClose();
UserManager.getPlayer(spoutPlayer).getSpoutHud().onMenuClose();
spoutPlayer.getMainScreen().setDirty(true);
}
}
@ -77,7 +77,7 @@ public class SpoutListener implements Listener {
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onKeyPressedEvent(KeyPressedEvent event) {
public void onKeyPressed(KeyPressedEvent event) {
SpoutPlayer spoutPlayer = event.getPlayer();
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
@ -85,7 +85,7 @@ public class SpoutListener implements Listener {
}
if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) {
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getSpoutHud();
if (!spoutHud.isMenuOpened()) {
spoutHud.openMenu();

View File

@ -129,7 +129,7 @@ public class mcMMO extends JavaPlugin {
getLogger().setFilter(new LogFilter(this));
metadataValue = new FixedMetadataValue(this, true);
setupSpout();
spoutEnabled = getServer().getPluginManager().getPlugin("Spout") != null;
mcpcEnabled = getServer().getName().equals("MCPC+");
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
@ -138,6 +138,10 @@ public class mcMMO extends JavaPlugin {
setupFilePaths();
if (spoutEnabled) {
setupSpout();
}
modManager = new ModManager();
loadConfigFiles();
@ -445,12 +449,6 @@ public class mcMMO extends JavaPlugin {
}
private void setupSpout() {
if (!getServer().getPluginManager().isPluginEnabled("Spout")) {
return;
}
spoutEnabled = true;
SpoutConfig.getInstance();
getServer().getPluginManager().registerEvents(new SpoutListener(), this);
SpoutUtils.preCacheFiles();

View File

@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.util.player.UserManager;
@ -153,15 +152,12 @@ public final class Misc {
public static void profileCleanup(String playerName) {
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOHud spoutHud = mcMMOPlayer.getProfile().getSpoutHud();
McMMOHud spoutHud = UserManager.getPlayer(player).getSpoutHud();
if (spoutHud != null) {
spoutHud.removeWidgets();
}
UserManager.remove(playerName);
if (player != null) {
UserManager.remove(player);
UserManager.addUser(player);