This is stable and fast plugin for pmmp that allows server connect to WaterDog plugin StarGate. It make easier communication between server. Includes API fur custom packets, transferring players and more
Download here!
- Fast communication between servers
- Custom packets
- Moving players between servers (API)
More features will be added very soon
You can access StarGate-Atlantis by StarGateAtlantis::getInstance()
RegisterPacket(StarGatePacket packet)
Really simple method for registring PacketputPacket(StarGatePacket packet, string $client)
This allows you to send packet. Packet must be registered firsttransferPlayer(Player player, string server, string $client)
This we use to transfer Player between serverskickPlayer(Player player, string reason, string $client)
Kick player from any server connected to StarGate networkisOnline(Player player, string $client)
Check if player is online. Sends back response 'true!server' or 'false'. Examples here.forwardPacket(string $destClient, string $localClient, StarGatePacket $packet)
Using ForwardPacket you can forward packet to other client/serveraddServer(string $address, string $port, string $name, string $client)
Add server to list and allows players to transferremoveServer(string $name, string $client)
Remove server from server list
Client variable in API is used to specify destination proxy (if more instances are used). It is not important to define it, if one one proxy is used.
$player = PLUGIN::getInstance()->getPlayer("alemiz003");
$server = "lobby2";
StarGateAtlantis::getInstance()->transferPlayer($player, $server);
To more examples look here!
Received Packets are handled by CustomPacketEvent
. Official Packets are handled (if needed) automaticly
Accessing Packet from Event:
public function getPacket() {
return $this->packet;
}
Response checking is useful when we want to get some data created by packet back to client.
PHP allows you to use simple closures to handle result:
$closure = function ($response){
StarGateAtlantis::getInstance()->getLogger()->info("§a".$response);
};
StarGateAtlantis::getInstance()->isOnline("alemiz0003", $closure);
For more info please consider looking here.
For better understanding please read StarGatePacket and WelcomePacket
If you have servers inside Docker container this is for you. StarGate allows you to create/remove/start/stop any container. Using ServerManagePacket
you can set container exposed ports and env. variables too.
Working example can be found here.
Convertor is used for encoding
and decoding
packets. We can use it for static and nonstatic usage
Functions:
-
packetStringData(string packetString)
Exports packetString to data array -
putInt(int integer)
Pushes Integer to array -
putString(string string)
Pushes String to array -
getString(int key)
Returns String from array by key value -
getPacketString()
Returns packetString from array data -
static getInt(string string)
Returns Integer from String -
static getForcePacketString(array strings)
Returns packetString from given array -
static getPacketStringData(string packetString)
Returns array data from given string
$convertor = new Convertor($this->getID());
$convertor->putString($this->server);
$convertor->putInt($this->tps);
$this->encoded = $convertor->getPacketString();
$data = Convertor::getPacketStringData($packetString);
$packetId = (int) $data[0];