So I'm currently working on a plugin and I've decided to use commands to move players from servers (This is configurable don't worry) and I have this code. Code (Text): if (collection.isUseCommand()) { player.performCommand("server " + collection.getLobby()); But it just says "Unknown command" on the server. Any ideas why?
Oh wait nevermind found it. Problem is, why won't this command just work as is? The command works normally when in game and all I'm doing is just performing it in the code? Rather confused at this point xD
In your on Enable open the channel. Code (Text): Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); Send the player Code (Text): public static void sendPlayerToServer(Player player, String server){ ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Connect"); out.writeUTF(server); player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); }
Yeah this is currently my main source of doing this. Haven't worked with this before, it's quite fun ^-^
The Plugin Messaging Channel only works if there is at least one player online on the target server. I personally use Sockets because they can transfer data even with no players online.
Which one should be used depends on the use case, really. For half the messages, it wouldn't make any sense to use it without actual players online. If you still require sockets, make sure you make them secure .
Hmmm I'll take this into account for the future. For now, since I'm working with players anyway, I'll just do that for now. Thanks for the help!
Blocking requests which are from an IP which is not whitelisted, and giving them a random token which they need in a subsequent request to prevent IP spoofing.