Solved how to stop fishing hooks from damaging teammates?

Discussion in 'Spigot Plugin Development' started by Swiftlicious, Aug 15, 2019.

  1. So what i'm trying to do basically is stop every method of team damage happening if two players are on the same team... so far I've blocked everything except fishing hooks from being annoying and still working on the teammates.. does anyone know what I did wrong?


    Code (Text):
                    if (e.getDamager() instanceof FishHook) {
                        FishHook a = (FishHook) e.getDamager();
                        if (a.getServer() instanceof Player) {
                        Player d = (Player) a.getServer();
                        String TeamD = Methods.getExactTeam(d);
                        String TeamP = Methods.getExactTeam(p);
                        if (TeamD.equalsIgnoreCase(TeamP)) {
                            e.setCancelled(true);
                            d.sendMessage(Chat.color(prefix + " " + friendly_fire));
                            return;
                        } else {
                            e.setCancelled(false);
                        }
                    }
                }
     
  2. x86

    x86

    Im guessing you are using EntityDamageByEntityEvent?

    Thats only called when a player actually gets damaged, if you are using 1.9+ fishing rods won't damage players so the event won't work.
    If you are on 1.9+ and using a plugin to add fishing rod damage back remember it could just be damaging the entity using a different method.

    I would recommend debugging more to find out what is happening.

    If you want to use the scoreboard teams that should also fix it.
     
  3. oh yes sorry I am using EntityDamagebyEntityEvent and I do have a plugin for 1.12.2 that makes fishing rods return back to 1.8 days.
    I like the ability for it to be done to opposing teams but not the same team and I unfortunately don't use the scoreboard teams to create my teams as well.
     
  4. x86

    x86

    The plugin you are using needs to damage the player as FishHook for your code to work
     
    • Informative Informative x 1