mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-09-06 12:38:07 +02:00
Fix Colors not saving correctly. Closes #26
This commit is contained in:
parent
04346f0efc
commit
f7bdffa365
@ -11,35 +11,48 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
enum EnglishChatColor {
|
||||
AQUA(ChatColor.AQUA),
|
||||
BLACK(ChatColor.BLACK),
|
||||
BLUE(ChatColor.BLUE),
|
||||
DARKAQUA(ChatColor.DARK_AQUA),
|
||||
DARKBLUE(ChatColor.DARK_BLUE),
|
||||
DARKGRAY(ChatColor.DARK_GRAY),
|
||||
DARKGREEN(ChatColor.DARK_GREEN),
|
||||
DARKPURPLE(ChatColor.DARK_PURPLE),
|
||||
DARKRED(ChatColor.DARK_RED),
|
||||
GOLD(ChatColor.GOLD),
|
||||
GRAY(ChatColor.GRAY),
|
||||
GREEN(ChatColor.GREEN),
|
||||
LIGHTPURPLE(ChatColor.LIGHT_PURPLE),
|
||||
RED(ChatColor.RED),
|
||||
YELLOW(ChatColor.YELLOW),
|
||||
WHITE(ChatColor.WHITE);
|
||||
AQUA("AQUA", ChatColor.AQUA),
|
||||
BLACK("BLACK", ChatColor.BLACK),
|
||||
BLUE("BLUE", ChatColor.BLUE),
|
||||
DARKAQUA("DARKAQUA", ChatColor.DARK_AQUA),
|
||||
DARKBLUE("DARKBLUE", ChatColor.DARK_BLUE),
|
||||
DARKGRAY("DARKGRAY", ChatColor.DARK_GRAY),
|
||||
DARKGREEN("DARKGREEN", ChatColor.DARK_GREEN),
|
||||
DARKPURPLE("DARKPURPLE", ChatColor.DARK_PURPLE),
|
||||
DARKRED("DARKRED", ChatColor.DARK_RED),
|
||||
GOLD("GOLD", ChatColor.GOLD),
|
||||
GRAY("GRAY", ChatColor.GRAY),
|
||||
GREEN("GREEN", ChatColor.GREEN),
|
||||
LIGHTPURPLE("LIGHTPURPLE", ChatColor.LIGHT_PURPLE),
|
||||
RED("RED", ChatColor.RED),
|
||||
YELLOW("YELLOW", ChatColor.YELLOW),
|
||||
WHITE("WHITE", ChatColor.WHITE);
|
||||
private ChatColor color;
|
||||
private String text;
|
||||
|
||||
EnglishChatColor(ChatColor color) {
|
||||
EnglishChatColor(String name, ChatColor color) {
|
||||
this.color = color;
|
||||
this.text = name;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.toString();
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public static EnglishChatColor fromString(String text) {
|
||||
if (text != null) {
|
||||
for (EnglishChatColor c : EnglishChatColor.values()) {
|
||||
if (text.equalsIgnoreCase(c.text)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return EnglishChatColor.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
public class MVWorld {
|
||||
@ -460,19 +473,10 @@ public class MVWorld {
|
||||
}
|
||||
|
||||
public void setAliasColor(String aliasColor) {
|
||||
try {
|
||||
this.aliasColor = EnglishChatColor.valueOf(aliasColor).getColor();
|
||||
} catch (Exception e) {
|
||||
this.aliasColor = ChatColor.WHITE;
|
||||
}
|
||||
if (this.aliasColor != null) {
|
||||
this.config.setProperty("worlds." + this.name + ".alias.color", aliasColor);
|
||||
this.config.save();
|
||||
} else {
|
||||
this.plugin.log(Level.WARNING, "Color \"" + aliasColor + "\" was not found.");
|
||||
this.aliasColor = ChatColor.WHITE;
|
||||
}
|
||||
|
||||
EnglishChatColor color = EnglishChatColor.fromString(aliasColor);
|
||||
this.aliasColor = color.getColor();
|
||||
this.config.setProperty("worlds." + this.name + ".alias.color", color.getText());
|
||||
this.config.save();
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user