mirror of
https://github.com/rockyhawk64/CommandPanels.git
synced 2025-11-18 07:14:17 +01:00
velocity fix
This commit is contained in:
parent
14a36c43b0
commit
e93ce2dcf5
@ -43,7 +43,6 @@ public class Context {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(generator, plugin);
|
||||
|
||||
// Register proxy channels
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "velocity:main");
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
|
||||
// Register PlaceholderAPI in run task to ensure initialisation is complete
|
||||
|
||||
@ -18,32 +18,14 @@ public class ServerTag implements CommandTagResolver {
|
||||
public void handle(Context ctx, Panel panel, Player player, String raw, String command) {
|
||||
// Remove the tag prefix and parse placeholders
|
||||
String parsedCmd = ctx.text.parseTextToString(player, command);
|
||||
String[] args = parsedCmd.split("\\s+");
|
||||
|
||||
if (args.length == 0 || args[0].isEmpty()) {
|
||||
ctx.text.sendError(player, "No server was specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = args[0];
|
||||
String proxyType = "bungeecord"; // default proxy type
|
||||
|
||||
// Check for optional args (perm ignored since always forced, type supported)
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith("type=")) {
|
||||
String type = arg.substring(5).toLowerCase();
|
||||
if (type.equals("velocity") || type.equals("bungeecord")) {
|
||||
proxyType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare and send plugin message to proxy without permission checks
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(serverName);
|
||||
out.writeUTF(parsedCmd);
|
||||
|
||||
String channel = proxyType.equals("velocity") ? "velocity:main" : "BungeeCord";
|
||||
// Velocity and BungeeCord both can use this message
|
||||
String channel = "BungeeCord";
|
||||
player.sendPluginMessage(ctx.plugin, channel, out.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user