feat: Adds ability to configure warp message

This commit is contained in:
Mohammed Al-Dahleh 2021-11-28 22:47:48 -05:00 committed by Sekwah
parent a9e660db65
commit 3928922de3
3 changed files with 15 additions and 5 deletions

View File

@ -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<warp>&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("<warp>", 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");

View File

@ -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();

View File

@ -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<warp>&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.