Display particle effects based on team

Discussion in 'Plugin Development' started by jstN0body, Mar 31, 2020.

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

    jstN0body

    I want to display particle effects when a projectile hits based on teams, what am I doing wrong because this isn't working for me?
    Code:
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onProjectileHit(ProjectileHitEvent event) {
            World world = event.getEntity().getWorld();
            Player shooter = (Player) event.getEntity().getShooter();
            Location location = event.getEntity().getLocation();
            Material heldItem = shooter.getItemInHand().getType();
            Team team = shooter.getScoreboard().getPlayerTeam(shooter);
            Team blueTeam = shooter.getScoreboard().getTeam("Blue");
            if (team == blueTeam && heldItem == Material.IRON_SPADE) {
                world.playEffect(location, Effect.FLAME, 1, 25);
            }
        }
    
     
  2. First of all, I would recommend to use shooter.getInventory().getItemInMainHand(), because it isn't deprecated. That isn't the problem though.

    If I were to have a guess, you should do team.equals(blueTeam) instead of team == blueTeam. Doing == is fine for numbers and enums (like Material) but most other things require .equals(), because else it might not work.
     
  3. Offline

    NukerFall

    Ping everything.
    Have you registered your events?
    Error?
     
Thread Status:
Not open for further replies.

Share This Page