mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Improve config and PAPI support
This commit is contained in:
1 parent
cfedf0e452
commit
a020f2f6a7
7 files changed
+25
-15
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
package net.draycia.simplechat;
|
package net.draycia.simplechat;
|
||||||
|
|
||||||
import de.themoep.minedown.MineDown;
|
import de.themoep.minedown.MineDown;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.listeners.*;
|
import net.draycia.simplechat.listeners.*;
|
||||||
import net.draycia.simplechat.managers.*;
|
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.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer;
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
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) {
|
public Component processMessage(String input, String... placeholders) {
|
||||||
switch (getConfig().getString("formatting.type", "minimessage").toLowerCase()) {
|
switch (getConfig().getString("formatting.type", "minimessage").toLowerCase()) {
|
||||||
case "minedown":
|
case "minedown":
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ChannelCommand extends BaseCommand {
|
|||||||
if (args == null || args.length == 0) {
|
if (args == null || args.length == 0) {
|
||||||
user.setSelectedChannel(channel);
|
user.setSelectedChannel(channel);
|
||||||
|
|
||||||
user.sendMessage(simpleChat.processMessage(channel.getSwitchMessage(),
|
user.sendMessage(simpleChat.processMessageWithPapi(player, channel.getSwitchMessage(),
|
||||||
"br", "\n",
|
"br", "\n",
|
||||||
"color", "<" + channel.getColor().toString() + ">",
|
"color", "<" + channel.getColor().toString() + ">",
|
||||||
"channel", channel.getName()));
|
"channel", channel.getName()));
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class IgnoreCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(simpleChat.processMessage(message, "br", "\n"));
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ public class SetColorCommand extends BaseCommand {
|
|||||||
|
|
||||||
settings.setColor(TextColor.fromHexString(color));
|
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", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
|
"br", "\n", "color", "<color:" + color + ">", "channel", channel.getName(), "hex", color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -35,7 +35,7 @@ public class SpyChannelCommand extends BaseCommand {
|
|||||||
message = simpleChat.getConfig().getString("language.spy-toggled-on");
|
message = simpleChat.getConfig().getString("language.spy-toggled-on");
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(simpleChat.processMessage(message, "br", "\n",
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class SpyChannelCommand extends BaseCommand {
|
|||||||
message = simpleChat.getConfig().getString("language.spy-whispers-on");
|
message = simpleChat.getConfig().getString("language.spy-whispers-on");
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(simpleChat.processMessage(message, "br", "\n"));
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ public class ToggleCommand extends BaseCommand {
|
|||||||
message = channel.getToggleOnMessage();
|
message = channel.getToggleOnMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage(simpleChat.processMessage(message, "br", "\n",
|
user.sendMessage(simpleChat.processMessageWithPapi(player, message, "br", "\n",
|
||||||
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
"color", "<color:" + channel.getColor().toString() + ">", "channel", channel.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
# All of the settings under this 'default' section can be applied to each channel individually to override these.
|
# 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.
|
# These are provided as a way to configure default channel settings.
|
||||||
default:
|
default:
|
||||||
|
# switch-message, toggle-off-message and toggle-on-message support PlaceholderAPI
|
||||||
switch-message: '<gray>You are now in <color><channel> <gray>chat!'
|
switch-message: '<gray>You are now in <color><channel> <gray>chat!'
|
||||||
switch-other-message: '<gray><player> is now in <color><channel> <gray>chat!'
|
switch-other-message: '<gray><player> is now in <color><channel> <gray>chat!'
|
||||||
toggle-on-message: '<gray>You can now see <color><channel> <gray>chat!'
|
toggle-on-message: '<gray>You can now see <color><channel> <gray>chat!'
|
||||||
@@ -17,7 +18,6 @@ default:
|
|||||||
formats:
|
formats:
|
||||||
# Placeholders: username, displayname, channel, server, message, primaryrole
|
# Placeholders: username, displayname, channel, server, message, primaryrole
|
||||||
# Also supports PlaceholderAPI
|
# Also supports PlaceholderAPI
|
||||||
discord-to-mc: '<gray>[<blue>Discord<gray>] <username><white>: <pre><message>'
|
|
||||||
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <gray>» <white><pre><message>'
|
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <gray>» <white><pre><message>'
|
||||||
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<gray>: <white><pre><message>'
|
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<gray>: <white><pre><message>'
|
||||||
color: '#FFFFFF'
|
color: '#FFFFFF'
|
||||||
@@ -59,22 +59,26 @@ formatting:
|
|||||||
type: 'MiniMessage'
|
type: 'MiniMessage'
|
||||||
|
|
||||||
language:
|
language:
|
||||||
ignoring-user: '<green>You are now ignoring <gold><player><green>!'
|
# The following messages are only compatible with MiniMessage
|
||||||
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
|
||||||
ignore-exempt: '<red>User <player> <red>is exempt from being ignored!'
|
|
||||||
reloaded: '<yellow>Chat config has been reloaded!'
|
reloaded: '<yellow>Chat config has been reloaded!'
|
||||||
me: '<italic><dark_purple>*%player_displayname% <pre><message></pre>*</dark_purple></italic>'
|
|
||||||
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><green>] <message>'
|
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><green>] <message>'
|
||||||
message-from-other: '<green>[<gray><sender> <gold>-> <gray>Me<green>] <message>'
|
message-from-other: '<green>[<gray><sender> <gold>-> <gray>Me<green>] <message>'
|
||||||
spy-whispers: '<yellow>Spy [<gray><sender> <gold>-> <gray><target><yellow>] <message>'
|
spy-whispers: '<yellow>Spy [<gray><sender> <gold>-> <gray><target><yellow>] <message>'
|
||||||
spy-whispers-on: '<gray>You are now spying on whispers!'
|
|
||||||
spy-whispers-off: '<gray>You are no longer spying on whispers!'
|
|
||||||
no-reply-target: '<red>You have no one to reply to!'
|
no-reply-target: '<red>You have no one to reply to!'
|
||||||
|
empty-channel: '<green>Nobody is around to hear you!' #<channel>
|
||||||
|
|
||||||
|
# The following messages are compatible with PlaceholderAPI
|
||||||
|
me: '<italic><dark_purple>*%player_displayname% <pre><message></pre>*</dark_purple></italic>'
|
||||||
|
ignoring-user: '<green>You are now ignoring <gold><player><green>!'
|
||||||
|
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
||||||
|
ignore-exempt: '<red>User <player> <red>is exempt from being ignored!'
|
||||||
channel-color-set: "<green>You have set <color><channel> <green>color to <hex>!"
|
channel-color-set: "<green>You have set <color><channel> <green>color to <hex>!"
|
||||||
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
|
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
|
||||||
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
|
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
|
||||||
empty-channel: '<green>Nobody is around to hear you!' #<channel>
|
spy-whispers-on: '<gray>You are now spying on whispers!'
|
||||||
# The following messages are not MiniMessage compatible
|
spy-whispers-off: '<gray>You are no longer spying on whispers!'
|
||||||
|
|
||||||
|
# The following messages are not MiniMessage or PAPI compatible
|
||||||
cannot-use-channel: "You cannot use that channel!"
|
cannot-use-channel: "You cannot use that channel!"
|
||||||
town-cannot-use: 'You are not in a town!'
|
town-cannot-use: 'You are not in a town!'
|
||||||
nation-cannot-use: 'You are not in a nation!'
|
nation-cannot-use: 'You are not in a nation!'
|
||||||
|
|||||||
Reference in new issue
Block a user