-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
Hiding players from each other in a BukkitRunnable breaks hiding in the player list (tab list).
Here's some sample code you can copy-paste to reproduce it:
public class TestPlugin extends JavaPlugin implements Listener { @Override public void onEnable() { // Listen to events Bukkit.getPluginManager().registerEvents(this, this); } @EventHandler public void onJoin(final PlayerJoinEvent event) { // Hide all players from each other on the next tick new BukkitRunnable() { public void run() { Player player = event.getPlayer(); for (Player other : Bukkit.getOnlinePlayers()) { if (other.equals(player)) continue; // Skip self // Hide from each other other.hidePlayer(player); player.hidePlayer(other); // Confirm in console that this code is getting executed getLogger().log(Level.INFO, "Hiding " + other.getName() + " and " + player.getName() + " from each other by task"); } } }.runTaskLater(this, 1); } @EventHandler public void onCommand(PlayerCommandPreprocessEvent event) { if (event.getMessage().equalsIgnoreCase("/hideall")) { Player player = event.getPlayer(); for (Player other : Bukkit.getOnlinePlayers()) { if (other.equals(player)) continue; // Skip self // Hide from each other other.hidePlayer(player); player.hidePlayer(other); // Confirm in console that this code is getting executed getLogger().log(Level.INFO, "Hiding " + other.getName() + " and " + player.getName() + " from each other by /hideall"); } } } }
# PlayerA joins the game
- PlayerB joins the game
- The two players cannot see each other in the game, as they are both hidden, but:
- PlayerA can see PlayerB on the player list, but PlayerB can't see PlayerA on the player list
- Running the "/hideall" command doesn't fix it. It seems that if you do it in a runnable task it breaks hiding completely for the involved players