Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Disabled remove button for now until Devs add functionality or we fin…
Browse files Browse the repository at this point in the history
…d a better way to do it.
  • Loading branch information
ricky-davis committed Jul 12, 2020
1 parent a269e46 commit d0b4305
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
12 changes: 10 additions & 2 deletions assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const tick = async () => {
"</td>";
}
$("#onlinePlayersTable>tbody").append(row);
} else if (p.playerName != "") {
} else {
$("#offlinePlayersTable>tbody").append(row);
if (isAdmin) {
row.innerHTML +=
Expand Down Expand Up @@ -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");
}
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ h5 {
margin: 0;
line-height: 200%;
}

#onlinePlayersRow {
z-index: 10000;
}
#banner {
background: #17142f;
white-space: nowrap;
Expand Down
66 changes: 39 additions & 27 deletions cogs/AstroWebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,26 @@ 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:
player = [x for x in players if x['playerName']
== 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

Expand All @@ -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")
Expand Down

0 comments on commit d0b4305

Please sign in to comment.