mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Caching options is bad, and so was that way of getting the menu key.
This commit is contained in:
parent
36bdb8a63e
commit
00dee500e0
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.config.spout;
|
||||
|
||||
import org.getspout.spoutapi.keyboard.Keyboard;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
@ -34,7 +36,14 @@ public class SpoutConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
|
||||
public Keyboard getMenuKey() {
|
||||
try {
|
||||
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return Keyboard.KEY_M;
|
||||
}
|
||||
}
|
||||
|
||||
/* XP Bar */
|
||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||
|
@ -11,13 +11,13 @@ import org.getspout.spoutapi.gui.Button;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||
|
||||
public class SpoutListener implements Listener {
|
||||
|
||||
@ -32,7 +32,7 @@ public class SpoutListener implements Listener {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer);
|
||||
|
||||
// TODO: Add custom titles based on skills
|
||||
if (SpoutUtils.showPowerLevel) {
|
||||
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public class SpoutListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey() == SpoutUtils.menuKey) {
|
||||
if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) {
|
||||
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
|
||||
|
||||
if (!spoutHud.isMenuOpened()) {
|
||||
|
@ -321,7 +321,6 @@ public class mcMMO extends JavaPlugin {
|
||||
spoutEnabled = true;
|
||||
|
||||
SpoutConfig.getInstance();
|
||||
SpoutUtils.setupSpoutConfigs();
|
||||
SpoutUtils.registerCustomEvent();
|
||||
SpoutUtils.preCacheFiles();
|
||||
SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload
|
||||
|
@ -13,13 +13,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.keyboard.Keyboard;
|
||||
import org.getspout.spoutapi.player.FileManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.listeners.SpoutListener;
|
||||
@ -37,10 +35,8 @@ public class SpoutUtils {
|
||||
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
||||
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
||||
|
||||
public static boolean showPowerLevel;
|
||||
|
||||
private final static SpoutListener spoutListener = new SpoutListener();
|
||||
public static Keyboard menuKey;
|
||||
// public static Keyboard menuKey;
|
||||
|
||||
/**
|
||||
* Write file to disk.
|
||||
@ -148,25 +144,6 @@ public class SpoutUtils {
|
||||
writeFile("level.wav", soundDirectory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Spout config options
|
||||
*/
|
||||
public static void setupSpoutConfigs() {
|
||||
showPowerLevel = SpoutConfig.getInstance().getShowPowerLevel();
|
||||
String temp = SpoutConfig.getInstance().getMenuKey();
|
||||
|
||||
for (Keyboard x : Keyboard.values()) {
|
||||
if (x.toString().equalsIgnoreCase(temp)) {
|
||||
menuKey = x;
|
||||
}
|
||||
}
|
||||
|
||||
if (menuKey == null) {
|
||||
mcMMO.p.getLogger().warning("Invalid KEY for Menu.Key, using KEY_M");
|
||||
menuKey = Keyboard.KEY_M;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the Spout files in the Resources folder.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user