diff --git a/bukkit/src/main/java/net/william278/huskhomes/listener/BukkitEventListener.java b/bukkit/src/main/java/net/william278/huskhomes/listener/BukkitEventListener.java index bc3cb167..b9e5de11 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/listener/BukkitEventListener.java +++ b/bukkit/src/main/java/net/william278/huskhomes/listener/BukkitEventListener.java @@ -65,6 +65,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) { if (usePaperEvents) { return; } + getPlugin().getOnlineUserMap().remove(event.getPlayer().getUniqueId()); super.handlePlayerRespawn(getPlugin().getOnlineUser(event.getPlayer())); } diff --git a/bukkit/src/main/java/net/william278/huskhomes/user/BukkitUserProvider.java b/bukkit/src/main/java/net/william278/huskhomes/user/BukkitUserProvider.java index 6dcf32a1..b1162ecc 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/user/BukkitUserProvider.java +++ b/bukkit/src/main/java/net/william278/huskhomes/user/BukkitUserProvider.java @@ -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; diff --git a/fabric/src/main/java/net/william278/huskhomes/user/FabricUserProvider.java b/fabric/src/main/java/net/william278/huskhomes/user/FabricUserProvider.java index 8cdf9752..fcaab767 100644 --- a/fabric/src/main/java/net/william278/huskhomes/user/FabricUserProvider.java +++ b/fabric/src/main/java/net/william278/huskhomes/user/FabricUserProvider.java @@ -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; diff --git a/gradle.properties b/gradle.properties index 04878c16..e2deb14c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/paper/src/main/java/net/william278/huskhomes/listener/PaperEventListener.java b/paper/src/main/java/net/william278/huskhomes/listener/PaperEventListener.java index 86607a05..15cb22c1 100644 --- a/paper/src/main/java/net/william278/huskhomes/listener/PaperEventListener.java +++ b/paper/src/main/java/net/william278/huskhomes/listener/PaperEventListener.java @@ -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; }