diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/SimpleChat.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/SimpleChat.java index a9510a67..85c0bec8 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/SimpleChat.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/SimpleChat.java @@ -1,6 +1,7 @@ package net.draycia.simplechat; import de.themoep.minedown.MineDown; +import me.clip.placeholderapi.PlaceholderAPI; import net.draycia.simplechat.channels.ChatChannel; import net.draycia.simplechat.listeners.*; import net.draycia.simplechat.managers.*; @@ -13,6 +14,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer; import net.milkbowl.vault.permission.Permission; +import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -106,6 +108,10 @@ public final class SimpleChat extends JavaPlugin { } } + public Component processMessageWithPapi(Player player, String input, String... placeholders) { + return processMessage(PlaceholderAPI.setPlaceholders(player, input)); + } + public Component processMessage(String input, String... placeholders) { switch (getConfig().getString("formatting.type", "minimessage").toLowerCase()) { case "minedown": diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ChannelCommand.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ChannelCommand.java index 62725a8c..d2fb6ebd 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ChannelCommand.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ChannelCommand.java @@ -27,7 +27,7 @@ public class ChannelCommand extends BaseCommand { if (args == null || args.length == 0) { user.setSelectedChannel(channel); - user.sendMessage(simpleChat.processMessage(channel.getSwitchMessage(), + user.sendMessage(simpleChat.processMessageWithPapi(player, channel.getSwitchMessage(), "br", "\n", "color", "<" + channel.getColor().toString() + ">", "channel", channel.getName())); diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/IgnoreCommand.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/IgnoreCommand.java index dfff1ec6..a370b406 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/IgnoreCommand.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/IgnoreCommand.java @@ -41,7 +41,7 @@ public class IgnoreCommand extends BaseCommand { } } - user.sendMessage(simpleChat.processMessage(message, "br", "\n")); + user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n")); } } diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SetColorCommand.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SetColorCommand.java index 227579ec..3deecc1c 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SetColorCommand.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SetColorCommand.java @@ -39,7 +39,7 @@ public class SetColorCommand extends BaseCommand { settings.setColor(TextColor.fromHexString(color)); - user.sendMessage(simpleChat.processMessage(simpleChat.getConfig().getString("language.channel-color-set"), + user.sendMessage(simpleChat.processMessageWithPapi(player, simpleChat.getConfig().getString("language.channel-color-set"), "br", "\n", "color", "", "channel", channel.getName(), "hex", color)); } diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SpyChannelCommand.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SpyChannelCommand.java index 766f5ea3..8f829632 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SpyChannelCommand.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/SpyChannelCommand.java @@ -35,7 +35,7 @@ public class SpyChannelCommand extends BaseCommand { message = simpleChat.getConfig().getString("language.spy-toggled-on"); } - user.sendMessage(simpleChat.processMessage(message, "br", "\n", + user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n", "color", "", "channel", channel.getName())); } @@ -53,7 +53,7 @@ public class SpyChannelCommand extends BaseCommand { message = simpleChat.getConfig().getString("language.spy-whispers-on"); } - user.sendMessage(simpleChat.processMessage(message, "br", "\n")); + user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n")); } } diff --git a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ToggleCommand.java b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ToggleCommand.java index c09541b1..d143e9d1 100644 --- a/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ToggleCommand.java +++ b/SimpleChatPlugin/src/main/java/net/draycia/simplechat/commands/ToggleCommand.java @@ -36,7 +36,7 @@ public class ToggleCommand extends BaseCommand { message = channel.getToggleOnMessage(); } - user.sendMessage(simpleChat.processMessage(message, "br", "\n", + user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n", "color", "", "channel", channel.getName())); } diff --git a/SimpleChatPlugin/src/main/resources/config.yml b/SimpleChatPlugin/src/main/resources/config.yml index 023d2733..5177126e 100644 --- a/SimpleChatPlugin/src/main/resources/config.yml +++ b/SimpleChatPlugin/src/main/resources/config.yml @@ -8,6 +8,7 @@ # All of the settings under this 'default' section can be applied to each channel individually to override these. # These are provided as a way to configure default channel settings. default: + # switch-message, toggle-off-message and toggle-on-message support PlaceholderAPI switch-message: 'You are now in chat!' switch-other-message: ' is now in chat!' toggle-on-message: 'You can now see chat!' @@ -17,7 +18,6 @@ default: formats: # Placeholders: username, displayname, channel, server, message, primaryrole # Also supports PlaceholderAPI - discord-to-mc: '[Discord] :
'
     staff: '{[%vault_prefix%]} %player_displayname% ยป 
'
     default: '[%vault_prefix%] %player_displayname%: 
'
   color: '#FFFFFF'
@@ -59,22 +59,26 @@ formatting:
   type: 'MiniMessage'
 
 language:
-  ignoring-user: 'You are now ignoring !'
-  not-ignoring-user: 'You are no longer ignoring !'
-  ignore-exempt: 'User  is exempt from being ignored!'
+  # The following messages are only compatible with MiniMessage
   reloaded: 'Chat config has been reloaded!'
-  me: '*%player_displayname% 
*
' message-to-other: '[Me -> ] ' message-from-other: '[ -> Me] ' spy-whispers: 'Spy [ -> ] ' - spy-whispers-on: 'You are now spying on whispers!' - spy-whispers-off: 'You are no longer spying on whispers!' no-reply-target: 'You have no one to reply to!' + empty-channel: 'Nobody is around to hear you!' # + + # The following messages are compatible with PlaceholderAPI + me: '*%player_displayname%
*
' + ignoring-user: 'You are now ignoring !' + not-ignoring-user: 'You are no longer ignoring !' + ignore-exempt: 'User is exempt from being ignored!' channel-color-set: "You have set color to !" spy-toggled-on: 'You are now spying on chat!' spy-toggled-off: 'You are no longer spying on chat!' - empty-channel: 'Nobody is around to hear you!' # - # The following messages are not MiniMessage compatible + spy-whispers-on: 'You are now spying on whispers!' + spy-whispers-off: 'You are no longer spying on whispers!' + + # The following messages are not MiniMessage or PAPI compatible cannot-use-channel: "You cannot use that channel!" town-cannot-use: 'You are not in a town!' nation-cannot-use: 'You are not in a nation!'