BungeeBridge 1.6.3

[API] Let your Bukkit communicate with BungeeCord!

  1. dommi2212
    header.png ... is the way to let your Spigot-Servers communicate with your Bungeecord-Instance!

    For Server-Owners.png
    If you install a plugin which needs this API you have to install it using the Installation-Guide. It won't have any effect for you!
    Keep in mind: You always have to use the same version of BungeeBridgeS and BungeeBridgeC!!!

    For Developers.png
    BungeeBridge is - like the name already says - a bridge between Spigot or Bukkit and Bungeecord.
    This API gives you the possibility to let Spigot communicate with Bungeecord. You just have to add it to your Workspace (BungeeBridge_Client for Spigot; BungeeBridge_Server for Bungeecord) and maybe to your plugin.yml as "depend" or "softdepend" (BungeeBridgeC and BungeeBridgeS)
    Now you can use all packets (See below)

    Please note: I'm currently working on BungeeBridge2! That means, that you will not receive full support for version 1.6.3 as it will be deprecated soon anyway.

    Installation-Guide.png (Also included in README.txt in BungeeBridge.zip)
    1.) Download BungeeBridge.zip from this page!
    2.) Unzip the File and copy BungeeBridge_Client.jar to Spigot/plugins/ and BungeeBridge_Server to Bungeecord/plugins/
    3.) Startup your Bungeecord and Spigot
    4.) Stop your Bungeecord and Spigot
    5.) Look into your plugins folder of Spigot & Bungeecord
    6.) Edit the config.yml to your need
    7.) You're done! Now you can look for plugins who use this API!

    Packet-Tutorials.png
    This will tell you if a player is on any server on the network:
    Code (Text):
    PacketIsPlayerOnline packet = new PacketIsPlayerOnline("dommi2212");
    Object obj = packet.send();
    IsOnlineResult isOnline = (IsOnlineResult) obj;

    if(isOnline == IsOnlineResult.ONLINE) {
      System.out.println("Yeah! Dommi is online!");
    }
    1.) Create a new "PacketItPlayerOnline" with argument "dommi2212"
    2.) Send the packet. "packet.send()" returns an Object
    3.) Cast "obj" to "IsOnlineResult" (You can see the returned type in the desc. of every packet)
    4.) Process the result (Here: Write in console if "dommi2212" is online)
    Note: Often you should prefer to run packet.send() async!
    This Tutorial moved to the BungeeBridge-Wiki!
    The page can be found here!
    Since version 1.6.0 ("The Event-Update") BungeeBridge offers an Event-API, allowing Spigot to call Events on BungeeCord.
    This requires advanced Knowledge in Java, Spigot, Bungeecord and BungeeBridge!

    How it works:
    A caller (e.g.: ListenerChat) listens on an action. This can be a Spigot-Event, a command or any other action you define. The caller creates an PacketFireEvent with a wrapped Event (e.g.: WrappedAsyncPlayerChatEvent) and sends it to BungeeBridgeS. BBS accepts the packet and extracts the event. Any plugin can register a WrappedEvent to BBS. After extracting the event, BBS checks the database for matching events. If an event is found, BBS calls "toEvent();"-method of the packet and fires it.
    Sounds quite complicated? Here the implementation in BungeeBridge for broadcasting Spigot's AsyncPlayerChatEvent to Bungee:

    On Spigot:
    Registering a listener for AsyncPlayerChatEvent and sending a PacketFireEvent:
    Code (Text):

    @EventHandler(priority = EventPriority.MONITOR)
       public void onChat(AsyncPlayerChatEvent e) {
         PacketFireEvent packet = new PacketFireEvent(new WrappedAsyncPlayerChatEvent(e.getPlayer().getUniqueId(), e.getMessage(), e.getFormat(), BungeeBridgeC.getBungeename()));
         packet.send();
       }
     
    The WrappedAsyncPlayerChatEvent is a wrapped "form" of Spigot's AsyncPlayerChatEvent:
    Code (Text):

    public class WrappedAsyncPlayerChatEvent extends WrappedEvent {

       private static final long serialVersionUID = -6973004689464370567L;
       private UUID uuid;
       private String message;
       private String format;
       private String bungeename;

       public WrappedAsyncPlayerChatEvent(UUID uuid, String message, String format, String bungeename) {
         this.uuid = uuid;
         this.message = message;
         this.format = format;
         this.bungeename = bungeename;
       }

       public UUID getUUID() {
         return uuid;
       }

       public String getMessage() {
         return message;
       }

       public String getFormat() {
         return format;
       }

       public String getBungeename() {
         return bungeename;
       }
     
    On Bungeecord:
    Registering the event to the database. This is important to get your event called by Bungeecord:
    Code (Text):

    PacketFireEventHandler.registerEvent(instance, WrappedAsyncPlayerChatEvent.class);
     
    On Bungee the WrappedAsyncPlayerChatEvent is a wrapped "form" of Spigot's AsyncPlayerChatEvent, too. On Bungee WrappedEvents have to declare a "toEvent();"-Method:
    Code (Text):

    public class WrappedAsyncPlayerChatEvent extends WrappedEvent {

       private static final long serialVersionUID = -6973004689464370567L;
       private UUID uuid;
       private String message;
       private String format;
       private String bungeename;

       public WrappedAsyncPlayerChatEvent(UUID uuid, String message, String format, String bungeename) {
         this.uuid = uuid;
         this.message = message;
         this.format = format;
         this.bungeename = bungeename;
       }

       public UUID getUUID() {
         return uuid;
       }

       public String getMessage() {
         return message;
       }

       public String getFormat() {
         return format;
       }

       public String getBungeename() {
         return bungeename;
       }

       @Override
       public Event toEvent() {
         return new AsyncPlayerChatEvent(uuid, message, format, bungeename);
       }
     
    The AsyncPlayerChatEvent on Bungeecord represents Spigot's Event. It has to extend Bungee's Event:
    Code (Text):

    public class AsyncPlayerChatEvent extends Event {

       private UUID uuid;
       private String message;
       private String format;
       private String bungeename;

       public AsyncPlayerChatEvent(UUID uuid, String message, String format, String bungeename) {
         this.uuid = uuid;
         this.message = message;
         this.format = format;
         this.bungeename = bungeename;
       }

       public UUID getUUID() {
         return uuid;
       }

       public String getMessage() {
         return message;
       }

       public String getFormat() {
         return format;
       }

       public String getBungeename() {
         return bungeename;
       }
     
    Now you can just listen on AsyncPlayerChatEvents.
    Common Pitfalls:
    - PacketFireEvents don't answer. You can't set the result of an event
    - You have to declare an "serialVersionUID" of type "private static final long" in the wrapped events, which has to be the same on Bungee and Spigot.
    - You have to create an unwrapped event on Bungee, which is returned by the "toEvent();"-method of your WrappedEvent.
    - You have to register the wrapped event to the database.

    Known Packets.png
    Since: 1.6.0
    Description: Packet used to chat a message or send a command as a player.
    Returns: -
    Constructor(s): new PacketChat(UUID uuid, String message);
    Since: 1.0.0
    Description: Packet used to connect a player to a server.
    Returns: ConnectResult result
    Constructor(s): new PacketConnectPlayer(UUID uuid, String server);
    Since: 1.2.0
    Description: Packet used to send custom Subjects & Data.
    Returns: Answer of your Bungeecord-Plugin
    Constructor(s): new PacketCustom(String channel, Object subject);
    Please have a look on the PacketCustom-Tutorial!
    Since: 1.6.0
    Description: Packet used to fire an event on BungeeCord.
    Returns: -
    Constructor(s): new PacketFireEvent(WrappedEvent event);
    Please have a look on the Event-API-Tutorial!
    Since: 1.1.0
    Description: Packet used to get the MOTD of a server.
    Returns: String MOTD
    Constructor(s): PacketGetMOTDServer(String bungeename);
    Since: 1.0.0
    Description: Packet used to get count of players on the network.
    Returns: int onlinecount
    Constructor(s): new PacketGetOnlineCountGlobal();
    Since: 1.0.0
    Description: Packet used to get count of players on a server.
    Returns: int onlinecount
    Constructor(s): PacketGetOnlineCountServer(String server);
    Since: 1.0.0
    Description: Packet used to get a player's IP.
    Returns: InetSocketAddress address
    Constructor(s): new PacketGetPlayerIP(UUID uuid);
    Since: 1.0.0
    Description: Packet used to get a player's name.
    Returns: String name
    Constructor(s): new PacketGetPlayerName(UUID uuid);
    Since: 1.0.0
    Description: Packet used to resolve the uuid of all players.
    Returns: List<UUID> uuids
    Constructor(s): new PacketGetPlayersGlobal();
    Since: 1.0.0
    Description: Packet used to resolve the uuid of all players on a server.
    Returns: List<UUID> uuids.
    Constructor(s): new PacketGetPlayersServer(String server);
    Since: 1.0.0
    Description: Packet used to get a player's uuid by their name.
    Returns: UUID uuid
    Constructor(s): new PacketGetPlayerUUID(String name);
    Since: 1.2.0
    Description: Packet used to get name of a player's server.
    Returns: String bungeename
    Constructor(s): new PacketGetServerByPlayer(UUID uuid);
    Since: 1.0.0
    Description: Packet used to get the IP of a server
    Returns: InetSocketAddress address
    Constructor(s): new PacketGetServerIP(String server);
    Since: 1.0.0
    Description: Packet used to get the names of all servers.
    Returns: List<String> servers
    Constructor(s): new PacketGetServers();
    Since: 1.5.1
    Description: Packet used to get the slots of a server.
    Returns: int slots
    Constructor(s): new PacketGetSlotsServer(String bungeename);
    Since: 1.0.0
    Description: Packet used to check if a player is online.
    Returns: IsOnlineResult result
    Constructor(s): new PacketIsPlayerOnline(UUID uuid);
    new PacketIsPlayerOnline(String name);
    Since: 1.2.0
    Description: Packet used to check if a server is online/responds.
    Returns: boolean result
    Constructor(s): new PacketIsServerOnline(String bungeename);
    Since: 1.0.0
    Description: Kicks all Players on the network.
    Returns: -
    Constructor(s): new PacketKickAllPlayers(String message);
    Since: 1.0.0
    Description: Packet used to kick a player from the network.
    Returns: -
    Constructor(s): new PacketKickPlayer(UUID uuid, String message);
    Since: 1.0.0
    Description: Packet used to send a message to all players on the network.
    Returns: -
    Constructor(s): new PacketMessageAllPlayers(String message);
    Since: 1.0.0
    Description: Packet used to send a message to a player.
    Returns: -
    Constructor(s): new PacketMessagePlayer(UUID uuid, String message);
    Since: 1.5.1
    Description: Packet used run command(s) from BungeeCord-Console.
    Returns: -
    Constructor(s): new PacketRunCommand(String... commands);
    Since: 1.4.0
    Description: Packet used to send a actionbar to a player.
    Returns: -
    Constructor(s): new PacketSendActionbar(UUID uuid, String actionbar);
    Since: 1.5.0
    Description: Packet used to send a title to all players.
    Returns: -
    Constructor(s): new PacketSendTitle(PackedTitle title);
    Since: 1.4.0
    Description: Packet used to send a title to a player.
    Returns: -
    Constructor(s): new PacketSendTitle(UUID uuid, PackedTitle title);
    Since: 1.0.0
    Description: Packet used to stop the proxy.
    Returns: -
    Constructor(s): new PacketStopProxy();
    new PacketStopProxy(String message);
    Since: 1.6.2
    Description: Packet used to send a JSON- or "Tellraw"-Message to a player. A JSON-String can be obtained easily by using ComponentSerializer#toString(BaseComponent) of Spigot's ChatAPI.
    Returns: -
    Constructor(s): new PacketTellraw(UUID uuid, String jsonString);
    Since: 1.0.0
    Description: Packet used to write a message to the console.
    Returns: -
    Constructor(s): new PacketWriteConsole(String message);
    new PacketWriteConsole(String message, Level level);

    Source, Wiki and Documentation.png
    The whole BungeeBridge-Project is opensource and can be used under the therms of MIT license!
    See this for Source!
    Click here for the wiki (not finished yet)!
    The documentation is available here for client and here for server!
    Of course you are allowed to help me using Issues or Pull-Requests!

    Design made by NitroFox0! Make sure to visit his profile!
    Seloex, LimeGlass, niho1212 and 2 others like this.

Recent Reviews

  1. Seloex
    Seloex
    5/5,
    Version: 1.6.3
    Really Nice resource, I recommend everyone to take a close look at this resource :D
  2. gnomik12
    gnomik12
    5/5,
    Version: 1.6.3
    i did not understand how to use this packets? Can anyone help me?
    --------------------------------------------
  3. BrunoAvixdubSB
    BrunoAvixdubSB
    4/5,
    Version: 1.6.3
    Nice plugin and one question the plugin no wpork for send command of PermissionEX ? .
  4. Ephysios
    Ephysios
    5/5,
    Version: 1.6.3
    Nice ressource, thank you ! Does the plugin still work if the BungeeCord (server) is not on the same machine as the servers (client)?
  5. Preodym
    Preodym
    5/5,
    Version: 1.6.3
    hey

    Is it possible to send packets from the bungee to the spigot server? So that the bungee executes a command on all servers?

    This is a very nice plugin!

    best regards
    - Preodym
    1. dommi2212
      Author's Response
      Hey, thanks for your rating :)

      Sadly I have to tell you, that there is currently no option to send packets from Bungeecord to Spigot, but I'm currently working on it.
  6. Msql
    Msql
    5/5,
    Version: 1.6.3
    Awesome plugin. Hope it will support redis plugin for Bungeecord (It connects bungeecord proxy to one network). I need this support a lot :P!
  7. Acquized
    Acquized
    5/5,
    Version: 1.6.3
    This is the best communication Plugin between Bungee and Spigot! Really thanks for this great plugin! You can make ANYTHING, even a sign system with this plugin. A must have for any big Bungee System!
  8. svdragster
    svdragster
    5/5,
    Version: 1.6.3
    Awesome API, easy to use, quick bug fixes! I've messaged the author to check out the big memory usage, and he fixed it within a short amount of time.
  9. val59000
    val59000
    5/5,
    Version: 1.6.2
    This is fantastic, with this I am now able to run Bungee Command from a Spigot console. Thanks !
  10. KillerUpdate
    KillerUpdate
    5/5,
    Version: 1.6.2
    Perfect !