-
-
Notifications
You must be signed in to change notification settings - Fork 25
GH-1370 Fix vanish player collision #1370
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import org.bukkit.plugin.Plugin; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
@@ -16,6 +17,7 @@ class VanishInvisibleService { | |
|
|
||
| private final Set<UUID> vanishedPlayers = ConcurrentHashMap.newKeySet(); | ||
| private final Set<String> vanishedPlayerNames = ConcurrentHashMap.newKeySet(); | ||
| private final Map<UUID, Boolean> previousCollidableStates = new ConcurrentHashMap<>(); | ||
|
|
||
| private final Plugin plugin; | ||
| private final Server server; | ||
|
|
@@ -27,6 +29,9 @@ class VanishInvisibleService { | |
| } | ||
|
|
||
| void hidePlayer(Player player) { | ||
| this.previousCollidableStates.putIfAbsent(player.getUniqueId(), player.isCollidable()); | ||
| player.setCollidable(false); | ||
|
|
||
| for (Player online : this.server.getOnlinePlayers()) { | ||
| if (online.hasPermission(VanishPermissionConstant.VANISH_SEE_PERMISSION)) { | ||
| continue; | ||
|
|
@@ -48,6 +53,11 @@ void showPlayer(Player player) { | |
| } | ||
| this.vanishedPlayers.remove(player.getUniqueId()); | ||
| this.vanishedPlayerNames.remove(player.getName()); | ||
|
|
||
| Boolean previousCollidableState = this.previousCollidableStates.remove(player.getUniqueId()); | ||
| if (previousCollidableState != null) { | ||
| player.setCollidable(previousCollidableState); | ||
| } | ||
| } | ||
|
Comment on lines
+57
to
61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Storing the previous collidable state by To prevent this, we should expose a cleanup method to remove the player's state when they disconnect, which should be called from the player quit listener. Boolean previousCollidableState = this.previousCollidableStates.remove(player.getUniqueId());
if (previousCollidableState != null) {
player.setCollidable(previousCollidableState);
}
}
void removePreviousCollidableState(UUID uuid) {
this.previousCollidableStates.remove(uuid);
} |
||
|
|
||
| void hideVanishedPlayersFrom(Player player) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the plugin is disabled or reloaded while a player is vanished,
PlayerQuitController.onQuitis not involved;EternalCore.disable()only publishesEternalShutdownEvent. This newsetCollidable(false)state is player state rather than plugin-scoped hide state, butpreviousCollidableStatesis discarded with the service instance and no shutdown subscriber restores it, so online vanished players can remain non-collidable after a reload with no way for/vanishto restore their original value. Please restore the saved collision states during shutdown.Useful? React with 👍 / 👎.