mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 11:03:43 +01:00 
			
		
		
		
	Better way to get the HUD type.
This commit is contained in:
		@@ -14,16 +14,15 @@ public class MchudCommand extends SpoutCommand {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
 | 
					    protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
 | 
				
			||||||
        for (HudType hudType : HudType.values()) {
 | 
					        try {
 | 
				
			||||||
            if (hudType.toString().equalsIgnoreCase(args[0])) {
 | 
					            playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
 | 
				
			||||||
                playerProfile.setHudType(hudType);
 | 
					 | 
				
			||||||
            spoutHud.initializeXpBar();
 | 
					            spoutHud.initializeXpBar();
 | 
				
			||||||
            spoutHud.updateXpBar();
 | 
					            spoutHud.updateXpBar();
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					        catch (IllegalArgumentException ex) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
 | 
					            sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,11 +6,9 @@ import com.gmail.nossr50.datatypes.spout.huds.HudType;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class SpoutConfig extends ConfigLoader {
 | 
					public class SpoutConfig extends ConfigLoader {
 | 
				
			||||||
    private static SpoutConfig instance;
 | 
					    private static SpoutConfig instance;
 | 
				
			||||||
    public HudType defaultHudType;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private SpoutConfig() {
 | 
					    private SpoutConfig() {
 | 
				
			||||||
        super("spout.yml");
 | 
					        super("spout.yml");
 | 
				
			||||||
        loadKeys();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static SpoutConfig getInstance() {
 | 
					    public static SpoutConfig getInstance() {
 | 
				
			||||||
@@ -24,17 +22,14 @@ public class SpoutConfig extends ConfigLoader {
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void loadKeys() {
 | 
					    protected void loadKeys() {
 | 
				
			||||||
        // Setup default HUD
 | 
					        // Setup default HUD
 | 
				
			||||||
        String temp = config.getString("Spout.HUD.Default", "STANDARD");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (HudType hudType : HudType.values()) {
 | 
					 | 
				
			||||||
            if (hudType.toString().equalsIgnoreCase(temp)) {
 | 
					 | 
				
			||||||
                defaultHudType = hudType;
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (defaultHudType == null) {
 | 
					    public HudType getDefaultHudType() {
 | 
				
			||||||
            defaultHudType = HudType.STANDARD;
 | 
					        try {
 | 
				
			||||||
 | 
					            return HudType.valueOf(config.getString("Spout.HUD.Default", "STANDARD").toUpperCase().trim());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (IllegalArgumentException ex) {
 | 
				
			||||||
 | 
					            return HudType.STANDARD;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ public class PlayerProfile {
 | 
				
			|||||||
        mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
 | 
					        mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (mcMMO.spoutEnabled) {
 | 
					        if (mcMMO.spoutEnabled) {
 | 
				
			||||||
            hudType = SpoutConfig.getInstance().defaultHudType;
 | 
					            hudType = SpoutConfig.getInstance().getDefaultHudType();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            hudType = HudType.DISABLED;
 | 
					            hudType = HudType.DISABLED;
 | 
				
			||||||
@@ -94,11 +94,7 @@ public class PlayerProfile {
 | 
				
			|||||||
            DatabaseManager.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
 | 
					            DatabaseManager.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            for (HudType type : HudType.values()) {
 | 
					            hudType = HudType.valueOf(huds.get(1).get(0));
 | 
				
			||||||
                if (type.toString().equalsIgnoreCase(huds.get(1).get(0))) {
 | 
					 | 
				
			||||||
                    hudType = type;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        mobHealthbarType = MobHealthbarType.valueOf(DatabaseManager.read("SELECT mobhealthbar FROM " + tablePrefix + "huds WHERE user_id = " + userId).get(1).get(0));
 | 
					        mobHealthbarType = MobHealthbarType.valueOf(DatabaseManager.read("SELECT mobhealthbar FROM " + tablePrefix + "huds WHERE user_id = " + userId).get(1).get(0));
 | 
				
			||||||
@@ -312,11 +308,7 @@ public class PlayerProfile {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (character.length > 33) {
 | 
					                if (character.length > 33) {
 | 
				
			||||||
                    for (HudType type : HudType.values()) {
 | 
					                    hudType = HudType.valueOf(character[33]);
 | 
				
			||||||
                        if (type.toString().equalsIgnoreCase(character[33])) {
 | 
					 | 
				
			||||||
                            hudType = type;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (character.length > 34) {
 | 
					                if (character.length > 34) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user