diff --git a/pom.xml b/pom.xml
index 588e236..0686865 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,6 +151,10 @@
papermc-repo
https://repo.papermc.io/repository/maven-public/
+
+ jitpack.io
+ https://jitpack.io
+
@@ -166,5 +170,10 @@
5.4
provided
+
+ net.william278
+ PAPIProxyBridge
+ 1.0
+
diff --git a/src/main/java/me/feusalamander/vmessage/Listeners.java b/src/main/java/me/feusalamander/vmessage/Listeners.java
index 730609c..8232751 100644
--- a/src/main/java/me/feusalamander/vmessage/Listeners.java
+++ b/src/main/java/me/feusalamander/vmessage/Listeners.java
@@ -1,10 +1,8 @@
package me.feusalamander.vmessage;
-import com.google.common.annotations.Beta;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.player.PlayerChatEvent;
-import com.velocitypowered.api.event.player.ServerConnectedEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
@@ -16,16 +14,14 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.cacheddata.CachedMetaData;
-import net.luckperms.api.context.Context;
-import net.luckperms.api.context.ContextManager;
-import net.luckperms.api.model.user.User;
+import net.william278.papiproxybridge.api.PlaceholderAPI;
+import net.william278.papiproxybridge.user.OnlineUser;
-import java.net.ProtocolException;
-import java.security.SignatureException;
import java.util.Objects;
import java.util.Optional;
-import java.util.SortedMap;
-import java.util.concurrent.CompletionException;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+
@SuppressWarnings({"UnstableApiUsage", "deprecation"})
public final class Listeners {
public static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder()
@@ -34,6 +30,7 @@ public final class Listeners {
.build();
public static final MiniMessage mm = MiniMessage.miniMessage();
private LuckPerms luckPermsAPI;
+ private PlaceholderAPI placeholderAPI;
private final Configuration configuration;
private final ProxyServer proxyServer;
@@ -41,10 +38,12 @@ public final class Listeners {
if (proxyServer.getPluginManager().getPlugin("luckperms").isPresent()) {
this.luckPermsAPI = LuckPermsProvider.get();
}
+ if (proxyServer.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
+ this.placeholderAPI = PlaceholderAPI.getInstance();
+ }
this.configuration = configuration;
this.proxyServer = proxyServer;
}
-
@Subscribe
private void onMessage(final PlayerChatEvent e) {
if (!configuration.isMessageEnabled()) {
@@ -55,7 +54,6 @@ public final class Listeners {
}
message(e.getPlayer(), e.getMessage());
}
-
@Subscribe
private void onLeave(final DisconnectEvent e) {
if (!configuration.isLeaveEnabled()) {
@@ -66,7 +64,9 @@ public final class Listeners {
if (server.isEmpty()) {
return;
}
- String message = configuration.getLeaveFormat()
+ String message = configuration.getLeaveFormat();
+ message = placeholder(message, p);
+ message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", server.get().getServerInfo().getName());
if (luckPermsAPI != null) {
@@ -79,7 +79,6 @@ public final class Listeners {
}
}
-
@Subscribe
private void onChange(final ServerPostConnectEvent e) {
if (!configuration.isChangeEnabled() && !configuration.isJoinEnabled()) {
@@ -93,7 +92,9 @@ public final class Listeners {
return;
}
final ServerConnection actual = serverConnection.get();
- String message = configuration.getChangeFormat()
+ String message = configuration.getChangeFormat();
+ message = placeholder(message, p);
+ message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", pre.getServerInfo().getName())
.replace("#server#", actual.getServerInfo().getName());
@@ -109,7 +110,9 @@ public final class Listeners {
if (!configuration.isJoinEnabled()) {
return;
}
- String message = configuration.getJoinFormat()
+ String message = configuration.getJoinFormat();
+ message = placeholder(message, p);
+ message = message
.replace("#player#", p.getUsername())
.replace("#server#", serverConnection.get().getServerInfo().getName());
if (luckPermsAPI != null) {
@@ -122,7 +125,6 @@ public final class Listeners {
}
}
}
-
private String luckperms(String message, final Player p) {
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
final String prefix = data.getPrefix();
@@ -136,10 +138,18 @@ public final class Listeners {
message = message.replace("#prefix#", "").replace("#suffix#", "");
return message;
}
-
+ private String placeholder(String message, final Player player){
+ if(placeholderAPI == null)return message;
+ UUID p = player.getUniqueId();
+ AtomicReference formated = new AtomicReference<>("");
+ placeholderAPI.formatPlaceholders("Hello %player_name%!", p).thenAccept(formatedd -> {proxyServer.sendMessage(Component.text("test: "+formatedd));});
+ return formated.get();
+ }
public void message(final Player p, final String m) {
final boolean permission = p.hasPermission("vmessage.minimessage");
- String message = configuration.getMessageFormat()
+ String message = configuration.getMessageFormat();
+ message = placeholder(message, p);
+ message = message
.replace("#player#", p.getUsername())
.replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
if (luckPermsAPI != null) {
diff --git a/src/main/java/me/feusalamander/vmessage/VMessage.java b/src/main/java/me/feusalamander/vmessage/VMessage.java
index 8ae2ece..bc9d145 100644
--- a/src/main/java/me/feusalamander/vmessage/VMessage.java
+++ b/src/main/java/me/feusalamander/vmessage/VMessage.java
@@ -20,7 +20,10 @@ import java.nio.file.Path;
version = "1.5.3",
description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"},
- dependencies = { @Dependency(id = "luckperms", optional = true) }
+ dependencies = {
+ @Dependency(id = "luckperms", optional = true),
+ @Dependency(id = "papiproxybridge",optional = true)
+ }
)
public class VMessage {
private final ProxyServer proxy;
diff --git a/src/main/resources/config.toml b/src/main/resources/config.toml
index 53dddc7..dfa6f67 100644
--- a/src/main/resources/config.toml
+++ b/src/main/resources/config.toml
@@ -1,3 +1,4 @@
+#you can use placeholders from placeholder api
[Message-format]
#set it to true to use MiniMessage and false to use hex colors
minimessage = false