Solved Assigning Player to Entity

Discussion in 'Plugin Development' started by funkystudios, Feb 14, 2013.

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

    funkystudios

    I am developing a plugin that allows users to throw TNT as grenades (right click, the drop is shot out in your direction) rather than placing them. However, in my plugin, there are teams, which brings up the issue of team killing. How would I be able to detect if a player on the same team is damaged by a TNT throw?

    It seems like I would have to make a hashmap with each grenade assigned to the player or team. Then later detect if the damage is done from an item in the hashmap... Any ideas? Thanks in advance.
     
  2. Offline

    wheatley09

    Protect around the player by a certain number of blocks. Don't know the code but you'd need something of a radius, also something to detect the player that dropped the block.
     
  3. Offline

    Lecrayen

    you tried metadata for each team member? Say blue team gets ("Team" = "blue") and red team gets ("Team" = "red"). Just call the metadata when the player is going to take the damage and cancel it if the players are on the same team
     
  4. Offline

    funkystudios

    When would I retrieve the metadata? I can't quite figure it out from EntityDamageEvent.

    Never mind, EntityDamageByEntityEvent...

    Just realized that world.createExplosion does not have an entity tied to it. I may just use PrimedTNT rather than an item drop since PrimedTNT will explode on its own.

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

    Areoace

    Make 2 variables, in this ase blue and red team are against each other

    Player blues = event.getPlayer();
    Player red = event.getPlayer();
    //create explosion
    //make an exception if a blue throws it, it will set the damage for blues to 0, event.setDamage(0);

    Hope this helps.
     
Thread Status:
Not open for further replies.

Share This Page