104 lines
2.8 KiB
Java
104 lines
2.8 KiB
Java
package cc.fascinated.config;
|
|
|
|
import cc.fascinated.Aetheria;
|
|
import cc.fascinated.utils.io.Config;
|
|
import lombok.Getter;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
@Getter
|
|
public enum Lang {
|
|
|
|
PREFIX("prefix"),
|
|
PREFIX_FORMAT("prefix-format"),
|
|
ADMIN_PREFIX("admin-prefix"),
|
|
HELP_COMMAND("help-command"),
|
|
GIT_COMMAND("git-command"),
|
|
SEED_COMMAND("seed-command"),
|
|
TOTAL_JOINS_COMMAND("total-joins-command"),
|
|
WORLD_SIZE_COMMAND_HEADER("world-size-command.header"),
|
|
WORLD_SIZE_COMMAND_FORMAT("world-size-command.format"),
|
|
WORLD_SIZE_COMMAND_FOOTER("world-size-command.footer"),
|
|
VOTE_COMMAND_HEADER("vote-command.header"),
|
|
VOTE_COMMAND_FORMAT("vote-command.format"),
|
|
VOTE_COMMAND_LINKS("vote-command.links"),
|
|
VOTE_STATS_COMMAND("vote-stats-command"),
|
|
SAVE_ACCOUNTS_COMMAND_SAVING("save-accounts-command.saving"),
|
|
SAVE_ACCOUNTS_COMMAND_SAVED("save-accounts-command.saved"),
|
|
BLOCKED_MESSAGE("blocked-message"),
|
|
BLOCKED_MESSAGE_ALERT("blocked-message-alert"),
|
|
CHAT_FORMAT("chat-format"),
|
|
FIRST_JOIN_MESSAGE("first-join-message"),
|
|
JOIN_MESSAGE("join-message"),
|
|
QUIT_MESSAGE("quit-message"),
|
|
COMMAND_SPY_ENABLED("command-spy.toggled-on"),
|
|
COMMAND_SPY_DISABLED("command-spy.toggled-off"),
|
|
COMMAND_SPY_FORMAT("command-spy.format"),
|
|
RENDER_DISTANCE_MESSAGE("render-distance-message"),
|
|
VOTE_VOTED("vote.voted"),
|
|
VOTE_BROADCAST("vote.broadcast"),
|
|
STAFF_CHAT_FORMAT("staff-chat.format"),
|
|
STAFF_CHAT_USAGE("staff-chat.usage");
|
|
|
|
/**
|
|
* The path of the lang in the lang.yml file.
|
|
*/
|
|
private final String path;
|
|
|
|
Lang(String path) {
|
|
this.path = path;
|
|
}
|
|
|
|
/**
|
|
* Cache of the lang values.
|
|
*/
|
|
private static final HashMap<String, Object> cache = new HashMap<>();
|
|
|
|
/**
|
|
* The lang configuration.
|
|
*/
|
|
private final Config langConfig = new Config(Aetheria.INSTANCE, "lang.yml", null);
|
|
|
|
/**
|
|
* Gets as an object.
|
|
*
|
|
* @return the string
|
|
*/
|
|
public Object get() {
|
|
return cache.computeIfAbsent(path, key -> {
|
|
FileConfiguration configuration = langConfig.getFileConfiguration();
|
|
if (configuration.get(path) == null) {
|
|
throw new IllegalArgumentException("Path " + path + " does not exist in the lang.yml file.");
|
|
}
|
|
return configuration.get(path);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Gets as a string.
|
|
*
|
|
* @return the string
|
|
*/
|
|
public String getAsString() {
|
|
return (String) get();
|
|
}
|
|
|
|
/**
|
|
* Gets as a string list.
|
|
*
|
|
* @return the string list
|
|
*/
|
|
public List<String> getAsStringList() {
|
|
return (List<String>) get();
|
|
}
|
|
|
|
/**
|
|
* Clear the cache.
|
|
*/
|
|
public static void clear() {
|
|
cache.clear();
|
|
}
|
|
}
|