Hide all players

Discussion in 'Plugin Development' started by Stackore, Apr 27, 2014.

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

    Stackore

    Okey i know this is a nooby question but how i do when a player right click a watch all other players get invisible?
    Code:java
    1. @EventHandler
    2. public void PlayerVis(PlayerInteractEvent e) {
    3. Player p = e.getPlayer();
    4. Action a = e.getAction();
    5. if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {
    6.  
    7. }
    8. if (p.getItemInHand().getType() == Material.WATCH) {
    9.  
    10.  
     
  2. Offline

    Gater12

    Stackore
    Loop through all the players online and hide them to the player.
     
  3. Offline

    TGRHavoc

    Stackore
    Firstly, I would put the "If item is watch" statement inside the "If rightclicking air or block" statement. Then just loop through all the players setting them invisible to the player who clicked the watch.
     
  4. Offline

    Stackore

    Example?
     
  5. Code:java
    1. for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
    2. p.hidePlayer(onlinePlayer);
    3. }
     
  6. Offline

    TGRHavoc

  7. Offline

    Stackore

    Thanks :)
     
  8. No problem, happy coding :D
     
Thread Status:
Not open for further replies.

Share This Page