diff options
| author | Ritabrata Das <[email protected]> | 2025-02-15 19:48:02 +0530 |
|---|---|---|
| committer | Ritabrata Das <[email protected]> | 2025-02-15 19:48:02 +0530 |
| commit | 33251e2c8e9e7983084777b518c7d72b539e1be8 (patch) | |
| tree | 56e1409ff72f10ab02272ee8ff60270ff5fec10a /docs | |
| parent | 5e2a39e0bd9c2ac9c429d79a542f39d08e80eef0 (diff) | |
Add some documentation, favicion
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/README.md | 91 | ||||
| -rw-r--r-- | docs/favicon.ico | bin | 0 -> 15406 bytes | |||
| -rw-r--r-- | docs/index.html | 43 |
3 files changed, 113 insertions, 21 deletions
diff --git a/docs/README.md b/docs/README.md index 7571812..736c0aa 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,92 @@ # Sakuya AC API Documentation -> An awesome project. +Sakuya AC : The perfect and elegant YSFlight Proxy Software. It is written in Python. Uses +asyncio so that it doesn't lag. This documentation will guide you through creating your +own Plugin for Sakuya AC. + +## Getting Started + +To get started with Sakuya AC, you need to have Python 3.9 or higher installed on your system. + +### Basic Structure of a Plugin + +There are two ways to work with the proxy: +1. Hooks : These actually modify the incoming/outgoing packets from YSF Server, these are blocking +and can be used to modify the packets. +- Example : G Limiter, Chat Filter; As these need to modify the packets at that instant + +2. Commands : These are non essential and do not modify the incoming/outgong packets, you can send your +own packets to server/client. These are non blocking. +- Example : Fog color changer, Ban command; these do not need to modify any commands at that instant + +- All plugins are saved in plugins directory in the root of the project. + +### Simple Command Plugin + +```python +""" +This is an example test command! +""" + +from lib import YSchat +from time import sleep + +ENABLED = False + +class Plugin: + def __init__(self): + self.plugin_manager = None + + def register(self, plugin_manager): + self.plugin_manager = plugin_manager + self.plugin_manager.register_command('test', self.test) + self.plugin_manager.register_command('timer', self.timer) + + def test(self, full_message, player, message_to_client, message_to_server): + message_to_client.append(YSchat.message("Test command received")) + return True + + def timer(self, full_message, player, message_to_client, message_to_server): + sleep(5) + message_to_client.append(YSchat.message("Timer ended")) + return True +``` +- You start the plugin by giving it a description, +- You must have a global ENABLED variable, which is set by the user + if they wish to enable the plugin or not +- You must have a class Plugin, which has a register method + use ``register_command`` to register a command. + -- ``self.plugin_manager.register_command('command_name', self.function_name)`` +- now self.function_name must take the shown parameters + +### Simple Hooks Plugin + +```python +"""This plugin will flash the lights/fog colour whenever a flight status update +is sent +It can be enabled here by changing the value of ENABLED to True.""" +from lib.PacketManager.packets import FSNETCMD_SKYCOLOR, FSNETCMD_FOGCOLOR +from random import randint +ENABLED = True + +class Plugin: + def __init__(self): + self.plugin_manager = None + + def register(self, plugin_manager): + self.plugin_manager = plugin_manager + self.plugin_manager.register_hook('on_flight_data', self.on_receive) + + def on_receive(self, data, player, messages_to_client, *args): + sky_colour_packet = FSNETCMD_SKYCOLOR.encode(randint(0, 255), randint(0, 255), randint(0, 255), True) + fog_colour_packet = FSNETCMD_FOGCOLOR.encode(randint(0, 255), randint(0, 255), randint(0, 255), True) + messages_to_client.append(sky_colour_packet) + messages_to_client.append(fog_colour_packet) + return True +``` +- Unlike the previous example, this uses a hook which modifies the packet from the server at that instant +- You must return True at the end of the function to indicate that the original packet will be sent + -- (In this case, the orginal packet is the flight data, not sending will cause the client to + not receive the flight data) +- returning False, means the orginal packet which triggered the hook will not be sent to the YSF server, +this is useful for chat filters etc. diff --git a/docs/favicon.ico b/docs/favicon.ico Binary files differnew file mode 100644 index 0000000..3e93493 --- /dev/null +++ b/docs/favicon.ico diff --git a/docs/index.html b/docs/index.html index 04dd4a7..10e4705 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,22 +1,25 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> -<head> - <meta charset="UTF-8"> - <title>Document</title> - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> - <meta name="description" content="Description"> - <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> - <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css"> -</head> -<body> - <div id="app"></div> - <script> - window.$docsify = { - name: '', - repo: '' - } - </script> - <!-- Docsify v4 --> - <script src="//cdn.jsdelivr.net/npm/docsify@4"></script> -</body> + <head> + <meta charset="UTF-8" /> + <title>Sakuya AC Documentation</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> + <meta + name="description" + content="API Documentations for developing plugins for Sakuya AC" + /> + <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" /> + <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css" /> + </head> + <body> + <div id="app"></div> + <script> + window.$docsify = { + name: "", + repo: "", + }; + </script> + <!-- Docsify v4 --> + <script src="//cdn.jsdelivr.net/npm/docsify@4"></script> + </body> </html> |
