Solved I need help with this error

Discussion in 'Plugin Development' started by HahaPluginGoBrrrrrrrrrrr, Oct 26, 2020.

  1. Stacktrace:
    Code:
    [17:04:05 ERROR]: Could not pass event EntityDamageByEntityEvent to SimpleWands v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEvent(CraftEventFactory.java:86) [craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEntityDamageEvent(CraftEventFactory.java:536) [craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleEntityDamageEvent(CraftEventFactory.java:449) [craftbukkit.jar:git-Bukkit-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleLivingEntityDamageEvent(CraftEventFactory.java:568) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityLiving.d(EntityLiving.java:1092) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:733) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntitySnowball.a(SourceFile:30) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityProjectile.t_(EntityProjectile.java:154) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.World.entityJoinedWorld(World.java:1420) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.World.g(World.java:1398) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.World.tickEntities(World.java:1269) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.WorldServer.tickEntities(WorldServer.java:560) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:727) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit.jar:git-Bukkit-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit.jar:git-Bukkit-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_271]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
            at me.TA4.thingyprojhit.onthingamajig(thingyprojhit.java:16) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_271]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[craftbukkit.jar:git-Bukkit-18fbb24]
            ... 20 more
    The code:
    Code:
    //PlayerInteract(works fine)
    package me.TA4;
    
    import org.bukkit.Material;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Projectile;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    
    public class PlayerInteractThingy implements Listener {
        @SuppressWarnings("deprecation")
        @EventHandler
        public void thenameofclassimtoolazy(PlayerInteractEvent e) {
            if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                if(e.getPlayer().getItemInHand().getType() == Material.STICK) {
                    if(e.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals("Wand of Transportation")) {
                        if(e.getPlayer().isInsideVehicle() == true) {
                            return;
                        }else if(e.getPlayer().isInsideVehicle() == false){
                            Player p = e.getPlayer();
                            Entity entp = e.getPlayer();
                            Projectile ent = p.throwSnowball();
                            ent.setPassenger(entp);
                            ent.setShooter(p);
                            ent.setCustomName("TravelingSnow," + entp.getCustomName());
                            return;
                        }else {
                            return;
                        }
                    }else if(e.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals("Wand of Demise")){
                        Player p = e.getPlayer();
                        Projectile ent = p.throwSnowball();
                        ent.setShooter(p);
                        ent.setCustomName("DEADLYSNOW");
                        return;
                    }else {
                        return;
                    }
                }else {
                    return;
                }
            }else {
                return;
            }
        }
    }
    Code:
    //This is whats causing the error
    package me.TA4;
    
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Projectile;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    
    public class thingyprojhit implements Listener {
        @EventHandler(priority = EventPriority.HIGH)
        public void onthingamajig(EntityDamageByEntityEvent e) {
             if(e.getDamager() instanceof Projectile) {
                 Entity ent = e.getDamager();
                 String[] beepbeepboop = ent.getCustomName().split(",", 2);
                 if(e.getEntity().getCustomName().equalsIgnoreCase(beepbeepboop[1])) {
                     e.setCancelled(true);
                     return;
                 }else if(beepbeepboop[0].equalsIgnoreCase("TravelingSnow")) {
                     e.setCancelled(true);
                     return;
                 }else if(e.getDamager().getCustomName().equals("DEADLYSNOW")) {
                     e.setDamage(20);
                     return;
                 }else {
                     return;
                 }
             }else {
                 return;
             }
        }
    }
     
    Last edited by a moderator: Oct 27, 2020
  2. Online

    timtower Moderator Moderator

  3. thanks
     

Share This Page