Alemiz112 / StarGate-Atlantis

This is stable and fast plugin for PMMP that allows server connect to WaterDog plugin StarGate. It make easier communication between server. Includes API for custom packets, transferring players and more
Apache License 2.0
48 stars 18 forks source link

StarGate-Atlantis

Discord server

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!

🎯Features:

More features will be added very soon

🔧API

You can access StarGate-Atlantis by StarGateAtlantis::getInstance()

Avalibe Functions

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.

Example:
$player = PLUGIN::getInstance()->getPlayer("alemiz003");
$server = "lobby2";

StarGateAtlantis::getInstance()->transferPlayer($player, $server);

To more examples look here!

📦Packet Handling

Received Packets are handled by CustomPacketEvent. Official Packets are handled (if needed) automaticly

Accessing Packet from Event:

public function getPacket() {
  return $this->packet;
}

📞ResponseCheckTask

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.

⚙️Creating Own Packets

For better understanding please read StarGatePacket and WelcomePacket

Docker Implementation

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

Convertor is used for encoding and decoding packets. We can use it for static and nonstatic usage
Functions:

Example (nonstatic):
$convertor = new Convertor($this->getID());
$convertor->putString($this->server);
$convertor->putInt($this->tps);

$this->encoded = $convertor->getPacketString();
Example (static):
$data = Convertor::getPacketStringData($packetString);
$packetId = (int) $data[0];