Added in every language file the new configoption
This commit is contained in:
Butzlabben 2019-02-26 23:21:14 +01:00
parent ea9c7c5b5e
commit dcca582135
13 changed files with 232 additions and 222 deletions

View File

@ -99,7 +99,7 @@ public class WSCommand {
// Implementation check for #15
if (template.getCost() > 0) {
if (!MoneyUtil.hasMoney(p.getUniqueId(), template.getCost())) {
// TODO send not enough money message
p.sendMessage(MessageConfig.getNotEnoughMoney());
return;
}
MoneyUtil.removeMoney(p.getUniqueId(), template.getCost());

View File

@ -1,289 +1,287 @@
package de.butzlabben.world.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import de.butzlabben.world.WorldSystem;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import de.butzlabben.world.WorldSystem;
import net.md_5.bungee.api.ChatColor;
public class MessageConfig {
private MessageConfig() {
}
private MessageConfig() {
}
private static List<String> defaultCmdHelp = new ArrayList<>(20);
private static List<String> defaultCmdHelp = new ArrayList<>(20);
static {
defaultCmdHelp.add("/ws get §8- §7Will give you a World");
defaultCmdHelp.add("/ws home §8- §7Teleports you on your World");
defaultCmdHelp.add("/ws sethome §8- §7Sets a specific home");
defaultCmdHelp.add("/ws tp §8- §7Teleports you on a specific World");
defaultCmdHelp.add("/ws addmember §8- §7Adds a player to your World");
defaultCmdHelp.add("/ws delmember§8 - §7Removes a player from your World");
defaultCmdHelp.add("/ws tnt §8- §7Allows/Denys TNT on your World");
defaultCmdHelp.add("/ws fire §8- §7Allows/Denys Fire on your World");
defaultCmdHelp.add("/ws togglechgm §8- §7Allows/Denys a player changing gamemode");
defaultCmdHelp.add("/ws togglebuild §8- §7Allows/Denys a player building");
defaultCmdHelp.add("/ws toggletp §8- §7Allows/Denys a player teleporting");
defaultCmdHelp.add("/ws info §8- §7Shows information about the World");
defaultCmdHelp.add("/ws reset §8- §7Will reset your World");
}
static {
defaultCmdHelp.add("/ws get §8- §7Will give you a World");
defaultCmdHelp.add("/ws home §8- §7Teleports you on your World");
defaultCmdHelp.add("/ws sethome §8- §7Sets a specific home");
defaultCmdHelp.add("/ws tp §8- §7Teleports you on a specific World");
defaultCmdHelp.add("/ws addmember §8- §7Adds a player to your World");
defaultCmdHelp.add("/ws delmember§8 - §7Removes a player from your World");
defaultCmdHelp.add("/ws tnt §8- §7Allows/Denys TNT on your World");
defaultCmdHelp.add("/ws fire §8- §7Allows/Denys Fire on your World");
defaultCmdHelp.add("/ws togglechgm §8- §7Allows/Denys a player changing gamemode");
defaultCmdHelp.add("/ws togglebuild §8- §7Allows/Denys a player building");
defaultCmdHelp.add("/ws toggletp §8- §7Allows/Denys a player teleporting");
defaultCmdHelp.add("/ws info §8- §7Shows information about the World");
defaultCmdHelp.add("/ws reset §8- §7Will reset your World");
}
private static File file;
// private static HashMap<String, File> languages = new HashMap<>();
private static File file;
// private static HashMap<String, File> languages = new HashMap<>();
public static void checkConfig(File f) {
file = f;
if (file.exists() == false) {
try {
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource(f.getName());
if (in == null) {
in = JavaPlugin.getPlugin(WorldSystem.class).getResource("custom.yml");
}
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Config");
e.printStackTrace();
}
}
}
public static void checkConfig(File f) {
file = f;
if (file.exists() == false) {
try {
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource(f.getName());
private static YamlConfiguration getConfig() {
try {
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
if (in == null) {
in = JavaPlugin.getPlugin(WorldSystem.class).getResource("custom.yml");
}
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Config");
e.printStackTrace();
}
}
}
private static String getRawMessage(String path, String alt) {
return ChatColor.translateAlternateColorCodes('&', getConfig().getString(path, alt));
}
private static YamlConfiguration getConfig() {
try {
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
private static String getMessage(String path, String alt) {
return PluginConfig.getPrefix() + getRawMessage(path, alt);
}
private static String getRawMessage(String path, String alt) {
return ChatColor.translateAlternateColorCodes('&', getConfig().getString(path, alt));
}
public static String getNoPermission() {
return getMessage("nopermission", "§cYou don't have permissions!");
}
private static String getMessage(String path, String alt) {
return PluginConfig.getPrefix() + getRawMessage(path, alt);
}
public static String getSettingUpWorld() {
return getMessage("world.setting_up", "§aSetting up world...");
}
public static String getNoPermission() {
return getMessage("nopermission", "§cYou don't have permissions!");
}
public static String getPlayerList() {
return getMessage("world.playerlist", "Player in this world: %player");
}
public static String getSettingUpWorld() {
return getMessage("world.setting_up", "§aSetting up world...");
}
public static String getLagDetection() {
return getMessage("lagdetection", "Lagdetection in world from: §c%world");
}
public static String getPlayerList() {
return getMessage("world.playerlist", "Player in this world: %player");
}
public static String getWrongUsage() {
return getMessage("wrong_usage", "§c%usage");
}
public static String getLagDetection() {
return getMessage("lagdetection", "Lagdetection in world from: §c%world");
}
public static String getNoWorldOwn() {
return getMessage("world.does_not_exists.own", "§cYou don't have a world!");
}
public static String getWrongUsage() {
return getMessage("wrong_usage", "§c%usage");
}
public static String getNoWorldOther() {
return getMessage("world.does_not_exists.other", "§cThis player doesn't has a world!");
}
public static String getNoWorldOwn() {
return getMessage("world.does_not_exists.own", "§cYou don't have a world!");
}
public static String getNotRegistered() {
return getMessage("not_registered", "§cThis player hasn't joined yet!");
}
public static String getNoWorldOther() {
return getMessage("world.does_not_exists.other", "§cThis player doesn't has a world!");
}
public static String getAlreadyMember() {
return getMessage("member.already_added", "§cThis player is already a member!");
}
public static String getNotRegistered() {
return getMessage("not_registered", "§cThis player hasn't joined yet!");
}
public static String getMemberAdded() {
return getMessage("member.added", "You have added &c%player&6 to your World!");
}
public static String getAlreadyMember() {
return getMessage("member.already_added", "§cThis player is already a member!");
}
public static String getUnknownError() {
return getMessage("unknown_error", "§cSomething went wrong...");
}
public static String getMemberAdded() {
return getMessage("member.added", "You have added &c%player&6 to your World!");
}
public static String getDeleteWorldOwn() {
return getMessage("world.delete.own", "§cYour world was deleted!");
}
public static String getUnknownError() {
return getMessage("unknown_error", "§cSomething went wrong...");
}
public static String getDeleteWorldOther() {
return getMessage("world.delete.other", "You deleted the world of §c%player§6!");
}
public static String getDeleteWorldOwn() {
return getMessage("world.delete.own", "§cYour world was deleted!");
}
public static String getNoMemberOwn() {
return getMessage("member.not_added.own", "§cThis player isn't a member!");
}
public static String getDeleteWorldOther() {
return getMessage("world.delete.other", "You deleted the world of §c%player§6!");
}
public static String getMemberRemoved() {
return getMessage("member.removed", "You removed §c%player§6 from your world!");
}
public static String getNoMemberAdded() {
return getMessage("member.no_one_added", "§cThere are no members added");
}
public static String getNoMemberOwn() {
return getMessage("member.not_added.own", "§cThis player isn't a member!");
}
public static String getWorldAlreadyExists() {
return getMessage("world.already_exists", "§cYou already have a world!");
}
public static String getMemberRemoved() {
return getMessage("member.removed", "You removed §c%player§6 from your world!");
}
public static String getWorldCreated() {
return getMessage("world.created", "Your world is now ready. Get there with §a/ws home");
}
public static String getWorldStillCreating() {
return getMessage("world.still_creating", "§cWorld is still creating");
}
public static String getNoMemberAdded() {
return getMessage("member.no_one_added", "§cThere are no members added");
}
public static String getNotOnWorld() {
return getMessage("world.not_on", "§cYou are not on a world!");
}
public static String getWorldAlreadyExists() {
return getMessage("world.already_exists", "§cYou already have a world!");
}
public static String getWorldStillLoaded() {
return getMessage("world.still_loaded", "§cYour world is still loaded!");
}
public static String getWorldCreated() {
return getMessage("world.created", "Your world is now ready. Get there with §a/ws home");
}
public static String getNoRequestSend() {
return getMessage("request.not_sent", "§cYou didn't send a request!");
}
public static String getWorldStillCreating() {
return getMessage("world.still_creating", "§cWorld is still creating");
}
public static String getWorldReseted() {
return getMessage("world.reseted", "Your world was reseted!");
}
public static String getNotOnWorld() {
return getMessage("world.not_on", "§cYou are not on a world!");
}
public static String getInvalidInput() {
return getMessage("request.invalid_input", "§c%input is not a valid input!");
}
public static String getWorldStillLoaded() {
return getMessage("world.still_loaded", "§cYour world is still loaded!");
}
public static String getRequestAlreadySent() {
return getMessage("request.already_sent", "§cYou already sent a request!");
}
public static String getNoRequestSend() {
return getMessage("request.not_sent", "§cYou didn't send a request!");
}
public static String getRequestExpired() {
return getMessage("request.expired", "§cYou request is expired!");
}
public static String getWorldReseted() {
return getMessage("world.reseted", "Your world was reseted!");
}
public static String getTimeUntilExpires() {
return getMessage("request.until_expire", "§cYour request expires in %time seconds!");
}
public static String getInvalidInput() {
return getMessage("request.invalid_input", "§c%input is not a valid input!");
}
public static String getConfirmRequest() {
return getMessage("request.confirm", "§cPlease confirm reset of your world: %command");
}
public static String getRequestAlreadySent() {
return getMessage("request.already_sent", "§cYou already sent a request!");
}
public static String getNoMemberOther() {
return getMessage("member.not_added.other", "§cYou are not added to this world!");
}
public static String getRequestExpired() {
return getMessage("request.expired", "§cYou request is expired!");
}
public static String getInfoOwner() {
return getMessage("info.owner", "Owner: %data");
}
public static String getTimeUntilExpires() {
return getMessage("request.until_expire", "§cYour request expires in %time seconds!");
}
public static String getInfoId() {
return getMessage("info.id", "ID: %data");
}
public static String getConfirmRequest() {
return getMessage("request.confirm", "§cPlease confirm reset of your world: %command");
}
public static String getInfoMember() {
return getMessage("info.member", "Member: %data");
}
public static String getNoMemberOther() {
return getMessage("member.not_added.other", "§cYou are not added to this world!");
}
public static String getInfoTnt() {
return getMessage("info.tnt", "TNT: %data");
}
public static String getInfoOwner() {
return getMessage("info.owner", "Owner: %data");
}
public static String getInfoFire() {
return getMessage("info.fire", "Fire: %data");
}
public static String getInfoId() {
return getMessage("info.id", "ID: %data");
}
public static String getInfoEnabled() {
return getRawMessage("info.enabled", "§aOn");
}
public static String getInfoMember() {
return getMessage("info.member", "Member: %data");
}
public static String getInfoDisabled() {
return getRawMessage("info.disabled", "§cOff");
}
public static String getInfoTnt() {
return getMessage("info.tnt", "TNT: %data");
}
public static String getToggleGameModeEnabled() {
return getMessage("toggle.gamemode.enabled", "§a%player§6 can now change his gamemode!");
}
public static String getInfoFire() {
return getMessage("info.fire", "Fire: %data");
}
public static String getToggleGameModeDisabled() {
return getMessage("toggle.gamemode.disabled", "§c%player§6 can no longer change his gamemode!");
}
public static String getInfoEnabled() {
return getRawMessage("info.enabled", "§aOn");
}
public static String getToggleTeleportEnabled() {
return getMessage("toggle.teleport.enabled", "§a%player§6 can now teleport!");
}
public static String getInfoDisabled() {
return getRawMessage("info.disabled", "§cOff");
}
public static String getToggleTeleportDisabled() {
return getMessage("toggle.teleport.disabled", "§c%player§6 can no longer teleport!");
}
public static String getToggleGameModeEnabled() {
return getMessage("toggle.gamemode.enabled", "§a%player§6 can now change his gamemode!");
}
public static String getToggleBuildEnabled() {
return getMessage("toggle.build.enabled", "§a%player§6 can now build!");
}
public static String getToggleGameModeDisabled() {
return getMessage("toggle.gamemode.disabled", "§c%player§6 can no longer change his gamemode!");
}
public static String getToggleBuildDisabled() {
return getMessage("toggle.build.disabled", "§c%player§6 can no longer build!");
}
public static String getToggleTeleportEnabled() {
return getMessage("toggle.teleport.enabled", "§a%player§6 can now teleport!");
}
public static String getToggleWorldeditEnabled() {
return getMessage("toggle.worldedit.enabled", "§a%player§6 can now use WorldEdit!");
}
public static String getToggleTeleportDisabled() {
return getMessage("toggle.teleport.disabled", "§c%player§6 can no longer teleport!");
}
public static String getToggleWorldeditDisabled() {
return getMessage("toggle.worldedit.disabled", "§c%player§6 can no longer use WorldEdit!");
}
public static String getToggleBuildEnabled() {
return getMessage("toggle.build.enabled", "§a%player§6 can now build!");
}
public static String getToggleBuildDisabled() {
return getMessage("toggle.build.disabled", "§c%player§6 can no longer build!");
}
public static String getToggleWorldeditEnabled() {
return getMessage("toggle.worldedit.enabled", "§a%player§6 can now use WorldEdit!");
}
public static String getToggleWorldeditDisabled() {
return getMessage("toggle.worldedit.disabled", "§c%player§6 can no longer use WorldEdit!");
}
public static String getToggleFireEnabled() {
return getMessage("toggle.fire.enabled", "§aYou activated fire!");
}
public static String getToggleFireEnabled() {
return getMessage("toggle.fire.enabled", "§aYou activated fire!");
}
public static String getToggleFireDisabled() {
return getMessage("toggle.fire.disabled", "§cYou deactivated fire!");
}
public static String getToggleFireDisabled() {
return getMessage("toggle.fire.disabled", "§cYou deactivated fire!");
}
public static String getToggleTntEnabled() {
return getMessage("toggle.tnt.enabled", "§aYou activated TNT-Damage!");
}
public static String getToggleTntEnabled() {
return getMessage("toggle.tnt.enabled", "§aYou activated TNT-Damage!");
}
public static String getToggleTntDisabled() {
return getMessage("toggle.tnt.disabled", "§cYou deactivated TNT-Damage!");
}
public static String getToggleTntDisabled() {
return getMessage("toggle.tnt.disabled", "§cYou deactivated TNT-Damage!");
}
public static String getDeleteCommandHelp() {
return getMessage("command_help.delete_command", "/ws delete §8- §7Will delete a World");
}
public static String getDeleteCommandHelp() {
return getMessage("command_help.delete_command", "/ws delete §8- §7Will delete a World");
}
public static List<String> getCommandHelp() {
List<String> list = getConfig().getStringList("command_help.list");
if (list == null)
list = defaultCmdHelp;
list = list.stream().map(s -> ChatColor.translateAlternateColorCodes('&', s)).collect(Collectors.toList());
return list;
}
public static List<String> getCommandHelp() {
List<String> list = getConfig().getStringList("command_help.list");
if (list == null)
list = defaultCmdHelp;
list = list.stream().map(s -> ChatColor.translateAlternateColorCodes('&', s)).collect(Collectors.toList());
return list;
}
public static String getHomeSet() {
return getMessage("world.set_home", "You set the home");
}
public static String getHomeSet() {
return getMessage("world.set_home", "You set the home");
}
public static String getNotEnoughMoney() {
return getMessage("not_enough_money", "You do not have enough money");
}
}

View File

@ -20,6 +20,8 @@ world:
playerlist: "%players"
still_creating: ""
set_home: ""
not_enough_money: ""
member:
removed: "%player"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Spieler in der Welt: %players"
still_creating: "&cWelt wird noch erstellt..."
set_home: "Du hast das Home gesetzt"
not_enough_money: "Du hast nicht genug Geld"
member:
removed: "Du hast &c%player&6 von deiner Welt entfernt!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Players in this world: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "You removed &c%player&6 from your world!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Jugadores en este mundo: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "Has eliminado a &c%player&6 de tu mundo."

View File

@ -20,6 +20,7 @@ world:
playerlist: "Pelaajat tässä maailmassa: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "Poistit pelaajan &c%player&6 maailmastasi!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Joueurs dans ce monde: %players"
still_creating: "&cLe monde est encore en train de se créer"
set_home: "Vous avez placé le home"
not_enough_money: "You do not have enough money"
member:
removed: "Vous avez retiré &c%player&6 de votre monde!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Játékos ebben a világban: %player"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "Törölted &c%player&6 játékost a világodból!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "speler is in wereld: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "Jij hebt &c%player&6 verwijderd van jouw wereld!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Gracze na tym świecie: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "Usunąłeś &c%player&6 ze swojego świata!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "Игроков в мире: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "Ты удалил &c%player&6 из твоего мира!"

View File

@ -20,6 +20,7 @@ world:
playerlist: "玩家: %players 在这个世界上"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
not_enough_money: "You do not have enough money"
member:
removed: "玩家 &c%player&6 从你的世界移除!"