Display banned status in Steam lobbies
This commit is contained in:
@@ -250,9 +250,10 @@ public class JoinDialog extends BaseDialog{
|
|||||||
buildServer(host, server.content, false);
|
buildServer(host, server.content, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildServer(Host host, Table content, boolean inner){
|
void buildServer(Host host, Table content, boolean local){
|
||||||
content.top().left();
|
content.top().left();
|
||||||
String versionString = getVersionString(host);
|
boolean isBanned = local && Vars.steam && host.description != null && host.description.equals("[banned]");
|
||||||
|
String versionString = getVersionString(host) + (isBanned ? "[red] [banned]" : "");
|
||||||
|
|
||||||
float twidth = targetWidth() - 40f;
|
float twidth = targetWidth() - 40f;
|
||||||
|
|
||||||
@@ -260,7 +261,7 @@ public class JoinDialog extends BaseDialog{
|
|||||||
|
|
||||||
Color color = Pal.gray;
|
Color color = Pal.gray;
|
||||||
|
|
||||||
if(inner){
|
if(local){
|
||||||
content.table(Tex.whiteui, t -> {
|
content.table(Tex.whiteui, t -> {
|
||||||
t.left();
|
t.left();
|
||||||
t.setColor(color);
|
t.setColor(color);
|
||||||
@@ -274,7 +275,7 @@ public class JoinDialog extends BaseDialog{
|
|||||||
t.setColor(color);
|
t.setColor(color);
|
||||||
t.left();
|
t.left();
|
||||||
|
|
||||||
if(!host.description.isEmpty()){
|
if(!host.description.isEmpty() && !isBanned){
|
||||||
//limit newlines.
|
//limit newlines.
|
||||||
int count = 0;
|
int count = 0;
|
||||||
StringBuilder result = new StringBuilder(host.description.length());
|
StringBuilder result = new StringBuilder(host.description.length());
|
||||||
|
|||||||
@@ -107,6 +107,9 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
|
|
||||||
Events.on(WaveEvent.class, e -> updateWave());
|
Events.on(WaveEvent.class, e -> updateWave());
|
||||||
Events.run(Trigger.newGame, this::updateWave);
|
Events.run(Trigger.newGame, this::updateWave);
|
||||||
|
|
||||||
|
Events.on(PlayerIpBanEvent.class, e -> updateBans(e.ip));
|
||||||
|
Events.on(PlayerIpUnbanEvent.class, e -> updateBans(e.ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSteamClient(){
|
public boolean isSteamClient(){
|
||||||
@@ -207,6 +210,12 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Updates the ban list so that lobbies don't appear for banned players. The list will only be updated when a steam player is banned/unbanned. */
|
||||||
|
void updateBans(String changed){
|
||||||
|
if(changed != null && !changed.startsWith("steam:")) return; //hacky way to ignore non-steam ids
|
||||||
|
smat.setLobbyData(currentLobby, "banned", netServer.admins.bannedIPs.select(ip -> ip.contains("steam:")).reduce(new StringBuilder(), (ip, str) -> str.append(ip.substring(6)).append(',')).toString()); //list of handles split by commas
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeServer(){
|
public void closeServer(){
|
||||||
provider.closeServer();
|
provider.closeServer();
|
||||||
@@ -321,6 +330,11 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
String mode = smat.getLobbyData(lobby, "gamemode");
|
String mode = smat.getLobbyData(lobby, "gamemode");
|
||||||
//make sure versions are equal, don't list incompatible lobbies
|
//make sure versions are equal, don't list incompatible lobbies
|
||||||
if(mode == null || mode.isEmpty() || (Version.build != -1 && Strings.parseInt(smat.getLobbyData(lobby, "version"), -1) != Version.build)) continue;
|
if(mode == null || mode.isEmpty() || (Version.build != -1 && Strings.parseInt(smat.getLobbyData(lobby, "version"), -1) != Version.build)) continue;
|
||||||
|
|
||||||
|
String banList = smat.getLobbyData(lobby, "banned");
|
||||||
|
|
||||||
|
boolean banned = banList.length() > 0 && Structs.contains(banList.split(","), SVars.user.user.getSteamID().getAccountID() + "");
|
||||||
|
|
||||||
Host out = new Host(
|
Host out = new Host(
|
||||||
-1, //invalid ping
|
-1, //invalid ping
|
||||||
smat.getLobbyData(lobby, "name"),
|
smat.getLobbyData(lobby, "name"),
|
||||||
@@ -332,7 +346,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
smat.getLobbyData(lobby, "versionType"),
|
smat.getLobbyData(lobby, "versionType"),
|
||||||
Gamemode.valueOf(mode),
|
Gamemode.valueOf(mode),
|
||||||
smat.getLobbyMemberLimit(lobby),
|
smat.getLobbyMemberLimit(lobby),
|
||||||
"",
|
banned ? "[banned]" : "",
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
hosts.add(out);
|
hosts.add(out);
|
||||||
@@ -365,6 +379,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||||||
smat.setLobbyData(steamID, "versionType", Version.type);
|
smat.setLobbyData(steamID, "versionType", Version.type);
|
||||||
smat.setLobbyData(steamID, "wave", state.wave + "");
|
smat.setLobbyData(steamID, "wave", state.wave + "");
|
||||||
smat.setLobbyData(steamID, "gamemode", state.rules.mode().name() + "");
|
smat.setLobbyData(steamID, "gamemode", state.rules.mode().name() + "");
|
||||||
|
updateBans(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user