mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-02 16:59:56 +01: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;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
enum EnglishChatColor {
|
enum EnglishChatColor {
|
||||||
AQUA(ChatColor.AQUA),
|
AQUA("AQUA", ChatColor.AQUA),
|
||||||
BLACK(ChatColor.BLACK),
|
BLACK("BLACK", ChatColor.BLACK),
|
||||||
BLUE(ChatColor.BLUE),
|
BLUE("BLUE", ChatColor.BLUE),
|
||||||
DARKAQUA(ChatColor.DARK_AQUA),
|
DARKAQUA("DARKAQUA", ChatColor.DARK_AQUA),
|
||||||
DARKBLUE(ChatColor.DARK_BLUE),
|
DARKBLUE("DARKBLUE", ChatColor.DARK_BLUE),
|
||||||
DARKGRAY(ChatColor.DARK_GRAY),
|
DARKGRAY("DARKGRAY", ChatColor.DARK_GRAY),
|
||||||
DARKGREEN(ChatColor.DARK_GREEN),
|
DARKGREEN("DARKGREEN", ChatColor.DARK_GREEN),
|
||||||
DARKPURPLE(ChatColor.DARK_PURPLE),
|
DARKPURPLE("DARKPURPLE", ChatColor.DARK_PURPLE),
|
||||||
DARKRED(ChatColor.DARK_RED),
|
DARKRED("DARKRED", ChatColor.DARK_RED),
|
||||||
GOLD(ChatColor.GOLD),
|
GOLD("GOLD", ChatColor.GOLD),
|
||||||
GRAY(ChatColor.GRAY),
|
GRAY("GRAY", ChatColor.GRAY),
|
||||||
GREEN(ChatColor.GREEN),
|
GREEN("GREEN", ChatColor.GREEN),
|
||||||
LIGHTPURPLE(ChatColor.LIGHT_PURPLE),
|
LIGHTPURPLE("LIGHTPURPLE", ChatColor.LIGHT_PURPLE),
|
||||||
RED(ChatColor.RED),
|
RED("RED", ChatColor.RED),
|
||||||
YELLOW(ChatColor.YELLOW),
|
YELLOW("YELLOW", ChatColor.YELLOW),
|
||||||
WHITE(ChatColor.WHITE);
|
WHITE("WHITE", ChatColor.WHITE);
|
||||||
private ChatColor color;
|
private ChatColor color;
|
||||||
|
private String text;
|
||||||
|
|
||||||
EnglishChatColor(ChatColor color) {
|
EnglishChatColor(String name, ChatColor color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.text = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return this.toString();
|
return this.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor() {
|
public ChatColor getColor() {
|
||||||
return this.color;
|
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 {
|
public class MVWorld {
|
||||||
@ -460,19 +473,10 @@ public class MVWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAliasColor(String aliasColor) {
|
public void setAliasColor(String aliasColor) {
|
||||||
try {
|
EnglishChatColor color = EnglishChatColor.fromString(aliasColor);
|
||||||
this.aliasColor = EnglishChatColor.valueOf(aliasColor).getColor();
|
this.aliasColor = color.getColor();
|
||||||
} catch (Exception e) {
|
this.config.setProperty("worlds." + this.name + ".alias.color", color.getText());
|
||||||
this.aliasColor = ChatColor.WHITE;
|
this.config.save();
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user