Cleave

Discussion in 'Plugin Help/Development/Requests' started by Hex_27, Jul 21, 2015.

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

    Hex_27

    I want to damage mobs around the target and call entitydamagebyentity on it, but I don't want to repeatedly cleave cleaved targets. To clarify what i mean, here's my code
    Code:
    public ArrayList<EntityDamageByEntityEvent> cleaveevents = new ArrayList<EntityDamageByEntityEvent>();
    
    public void onDamage(EntityDamageByEntityEvent event){
    
    cleaveevents.add(event);
                    if(this.cleaveevents.contains(event)){
                        cleave(p,event.getEntity(),2,event.getDamage());
                       
                   
                    }
    }
    
        @SuppressWarnings("deprecation")
        public void cleave(Player p, Entity target, int radius, double damage){
            for(Entity e:target.getNearbyEntities(radius, radius, radius)){
                if(e instanceof Damageable&&
                        e != target){
                    ((Damageable) e).damage(damage);
                EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, e, DamageCause.ENTITY_ATTACK, damage);
               
                Bukkit.getPluginManager().callEvent(event);
                }
                }
        }
    
    But it is giving me this error:

    Code:
    sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_11]
        at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_11]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot-1.8.3.jar:git-Spigot-2ec6f06-7722428]
        at me.leothepro555.skills.Draconic.cleave(Draconic.java:218) ~[?:?]
        at me.leothepro555.skills.Draconic.onEntityAttack(Draconic.java:53) ~[?:?]
        at 
    The error is directed at EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, e, DamageCause.ENTITY_ATTACK, damage);
     
  2. @Hex_27
    1. at me.leothepro555.skills.Draconic.onEntityAttack(Draconic.java:53) ~[?:?]
    That's another method that you didn't show
     
  3. Offline

    Agentleader1

    There's a lot of unnecessary work done here. In the bukkit api, you can use damage(double, entity) which will automatically trigger it's own entitydamagebyentityevent.
     
  4. Offline

    Hex_27

    @Agentleader1 How does damage(double) set the damager to the player?
    @megamichiel It directs to the method "cleave". I've tried it in this plain method, and it gives the same error
     
    Last edited: Jul 22, 2015
  5. @Hex_27
    Entity#damage(double amount, Entity source);
     
  6. Moved to Bukkit Alternates.
     
  7. Offline

    Hex_27

    Doesn't that repeat the cleave over and over again for each mob nearby?
     
  8. @Hex_27
    Could you explain to me what the whole point of cleave is? It seems to me that when an entity is damaged you damage another time so it will repeat
     
  9. Offline

    Hex_27

    @megamichiel It's purpose is to damage all surrounding mobs, except the attacker. I also want it to trigger entitydamagebyentityevent for other purposes, but not to repeat cleave again.
     
Thread Status:
Not open for further replies.

Share This Page