.

.

You don’t like Plugin Messaging Channels? You want to use sockets but you think it’s too difficult for you? This API allows developers to send data from Bungee to Spigot/Sponge and from Spigot/Sponge to Bungee.

♦ Use Sockets (in case you haven’t understood yet)

♦ Very easy-to-use

♦ Call Bungee and Spigot/Sponge events

♦ Lightweight, fast, efficient

♦ Encrypted data transfer (RSA encryption)

You have to install and configure Socket4MC on BungeeCord and on all your Spigot/Sponge servers

BungeeCord configuration:

port: 25575
name: "MyBungee"
security-level: 1
password: "My Secret Password"

Spigot/Sponge configuration:

host: "localhost"
port: 25575
name: "MySponge" // or "Factions", "Lobby", ...
password: "My Secret Password"

♦ host: BungeeCord’s address (e.g. mc.rhaz.fr, localhost) Set it to localhost if you don’t know what is it

♦ port: A port used for communication (not the same as your BungeeCord port)

♦ name: The server name (e.g. Factions, SmashBros) in lower case

security-level:

0=no security,

1=AES encryption,

2=AES encryption and RSA keys sent

password: A password used to prevent third party connections

----------------- on Sponge -------------------

// Send a message "Ping!" to BungeeCord over channel "MyChannel"
public void sendPing()
	JSONMap map = new JSONMap(
		"message", "Ping!"
	);

	Socket4Sponge.getClient().write("MyChannel", map);
}

// Send it when it is connected
@Listener
public void onHandshake(ClientSocketHandshakeEvent e){
	sendPing();
}

------------------- on BungeeCord -------------------

@Override
public void onEnable() {
   getProxy().getPluginManager().registerListener(this, this);
}

// Receive a message "Ping!" from Spigot and send "Pong!"
@EventHandler
public void onSocketMessage(ServerSocketJSONEvent e){

	String channel = e.getChannel(); // The channel name
 
	if(!channel.equals("MyChannel")) return;

	String name = e.getName(); // The name of the server

	String message = e.getExtraString("message");
 
	getLogger().info("Received message from " + name + ": " + message);

	if(message.equals("Ping!")){
		e.write("message", "Pong!"); // Quick reply to this channel
	}
 
}

.

.

Category: Developer Tools

Published on May 6, 2018

views

stars

watchers

total downloads

Promoted Versions

Pages

Members