mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 12:06:17 +01:00
feat: Adds ability to configure warp message
This commit is contained in:
parent
a9e660db65
commit
3928922de3
@ -1,27 +1,34 @@
|
|||||||
package com.sekwah.advancedportals.bukkit;
|
package com.sekwah.advancedportals.bukkit;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class PluginMessages {
|
public class PluginMessages {
|
||||||
private final AdvancedPortalsPlugin plugin;
|
private static String WARP_MESSAGE;
|
||||||
public boolean useCustomPrefix = false;
|
public boolean useCustomPrefix = false;
|
||||||
public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
|
public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
|
||||||
public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
|
public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
|
||||||
|
|
||||||
public PluginMessages (AdvancedPortalsPlugin plugin) {
|
public PluginMessages (AdvancedPortalsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||||
ConfigAccessor config = new ConfigAccessor(this.plugin, "config.yml");
|
|
||||||
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
|
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
|
||||||
if (useCustomPrefix) {
|
if (useCustomPrefix) {
|
||||||
PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&(?=[0-9a-fk-or])", "\u00A7");
|
PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&(?=[0-9a-fk-or])", "\u00A7");
|
||||||
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").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
|
// This class is so then the common messages in commands or just messages over the commands are the same and can be
|
||||||
// easily changed.
|
// 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) {
|
public static void UnknownCommand(CommandSender sender, String command) {
|
||||||
sender.sendMessage(customPrefixFail + " You need to type something after /" + command + "\n");
|
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");
|
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");
|
||||||
|
@ -164,10 +164,10 @@ public class Destination {
|
|||||||
|
|
||||||
if (PORTAL_MESSAGE_DISPLAY == 1) {
|
if (PORTAL_MESSAGE_DISPLAY == 1) {
|
||||||
player.sendMessage("");
|
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("");
|
player.sendMessage("");
|
||||||
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
|
} 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();
|
Location newLoc = player.getLocation();
|
||||||
|
@ -65,6 +65,9 @@ CustomPrefix: '&a[&eAdvancedPortals&a]'
|
|||||||
|
|
||||||
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
|
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
|
||||||
|
|
||||||
|
# Message sent to player in chat/action bar on warp
|
||||||
|
WarpMessage: '&aYou have warped to &e<warp>&a.'
|
||||||
|
|
||||||
BlockSpectatorMode: false
|
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.
|
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
|
||||||
|
Loading…
Reference in New Issue
Block a user