Add Player To Command

This commit is contained in:
RayzsYT committed 2024-06-10 19:35:59 +02:00
1 parent 9836b25524
commit b643366e9e
4 files changed
+32 -4

No files matched your search

@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.commands;
import de.rayzs.pat.plugin.process.CommandProcess;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import java.util.List;
@@ -9,8 +10,14 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(commandSender instanceof Player) {
Player player = (Player) commandSender;
CommandProcess.handleCommand(player, strings, s);
return true;
}
CommandProcess.handleCommand(commandSender, strings, s);
return false;
return true;
}
@Override
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.commands;
import de.rayzs.pat.plugin.process.CommandProcess;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.*;
public class BungeeCommand extends Command implements TabExecutor {
@@ -12,6 +13,12 @@ public class BungeeCommand extends Command implements TabExecutor {
@Override
public void execute(CommandSender commandSender, String[] strings) {
if(commandSender instanceof ProxiedPlayer) {
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) commandSender;
CommandProcess.handleCommand(proxiedPlayer, strings, "bpat");
return;
}
CommandProcess.handleCommand(commandSender, strings, "bpat");
}
@@ -1,6 +1,7 @@
package de.rayzs.pat.plugin.commands;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.proxy.Player;
import de.rayzs.pat.plugin.process.CommandProcess;
import java.util.List;
@@ -8,6 +9,12 @@ public class VelocityCommand implements SimpleCommand {
@Override
public void execute(Invocation invocation) {
if(invocation.source() instanceof Player) {
Player player = (Player) invocation.source();
CommandProcess.handleCommand(player, invocation.arguments(), "bpat");
return;
}
CommandProcess.handleCommand(invocation.source(), invocation.arguments(), "bpat");
}
@@ -27,15 +27,22 @@ public class ProxyPlaceholderReplacer {
uuid = ((com.velocitypowered.api.proxy.Player) playerObj).getUniqueId();
} else if(Reflection.isProxyServer()) {
if (playerObj instanceof net.md_5.bungee.api.connection.ProxiedPlayer)
System.out.println("Checking through proxy");
if (playerObj instanceof net.md_5.bungee.api.connection.ProxiedPlayer) {
System.out.println("Is ProxiedPlayer");
uuid = ((net.md_5.bungee.api.connection.ProxiedPlayer) playerObj).getUniqueId();
} else System.out.println("No proxied player ;C -> " + playerObj);
} else {
if(playerObj instanceof org.bukkit.entity.Player)
uuid = ((org.bukkit.entity.Player) playerObj).getUniqueId();
}
if(uuid == null) return false;
if(uuid == null) {
System.out.println("Ignore translation: " + text);
return false;
}
System.out.println("Translated: " + text);
PLACEHOLDER_API.formatPlaceholders(text, uuid).thenAccept(consumer);
return true;