Skip to content

Commit

Permalink
fix: ensure caching respects player state
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Nov 10, 2024
1 parent d537952 commit 294f24f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
if (usePaperEvents) {
return;
}
getPlugin().getOnlineUserMap().remove(event.getPlayer().getUniqueId());
super.handlePlayerRespawn(getPlugin().getOnlineUser(event.getPlayer()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ default BukkitUser getOnlineUser(@Nullable Player player) {
throw new IllegalArgumentException("Player is not online");
}
BukkitUser user = (BukkitUser) getOnlineUserMap().get(player.getUniqueId());
if (user == null) {
if (user == null || !user.getPlayer().isOnline()) {
user = BukkitUser.adapt(player, getPlugin());
getOnlineUserMap().put(player.getUniqueId(), user);
return user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ default FabricUser getOnlineUser(@Nullable ServerPlayerEntity player) {
throw new IllegalArgumentException("Player is not online");
}
FabricUser user = (FabricUser) getOnlineUserMap().get(player.getUuid());
if (user == null) {
if (user == null || user.getPlayer().isRemoved() || user.getPlayer().isDisconnected()) {
user = FabricUser.adapt(player, getPlugin());
getOnlineUserMap().put(player.getUuid(), user);
return user;
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true

# Plugin metadata
plugin_version=4.8.1
plugin_version=4.8.2
plugin_archive=huskhomes
plugin_description=The powerful & intuitive homes, warps, and teleportation suite

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void onPlayerUpdateRespawnLocation(PlayerSetSpawnEvent event) {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
getPlugin().getOnlineUserMap().remove(event.getPlayer().getUniqueId());
if (event.getRespawnReason() != PlayerRespawnEvent.RespawnReason.DEATH) {
return;
}
Expand Down

0 comments on commit 294f24f

Please sign in to comment.