Initial commit: LoChat v1.0.0 with Gradient module
This commit is contained in:
commit
252b0a60db
86 changed files with 8922 additions and 0 deletions
60
src/main/java/com/loki/lochat/config/MessageConfig.java
Normal file
60
src/main/java/com/loki/lochat/config/MessageConfig.java
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package com.loki.lochat.config;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MessageConfig {
|
||||
|
||||
private final LoChat plugin;
|
||||
private FileConfiguration messages;
|
||||
private File messagesFile;
|
||||
|
||||
public MessageConfig(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
loadMessages();
|
||||
}
|
||||
|
||||
private void loadMessages() {
|
||||
messagesFile = new File(plugin.getDataFolder(), "messages.yml");
|
||||
if (!messagesFile.exists()) {
|
||||
plugin.saveResource("messages.yml", false);
|
||||
}
|
||||
messages = YamlConfiguration.loadConfiguration(messagesFile);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
loadMessages();
|
||||
}
|
||||
|
||||
public String get(String path) {
|
||||
return messages.getString(path, "<red>Message not found: " + path + "</red>");
|
||||
}
|
||||
|
||||
public String get(String path, String... replacements) {
|
||||
String message = get(path);
|
||||
for (int i = 0; i < replacements.length - 1; i += 2) {
|
||||
message = message.replace(replacements[i], replacements[i + 1]);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
public String getPrefix() {
|
||||
return get("prefix");
|
||||
}
|
||||
|
||||
public String getNoPermission() {
|
||||
return get("errors.no-permission");
|
||||
}
|
||||
|
||||
public String getPlayerNotFound() {
|
||||
return get("errors.player-not-found");
|
||||
}
|
||||
|
||||
public String getInvalidUsage(String usage) {
|
||||
return get("errors.invalid-usage", "{usage}", usage);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue