Need Help Hiding Players

Discussion in 'Plugin Development' started by MrGamingLion66, Oct 8, 2016.

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

    MrGamingLion66

    Hello everyone, as a sky wars plugin I am making for my friends server, instead of killing players when they die I want to pretend to kill them so they don't see the you died screen. However I can't seem to figure out how to hide the players.

    Code:
    @EventHandler(priority = EventPriority.HIGHEST)
        public void PlayerDamageReceive(EntityDamageByEntityEvent e)
        {  
            World mainworld = Bukkit.getWorld("RomanEmpire");
            Player p = (Player) e.getEntity();
          
            if(e.getEntity() instanceof Player)
            {
                Player damaged = (Player) e.getEntity();
                if(e.getDamager() instanceof Player)
                {
                    Player damager = (Player) e.getDamager();
                  
                    if(damaged.getWorld().equals(mainworld))
                    {
                        if((damaged.getHealth()-e.getDamage()) <= 0)
                        {
                            e.setCancelled(true);
                            p.hidePlayer(damaged);
                            Bukkit.broadcastMessage(damaged.getName() + " has been slain by " + damager.getName());
                        }
                    }
                }
            }
    Can anyone help?
     
  2. Offline

    Zombie_Striker

    @MrGamingLion66
    1. for-each loop through all the players you want the 'killed' player to be hidden from (if you want to hide the killed player from all players, loop through all players online)
    2. For each player, use the hidePlayer method to hide the player.
    3. Whenever you want to show the player again, for loop through all those players again and use the .showPlayer method.
     
Thread Status:
Not open for further replies.

Share This Page