Solved Error with Entities

Discussion in 'Spigot Plugin Development' started by MakingTheMagic, Jul 2, 2016.

Thread Status:
Not open for further replies.
  1. Hey guys!

    Whenever an event runs it kicks me of the server, this is the kick message:
    Code (Text):
    Internal Exception: io.netty.handler.codec.EncoderException: java.lang.RuntimeException: An internal error occured.
     
    this is my other console error:

    Code (Text):
    ... 15 more
    02.07 09:17:42 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at net.mini.mcd.commands.rides.BEvent.onInventoryChange(BEvent.java:110) ~[?:?]
    02.07 09:17:42 [Server] INFO at net.mini.mcd.commands.Balloons.spawnBalloon(Balloons.java:231) ~[?:?]
    02.07 09:17:42 [Server] INFO Caused by: java.lang.NullPointerException
    02.07 09:17:42 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:556) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:653) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:714) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_71]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot.a(SourceFile:8) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot.a(SourceFile:30) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:931) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8-20150820a.jar:git-Spigot-fdc1440-53fac9f]
    02.07 09:17:42 [Server] INFO org.bukkit.event.EventException
    02.07 09:17:42 [Server] ERROR Could not pass event PlayerItemHeldEvent to McDiscoveryCore v2.8
     
    this is my code for the "onInventoryChange":

    Code (Text):
      @EventHandler
          public void onInventoryChange(PlayerItemHeldEvent e)
          {
            Player p = e.getPlayer();
            ItemStack newItem = p.getInventory().getItem(e.getNewSlot());
            if (newItem == null)
            {
              if (MainClass.balloonList.containsKey(p))
              {
                ArmorStand as = null;
                CustomBat bat = null;
               
                HashMap<ArmorStand, CustomBat> entities = (HashMap)MainClass.balloonList.get(p);
                for (ArmorStand armor : entities.keySet())
                {
                  as = armor;
                  CustomBat bat1 = (CustomBat)entities.get(as);
                 
                  bat = bat1;
                }
                if (as != null) {
                  as.remove();
                }
                if (bat != null) {
                  bat.getBukkitEntity().remove();
                }
                MainClass.balloonList.remove(p);
              }
              return;
            }
            CustomBat bat1;
            if (newItem.getType() != Material.SKULL_ITEM)
            {
              if (MainClass.balloonList.containsKey(p))
              {
                ArmorStand as = null;
                CustomBat bat = null;
               
                HashMap<ArmorStand, CustomBat> entities = (HashMap)MainClass.balloonList.get(p);
                for (ArmorStand armor : entities.keySet())
                {
                  as = armor;
                  bat1 = (CustomBat)entities.get(as);
                 
                  bat = bat1;
                }
                if (as != null) {
                  as.remove();
                }
                if (bat != null) {
                  bat.getBukkitEntity().remove();
                }
                MainClass.balloonList.remove(p);
              }
              return;
            }
            if (newItem.hasItemMeta())
            {
              String name = newItem.getItemMeta().getDisplayName();
              if (name.contains("Balloon!"))
              {
                if (MainClass.balloonList.containsKey(p))
                {
                  ArmorStand as = null;
                  CustomBat bat = null;
                 
                  HashMap<ArmorStand, CustomBat> entities = (HashMap)MainClass.balloonList.get(p);
                  for (ArmorStand armor : entities.keySet())
                  {
                    as = armor;
                    CustomBat bat11 = (CustomBat)entities.get(as);
                   
                    bat = bat11;
                  }
                  if (as != null) {
                    as.remove();
                  }
                  if (bat != null) {
                    bat.getBukkitEntity().remove();
                  }
                  MainClass.balloonList.remove(p);
                }
                if (!Cooldown.isInCooldown(p.getUniqueId(), "balloon"))
                {
                  Cooldown cd = new Cooldown(p.getUniqueId(), "balloon", 5);
                  cd.start();
                  Bukkit.getLogger().info("...");
                  String cutNameType = name.replace(" Balloon!", "").replace("&d", "");
                  cutNameType = ChatColor.stripColor(cutNameType);
                  Bukkit.getLogger().info("Name of balloon: " + cutNameType);
                  Balloons balloons = new Balloons();
                  balloons.spawnBalloon(p, cutNameType);
                }
                else
                {
                  p.sendMessage(ChatColor.RED + "You cannot pull out the balloon for another " + ChatColor.GRAY +
                    Cooldown.getTimeLeft(p.getUniqueId(), "balloon") + ChatColor.RED + " seconds!");
                }
              }
              else
              {
                Bukkit.getLogger().info("Name:" + name);
              }
            }
          }
    }
     
    and this is my code
    for the spawnballoon:

    Code (Text):
    public void spawnBalloon(Player player,String type)
        {
            String head = balloonz.getString("balloons." + type + ".skin");
           
              ItemStack skull;
             
           
                    skull = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
                    SkullMeta meta = (SkullMeta) skull.getItemMeta();
                    meta.setOwner(head + "");
                    Bukkit.getLogger().info("Getting head of : " + head);
                    meta.setDisplayName(ChatColor.LIGHT_PURPLE + " Balloon!");
                    skull.setItemMeta(meta);
           
           
                    skull = CustomHead.getSkull(head);

               
              ArmorStand as = (ArmorStand) player.getWorld().spawnEntity(player.getLocation().add(0, 3, 0),EntityType.ARMOR_STAND);
                EntityArmorStand ce = (EntityArmorStand) ((CraftEntity) as).getHandle();
                CustomBat bat = CustomBat.spawnCar(as.getLocation().add(0, 0.5, 0), as.getWorld(), 0, 0);
                as.setLeashHolder(player);
               
                as.setHelmet(skull);
                as.setVisible(false);
                as.setGravity(true);
                as.setBasePlate(false);
                bat.setInvisible(true);

                Chicken batBukkit = (Chicken) bat.getBukkitEntity();
                batBukkit.setLeashHolder(player);
    //            bat.addEffect(new net.minecraft.server.v1_8_R3.MobEffect(14,9999999,10,true,true));
                bat.addEffect(new net.minecraft.server.v1_8_R3.MobEffect(14, 9999999, 10,true,true));
               
                Bukkit.getLogger().info("Leashed: " + player.isLeashed());
                ce.noclip=true;
                bat.noclip=true;
                //as.set
                //ArrayList<ArmorStand> balloon = new ArrayList<ArmorStand>();
                HashMap<ArmorStand,CustomBat> hm = new HashMap<ArmorStand,CustomBat>();
                hm.put(as, bat);
                MainClass.balloonList.put(player, hm);
                }
               
             
    }
     
    How can I fix this?

    Thanks,
    any help is appreciated! :D
     
  2. Can you point us towards where line 231 is in Balloons.java ?
     
  3. Its an empty line.
     
  4. That means you modified the code since the crash log. Redo the steps to get the error, and then point us towards the line it tells you
     
  5. Code (Text):
    reason: Internal Exception: io.netty.handler.codec.EncoderException: java.lang.RuntimeException: An internal error occured.
     
    Okay, so it kicks me with that, but with no error anything.
    It spawns an armorstand above then kicks me, so its like their is a piece of code failing.
     
Thread Status:
Not open for further replies.