diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java index 35350f8f..b33c27cf 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java @@ -62,17 +62,17 @@ public void onCommand(CommandSenderContainer sender, String commandExecuted, Str catch(NumberFormatException e) { String subCommand = args[1].toLowerCase(); if(this.subCommandRegistry.isArgRegistered(subCommand)) { - sender.sendMessage(Lang.translateInsertVariablesColor("command.help.subcommandheader", + sender.sendMessage(Lang.translateInsertVariables("command.help.subcommandheader", commandExecuted.substring(0,1).toUpperCase() + commandExecuted.substring(1).toLowerCase(), subCommand)); sender.sendMessage("\u00A77" + this.getSubCommand(subCommand).getDetailedHelpText()); } else { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1])); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translateInsertVariables("command.help.invalidhelp", args[1])); } return; } } - sender.sendMessage(Lang.translateInsertVariablesColor("command.help.header", + sender.sendMessage(Lang.translateInsertVariables("command.help.header", commandExecuted.substring(0,1).toUpperCase() + commandExecuted.substring(1).toLowerCase(), helpPage, pages)); sender.sendMessage("\u00A7a█\u00A77 = Permission \u00A7c█\u00A77 = No Permission"); int subCommandOffset = (helpPage - 1) * this.subCommandsPerPage; @@ -95,17 +95,17 @@ public void onCommand(CommandSenderContainer sender, String commandExecuted, Str subCommand.onCommand(sender, args); } else { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.subcommand.nopermission", + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translateInsertVariables("command.subcommand.nopermission", commandExecuted)); } return; } } - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.subcommand.invalid")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.subcommand.invalid")); } } else { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.noargs", commandExecuted)); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translateInsertVariables("command.noargs", commandExecuted)); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java index 11bceb34..ea051364 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java @@ -1,11 +1,9 @@ package com.sekwah.advancedportals.core.commands.subcommands.desti; -import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.data.DataTag; -import com.sekwah.advancedportals.core.destination.Destination; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.TagReader; @@ -19,7 +17,7 @@ public void onCommand(CommandSenderContainer sender, String[] args) { if(args.length > 1) { PlayerContainer player = sender.getPlayerContainer(); if(player == null) { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.createdesti.console")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.createdesti.console")); return; } ArrayList destiTags = TagReader.getTagsFromArgs(args); @@ -43,7 +41,7 @@ public void onCommand(CommandSenderContainer sender, String[] args) { }*/ } else { - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.error.noname")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.error.noname")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java index c154b3cc..3f5942e4 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java @@ -1,16 +1,13 @@ package com.sekwah.advancedportals.core.commands.subcommands.portal; -import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.data.DataTag; -import com.sekwah.advancedportals.core.portal.AdvancedPortal; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.TagReader; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class CreatePortalSubCommand implements SubCommand { @@ -20,7 +17,7 @@ public void onCommand(CommandSenderContainer sender, String[] args) { if(args.length > 1) { PlayerContainer player = sender.getPlayerContainer(); if(player == null) { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.create.console")); return; } ArrayList portalTags = TagReader.getTagsFromArgs(args); @@ -35,10 +32,10 @@ public void onCommand(CommandSenderContainer sender, String[] args) { sender.sendMessage("\u00A7a" + tag.NAME + "\u00A77:\u00A7e" + tag.VALUE); } }*/ - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.create.error")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.create.error")); } else { - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.error.noname")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.error.noname")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java index 10f99c7a..a1f228aa 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java @@ -18,13 +18,13 @@ public class EndGatewayBlockSubCommand implements SubCommand { public void onCommand(CommandSenderContainer sender, String[] args) { PlayerContainer player = sender.getPlayerContainer(); if(player == null) { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.playeronly")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.playeronly")); } else { player.giveWool("BLACK", "\u00A78Gateway Block Placer" , "\u00A7rThis wool is made of a magical substance", "\u00A7rRight Click: Place portal block"); - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.gatewayblock")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.gatewayblock")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java index e4f01607..fdaa05c0 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java @@ -18,13 +18,13 @@ public class EndPortalBlockSubCommand implements SubCommand { public void onCommand(CommandSenderContainer sender, String[] args) { PlayerContainer player = sender.getPlayerContainer(); if(player == null) { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.playeronly")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.playeronly")); } else { player.giveWool("BLACK", "\u00A78End Portal Block Placer" , "\u00A7rThis wool is made of a magical substance", "\u00A7rRight Click: Place portal block"); - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.endportalblock")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.endportalblock")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java index 1e26c6d3..22414a32 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java @@ -19,7 +19,7 @@ public LangUpdateSubCommand() { @Override public void onCommand(CommandSenderContainer sender, String[] args) { this.portalsCore.getDataStorage().copyDefaultFile("lang/en_GB.lang", true); - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("translatedata.replaced")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("translatedata.replaced")); } @Override diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java index c3c0f693..5c2a5762 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java @@ -19,14 +19,14 @@ public class PortalBlockSubCommand implements SubCommand { public void onCommand(CommandSenderContainer sender, String[] args) { PlayerContainer player = sender.getPlayerContainer(); if(player == null) { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.playeronly")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.playeronly")); } else { player.giveWool("PURPLE", "\u00A75Portal Block Placer" , "\u00A7rThis wool is made of a magical substance", "\u00A7rRight Click: Place portal block", "\u00A7rLeft Click: Rotate portal block"); - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.portalblock")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.portalblock")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadSubCommand.java index 7f1e1fb3..d26f092e 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadSubCommand.java @@ -19,7 +19,7 @@ public void onCommand(CommandSenderContainer sender, String[] args) { // TODO re-add or figure out a replacement. //portalsCore.getPortalServices().loadPortals(); //portalsCore.getDestinationServices().loadDestinations(); - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.reload.reloaded")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.reload.reloaded")); } @Override diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java index 0b666081..4a8af805 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java @@ -22,12 +22,12 @@ public class SelectorSubCommand implements SubCommand { public void onCommand(CommandSenderContainer sender, String[] args) { PlayerContainer player = sender.getPlayerContainer(); if(player == null) { - sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.playeronly")); + sender.sendMessage(Lang.translate("messageprefix.negative") + Lang.translate("command.playeronly")); } else { player.giveItem(configRepo.getSelectorMaterial(), "\u00A7ePortal Region Selector" , "\u00A7rThis wand with has the power to help", "\u00A7r create portals bistowed upon it!"); - sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.selector")); + sender.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("command.selector")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java index 6bfea11d..58b20603 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java @@ -11,7 +11,7 @@ public class VersionSubCommand implements SubCommand { @Override public void onCommand(CommandSenderContainer sender, String[] args) { - sender.sendMessage(Lang.translateColor("messageprefix.positive") + " Advanced Portals v" + AdvancedPortalsCore.version); + sender.sendMessage(Lang.translate("messageprefix.positive") + " Advanced Portals v" + AdvancedPortalsCore.version); } @Override diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java index 6e42a727..ca2e64d7 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java @@ -4,14 +4,12 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import com.google.inject.Inject; -import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.data.DataTag; import com.sekwah.advancedportals.core.data.PlayerLocation; import com.sekwah.advancedportals.core.destination.Destination; import com.sekwah.advancedportals.core.repository.IDestinationRepository; import com.sekwah.advancedportals.core.util.Lang; -import com.sekwah.advancedportals.core.warphandler.TagHandler; import java.io.IOException; import java.lang.reflect.Type; @@ -61,11 +59,11 @@ public ImmutableMap getDestinations() { public Destination createDesti(String name, PlayerContainer player, PlayerLocation playerLocation, ArrayList tags) { // TODO change to write messages if(name == null || name.equals("")) { - player.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("desti.error.noname")); + player.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("desti.error.noname")); return null; } else if(this.destinationRepository.containsKey(name)) { - player.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("desti.error.takenname")); + player.sendMessage(Lang.translate("messageprefix.positive") + Lang.translate("desti.error.takenname")); return null; } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java b/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java index 1ae495a3..062d6ed1 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java @@ -46,7 +46,9 @@ public static void loadLanguage(String fileName) { public static String translate(String s) { if (instance.languageMap.containsKey(s)) { - return instance.languageMap.get(s); + String translation = instance.languageMap.get(s); + translation = translation.replaceAll("\\\\u00A7", "\u00A7"); + return translation; } else { return s; } @@ -60,20 +62,6 @@ public static String translateInsertVariables(String s, Object... args) { return translation; } - public static String translateInsertVariablesColor(String s, Object... args) { - String translation = instance.translateColor(s); - for (int i = 1; i <= args.length; i++) { - translation = translation.replaceAll("%" + i + "\\$s", args[i-1].toString()); - } - return translation; - } - - public static String translateColor(String s) { - String translation = instance.translate(s); - translation = translation.replaceAll("\\\\u00A7", "\u00A7"); - return translation; - } - private void injectTranslations(Lang lang, String fileName) { try { //URL url = lang.getClass().getClassLoader().getResource("lang/" + fileName + ".lang");