Add PAPIProxyBridge Support

This commit is contained in:
RayzsYT committed 2024-06-10 19:12:18 +02:00
1 parent cc2f86f248
commit 9836b25524
4 files changed
+26 -9

No files matched your search

@@ -72,7 +72,10 @@ public class BungeeLoader extends Plugin {
if (manager.getPlugin("LuckPerms") != null)
LuckPermsAdapter.initialize();
Storage.USE_PAPIPROXYBRIDGE = manager.getPlugin("PAPIProxyBridge") != null;
if(manager.getPlugin("PAPIProxyBridge") != null) {
Storage.USE_PAPIPROXYBRIDGE = true;
Logger.info("Successfully hooked into PAPIProxyBridge!");
}
BungeePacketAnalyzer.injectAll();
}
@@ -92,7 +92,10 @@ public class VelocityLoader {
if(server.getPluginManager().getPlugin("luckperms").isPresent())
LuckPermsAdapter.initialize();
Storage.USE_PAPIPROXYBRIDGE = server.getPluginManager().getPlugin("papiproxybridge").isPresent();
if(server.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
Storage.USE_PAPIPROXYBRIDGE = true;
Logger.info("Successfully hooked into PAPIProxyBridge!");
}
}
public void startUpdaterTask() {
@@ -74,12 +74,14 @@ public class MessageTranslator {
}
public static void send(Object target, List<String> texts) {
texts.forEach(text -> send(target, text));
String stringList = StringUtils.buildStringList(texts);
send(target, stringList);
}
public static void send(Object target, List<String> texts, String... replacements) {
texts = replaceMessageList(texts, replacements);
texts.forEach(text -> send(target, text));
String stringList = StringUtils.buildStringList(texts);
send(target, stringList);
}
public static void send(Object target, String text, String... replacements) {
@@ -1,6 +1,7 @@
package de.rayzs.pat.utils.message.replacer.impl;
import de.rayzs.pat.utils.CommandSender;
import de.rayzs.pat.utils.Reflection;
import net.william278.papiproxybridge.api.PlaceholderAPI;
import java.util.UUID;
import java.util.function.Consumer;
@@ -17,14 +18,22 @@ public class ProxyPlaceholderReplacer {
UUID uuid = null;
if(playerObj != null)
if(playerObj instanceof CommandSender)
if(playerObj instanceof CommandSender) {
uuid = ((CommandSender) playerObj).getUniqueId();
else if(playerObj instanceof com.velocitypowered.api.proxy.Player)
uuid = ((com.velocitypowered.api.proxy.Player) playerObj).getUniqueId();
} else if(Reflection.isVelocityServer()) {
if (playerObj instanceof com.velocitypowered.api.proxy.Player)
uuid = ((com.velocitypowered.api.proxy.Player) playerObj).getUniqueId();
else if(playerObj instanceof org.bukkit.entity.Player)
uuid = ((org.bukkit.entity.Player) playerObj).getUniqueId();
} else if(Reflection.isProxyServer()) {
if (playerObj instanceof net.md_5.bungee.api.connection.ProxiedPlayer)
uuid = ((net.md_5.bungee.api.connection.ProxiedPlayer) playerObj).getUniqueId();
} else {
if(playerObj instanceof org.bukkit.entity.Player)
uuid = ((org.bukkit.entity.Player) playerObj).getUniqueId();
}
if(uuid == null) return false;
PLACEHOLDER_API.formatPlaceholders(text, uuid).thenAccept(consumer);