diff --git a/README.md b/README.md
index 2843652..62d8d64 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,8 @@
**Ever wanted to have your messages sent globally across your Velocity proxy with LuckPerms ranks ? Here's a simple plugin to do just that!**
- No Setup required, but you can still customize it with the config file
-- LuckPerms Prefix Support
+- LuckPerms Prefix and Suffix Support
- Velocity only
- Reload command: "/vmessage reload", permission: "*"
+- Global message command: "/sendall"
- You can also check my Bukkit plugin https://github.com/FeuSalamander/MiniWalls
diff --git a/pom.xml b/pom.xml
index 8a46107..3793bf1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -166,5 +166,10 @@
5.4
provided
+
+ net.kyori
+ adventure-text-minimessage
+ 4.12.0
+
diff --git a/src/main/java/me/feusalamander/vmessage/Configuration.java b/src/main/java/me/feusalamander/vmessage/Configuration.java
index 1353776..ade23a7 100644
--- a/src/main/java/me/feusalamander/vmessage/Configuration.java
+++ b/src/main/java/me/feusalamander/vmessage/Configuration.java
@@ -21,6 +21,7 @@ public final class Configuration {
private boolean joinEnabled;
private boolean leaveEnabled;
private boolean changeEnabled;
+ private boolean minimessage;
private Toml config;
private static File file;
@@ -34,6 +35,8 @@ public final class Configuration {
joinEnabled = config.getBoolean("Join.enabled", false);
leaveEnabled = config.getBoolean("Leave.enabled", false);
changeEnabled = config.getBoolean("Server-change.enabled", false);
+
+ minimessage = config.getBoolean("Message-format.minimessage");
this.config = config;
}
@@ -96,6 +99,9 @@ public final class Configuration {
public boolean isChangeEnabled() {
return this.changeEnabled;
}
+ public boolean isMinimessageEnabled(){
+ return this.minimessage;
+ }
void reload(){
config = config.read(file);
this.messageFormat = config.getString("Message.format");
@@ -107,5 +113,7 @@ public final class Configuration {
this.joinEnabled = config.getBoolean("Join.enabled");
this.leaveEnabled = config.getBoolean("Leave.enabled");
this.changeEnabled = config.getBoolean("Server-change.enabled");
+
+ this.minimessage = config.getBoolean("Message-format.minimessage");
}
}
diff --git a/src/main/java/me/feusalamander/vmessage/Listeners.java b/src/main/java/me/feusalamander/vmessage/Listeners.java
index 972441e..6be8f9a 100644
--- a/src/main/java/me/feusalamander/vmessage/Listeners.java
+++ b/src/main/java/me/feusalamander/vmessage/Listeners.java
@@ -12,6 +12,7 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
+import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
@@ -27,6 +28,7 @@ public final class Listeners {
.character('&')
.hexColors()
.build();
+ public static final MiniMessage mm = MiniMessage.miniMessage();
private LuckPerms luckPermsAPI;
private final Configuration configuration;
private final ProxyServer proxyServer;
@@ -44,21 +46,7 @@ public final class Listeners {
if (!configuration.isMessageEnabled()) {
return;
}
- Player p = e.getPlayer();
- String m = e.getMessage();
- String message = configuration.getMessageFormat()
- .replace("#player#", p.getUsername())
- .replace("#message#", m)
- .replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
- if (luckPermsAPI != null){
- message = luckperms(message, p);
- }
- final String finalMessage = message;
- proxyServer.getAllServers().forEach(server -> {
- if (!Objects.equals(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null), server.getServerInfo())){
- server.sendMessage(SERIALIZER.deserialize(finalMessage));
- }
- });
+ message(e.getPlayer(), e.getMessage());
}
@Subscribe
private void onLeave(DisconnectEvent e){
@@ -74,7 +62,12 @@ public final class Listeners {
if (luckPermsAPI != null){
message = luckperms(message, p);
}
- proxyServer.sendMessage(SERIALIZER.deserialize(message));
+ if(configuration.isMinimessageEnabled()){
+ proxyServer.sendMessage(mm.deserialize(message.replaceAll("§", "")));
+ }else{
+ proxyServer.sendMessage(SERIALIZER.deserialize(message));
+ }
+
}
@Subscribe
@@ -97,7 +90,11 @@ public final class Listeners {
if (luckPermsAPI != null){
message = luckperms(message, p);
}
- proxyServer.sendMessage(SERIALIZER.deserialize(message));
+ if(configuration.isMinimessageEnabled()){
+ proxyServer.sendMessage(mm.deserialize(message.replaceAll("§", "")));
+ }else{
+ proxyServer.sendMessage(SERIALIZER.deserialize(message));
+ }
}else{
if (!configuration.isJoinEnabled()) {
return;
@@ -106,7 +103,11 @@ public final class Listeners {
if (luckPermsAPI != null){
message = luckperms(message, p);
}
- proxyServer.sendMessage(SERIALIZER.deserialize(message));
+ if(configuration.isMinimessageEnabled()){
+ proxyServer.sendMessage(mm.deserialize(message.replaceAll("§", "")));
+ }else{
+ proxyServer.sendMessage(SERIALIZER.deserialize(message));
+ }
}
}
private String luckperms(String message, Player p){
@@ -119,4 +120,23 @@ public final class Listeners {
}
return message;
}
+ public void message(Player p, String m){
+ String message = configuration.getMessageFormat()
+ .replace("#player#", p.getUsername())
+ .replace("#message#", m)
+ .replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
+ if (luckPermsAPI != null){
+ message = luckperms(message, p);
+ }
+ final String finalMessage = message;
+ proxyServer.getAllServers().forEach(server -> {
+ if (!Objects.equals(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null), server.getServerInfo())){
+ if(configuration.isMinimessageEnabled()){
+ server.sendMessage(mm.deserialize(finalMessage.replaceAll("§", "")));
+ }else{
+ server.sendMessage(SERIALIZER.deserialize(finalMessage));
+ }
+ }
+ });
+ }
}
diff --git a/src/main/java/me/feusalamander/vmessage/ReloadCommand.java b/src/main/java/me/feusalamander/vmessage/ReloadCommand.java
index 540ab2d..2349ffc 100644
--- a/src/main/java/me/feusalamander/vmessage/ReloadCommand.java
+++ b/src/main/java/me/feusalamander/vmessage/ReloadCommand.java
@@ -34,19 +34,4 @@ public final class ReloadCommand implements SimpleCommand {
source.sendMessage(Component.text("The Vmessage's config has been succefully reloaded"));
}
}
-
- @Override
- public boolean hasPermission(final Invocation invocation) {
- return invocation.source().hasPermission("*");
- }
-
- @Override
- public List suggest(final Invocation invocation) {
- return List.of("reload");
- }
-
- @Override
- public CompletableFuture> suggestAsync(final Invocation invocation) {
- return CompletableFuture.completedFuture(List.of("reload"));
- }
}
diff --git a/src/main/java/me/feusalamander/vmessage/SendCommand.java b/src/main/java/me/feusalamander/vmessage/SendCommand.java
new file mode 100644
index 0000000..58019a9
--- /dev/null
+++ b/src/main/java/me/feusalamander/vmessage/SendCommand.java
@@ -0,0 +1,32 @@
+package me.feusalamander.vmessage;
+
+import com.velocitypowered.api.command.CommandSource;
+import com.velocitypowered.api.command.SimpleCommand;
+import com.velocitypowered.api.proxy.Player;
+import net.kyori.adventure.text.Component;
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+public final class SendCommand implements SimpleCommand {
+ VMessage main;
+ SendCommand(VMessage main){
+ this.main = main;
+ }
+ @Override
+ public void execute(final Invocation invocation) {
+ CommandSource source = invocation.source();
+ String[] args = invocation.arguments();
+ if(!(source instanceof Player)){
+ return;
+ }
+ if(args.length == 0){
+ source.sendMessage(Component.text("§cUsage: /sendall *your message*"));
+ return;
+ }
+ Player p = (Player)source;
+ String s = args[0];
+ main.listeners.message(p, s);
+ }
+}
diff --git a/src/main/java/me/feusalamander/vmessage/VMessage.java b/src/main/java/me/feusalamander/vmessage/VMessage.java
index 829aa41..51b5e10 100644
--- a/src/main/java/me/feusalamander/vmessage/VMessage.java
+++ b/src/main/java/me/feusalamander/vmessage/VMessage.java
@@ -16,7 +16,7 @@ import java.nio.file.Path;
@Plugin(
id = "vmessage",
name = "Vmessage",
- version = "1.4",
+ version = "1.5",
description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"},
dependencies = { @Dependency(id = "luckperms", optional = true) }
@@ -26,6 +26,7 @@ public class VMessage {
private final Logger logger;
private final Metrics.Factory metricsFactory;
private final Path dataDirectory;
+ public Listeners listeners;
@Inject
public VMessage(ProxyServer proxy, Logger logger, Metrics.Factory metricsFactory, @DataDirectory Path dataDirectory) {
@@ -42,7 +43,8 @@ public class VMessage {
return;
}
metricsFactory.make(this, 16527);
- proxy.getEventManager().register(this, new Listeners(proxy, configuration));
+ listeners = new Listeners(proxy, configuration);
+ proxy.getEventManager().register(this, listeners);
logger.info("Vmessage by FeuSalamander is working !");
CommandManager commandManager = proxy.getCommandManager();
CommandMeta commandMeta = commandManager.metaBuilder("Vmessage")
@@ -50,5 +52,10 @@ public class VMessage {
.build();
SimpleCommand command = new ReloadCommand(dataDirectory, configuration);
commandManager.register(commandMeta, command);
+ CommandMeta sendmeta = commandManager.metaBuilder("sendall")
+ .plugin(this)
+ .build();
+ SimpleCommand sendcommand = new SendCommand(this);
+ commandManager.register(sendmeta, sendcommand);
}
}
diff --git a/src/main/resources/config.toml b/src/main/resources/config.toml
index c81689a..867de68 100644
--- a/src/main/resources/config.toml
+++ b/src/main/resources/config.toml
@@ -1,3 +1,6 @@
+[Message-format]
+#set it to true to use MiniMessage and false to use hex colors
+minimessage = false
[Message]
#place holders:
#- "#player#" : return the player name