From f5b5426327c53f0f8657d99b866af9ecaba8736b Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 3 Jun 2018 10:07:58 +0200 Subject: [PATCH] Created TextVariables class that contains common text placeholders --- locales/en-US.yml | 20 +++++++++---------- .../api/commands/CompositeCommand.java | 3 ++- .../api/commands/DefaultHelpCommand.java | 3 ++- .../tastybento/bskyblock/api/flags/Flag.java | 5 ++++- .../api/localization/TextVariables.java | 14 +++++++++++++ .../bskyblock/commands/AdminCommand.java | 3 ++- .../bskyblock/commands/IslandCommand.java | 3 ++- .../commands/admin/AdminGetRankCommand.java | 3 ++- .../admin/teams/AdminTeamAddCommand.java | 13 ++++++------ .../commands/island/IslandBanCommand.java | 3 ++- .../commands/island/IslandGoCommand.java | 3 ++- .../commands/island/IslandResetCommand.java | 10 +++++----- .../island/IslandResetnameCommand.java | 1 - .../commands/island/IslandSethomeCommand.java | 5 +++-- .../commands/island/IslandSetnameCommand.java | 5 +++-- .../commands/island/IslandUnbanCommand.java | 3 ++- .../island/teams/IslandTeamCommand.java | 5 ++++- .../teams/IslandTeamInviteAcceptCommand.java | 5 +++-- .../island/teams/IslandTeamInviteCommand.java | 12 +++++------ .../teams/IslandTeamInviteRejectCommand.java | 3 ++- .../island/teams/IslandTeamLeaveCommand.java | 3 ++- .../teams/IslandTeamPromoteCommand.java | 5 +++-- .../bskyblock/island/builders/Clipboard.java | 3 ++- .../island/builders/IslandBuilder.java | 11 +++++----- 24 files changed, 89 insertions(+), 55 deletions(-) create mode 100644 src/main/java/us/tastybento/bskyblock/api/localization/TextVariables.java diff --git a/locales/en-US.yml b/locales/en-US.yml index 027e520b5..ef995917f 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -36,7 +36,7 @@ general: unknown-command: "&cUnknown command. Do &b/[label] help &cfor help." warp-not-safe: "&cThat warp is not safe right now!" wrong-world: "&cYou are not in the right world to do that!" - you-must-wait: "&cYou must wait [seconds]s before you can do that command again" + you-must-wait: "&cYou must wait [number]s before you can do that command again" you-need: "&cYou need [permission]" tips: changing-obsidian-to-lava: "Changing obsidian back into lava. Be careful!" @@ -147,18 +147,18 @@ commands: must-remove-members: "You must remove all members from your island before you can restart it (/island kick )." none-left: "&cYou have no more resets left!" resets-left: "&cYou have [number] resets left" - confirm: "&cType &b/[label] reset confirm&c within [seconds]s to confirm reset" + confirm: "&cType &b/[label] reset confirm&c within [number]s to confirm reset" cancelled: "&bReset cancelled" sethome: description: "set your teleport point for /island" must-be-on-your-island: "You must be on your island to set home!" - num-homes: "Homes can be 1 to [max]." + num-homes: "Homes can be 1 to [number]." home-set: "Your island home has been set to your current location." parameters: "[home number]" setname: description: "set a name for your island" - name-too-short: "&cToo short. Minimum size is [length] characters." - name-too-long: "&cToo long. Maximum size is [length] characters." + name-too-short: "&cToo short. Minimum size is [number] characters." + name-too-long: "&cToo long. Maximum size is [number] characters." parameters: "" resetname: description: "reset your island name" @@ -175,7 +175,7 @@ commands: you-will-lose-your-island: "&cWARNING! You will lose your island if you accept!" errors: cannot-invite-self: "&cYou cannot invite yourself!" - cooldown: "&cYou cannot invite that person for another [time] seconds" + cooldown: "&cYou cannot invite that person for another [number] seconds" island-is-full: "&cYour island is full, you can't invite anyone else." none-invited-you: "&cNo one invited you :c." you-already-are-in-team: "&cYou are already on a team!" @@ -197,7 +197,7 @@ commands: cannot-leave: "&cTeamleaders cannot leave! Become a member first, or kick all members." description: "leave your island" type-again: "&cEnter the leave command again to confirm" - left-your-island: "&c[player] left your island" + left-your-island: "&c[name] left your island" kick: description: "remove a member from your island" parameters: "" @@ -229,14 +229,14 @@ commands: cannot-ban: "&cThat player cannot be banned." cannot-ban-member: "&cKick the team member first, then ban." player-already-banned: "&cPlayer is already banned" - owner-banned-you: "&b[owner]&c banned you from their island!" + owner-banned-you: "&b[name]&c banned you from their island!" you-are-banned: "&bYou are banned from this island!" unban: description: "unban a player from your island" parameters: "" cannot-unban-yourself: "&cYou cannot unban yourself!" player-not-banned: "&cPlayer is not banned" - you-are-unbanned: "&b[owner]&a unbanned you from their island!" + you-are-unbanned: "&b[name]&a unbanned you from their island!" banlist: description: "list banned players" noone: "&aNo one is banned on this island" @@ -357,6 +357,6 @@ language: new-island: sign: line0: "&1%bsb_plugin_name%" - line1: "[player]" + line1: "[name]" line2: "Don't fall!" line3: "Have fun! &c<3" \ No newline at end of file diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java index 7771c0781..29e342baa 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java @@ -21,6 +21,7 @@ import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.Settings; import us.tastybento.bskyblock.api.addons.Addon; import us.tastybento.bskyblock.api.events.command.CommandEvent; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.managers.IslandWorldManager; import us.tastybento.bskyblock.managers.IslandsManager; @@ -211,7 +212,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi // Check perms, but only if this isn't the console if ((sender instanceof Player) && !sender.isOp() && !cmd.getPermission().isEmpty() && !sender.hasPermission(cmd.getPermission())) { user.sendMessage("general.errors.no-permission"); - user.sendMessage("general.errors.you-need", "[permission]", cmd.getPermission()); + user.sendMessage("general.errors.you-need", TextVariables.PERMISSION, cmd.getPermission()); return true; } // Fire an event to see if this command should be cancelled diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java index cd1a500ee..cecda1f06 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java @@ -6,6 +6,7 @@ import java.util.Optional; import org.apache.commons.lang.math.NumberUtils; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; /** @@ -51,7 +52,7 @@ public class DefaultHelpCommand extends CompositeCommand { } } if (depth == 0) { - user.sendMessage("commands.help.header", "[label]", getIWM().getFriendlyName(getWorld())); + user.sendMessage("commands.help.header", TextVariables.LABEL, getIWM().getFriendlyName(getWorld())); } if (depth < MAX_DEPTH) { if (!parent.getLabel().equals(HELP)) { diff --git a/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java b/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java index 16d1e3684..8f5990127 100644 --- a/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java +++ b/src/main/java/us/tastybento/bskyblock/api/flags/Flag.java @@ -7,12 +7,15 @@ import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import us.tastybento.bskyblock.BSkyBlock; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.panels.PanelItem; import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.managers.RanksManager; +import javax.xml.soap.Text; + public class Flag implements Comparable { public enum Type { @@ -127,7 +130,7 @@ public class Flag implements Comparable { // Start the flag conversion PanelItemBuilder pib = new PanelItemBuilder() .icon(new ItemStack(icon)) - .name(user.getTranslation("protection.panel.flag-item.name-layout", "[name]", user.getTranslation("protection.flags." + id + ".name"))) + .name(user.getTranslation("protection.panel.flag-item.name-layout", TextVariables.NAME, user.getTranslation("protection.flags." + id + ".name"))) .clickHandler(clickHandler); pib.description(user.getTranslation("protection.panel.flag-item.description-layout", "[description]", user.getTranslation("protection.flags." + id + ".description"))); diff --git a/src/main/java/us/tastybento/bskyblock/api/localization/TextVariables.java b/src/main/java/us/tastybento/bskyblock/api/localization/TextVariables.java new file mode 100644 index 000000000..a96939c5d --- /dev/null +++ b/src/main/java/us/tastybento/bskyblock/api/localization/TextVariables.java @@ -0,0 +1,14 @@ +package us.tastybento.bskyblock.api.localization; + +/** + * Contains the common variables that can be used in texts. + * @author Poslovitch + */ +public class TextVariables { + + public static final String NAME = "[name]"; + public static final String NUMBER = "[number]"; + public static final String RANK = "[rank]"; + public static final String LABEL = "[label]"; + public static final String PERMISSION = "[permission]"; +} diff --git a/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java b/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java index 3a1a78940..9412ff001 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java @@ -3,6 +3,7 @@ package us.tastybento.bskyblock.commands; import java.util.List; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.commands.admin.AdminGetRankCommand; import us.tastybento.bskyblock.commands.admin.AdminInfoCommand; @@ -50,7 +51,7 @@ public class AdminCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { if (!args.isEmpty()) { - user.sendMessage("general.errors.unknown-command", "[label]", getTopLabel()); + user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel()); return false; } // By default run the attached help command, if it exists (it should) diff --git a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java index 8c92ac151..c89b7d057 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.commands.island.IslandAboutCommand; import us.tastybento.bskyblock.commands.island.IslandBanCommand; @@ -69,7 +70,7 @@ public class IslandCommand extends CompositeCommand { // No islands currently return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false); } - user.sendMessage("general.errors.unknown-command", "[label]", getTopLabel()); + user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel()); return false; } diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/AdminGetRankCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/AdminGetRankCommand.java index 2b1937734..66da8b39a 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/AdminGetRankCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/AdminGetRankCommand.java @@ -9,6 +9,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.managers.RanksManager; @@ -59,7 +60,7 @@ public class AdminGetRankCommand extends CompositeCommand { User target = User.getInstance(targetUUID); Island island = getPlugin().getIslands().getIsland(getWorld(), targetUUID); int currentRank = island.getRank(target); - user.sendMessage("commands.admin.getrank.rank-is", "[rank]", user.getTranslation(rm.getRank(currentRank))); + user.sendMessage("commands.admin.getrank.rank-is", TextVariables.RANK, user.getTranslation(rm.getRank(currentRank))); return true; } diff --git a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java index deabb7254..0de40a676 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/admin/teams/AdminTeamAddCommand.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.UUID; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; public class AdminTeamAddCommand extends CompositeCommand { @@ -30,12 +31,12 @@ public class AdminTeamAddCommand extends CompositeCommand { // Get leader and target UUID leaderUUID = getPlayers().getUUID(args.get(0)); if (leaderUUID == null) { - user.sendMessage("general.errors.unknown-player-name", "[name]", args.get(0)); + user.sendMessage("general.errors.unknown-player-name", TextVariables.NAME, args.get(0)); return false; } UUID targetUUID = getPlayers().getUUID(args.get(1)); if (targetUUID == null) { - user.sendMessage("general.errors.unknown-player-name", "[name]", args.get(1)); + user.sendMessage("general.errors.unknown-player-name", TextVariables.NAME, args.get(1)); return false; } if (!getIslands().hasIsland(getWorld(), leaderUUID)) { @@ -43,7 +44,7 @@ public class AdminTeamAddCommand extends CompositeCommand { return false; } if (getIslands().inTeam(getWorld(), leaderUUID) && !getIslands().getTeamLeader(getWorld(), leaderUUID).equals(leaderUUID)) { - user.sendMessage("commands.admin.team.add.name-not-leader", "[name]", args.get(0)); + user.sendMessage("commands.admin.team.add.name-not-leader", TextVariables.NAME, args.get(0)); getIslands().getIsland(getWorld(), leaderUUID).showMembers(getPlugin(), user); return false; } @@ -52,14 +53,14 @@ public class AdminTeamAddCommand extends CompositeCommand { return false; } if (getIslands().hasIsland(getWorld(), targetUUID)) { - user.sendMessage("commands.admin.team.add.name-has-island", "[name]", args.get(1)); + user.sendMessage("commands.admin.team.add.name-has-island", TextVariables.NAME, args.get(1)); return false; } // Success User target = User.getInstance(targetUUID); User leader = User.getInstance(leaderUUID); - leader.sendMessage("commands.island.team.invite.accept.name-joined-your-island", "[name]", getPlugin().getPlayers().getName(targetUUID)); - target.sendMessage("commands.island.team.invite.accept.you-joined-island", "[label]", getTopLabel()); + leader.sendMessage("commands.island.team.invite.accept.name-joined-your-island", TextVariables.NAME, getPlugin().getPlayers().getName(targetUUID)); + target.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel()); getIslands().getIsland(getWorld(), leaderUUID).addMember(targetUUID); user.sendMessage("general.success"); return true; diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandBanCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandBanCommand.java index 85a1c1928..9defccd68 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandBanCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandBanCommand.java @@ -10,6 +10,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.util.Util; @@ -78,7 +79,7 @@ public class IslandBanCommand extends CompositeCommand { Island island = getIslands().getIsland(getWorld(), user.getUniqueId()); if (island.addToBanList(targetUser.getUniqueId())) { user.sendMessage("general.success"); - targetUser.sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName()); + targetUser.sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName()); // If the player is online, has an island and on the banned island, move them home immediately if (targetUser.isOnline() && getIslands().hasIsland(getWorld(), targetUser.getUniqueId()) && island.onIsland(targetUser.getLocation())) { getIslands().homeTeleport(getWorld(), targetUser.getPlayer()); diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java index 41e9f6420..f5f4841e3 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java @@ -6,6 +6,7 @@ import org.apache.commons.lang.math.NumberUtils; import org.bukkit.ChatColor; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.util.Util; @@ -44,7 +45,7 @@ public class IslandGoCommand extends CompositeCommand { int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getIWM().getMaxHomes(getWorld())); if (homeValue > 1 && homeValue <= maxHomes) { getIslands().homeTeleport(getWorld(), user.getPlayer(), homeValue); - user.sendMessage("commands.island.go.tip", "[label]", getTopLabel()); + user.sendMessage("commands.island.go.tip", TextVariables.LABEL, getTopLabel()); return true; } } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java index 58fd53d4b..c3667f4c0 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java @@ -12,13 +12,13 @@ import org.bukkit.entity.Player; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.managers.island.NewIsland; public class IslandResetCommand extends CompositeCommand { - private static final String SECONDS_PLACEHOLDER = "[seconds]"; private Map cooldown; private Map confirm; @@ -39,7 +39,7 @@ public class IslandResetCommand extends CompositeCommand { public boolean execute(User user, List args) { // Check cooldown if (getSettings().getResetWait() > 0 && onRestartWaitTime(user) > 0 && !user.isOp()) { - user.sendMessage("general.errors.you-must-wait", SECONDS_PLACEHOLDER, String.valueOf(onRestartWaitTime(user))); + user.sendMessage("general.errors.you-must-wait", TextVariables.NUMBER, String.valueOf(onRestartWaitTime(user))); return false; } if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) { @@ -60,7 +60,7 @@ public class IslandResetCommand extends CompositeCommand { return false; } else { // Notify how many resets are left - user.sendMessage("commands.island.reset.resets-left", "[number]", String.valueOf(getPlayers().getResetsLeft(user.getUniqueId()))); + user.sendMessage("commands.island.reset.resets-left", TextVariables.NUMBER, String.valueOf(getPlayers().getResetsLeft(user.getUniqueId()))); } } // Check for non-confirm command @@ -80,13 +80,13 @@ public class IslandResetCommand extends CompositeCommand { } else { // Show how many seconds left to confirm int time = (int)((confirm.get(user.getUniqueId()) - System.currentTimeMillis()) / 1000D); - user.sendMessage("commands.island.reset.confirm", "[label]", getTopLabel(), SECONDS_PLACEHOLDER, String.valueOf(time)); + user.sendMessage("commands.island.reset.confirm", TextVariables.LABEL, getTopLabel(), TextVariables.NUMBER, String.valueOf(time)); } return true; } private void requestConfirmation(User user) { - user.sendMessage("commands.island.reset.confirm", "[label]", getTopLabel(), SECONDS_PLACEHOLDER, String.valueOf(getSettings().getConfirmationTime())); + user.sendMessage("commands.island.reset.confirm", TextVariables.LABEL, getTopLabel(), TextVariables.NUMBER, String.valueOf(getSettings().getConfirmationTime())); // Require confirmation confirm.put(user.getUniqueId(), System.currentTimeMillis() + getSettings().getConfirmationTime() * 1000L); Bukkit.getScheduler().runTaskLater(getPlugin(), () -> { diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java index 0783e0cba..4988fb5b0 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java @@ -21,7 +21,6 @@ public class IslandResetnameCommand extends CompositeCommand { setPermission("island.name"); setOnlyPlayer(true); setDescription("commands.island.resetname.description"); - } /* (non-Javadoc) diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java index 1f6f8776e..3989d1609 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.UUID; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.util.Util; @@ -46,14 +47,14 @@ public class IslandSethomeCommand extends CompositeCommand { try { number = Integer.valueOf(args.get(0)); if (number < 1 || number > maxHomes) { - user.sendMessage("commands.island.sethome.num-homes", "[max]", String.valueOf(maxHomes)); + user.sendMessage("commands.island.sethome.num-homes", TextVariables.NUMBER, String.valueOf(maxHomes)); return false; } else { getPlugin().getPlayers().setHomeLocation(user, user.getLocation(), number); user.sendMessage("commands.island.sethome.home-set"); } } catch (Exception e) { - user.sendMessage("commands.island.sethome.num-homes", "[max]", String.valueOf(maxHomes)); + user.sendMessage("commands.island.sethome.num-homes", TextVariables.NUMBER, String.valueOf(maxHomes)); return false; } } else { diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java index f2b2c0aae..779b4600b 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java @@ -8,6 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; /** @@ -56,11 +57,11 @@ public class IslandSetnameCommand extends CompositeCommand { // Check if the name isn't too short or too long if (name.length() < getSettings().getNameMinLength()) { - user.sendMessage("commands.island.setname.too-short", "[length]", String.valueOf(getSettings().getNameMinLength())); + user.sendMessage("commands.island.setname.too-short", TextVariables.NUMBER, String.valueOf(getSettings().getNameMinLength())); return false; } if (name.length() > getSettings().getNameMaxLength()) { - user.sendMessage("commands.island.setname.too-long", "[length]", String.valueOf(getSettings().getNameMaxLength())); + user.sendMessage("commands.island.setname.too-long", TextVariables.NUMBER, String.valueOf(getSettings().getNameMaxLength())); return false; } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandUnbanCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandUnbanCommand.java index 51076407b..e4a3e11af 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandUnbanCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandUnbanCommand.java @@ -6,6 +6,7 @@ import java.util.UUID; import java.util.stream.Collectors; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; import us.tastybento.bskyblock.util.Util; @@ -64,7 +65,7 @@ public class IslandUnbanCommand extends CompositeCommand { private boolean unban(User user, User targetUser) { if (getIslands().getIsland(getWorld(), user.getUniqueId()).removeFromBanList(targetUser.getUniqueId())) { user.sendMessage("general.success"); - targetUser.sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName()); + targetUser.sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName()); return true; } // Unbanning was blocked, maybe due to an event cancellation. Fail silently. diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java index f5a333c78..052cb979d 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java @@ -7,8 +7,11 @@ import java.util.UUID; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.events.IslandBaseEvent; import us.tastybento.bskyblock.api.events.team.TeamEvent; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; +import javax.xml.soap.Text; + public class IslandTeamCommand extends CompositeCommand { private IslandTeamInviteCommand inviteCommand; @@ -50,7 +53,7 @@ public class IslandTeamCommand extends CompositeCommand { if (teamLeaderUUID.equals(playerUUID)) { int maxSize = inviteCommand.getMaxTeamSize(user); if (teamMembers.size() < maxSize) { - user.sendMessage("commands.island.team.invite.you-can-invite", "[number]", String.valueOf(maxSize - teamMembers.size())); + user.sendMessage("commands.island.team.invite.you-can-invite", TextVariables.NUMBER, String.valueOf(maxSize - teamMembers.size())); } else { user.sendMessage("commands.island.team.invite.errors.island-is-full"); } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java index 763693cb8..ab63d380e 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java @@ -9,6 +9,7 @@ import org.bukkit.Location; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.events.IslandBaseEvent; import us.tastybento.bskyblock.api.events.team.TeamEvent; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; @@ -90,10 +91,10 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand { // Put player back into normal mode user.setGameMode(GameMode.SURVIVAL); - user.sendMessage("commands.island.team.invite.accept.you-joined-island", "[label]", getTopLabel()); + user.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel()); User inviter = User.getInstance(itc.getInviteCommand().getInviteList().get(playerUUID)); if (inviter != null) { - inviter.sendMessage("commands.island.team.invite.accept.name-joined-your-island", "[name]", user.getName()); + inviter.sendMessage("commands.island.team.invite.accept.name-joined-your-island", TextVariables.NAME, user.getName()); } getIslands().save(false); return true; diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java index 55409552d..7c9dc99fa 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java @@ -14,12 +14,12 @@ import com.google.common.collect.HashBiMap; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.events.IslandBaseEvent; import us.tastybento.bskyblock.api.events.team.TeamEvent; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.util.Util; public class IslandTeamInviteCommand extends CompositeCommand { - private static final String NAME_PLACEHOLDER = "[name]"; private BiMap inviteList; public IslandTeamInviteCommand(CompositeCommand islandCommand) { @@ -51,7 +51,7 @@ public class IslandTeamInviteCommand extends CompositeCommand { // Invite label with no name, i.e., /island invite - tells the player who has invited them so far if (inviteList.containsKey(playerUUID)) { OfflinePlayer inviter = getPlugin().getServer().getOfflinePlayer(inviteList.get(playerUUID)); - user.sendMessage("commands.island.team.invite.name-has-invited-you", NAME_PLACEHOLDER, inviter.getName()); + user.sendMessage("commands.island.team.invite.name-has-invited-you", TextVariables.NAME, inviter.getName()); return true; } // Show help @@ -78,7 +78,7 @@ public class IslandTeamInviteCommand extends CompositeCommand { // whether they are still on cooldown long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(getWorld(), playerUUID)); if (time > 0 && !user.isOp()) { - user.sendMessage("commands.island.team.invite.cooldown", "[time]", String.valueOf(time)); + user.sendMessage("commands.island.team.invite.cooldown", TextVariables.NUMBER, String.valueOf(time)); return false; } // Player cannot invite someone already on a team @@ -114,10 +114,10 @@ public class IslandTeamInviteCommand extends CompositeCommand { // Put the invited player (key) onto the list with inviter (value) // If someone else has invited a player, then this invite will overwrite the previous invite! inviteList.put(invitedPlayer.getUniqueId(), user.getUniqueId()); - user.sendMessage("commands.island.team.invite.invitation-sent", NAME_PLACEHOLDER, invitedPlayer.getName()); + user.sendMessage("commands.island.team.invite.invitation-sent", TextVariables.NAME, invitedPlayer.getName()); // Send message to online player - invitedPlayer.sendMessage("commands.island.team.invite.name-has-invited-you", NAME_PLACEHOLDER, user.getName()); - invitedPlayer.sendMessage("commands.island.team.invite.to-accept-or-reject", "[label]", getLabel()); + invitedPlayer.sendMessage("commands.island.team.invite.name-has-invited-you", TextVariables.NAME, user.getName()); + invitedPlayer.sendMessage("commands.island.team.invite.to-accept-or-reject", TextVariables.LABEL, getLabel()); if (getIslands().hasIsland(getWorld(), invitedPlayer.getUniqueId())) { invitedPlayer.sendMessage("commands.island.team.invite.you-will-lose-your-island"); } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java index 8e59c03cf..37b37de3b 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java @@ -6,6 +6,7 @@ import java.util.UUID; import us.tastybento.bskyblock.api.commands.CompositeCommand; import us.tastybento.bskyblock.api.events.IslandBaseEvent; import us.tastybento.bskyblock.api.events.team.TeamEvent; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; public class IslandTeamInviteRejectCommand extends CompositeCommand { @@ -46,7 +47,7 @@ public class IslandTeamInviteRejectCommand extends CompositeCommand { user.sendMessage("commands.island.team.invite.reject.you-rejected-invite"); User inviter = User.getInstance(itc.getInviteCommand().getInviteList().get(playerUUID)); - inviter.sendMessage("commands.island.team.invite.reject.name-rejected-your-invite", "[name]", user.getName()); + inviter.sendMessage("commands.island.team.invite.reject.name-rejected-your-invite", TextVariables.NAME, user.getName()); } else { // Someone typed /island reject and had not been invited // TODO: make the error nicer if there are invites in other worlds diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java index 4feeb9782..0e40ab5c6 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java @@ -8,6 +8,7 @@ import java.util.UUID; import org.bukkit.scheduler.BukkitRunnable; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; public class IslandTeamLeaveCommand extends CompositeCommand { @@ -40,7 +41,7 @@ public class IslandTeamLeaveCommand extends CompositeCommand { leaveSet.remove(user.getUniqueId()); UUID leaderUUID = getIslands().getTeamLeader(getWorld(), user.getUniqueId()); if (leaderUUID != null) { - User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", "[player]", user.getName()); + User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", TextVariables.NAME, user.getName()); } getIslands().removePlayer(getWorld(), user.getUniqueId()); user.sendMessage("general.success"); diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java index 7a3ec1dd6..36464de11 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java @@ -3,6 +3,7 @@ package us.tastybento.bskyblock.commands.island.teams; import java.util.List; import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; public class IslandTeamPromoteCommand extends CompositeCommand { @@ -60,7 +61,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand { if (nextRank > currentRank) { getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, nextRank); String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(nextRank)); - user.sendMessage("commands.island.team.promote.success", "[name]", target.getName(), "[rank]", rankName); + user.sendMessage("commands.island.team.promote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName); return true; } else { user.sendMessage("commands.island.team.promote.failure"); @@ -72,7 +73,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand { if (prevRank < currentRank) { getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, prevRank); String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(prevRank)); - user.sendMessage("commands.island.team.demote.success", "[name]", target.getName(), "[rank]", rankName); + user.sendMessage("commands.island.team.demote.success", TextVariables.NAME, target.getName(), TextVariables.RANK, rankName); return true; } else { user.sendMessage("commands.island.team.demote.failure"); diff --git a/src/main/java/us/tastybento/bskyblock/island/builders/Clipboard.java b/src/main/java/us/tastybento/bskyblock/island/builders/Clipboard.java index de672ffd5..d570c99c5 100644 --- a/src/main/java/us/tastybento/bskyblock/island/builders/Clipboard.java +++ b/src/main/java/us/tastybento/bskyblock/island/builders/Clipboard.java @@ -40,6 +40,7 @@ import org.bukkit.material.Openable; import org.bukkit.material.Redstone; import us.tastybento.bskyblock.BSkyBlock; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; public class Clipboard { @@ -109,7 +110,7 @@ public class Clipboard { } } } - user.sendMessage("commands.admin.schem.copied-blocks", "[number]", String.valueOf(count)); + user.sendMessage("commands.admin.schem.copied-blocks", TextVariables.NUMBER, String.valueOf(count)); copied = true; return true; } diff --git a/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java b/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java index e2f71c7c4..548d727e1 100644 --- a/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java +++ b/src/main/java/us/tastybento/bskyblock/island/builders/IslandBuilder.java @@ -20,6 +20,7 @@ import org.bukkit.material.Chest; import us.tastybento.bskyblock.Constants; import us.tastybento.bskyblock.Constants.GameType; +import us.tastybento.bskyblock.api.localization.TextVariables; import us.tastybento.bskyblock.api.user.User; import us.tastybento.bskyblock.database.objects.Island; @@ -37,8 +38,6 @@ public class IslandBuilder { END } - private static final String PLAYER_PLACEHOLDER = "[player]"; - private Island island; private World world; private IslandType type = IslandType.ISLAND; @@ -458,10 +457,10 @@ public class IslandBuilder { User user = User.getInstance(playerUUID); // Sets the lines of the sign - sign.setLine(0, user.getTranslation("new-island.sign.line0", PLAYER_PLACEHOLDER, playerName)); - sign.setLine(1, user.getTranslation("new-island.sign.line1", PLAYER_PLACEHOLDER, playerName)); - sign.setLine(2, user.getTranslation("new-island.sign.line2", PLAYER_PLACEHOLDER, playerName)); - sign.setLine(3, user.getTranslation("new-island.sign.line3", PLAYER_PLACEHOLDER, playerName)); + sign.setLine(0, user.getTranslation("new-island.sign.line0", TextVariables.NAME, playerName)); + sign.setLine(1, user.getTranslation("new-island.sign.line1", TextVariables.NAME, playerName)); + sign.setLine(2, user.getTranslation("new-island.sign.line2", TextVariables.NAME, playerName)); + sign.setLine(3, user.getTranslation("new-island.sign.line3", TextVariables.NAME, playerName)); ((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH); sign.update();