diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java b/src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java index 524b7b1..eca6448 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/PluginMessages.java @@ -1,27 +1,34 @@ package com.sekwah.advancedportals.bukkit; import com.sekwah.advancedportals.bukkit.config.ConfigAccessor; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; public class PluginMessages { - private final AdvancedPortalsPlugin plugin; + private static String WARP_MESSAGE; public boolean useCustomPrefix = false; public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]"; public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]"; public PluginMessages (AdvancedPortalsPlugin plugin) { - this.plugin = plugin; - ConfigAccessor config = new ConfigAccessor(this.plugin, "config.yml"); + ConfigAccessor config = new ConfigAccessor(plugin, "config.yml"); this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix"); if (useCustomPrefix) { PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&(?=[0-9a-fk-or])", "\u00A7"); PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&(?=[0-9a-fk-or])", "\u00A7"); } + + WARP_MESSAGE = ChatColor.translateAlternateColorCodes('&', config.getConfig().getString("WarpMessage", "&aYou have warped to &e&a")); } // This class is so then the common messages in commands or just messages over the commands are the same and can be // easily changed. + public static String getWarpMessage(String warp) { + String cleanedWarp = warp.replace("_", " "); + return WARP_MESSAGE.replace("", cleanedWarp); + } + public static void UnknownCommand(CommandSender sender, String command) { sender.sendMessage(customPrefixFail + " You need to type something after /" + command + "\n"); sender.sendMessage("\u00A7cIf you do not know what you can put or would like some help with the commands please type \u00A7e" + '"' + "\u00A7e/" + command + " help" + '"' + "\u00A7c\n"); diff --git a/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java index a43b91b..fd6763b 100644 --- a/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java +++ b/src/main/java/com/sekwah/advancedportals/bukkit/destinations/Destination.java @@ -164,10 +164,10 @@ public class Destination { if (PORTAL_MESSAGE_DISPLAY == 1) { player.sendMessage(""); - player.sendMessage(PluginMessages.customPrefix + "\u00A7a You have been warped to \u00A7e" + dest.replaceAll("_", " ") + "\u00A7a."); + player.sendMessage(PluginMessages.customPrefix + PluginMessages.getWarpMessage(dest)); player.sendMessage(""); } else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + dest.replaceAll("_", " ") + "\u00A7a.")); + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(PluginMessages.getWarpMessage(dest))); } Location newLoc = player.getLocation(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9cecfcc..352c6ad 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -65,6 +65,9 @@ CustomPrefix: '&a[&eAdvancedPortals&a]' CustomPrefixFail: '&c[&7AdvancedPortals&c]' +# Message sent to player in chat/action bar on warp +WarpMessage: '&aYou have warped to &e&a.' + BlockSpectatorMode: false PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.