diff options
| -rw-r--r-- | lib/Aircraft.py | 3 | ||||
| -rw-r--r-- | lib/plugin_manager.py | 3 | ||||
| -rw-r--r-- | plugins/crash_on_ground.py | 9 | ||||
| -rw-r--r-- | plugins/radar.py | 2 | ||||
| -rw-r--r-- | proxy.py | 12 |
5 files changed, 20 insertions, 9 deletions
diff --git a/lib/Aircraft.py b/lib/Aircraft.py index 5e6e24d..9f162ef 100644 --- a/lib/Aircraft.py +++ b/lib/Aircraft.py @@ -78,9 +78,8 @@ class Aircraft: return None if self.life == -1: self.life=packet.life - + self.prev_life = self.life - self.life = packet.life self.set_position(packet.position) self.set_attitude(packet.atti) diff --git a/lib/plugin_manager.py b/lib/plugin_manager.py index 0a9174c..b96045b 100644 --- a/lib/plugin_manager.py +++ b/lib/plugin_manager.py @@ -7,12 +7,13 @@ PLUGIN_DIR = os.path.join(os.path.dirname(__file__), '../plugins') sys.path.append(PLUGIN_DIR) class PluginManager: - def __init__(self): + def __init__(self, connected_players): self.plugins = {} self.hooks= {} self.commands = {'help': None} self.help_message = "List of Available Commands:\n" self.load_plugins() + self.connected_players = connected_players def load_plugins(self): for plugin in os.listdir(PLUGIN_DIR): diff --git a/plugins/crash_on_ground.py b/plugins/crash_on_ground.py index fb9d080..4cc334b 100644 --- a/plugins/crash_on_ground.py +++ b/plugins/crash_on_ground.py @@ -1,6 +1,6 @@ # This plugin renders the dead plane until crashes in ground # Thus disabling mid air dispawning when dead -from lib.PacketManager.packets import FSNETCMD_REMOVEAIRPLANE, FSNETCMD_READBACK +from lib.PacketManager.packets import FSNETCMD_REMOVEAIRPLANE, FSNETCMD_READBACK, FSNETCMD_GETDAMAGE ENABLED = True @@ -11,6 +11,7 @@ class Plugin: def register(self, plugin_manager): self.plugin_manager = plugin_manager #self.plugin_manager.register_hook('on_unjoin', self.on_death) + #self.plugin_manager.register_hook('on_add_object_server', self.on_join) self.plugin_manager.register_hook('on_remove_airplane_server', self.on_death) def on_death(self, data, player, message_to_client, message_to_server): @@ -18,6 +19,12 @@ class Plugin: if player.aircraft.id == FSNETCMD_REMOVEAIRPLANE(data).object_id: return True else: + decode = FSNETCMD_REMOVEAIRPLANE(data) + b = FSNETCMD_GETDAMAGE.encode(decode.object_id, 1, 1, + player.aircraft.id, 10000, + 11, 0, True) + message_to_client.append(b) + message_to_server.append(b) a = FSNETCMD_READBACK.encode(2, player.aircraft.id, True) message_to_server.append(a) return False diff --git a/plugins/radar.py b/plugins/radar.py index 7636dc4..e09447d 100644 --- a/plugins/radar.py +++ b/plugins/radar.py @@ -9,7 +9,7 @@ import struct import traceback ENABLED = True -RADIUS = 5000 # in meters, within this range planes with different IFF can see each other. +RADIUS = 9000 # in meters, within this range planes with different IFF can see each other. flying_players = {} @@ -56,7 +56,7 @@ info("Lisenced under GPLv3") info("Press CTRL+C to stop the proxy") #Load the plugins -plugin_manager = PluginManager() +plugin_manager = PluginManager(CONNECTED_PLAYERS) # Close Connection async def close_connection(client_writer, server_writer): @@ -135,6 +135,7 @@ async def handle_client(client_reader, client_writer): # if not keep_message: # data = None player.login(FSNETCMD_LOGON(packet)) + info(f"Player {player.username} connected from {player.ip}") if player.version != YSF_VERSION and VIA_VERSION: info(f"ViaVersion enabled : Porting {player.username} from {player.version} to {YSF_VERSION}") message_to_client.append(YSchat.message(f"Porting you to YSFlight {YSF_VERSION}, This is currently Experimental")) @@ -150,7 +151,8 @@ async def handle_client(client_reader, client_writer): asyncio.create_task(discord_send_message(CHANNEL_ID, f"{player.username} has took off in a {decode.aircraft}! 🛫")) elif packet_type == "FSNETCMD_AIRPLANESTATE": - player.aircraft.add_state(FSNETCMD_AIRPLANESTATE(packet)) #TODO: Do we want to convert all this to plugins? Probably not, but there is duplicated functionality + decode = FSNETCMD_AIRPLANESTATE(packet) + player.aircraft.add_state(decode) #TODO: Do we want to convert all this to plugins? Probably not, but there is duplicated functionality # keep_message = plugin_manager.triggar_hook('on_flight_data', packet, player, message_to_client, message_to_server) # if not keep_message: # data = None @@ -265,8 +267,10 @@ async def handle_client(client_reader, client_writer): """ if not player.connection_closed: player.connection_closed = True - if DISCORD_ENABLED and not player.is_a_bot: - await discord_send_message(CHANNEL_ID, f"{player.username} has left the server!") + if not player.is_a_bot: + message_to_server.append(YSchat.message(f"{player.username} has left the server!")) + if DISCORD_ENABLED: + await discord_send_message(CHANNEL_ID, f"{player.username} has left the server!") await close_connection(client_writer, server_writer) |
