Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disguise check and fix nicked user bug #1375

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public static boolean setVanished(MatchPlayer player, boolean vanish, boolean qu
return VANISH.get().setVanished(player, vanish, quiet);
}

public static boolean isDisguised(Player player) {
return isVanished(player) || getNick(player) != null;
}

// No-op Implementations

private static class NoopFriendIntegration implements FriendIntegration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,17 @@ public ServerPingDataListener(MatchManager matchManager, MapOrder mapOrder, Logg
this.logger = ClassLogger.get(assertNotNull(parentLogger), ServerPingDataListener.class);
this.ready = new AtomicBoolean();
this.legacySportPaper = new AtomicBoolean();
this.matchCache =
CacheBuilder.newBuilder()
.weakKeys()
.expireAfterWrite(5L, TimeUnit.SECONDS)
.build(
new CacheLoader<Match, JsonObject>() {
@Override
public JsonObject load(Match match) throws Exception {
JsonObject jsonObject = new JsonObject();
serializeMatch(match, jsonObject);
return jsonObject;
}
});
this.matchCache = CacheBuilder.newBuilder()
.weakKeys()
.expireAfterWrite(5L, TimeUnit.SECONDS)
.build(new CacheLoader<Match, JsonObject>() {
@Override
public JsonObject load(Match match) throws Exception {
JsonObject jsonObject = new JsonObject();
serializeMatch(match, jsonObject);
return jsonObject;
}
});
}

@EventHandler
Expand All @@ -74,25 +72,21 @@ public void onServerListPing(ServerListPingEvent event) {
Iterator<Player> playerSample = event.iterator();
while (playerSample.hasNext()) {
Player player = playerSample.next();
if (Integration.isVanished(player)) {
if (Integration.isDisguised(player)) {
playerSample.remove();
}
}

try {
JsonObject root = MISC_UTILS.getServerListExtra(event, PGM.get());
this.matchManager
.getMatches()
.forEachRemaining(
match -> {
String matchId = match.getId();
try {
root.add(matchId, this.matchCache.get(match));
} catch (ExecutionException e) {
this.logger.log(
Level.SEVERE, "Could not load server ping data for match: " + matchId, e);
}
});
this.matchManager.getMatches().forEachRemaining(match -> {
String matchId = match.getId();
try {
root.add(matchId, this.matchCache.get(match));
} catch (ExecutionException e) {
this.logger.log(Level.SEVERE, "Could not load server ping data for match: " + matchId, e);
}
});
} catch (NoSuchMethodError ex) {
legacySportPaper.compareAndSet(false, true);
}
Expand Down