diff --git a/assets/script.js b/assets/script.js index 8629049..51a3eab 100644 --- a/assets/script.js +++ b/assets/script.js @@ -181,7 +181,7 @@ const tick = async () => { ""; } $("#onlinePlayersTable>tbody").append(row); - } else if (p.playerName != "") { + } else { $("#offlinePlayersTable>tbody").append(row); if (isAdmin) { row.innerHTML += @@ -254,12 +254,13 @@ const createActionButtons = function (status, player) { .text("Reset Perms"); actionButtonBufferList.push(ResetButton); + /* RemoveButton = sButton .clone() .attr("data-action", "remove") .text("Remove"); actionButtonBufferList.push(RemoveButton); - + */ if (status != "online") { kickButton.addClass("disabled"); } @@ -272,6 +273,13 @@ const createActionButtons = function (status, player) { if (player.playerCategory == "Admin") { AdminButton.addClass("disabled"); } + if (player.playerName == "") { + kickButton.addClass("disabled"); + banButton.addClass("disabled"); + WLButton.addClass("disabled"); + AdminButton.addClass("disabled"); + ResetButton.addClass("disabled"); + } } actionButtonBufferList.forEach((element) => { DDMenu.append(element); diff --git a/assets/style.css b/assets/style.css index 199faab..843c8a9 100644 --- a/assets/style.css +++ b/assets/style.css @@ -36,7 +36,9 @@ h5 { margin: 0; line-height: 200%; } - +#onlinePlayersRow { + z-index: 10000; +} #banner { background: #17142f; white-space: nowrap; diff --git a/cogs/AstroWebServer.py b/cogs/AstroWebServer.py index 7cee7fd..a352d22 100644 --- a/cogs/AstroWebServer.py +++ b/cogs/AstroWebServer.py @@ -244,18 +244,18 @@ def post(self): players = self.launcher.DedicatedServer.players['playerInfo'] except: return - guid = None + playerGUID = None playerName = None player = None if "guid" in data and data["guid"] is not None: - guid = data["guid"] + playerGUID = data["guid"] - if guid: - playerGUID = guid + if playerGUID: player = [x for x in players if x['playerGuid'] - == playerGUID and x["playerName"] != ""][0] - + == playerGUID][0] playerName = player["playerName"] + if playerName == "": + playerName = None if "name" in data: playerName = data["name"] try: @@ -263,7 +263,7 @@ def post(self): == playerName][0] except: pass - if guid is None and playerName is None: + if playerGUID is None and playerName is None: self.write({"message": "Missing variable! (name or guid)"}) return @@ -275,46 +275,58 @@ def post(self): playerName) action = data['action'] if self.current_user == b"admin": - if guid: + if playerGUID: if action == "kick": self.launcher.DedicatedServer.AstroRCON.DSKickPlayerGuid( playerGUID) AstroLogging.logPrint(f"Kicking player: {playerName}") if action == "ban": - if guid: + if playerGUID: if len([x for x in players if x["playerName"] == playerName and x["inGame"]]) > 0: self.launcher.DedicatedServer.AstroRCON.DSKickPlayerGuid( playerGUID) - self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( - playerName, "Blacklisted") - self.launcher.DedicatedServer.refresh_settings() - AstroLogging.logPrint(f"Banning player: {playerName}") + if playerName: + self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( + playerName, "Blacklisted") + self.launcher.DedicatedServer.refresh_settings() + AstroLogging.logPrint(f"Banning player: {playerName}") if action == "WL": - self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( - playerName, "Whitelisted") - self.launcher.DedicatedServer.refresh_settings() - AstroLogging.logPrint(f"Whitelisting player: {playerName}") + if playerName: + self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( + playerName, "Whitelisted") + self.launcher.DedicatedServer.refresh_settings() + AstroLogging.logPrint(f"Whitelisting player: {playerName}") if action == "admin": - self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( - playerName, "Admin") - self.launcher.DedicatedServer.refresh_settings() - AstroLogging.logPrint(f"Setting player as Admin: {playerName}") + if playerName: + self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( + playerName, "Admin") + self.launcher.DedicatedServer.refresh_settings() + AstroLogging.logPrint( + f"Setting player as Admin: {playerName}") if action == "reset": - self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( - playerName, "Unlisted") - self.launcher.DedicatedServer.refresh_settings() - AstroLogging.logPrint( - f"Resetting perms for player: {playerName}") + if playerName: + self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( + playerName, "Unlisted") + self.launcher.DedicatedServer.refresh_settings() + AstroLogging.logPrint( + f"Resetting perms for player: {playerName}") if action == "remove": + self.launcher.DedicatedServer.AstroRCON.DSSetPlayerCategoryForPlayerName( + playerName, "Unlisted") pp = list( self.launcher.DedicatedServer.settings.PlayerProperties) + pp = [ - x for x in pp if f'PlayerFirstJoinName="{playerName}"' not in x and f'PlayerRecentJoinName="{playerName}"' not in x] + x for x in pp if not (((f'PlayerFirstJoinName="{playerName}"' in x + and 'PlayerRecentJoinName=""' in x) or + ('PlayerFirstJoinName=""' in x + and f'PlayerRecentJoinName="{playerName}"' in x)) + or f'PlayerGuid="{playerGUID}"' in x)] confPath = os.path.join( self.launcher.astroPath, r"Astro\Saved\Config\WindowsServer\AstroServerSettings.ini")