Skip to content

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

License

Notifications You must be signed in to change notification settings

Lucqs3318/StarGate-Atlantis

 
 

Repository files navigation

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:

  • Fast communication between servers
  • Custom packets
  • Moving players between servers (API)

More features will be added very soon

🔧API

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

Avalibe Functions

  • RegisterPacket(StarGatePacket packet) Really simple method for registring Packet
  • putPacket(StarGatePacket packet, string $client) This allows you to send packet. Packet must be registered first
  • transferPlayer(Player player, string server, string $client) This we use to transfer Player between servers
  • kickPlayer(Player player, string reason, string $client) Kick player from any server connected to StarGate network
  • isOnline(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/server
  • addServer(string $address, string $port, string $name, string $client) Add server to list and allows players to transfer
  • removeServer(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.

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:

  • 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

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];

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%