Skip to content

Commit

Permalink
Fix projected player remaining on certain server switching action
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Jan 7, 2025
1 parent 250d929 commit 1882ee8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/cn/zbx1425/projectme/sync/Synchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public class Synchronizer implements AutoCloseable {

private final Map<UUID, EntityProjection> currentProjections = new HashMap<>();

public static final String HMAP_ALL_KEY = "SSHARD_DATA_ALL";

public Synchronizer(String URI, MinecraftServer server) {
redisClient = RedisClient.create(URI);
redisConn = redisClient.connect(ByteBufCodec.INSTANCE);
Expand All @@ -47,13 +45,23 @@ public Synchronizer(String URI, MinecraftServer server) {
this.server = server;
}

public void notifyPlayerPresence(List<ServerPlayer> player) {
RedisMessage playerPresence = RedisMessage.beginPlayerPresence(player.size());
for (ServerPlayer p : player) {
public void notifyPlayerPresence(List<ServerPlayer> players) {
RedisMessage playerPresence = RedisMessage.beginPlayerPresence(players.size());
for (ServerPlayer p : players) {
boolean v1 = ProjectMe.computePlayerVisibility(p);
playerPresence.andWithPlayer(p, v1);
}
playerPresence.publishAsync(redisConn);

server.execute(() -> {
for (ServerPlayer p : players) {
EntityProjection currentEntity = currentProjections.get(p.getGameProfile().getId());
if (currentEntity != null) {
currentEntity.discard();
currentProjections.remove(p.getGameProfile().getId());
}
}
});
}

public void mockPlayerPresence(Vec3 position) {
Expand Down

0 comments on commit 1882ee8

Please sign in to comment.