diff options
| author | Ritabrata Das <[email protected]> | 2025-02-15 19:17:52 +0530 |
|---|---|---|
| committer | Ritabrata Das <[email protected]> | 2025-02-15 19:17:52 +0530 |
| commit | e8a42be368aa2a15c623a3e877ec39fca33edd8e (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /plugins | |
| parent | 71216e5082346dc6824b50dd103fb264fb205f3d (diff) | |
Initial Commit for docs
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/allcaps.py | 23 | ||||
| -rw-r--r-- | plugins/chat_weather_setter.py | 100 | ||||
| -rw-r--r-- | plugins/command_test.py | 26 | ||||
| -rw-r--r-- | plugins/custom_aircraft_list/Plugin.py | 42 | ||||
| -rw-r--r-- | plugins/custom_aircraft_list/__init__.py | 2 | ||||
| -rw-r--r-- | plugins/custom_aircraft_list/custom_list.json | 14 | ||||
| -rw-r--r-- | plugins/discolights.py | 22 | ||||
| -rw-r--r-- | plugins/over_g_damage.py | 31 | ||||
| -rw-r--r-- | plugins/smoke_on_damage/Plugin.py | 48 | ||||
| -rw-r--r-- | plugins/smoke_on_damage/__init__.py | 2 |
10 files changed, 0 insertions, 310 deletions
diff --git a/plugins/allcaps.py b/plugins/allcaps.py deleted file mode 100644 index 83b5aec..0000000 --- a/plugins/allcaps.py +++ /dev/null @@ -1,23 +0,0 @@ -"""This plugin will convert all chat messages to all caps. -It can be enabled here by changing the value of ENABLED to True.""" -from lib.PacketManager.packets import FSNETCMD_TEXTMESSAGE -from logging import info -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_hook('on_chat', self.on_chat) - - def on_chat(self, data, player,message_to_client, message_to_server): - if ENABLED: - message = FSNETCMD_TEXTMESSAGE(data, should_decode=True) - message.message = message.message.upper() - message = FSNETCMD_TEXTMESSAGE.encode(f"({message.user}){message.message}", with_size=True) - message_to_server.append(message) - - - return False diff --git a/plugins/chat_weather_setter.py b/plugins/chat_weather_setter.py deleted file mode 100644 index 5b31a38..0000000 --- a/plugins/chat_weather_setter.py +++ /dev/null @@ -1,100 +0,0 @@ -"""This plugin will set the weather based on a chat message. -""" -from lib.PacketManager.packets import FSNETCMD_SKYCOLOR, FSNETCMD_FOGCOLOR, FSNETCMD_TEXTMESSAGE, FSNETCMD_ENVIRONMENT -from random import randint -ENABLED = True - -class Plugin: - def __init__(self): - self.initialWeather = None - self.plugin_manager = None - - def register(self, plugin_manager): - self.plugin_manager = plugin_manager - #self.plugin_manager.register_hook('on_chat', self.on_chat) - self.plugin_manager.register_hook('on_environment_server', self.on_environment) - self.plugin_manager.register_command('fog', self.fog) - self.plugin_manager.register_command('sky', self.sky) - self.plugin_manager.register_command('time', self.time) - self.plugin_manager.register_command('vis', self.visibility) - - def fog(self, full_message, player, message_to_client, message_to_server): - try: - args = list(map(int, full_message[4:].split(','))) - except: - message_to_client.append(FSNETCMD_TEXTMESSAGE.encode("Invalid fog argument, usage /fog r,g,b", True)) - return - fog_colour_packet = FSNETCMD_FOGCOLOR.encode(args[0], args[1], args[2], True) - message_to_client.append(fog_colour_packet) - - def sky(self, full_message, player, message_to_client, message_to_server): - try: - args = list(map(int, full_message[4:].split(','))) - except Exception as e: - message_to_client.append(FSNETCMD_TEXTMESSAGE.encode("Invalid sky argument, usage /sky r,g,b", True)) - return True - sky_colour_packet = FSNETCMD_SKYCOLOR.encode(args[0], args[1], args[2], True) - message_to_client.append(sky_colour_packet) - return True - - def time(self, full_message, player, message_to_client, message_to_server): - requested = full_message[6:].lower() - if requested == 'day' and self.initialWeather: - packet = FSNETCMD_ENVIRONMENT.set_time(self.initialWeather.buffer, False, True) - self.initialWeather = FSNETCMD_ENVIRONMENT(packet[4:]) - message_to_client.append(packet) - - elif requested == 'night' and self.initialWeather: - packet = FSNETCMD_ENVIRONMENT.set_time(self.initialWeather.buffer, True, True) - self.initialWeather = FSNETCMD_ENVIRONMENT(packet[4:]) - message_to_client.append(packet) - - else: - message_to_client.append(FSNETCMD_TEXTMESSAGE.encode("Invalid time argument, usage /time night or /time day", True)) - return True - - def visibility(self, full_message, player, message_to_client, message_to_server): - visibility = int(full_message[4:]) - returnpacket = FSNETCMD_ENVIRONMENT.set_visibility(self.initialWeather.buffer, visibility, True) - self.initialWeather = FSNETCMD_ENVIRONMENT(returnpacket[4:]) - message_to_client.append(returnpacket) - return True - - """ - def on_chat(self, data, player, messages_to_client, *args): - if ENABLED: - message = FSNETCMD_TEXTMESSAGE(data).message - if message[:3].lower() == 'fog': - #We'll split the fog r,g,b message into a list of 3 integers - fog = list(map(int, message[4:].split(','))) - fog_colour_packet = FSNETCMD_FOGCOLOR.encode(fog[0], fog[1], fog[2], True) - messages_to_client.append(fog_colour_packet) - - if message[:3].lower() == 'sky': - sky = list(map(int, message[4:].split(','))) - sky_colour_packet = FSNETCMD_SKYCOLOR.encode(sky[0], sky[1], sky[2], True) - messages_to_client.append(sky_colour_packet) - - if message[:3].lower() == 'day' and self.initialWeather: - packet = FSNETCMD_ENVIRONMENT.set_time(self.initialWeather.buffer, False, True) - self.initialWeather = FSNETCMD_ENVIRONMENT(packet[4:]) - messages_to_client.append(packet) - - if message[:5].lower() == 'night' and self.initialWeather: - packet = FSNETCMD_ENVIRONMENT.set_time(self.initialWeather.buffer, True, True) - self.initialWeather = FSNETCMD_ENVIRONMENT(packet[4:]) - messages_to_client.append(packet) - - if message[:3].lower() == 'vis': - visibility = int(message[4:]) - returnpacket = FSNETCMD_ENVIRONMENT.set_visibility(self.initialWeather.buffer, visibility, True) - self.initialWeather = FSNETCMD_ENVIRONMENT(returnpacket[4:]) - messages_to_client.append(returnpacket) - return False - """ - - - def on_environment(self, data, *args): - """Store the initial weather packet for the server.""" - self.initialWeather = FSNETCMD_ENVIRONMENT(data) - return True diff --git a/plugins/command_test.py b/plugins/command_test.py deleted file mode 100644 index 6d8e8af..0000000 --- a/plugins/command_test.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -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 diff --git a/plugins/custom_aircraft_list/Plugin.py b/plugins/custom_aircraft_list/Plugin.py deleted file mode 100644 index 0fc1bd0..0000000 --- a/plugins/custom_aircraft_list/Plugin.py +++ /dev/null @@ -1,42 +0,0 @@ -"""TThis plugin will cause the aircraft to emit smoke if it's health is below a certain threshold. -It is also an example of a plugin as a folder/module. -This can be used as a basis for more complex plugins that may need multiple files.""" -from lib.PacketManager.packets import List_Constructor -from json import load -from struct import pack -from logging import error -ENABLED = False -custom_list_file = "plugins\\custom_aircraft_list\\custom_list.json" - -class Plugin: - def __init__(self): - self.plugin_manager = None - self.aircraft_list = [] - - def register(self, plugin_manager): - self.plugin_manager = plugin_manager - with open(custom_list_file, 'r', encoding='utf-8') as f: - json_file = load(f) - if isinstance(json_file,list): - self.aircraft_list = json_file - else: - error(f"Invalid JSON file {custom_list_file}. Must be a list of aircraft.") - self.plugin_manager.register_hook('on_list', self.on_list) - self.plugin_manager.register_hook('on_list_server', self.on_list_server) - - def on_list(self, packet, player, message_to_client, message_to_server): - if ENABLED: - return False - - def on_list_server(self, packet, player, message_to_client, message_to_server): - if ENABLED: - #Send the packet straight back to the server, and prevent it being passed to the client. - packet = pack("I",len(packet)) + packet - message_to_server.append(packet) - if not hasattr(player, 'custom_packet_sent'): - player.custom_packet_sent=True - #Send the custom list packets. - lc = List_Constructor(self.aircraft_list).get_packets() - for packet in lc: - message_to_client.append(packet) - return False diff --git a/plugins/custom_aircraft_list/__init__.py b/plugins/custom_aircraft_list/__init__.py deleted file mode 100644 index 425d2ad..0000000 --- a/plugins/custom_aircraft_list/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .Plugin import Plugin -from .Plugin import ENABLED
\ No newline at end of file diff --git a/plugins/custom_aircraft_list/custom_list.json b/plugins/custom_aircraft_list/custom_list.json deleted file mode 100644 index 987350d..0000000 --- a/plugins/custom_aircraft_list/custom_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "AIRBUS300", - "AIRBUS320", - "B737", - "B747", - "B767", - "B777", - "CONCORDE", - "DIAMOND_ECLIPSE", - "PIPER_ARCHER(WASHIN-AIR_MARKING)", - "T-400", - "U-125", - "U-125A" -] diff --git a/plugins/discolights.py b/plugins/discolights.py deleted file mode 100644 index db441e7..0000000 --- a/plugins/discolights.py +++ /dev/null @@ -1,22 +0,0 @@ -"""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 = False - -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): - if ENABLED: - 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 diff --git a/plugins/over_g_damage.py b/plugins/over_g_damage.py deleted file mode 100644 index 50c1b21..0000000 --- a/plugins/over_g_damage.py +++ /dev/null @@ -1,31 +0,0 @@ -"""This plugin will cause damage to the aircraft if -it exceeds the g-force limit set in the config file.""" -from lib.PacketManager.packets import FSNETCMD_GETDAMAGE, FSNETCMD_TEXTMESSAGE -from config import G_LIM -import time - -# CONFIG -ENABLED = True # Enable or disable the plugin -INTERVAL = 0.3 # Interval of second before G Limit check is enforced - -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): - if ENABLED: - if abs(player.aircraft.last_packet.g_value)> G_LIM: - if time.time() - player.aircraft.last_over_g_message > INTERVAL: - player.aircraft.last_over_g_message = time.time() - damage_packet = FSNETCMD_GETDAMAGE.encode(player.aircraft.id, - 1, 1, - player.aircraft.id, - 1, 11,0, True) - warning_message = FSNETCMD_TEXTMESSAGE.encode(f"You are exceeding the G Limit for the aircraft!, gValue = {player.aircraft.last_packet.g_value}!",True) - messages_to_client.append(damage_packet) - messages_to_client.append(warning_message) - return True diff --git a/plugins/smoke_on_damage/Plugin.py b/plugins/smoke_on_damage/Plugin.py deleted file mode 100644 index 08c184b..0000000 --- a/plugins/smoke_on_damage/Plugin.py +++ /dev/null @@ -1,48 +0,0 @@ -"""TThis plugin will cause the aircraft to emit smoke if it's health is below a certain threshold. -It is also an example of a plugin as a folder/module. -This can be used as a basis for more complex plugins that may need multiple files.""" -from lib.PacketManager.packets import FSNETCMD_AIRCMD, FSNETCMD_AIRPLANESTATE, FSNETCMD_TEXTMESSAGE -from logging import debug -from config import SMOKE_LIFE, SMOKE_PLANE -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_flight_data) - self.plugin_manager.register_hook('on_weapon_config', self.on_weapon_config) - - def on_flight_data(self, data, player,message_to_client, message_to_server): - """After the initial incoming flight packet, check whether - the health is below the threshold, if so add smoke""" - if SMOKE_PLANE and player.aircraft.life<SMOKE_LIFE: - - #Add smoke to the plane - smoke_packet = FSNETCMD_AIRPLANESTATE(data).smoke() - #forward it on to the server - - message_to_server.append(smoke_packet) - - - - if not player.aircraft.damage_engine_warn_sent: - player.aircraft.damage_engine_warn_sent = True - #Warn the player - message = "Your engine has been damaged! You can't turn on your afterburner!" - message_to_client.append(FSNETCMD_TEXTMESSAGE.encode(message,True)) - - debug(f"Engine damage warning sent to {player.username}") - - message_to_client.append(FSNETCMD_AIRCMD.set_afterburner(player.aircraft.id, False, True)) - - return False - - def on_weapon_config(self, data, player, message_to_client, message_to_server): - if ENABLED: - player.aircraft.just_repaired = True - if player.aircraft.get_initial_config_value("AFTBURNR") == "TRUE": - message_to_client.append(FSNETCMD_AIRCMD.set_afterburner(player.aircraft.id, True, True)) - return True diff --git a/plugins/smoke_on_damage/__init__.py b/plugins/smoke_on_damage/__init__.py deleted file mode 100644 index 425d2ad..0000000 --- a/plugins/smoke_on_damage/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .Plugin import Plugin -from .Plugin import ENABLED
\ No newline at end of file |
