Team friendlyfire

Discussion in 'Spigot Plugin Development' started by Svenna, May 25, 2015.

  1. Hey Spigot,

    It is time for me to make a "help post". I'm stuck with this weird problem.

    First of all, I need friendlyfire set to not allowed. If I use team.setAllowFriendlyFire(false); it won't work.
    So I tested out a different way, with a EntityDamageByEntityEvent. I test when a player is in the same team and then cancel it. But it doesn't work. WHY ?


    Code (Text):

    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;

    import svenna.vw.TeamManager;

    public class EventEntityDamageByEntityEvent implements Listener {
        public void onDamage(EntityDamageByEntityEvent e){
            Entity damaged = e.getEntity();
            Entity damager = e.getDamager();
            System.out.println("EVENT FIRED");
            if (damaged instanceof Player && damager instanceof Player){
                Player pdamaged = (Player) damaged;
                Player pdamager = (Player) damager;
                System.out.println("EVENT FIRED");
                if ({
                    if ({
                        System.out.println("Zelfde team RED");
                if ({
                    if ({
                        System.out.println("Zelfde team BLUE");

  2. There is only one possibility: Team.hasPlayer isn't returning the right stuff ;)
  3. But the event is not firing? I have the event registered. hasPlayer works for me in other methods?
  4. If the "EVENT FIRED" does not appear you have not registered the Listener.

    Else, your .hasPlayer method is wrong
  5. Why is my hasPlayer method wrong?
  6. Uh, where would that be necessary?
  7. Insert debug syso's around the code to see what's firing and what's not :)
  8. I have already ;). Non of them are firing..
  9. Registered your events? Are you using multiple classes? If so, don't forget to implement the applicable thing e.g. CommandExecutor or Listener :)
  10. When non of them fire you dont have your Listener registered. Sry
  11. Im pretty sure i did.. I'm ganna figure this out. If I have a solution I'll post it here. Otherways I will still ask for help ;)