No PVP in spawn area

Discussion in 'Plugin Development' started by mollekake, Sep 3, 2012.

Thread Status:
Not open for further replies.
  1. I'm almost done with my plugin, i just need a small adjustment.
    I don't want players to be able to hurt eachother in spawn, how can i prevent this?
    Should i listen to if they hurt someone and they are in spawn i cancel it? or would that take too much recources from the server since it would check every time.
    (i dont want to use world guard as this is just a small function of the world guard plugin)
     
  2. you can listen for the entity damage by entity event, see if the atttacker is an player, and the defender is an player to, if the defender is ... amount of blocks from spawn (location.distace()) cancel it, and send a message to the attacker that attacking in spawn is not allowed
     
  3. how do i check if the damaged entity is a player?
     
  4. Offline

    _Waffles_

    entity instanceof player
     
  5. like this?:
    Code:
    if(event.getDamager() instanceof Player){
                if(event.getEntity() instanceof Player){
                    //code stuff
                }
            }
     
  6. Offline

    _Waffles_

    Yea that should work
    edit: also, I would type that as
    if(event.getDamager() instanceof Player && event.getEntity() instanceof Player)
     
  7. yeah good idea, i was on that trail at first, but did it wrong so broke it apart.
     
  8. Offline

    Out2k

    Oh man , i really need this for my pvp server, and cant find anything that solves a no pvp just in spawn, without having a ton of non-used extras features. Any ideas on how long before you have the first version out? Thanks!
     
Thread Status:
Not open for further replies.

Share This Page