Damaging an invisible player

Discussion in 'Plugin Development' started by CeramicTitan, Nov 17, 2012.

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

    CeramicTitan

    Hi, so I have the method p.hideplayer but I didn't realise that this made the player invincible. So is there anyway to override the invincibility?

    My code:
    Code:JAVA
    1. @EventHandler
    2. public void onDamage(EntityDamageByEntityEvent event){
    3. Player p = (Player)event.getEntity();
    4. if(p instanceof Player){
    5. if(vanished.contains(p.getName())){
    6. for(Player players : Bukkit.getServer().getOnlinePlayers()){
    7. players.showPlayer(p);
    8. }
    9. p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.LAVA.getId());
    10. vanished.remove(p.getName());
    11. p.sendMessage("You have been Spotted!");
    12.  
    13. }
    14. }
    15. }
    16.  
     
  2. Offline

    Jnorr44

    Invincible or Invisible? I didn't know it made them invincible, maybe you are canceling the event somewhere?
     
  3. Offline

    CeramicTitan

    When they are invisible they are invincible
     
  4. Offline

    RealDope

    Uh I don't think it makes them invincible.. What makes you say that they are?
     
  5. Offline

    CeramicTitan

    When the player is invisible i can't attack them

    Only human entities can't attack the invisible but mobs can and it works fine

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  6. Offline

    Squirtle771

    You could just set the damage to the amount of damage you want them to take.
    So just add
    Code:
    p.setDamage(2);
    
     
  7. Offline

    CeramicTitan

    I need them to become visible on hit? but i cant hit them so i'm not too sure?
     
  8. Offline

    fireblast709

    if you hide the player, they basically do not exist for the other client. And so the other client will never send the packets where they attack a player, only packets where they 'dig'
     
  9. Offline

    CeramicTitan

    So this is
    So this is not possible?
     
  10. Offline

    fireblast709

    not as far as I know minecraft
     
Thread Status:
Not open for further replies.

Share This Page