[URGANT] Hiding Players

Discussion in 'Plugin Development' started by Michael Aztan, Sep 2, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Michael Aztan

    Hello there. I am making a simple plugin for my hub that vanishes all players for all players. This is my current code:

    Code:java
    1. package me.MichaelAztan.BraveHub;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.player.PlayerJoinEvent;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class BraveHub extends JavaPlugin implements Listener{
    16.  
    17. Logger logger = Logger.getLogger("Minecraft");
    18. public static BraveHub plugin;
    19.  
    20. public void onDisable() {
    21. org.bukkit.plugin.PluginDescriptionFile pdfFile = this.getDescription();
    22. this.logger.info("" + pdfFile.getName() + " has been disabled!");
    23. }
    24.  
    25. public void onEnable() {
    26. org.bukkit.plugin.PluginDescriptionFile pdfFile = this.getDescription();
    27. this.logger.info("" + pdfFile.getName() + " v" + pdfFile.getVersion() + " has been enabled!");
    28. this.saveDefaultConfig();
    29.  
    30. }
    31.  
    32. @EventHandler
    33. public void onPlayerJoin(PlayerJoinEvent event){
    34. updateHide();
    35. }
    36.  
    37. public void updateHide(){
    38. Player[] players = Bukkit.getOnlinePlayers();
    39. for(int i = 0; i < players.length; i++){
    40. Player player = players[i];
    41. for(int e = 0; e < players.length; e++){
    42. player.hidePlayer(players[i]);
    43. }
    44. }
    45. }
    46.  
    47. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    48. if (sender instanceof Player) {
    49. Player player = (Player) sender;
    50. if(commandLabel.equalsIgnoreCase("bravehubreload") || commandLabel.equalsIgnoreCase("bhr")){
    51. if(player.hasPermission("bravehub.reload")){
    52. reloadConfig();
    53. player.sendMessage(ChatColor.GREEN + "Config Reloaded!");
    54. }
    55. else{
    56. player.sendMessage(ChatColor.DARK_RED + "You do not have access to that command.");
    57. }
    58. }
    59. }
    60. else{
    61. if(commandLabel.equalsIgnoreCase("bravehubreload") || commandLabel.equalsIgnoreCase("bhr")){
    62. reloadConfig();
    63. logger.info(ChatColor.GREEN + "Config Reloaded!");
    64. }
    65. }
    66. return false;
    67. }
    68. }[/i][/i]


    Here is my error:
    When players join, they can see the players that were already online. But, the players that were already online cant see anyone.

    I need urgent help with this.
    Thanks,
    Michael
     
  2. Offline

    BajanAmerican

    Just put the players in a for loop.
    Code:
    for(Player pl : Bukkit.getOnlinePlayers(){
    pl.hidePlayer(<Player>);
    }
     
Thread Status:
Not open for further replies.

Share This Page