Skip to content

Commit f4b08d9

Browse files
R00tB33rManTim203
authored andcommitted
Added a region check for hide/show Player on Folia (#632)
Only kept the actual reported fix
1 parent a09f3ee commit f4b08d9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

spigot/src/main/java/org/geysermc/floodgate/util/SpigotVersionSpecificMethods.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.Map;
3636
import java.util.UUID;
3737
import java.util.concurrent.TimeUnit;
38+
import org.bukkit.Bukkit;
3839
import org.bukkit.entity.Player;
3940
import org.bukkit.plugin.Plugin;
4041
import org.geysermc.floodgate.SpigotPlugin;
@@ -123,7 +124,17 @@ public void hideAndShowPlayer(Player on, Player target) {
123124
// In Folia we don't have to schedule this as there is no concept of a single main thread.
124125
// Instead, we have to schedule the task per player.
125126
if (ClassNames.IS_FOLIA) {
126-
on.getScheduler().execute(plugin, () -> hideAndShowPlayer0(on, target), null, 0);
127+
on.getScheduler().execute(plugin, () -> {
128+
// This is a defensive check. The source should always be on the same region, as this is requested
129+
// from that player's context. The target however can be in a different region, which seems to trigger
130+
// ChunkMap$TrackedEntity.updatePlayer in a different thread for a thread-unsafe HashSet.
131+
// This should result in the skin not showing up for those specific players, but it's better than an
132+
// exception.
133+
if (!Bukkit.isOwnedByCurrentRegion(on) || !Bukkit.isOwnedByCurrentRegion(target)) {
134+
return;
135+
}
136+
hideAndShowPlayer0(on, target);
137+
}, null, 0);
127138
return;
128139
}
129140
hideAndShowPlayer0(on, target);

0 commit comments

Comments
 (0)