Cross Server Getting Certain Players

Discussion in 'Spigot Plugin Development' started by Accessory, May 25, 2015.

  1. I'm trying to make staff commands (Ex: /ban, /kick, etc) and when a staff member executes the command and actually bans or kicks a player it will message all staff members on each of the linked servers (W/ Bungee) saying the reason and all that. I know how to make the commands but how would I be able to check all players on all the servers so then I can check if they're mod, admin or owner? Thanks and help me ASAP.
  2. Depends. What you need is a communication between the BungeeCords. You can achieve this by using Netty or plain Sockets. Just google it ;)
  3. Do you mind helping me? I'm not that good with Sockets and I don't even know anything about Netty. The only thing I'm able to do with Sockets is check how many players are online, the max player slots and the MOTD.
  4. Gimme 10 minutes...
  5. Ok, took 20.

    You have to create a new Java Project. Create a new class called "Main" and paste the following code in there:

    Now save it and export it as a runnable jar file. Go to your server environment and execute the jar. The redirection is now active.
    Lets send and receive data on any bungeecord:

    In your BungeePlugin write: Bridge.connect("bungee01", "ipyouexecutedyourscripton");
    Replace bungee01 with a unique identifier for each bungee :)

    Send a command: Bridge.send("kick player Friwi");

    Then handle the command in, where the *********** line is. Cmd is "kick player Friwi" then. souceBungee is the Bungee its coming from!

    Hope i could help!

  6. Does it have to be a bungee plugin? And whats the server environment? Also The commands are "/staff kick" so how would I handle args or arguments? Thanks.
    #6 Accessory, May 25, 2015
    Last edited: May 25, 2015
  7. It doesnt have to be bungeecord. it can also be bukkit.

    For example you want to do a /kick command:

    When handling the command you first check, if the player is on your bungee. if so, kick him directly. Else, inform other bungeecords by calling

    Bridge.send("kick <player>");

    Then every bungee gets the variable cmd delivered as "kick <player>"

    Where the *********** are, insert:

    String split[] = cmd.split(" ");
    //Search for the player. If the player is online on this bungee kick him.
  8. How
    How would I be able to get the sender as a player and check if the target is online on bungee.
  9. Ok, lets explain this different. I guess you know skype. Now imagine a skype conversation where all your bungees are in. Now one bungee writes a command and everyone executes it. How the command is written and interpreted is completly your choice. you can include everything you need to know in there.

    kick player sender message
    kick player sender senderrank message
  10. You can also do this without creating any new sockets (some times you may be restricted by your host not to create new sockets and stuff like that)

    Check out BungeePluginMessages and especially the forward channel, it lets you forward information to servers between bungee. It won't be able to forward a message to a server unless there is a player online, but this shouldn't be a problem if the goal is to message all the players in the proxy as you would only need to message the sub-servers that have players online. Also I run a custom ban manager that is totally Bungee based. With bungee you can register commands and send direct messages, so register a bungee command like /kick and /ban and broadcast the message to all staff online. I have bungee lookup the staff prior in a custom manner as I also use partly run a custom ranks/permission systems (as you can see, I like doing stuff for my own server myself with custom coding :p)
  11. His aim was to communicate bungee -> bungee, not bungee-> spigot
  12. I cried a little.
    His aim was to communicate between two spigot servers who are linked by a BungeeCord server.

    @Accessory @xADudex was on the right track, just had the wrong plugin message. You probably want to use the KickPlayer channel to kick people off, and use a database to store bans and such.
  13. Ok, then i missunderstood him. I thought he would try to build a network with multiple bungees and search for a player on multiple bungeecords and kick that one.
  14. @DarkSeraphim The KickPlayer Channel could work but what I was trying to do was send a message to all staff members when someone kicks a player. Thus if a staff member is in the Hub or in Factions they would receive a message that someone was kicked in SG1 or something of that sort.
  15. @DarkSeraphim @xADudex I used the "Forward" Channel but it doesn't want to work. Am I doing this right?

    Code (Text):
                            ByteArrayDataOutput out = ByteStreams.newDataOutput();
                            out.writeUTF("Forward"); // So BungeeCord knows to forward it
                            out.writeUTF("BungeeCord"); // The channel name to check if this your data

                            ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
                            DataOutputStream msgout = new DataOutputStream(msgbytes);
                            try {
                                msgout.writeUTF(MsgType.staff + player.getDisplayName() + " §ekicked §l" + target.getName() + " §eon §l" + Bukkit.getServerName() + " §n" + msg);
                            } catch(IOException e) {

                            player.sendPluginMessage(API.instance, "BungeeCord", out.toByteArray());
  16. You should use something else then "BungeeCord" here:
    Code (Text):
                            out.writeUTF("BungeeCord"); // The channel name to check if this your data
    This channel is supposed to be unique for your plugin, so that your plugin recognizes the data, maybe something like your plugin name or "PluginName_Action", e.g. "BanManager_Broadcast" or something like that.

    Also you can remove the
    Code (Text):
    That is just an example of writing stuff other then UTF string (in this case the short 123)

    Also remember that you need a plugin on the receiving server reading the data. The plugin would in this instance look for the sub channel "BanManager_Broadcast" and only if the sub-channel matches then it would handle the data and broadcast it to the admins.