Making it so a player can't hurt certain players

Discussion in 'Plugin Development' started by techboy291, Aug 28, 2012.

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


    Hi, so I want to create a small CTF/CTW bukkit plugin for a friend's server and I was wondering how to make it so people from one team can only hurt people from the other team. Thanks for the help in advance :)
  2. Offline


    Well how do you store each team?
    If your using an arraylist say for team 1 and team 2, you can get the entity and if the entity matches the damager, event.setCancelled(true);
    Iain likes this.
  3. Offline


    Try doing something like this:
    Make an arraylist which stores players of each team
    Then do EntityDamageByEntity event and check the arraylist.
    if(hs.containsKey(e.getEntity())){    //if the hashmap contains the entity you are about to hit
                e.setCancelled(true);    //set cancelled
            } else {
                e.setCancelled(false);    //if it doesn't,hit the player 
    EDIT: slater pretty much covered it....darn didn't see his post
  4. Offline


    Oh, okay. My main problem was I couldn't find the right event for it. Thanks.
Thread Status:
Not open for further replies.

Share This Page