Plugin Help Getting rid of arrows and some of them their effects.

Discussion in 'Plugin Help/Development/Requests' started by Scorpionvssub, Aug 14, 2015.

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

    Scorpionvssub

    i been cracking my head around the issue on how to remove arrows, now i know there are plenty of tutorials out there regarding arrows in general but none with effect. or rather...both.

    private HashMap<Effect, List<Arrow>> arrows = new HashMap<>();
    private List<Arrow> normal = new ArrayList<>(); (Dont ask why 1 hashmap 1 array...)


    Code:
        @EventHandler
        public void onFlyingArrow(ProjectileLaunchEvent e) {
            final Projectile proj = e.getEntity();
            if (proj instanceof Arrow) {
                final Arrow arrow = (Arrow) proj;
                LivingEntity shooter = (LivingEntity) arrow.getShooter();
                if (shooter instanceof Player) {
                    final Player player = (Player) shooter;
                    if (plugin.tauriel.contains(player.getName())) {
                        if (!arrow.isOnGround()) {
                            Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
                                @Override
                                public void run() {
                                    String effect = plugin.getPlayerHandler().getPlayer(player).getArrow();
                                    if (effect != null) {
                                        arrow.getWorld().playEffect(proj.getLocation(), grabEffect(effect), 1);
                                    }
                                }
                            }, 0, 0);
                        }
                    }
                }
            }
        }
        @EventHandler
        public void onArrowHit(ProjectileHitEvent e) {
            if (e.getEntity() instanceof Arrow) {
                Arrow arrow = (Arrow) e.getEntity();
                if (normal.contains(arrow)) {
                    normal.remove(arrow);
                    arrow.remove();
                } else {
                    for (Effect effect : this.arrows.keySet()) {
                        if (this.arrows.get(effect).contains(arrow)) {
                            this.arrows.get(effect).remove(arrow);
                            arrow.remove();
                        }
                    }
                }
            }
        }
    The idea is simple, if people have an effect in their respective config section it will add that to the arrow which works fine, what doesnt work is removing arrows(effect/normal) and removing the effect if there are effects on an arrow, now i need to reload to get it out.

    Im probs better of using 2 lists or 2 hashmaps i know but i need a 3rd eye on this :p
     
Thread Status:
Not open for further replies.

Share This Page