Plugin works fine but error still shows up.

Discussion in 'Plugin Development' started by SandKastle, Jul 6, 2013.

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

    SandKastle

    So my plugin works completely fine but errors show up in console? It doesnt effect anything either. can someone maybe check out my source code and tell me if anything is wrong? PM me so i can send it.
     
  2. Offline

    ZeusAllMighty11

    You ask for help on a public forum, yet ask for a private message.

    can't you just post it here?
     
  3. Offline

    SandKastle

    TheGreenGamerHD Meh, i am kind of uptite of giving away my source codes. So i could but i dont want to.
     
  4. Offline

    ZeusAllMighty11

    Then don't post here. Simple as that.
     
  5. Offline

    SandKastle

    TheGreenGamerHD Your logic doesnt make sense, I am asking for help but dont want the source to be completely viewable by everyone. Why are you even posting on this thread if you dont like how i put it up?
     
  6. Offline

    Joeisi

    This is a forum. Its quite open. Just release the parts that are causing you an issue, and we can try to help you the best we can. If we need another section of code we will ask. We aren't asking you to release the entire plugin code.

    Maybe just show us the errors?
     
  7. Offline

    skore87

    And why are you making the thread? You won't find help this way.

    Funny enough though most that are so secretive about the code most often have crap code to begin with, hence the stack traces you can't seem to read yourself.
     
  8. Offline

    SandKastle

    Joeisi Thats the thing, there are no errors in a certain part of it. The error log says "line 84" but when i go to see something wrong, there is not something to be fixed.


    This is plugin development, so i know if i post my entire source code someone else will take it and edit the plugin.yml and some other words in it to make it theirs. It wouldnt even be hard to find the source code of it anyway because its the ONLY plugin i have put up. Well an updated and more efficient version i guess.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  9. Offline

    Joeisi

    ??? Make sure you are using your current build. Change your version number and make sure bukkit realizes it. (Bukkit prints the version when it enables the plugin)

    In error log do you mean a stack trace? Then you need to see if its something like a NullPointer or something. If not try removing any try catches and just watch catastrophic failure.
     
  10. Offline

    skore87

    Oh yeah, and an answer to the PM you just sent: I don't help in PMs.
     
    Minnymin3 likes this.
  11. Offline

    SandKastle

    i was just editing my post for it anyway o.o saved me time. But you dont understand that people will just take it edit a few things and call it theirs. which is why i didnt want to post it in the first place. BTW you are an asshole :)


    i sent you a pm or you can just look at the post above.

    Code:
    23:07:11 [SEVERE] Could not pass event CraftItemEvent to CraftableHorseArmor v1.
    1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at net.minecraft.server.v1_6_R1.PlayerConnection.a(PlayerConnection.java
    :1385)
            at net.minecraft.server.v1_6_R1.Packet102WindowClick.handle(SourceFile:3
    1)
            at net.minecraft.server.v1_6_R1.NetworkManager.b(NetworkManager.java:293
    )
            at net.minecraft.server.v1_6_R1.PlayerConnection.d(PlayerConnection.java
    :118)
            at net.minecraft.server.v1_6_R1.ServerConnection.b(SourceFile:37)
            at net.minecraft.server.v1_6_R1.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_6_R1.MinecraftServer.t(MinecraftServer.java:5
    90)
            at net.minecraft.server.v1_6_R1.DedicatedServer.t(DedicatedServer.java:2
    26)
            at net.minecraft.server.v1_6_R1.MinecraftServer.s(MinecraftServer.java:4
    86)
            at net.minecraft.server.v1_6_R1.MinecraftServer.run(MinecraftServer.java
    :419)
            at net.minecraft.server.v1_6_R1.ThreadServerApplication.run(SourceFile:5
    82)
    Caused by: java.util.ConcurrentModificationException
            at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
            at java.util.ArrayList$Itr.next(Unknown Source)
            at me.sandkastle.craftablehorsearmor.Main.onItemEvent(Main.java:87)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 14 more
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  12. Offline

    skore87

    Flattery will get you nowhere with me.
     
    Compressions likes this.
  13. Offline

    SandKastle

    why are you still here? Im not asking for your help.
     
  14. Offline

    Joeisi

    SandKastle Welcome to Open Source! Bukkit is licensed so that you have to share your source anyhow so GET OVER IT. Anyhow. What was the error the console threw?
     
  15. Offline

    SandKastle

    3 posts above this ( i think)

    EDIT: 4
     
  16. Offline

    Joeisi

    java.util.ConcurrentModificationException
    This occurs when you edit a list within a loop like a for loop.
    Below is your error. You simply can't do that. Lol. Take each human entity, add them to a separate list, then close them from there.

    Code:java
    1. for(HumanEntity he: e.getViewers())
    2. he.closeInventory();
    3. }


    Oh, and.....
    [​IMG]
     
  17. Offline

    SandKastle

    the reason i added those in the first place was to see if it fixed it but it had errors before i added those in also. i will get errors logs of that.
     
  18. Offline

    ZeusAllMighty11

    Try exporting again and searching for errors.


    Also, if you want help on a public forum, then don't ask for private help.

    I doubt anyone here would even want to steal your code.

    1) There's most likely better code than yours.
    2) it's not that hard to write a plugin
    3) Even if they stole it and made it theirs, they couldn't put it up on Bukkit Dev - so you wouldn't even know if they stole it or not.
    4) Many super large developers have posted their code, infact, they've made it open sourced. They don't care who sees it.

    Reading / writing to/from something in a loop will cause that.

    You need to either make it thread-safe (use an iterator?) or find another way to achieve it

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  19. Offline

    Joeisi


    Well at the moment, that is what your server is getting hung up on.
     
  20. Offline

    SandKastle

    This is the code without the for loops and the error will be in next post.

    Code:java
    1. package me.sandkastle.craftablehorsearmor;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Material;
    5. import org.bukkit.Server;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.EventPriority;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.inventory.CraftItemEvent;
    11. import org.bukkit.inventory.ItemStack;
    12. import org.bukkit.inventory.ShapedRecipe;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class Main extends JavaPlugin implements Listener{
    16. public void onEnable(){
    17. Server server = getServer();
    18. getServer().getPluginManager().registerEvents(this, this);
    19.  
    20. ShapedRecipe iha = new ShapedRecipe(new ItemStack(417));
    21. iha.shape(new String[] { " I", "IBI", "III" });
    22. iha.setIngredient('I', Material.IRON_INGOT);
    23. iha.setIngredient('B', Material.WOOL, 15);
    24.  
    25. ShapedRecipe gha = new ShapedRecipe(new ItemStack(418));
    26. gha.shape(new String[] { " I", "IBI", "III" });
    27. gha.setIngredient('I', Material.GOLD_INGOT);
    28. gha.setIngredient('B', Material.WOOL, 14);
    29.  
    30. ShapedRecipe dha = new ShapedRecipe(new ItemStack(419));
    31. dha.shape(new String[] { " I", "IBI", "III" });
    32. dha.setIngredient('I', Material.DIAMOND);
    33. dha.setIngredient('B', Material.WOOL, 11);
    34.  
    35. ShapedRecipe saddle = new ShapedRecipe(new ItemStack(329));
    36. saddle.shape(new String[] { "III", "IBI" });
    37. saddle.setIngredient('I', Material.LEATHER);
    38. saddle.setIngredient('B', Material.IRON_INGOT);
    39.  
    40. ShapedRecipe tag = new ShapedRecipe(new ItemStack(421));
    41. tag.shape(new String[] { " I", " B ", "B " });
    42. tag.setIngredient('I', Material.STRING);
    43. tag.setIngredient('B', Material.PAPER);
    44.  
    45. server.addRecipe(iha);
    46. server.addRecipe(gha);
    47. server.addRecipe(dha);
    48. server.addRecipe(saddle);
    49. server.addRecipe(tag);
    50. }
    51.  
    52. @EventHandler(priority=EventPriority.HIGHEST)
    53. public void onItemEvent(CraftItemEvent e) {
    54. Player p = (Player)e.getView().getPlayer();
    55. if ((!p.hasPermission("cha.saddle")) && (e.getInventory().getResult().getTypeId() == 329)) {
    56. p.sendMessage(ChatColor.RED + "You don't have permission to craft a saddle!");
    57. e.getInventory().setResult(null);
    58. }
    59.  
    60. else if ((!p.hasPermission("cha.iha")) && (e.getInventory().getResult().getTypeId() == 417)) {
    61. p.sendMessage(ChatColor.RED + "You don't have permission to craft iron horse armor!");
    62. e.getInventory().setResult(null);
    63. }
    64.  
    65. else if ((!p.hasPermission("cha.gha")) && (e.getInventory().getResult().getTypeId() == 418)) {
    66. p.sendMessage(ChatColor.RED + "You don't have permission to craft gold horse armor!");
    67. e.getInventory().setResult(null);
    68. }
    69.  
    70. else if ((!p.hasPermission("cha.dha")) && (e.getInventory().getResult().getTypeId() == 419)) {
    71. p.sendMessage(ChatColor.RED + "You don't have permission to craft diamond horse armor!");
    72. e.getInventory().setResult(null);
    73. }
    74.  
    75. else if ((!p.hasPermission("cha.tag")) && (e.getInventory().getResult().getTypeId() == 421)) {
    76. p.sendMessage(ChatColor.RED + "You don't have permission to craft a nametag!");
    77. e.getInventory().setResult(null);
    78. }
    79. }
    80. }


    Code:
    23:17:40 [SEVERE] Could not pass event CraftItemEvent to CraftableHorseArmor v1.
    1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at net.minecraft.server.v1_6_R1.PlayerConnection.a(PlayerConnection.java
    :1385)
            at net.minecraft.server.v1_6_R1.Packet102WindowClick.handle(SourceFile:3
    1)
            at net.minecraft.server.v1_6_R1.NetworkManager.b(NetworkManager.java:293
    )
            at net.minecraft.server.v1_6_R1.PlayerConnection.d(PlayerConnection.java
    :118)
            at net.minecraft.server.v1_6_R1.ServerConnection.b(SourceFile:37)
            at net.minecraft.server.v1_6_R1.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_6_R1.MinecraftServer.t(MinecraftServer.java:5
    90)
            at net.minecraft.server.v1_6_R1.DedicatedServer.t(DedicatedServer.java:2
    26)
            at net.minecraft.server.v1_6_R1.MinecraftServer.s(MinecraftServer.java:4
    86)
            at net.minecraft.server.v1_6_R1.MinecraftServer.run(MinecraftServer.java
    :419)
            at net.minecraft.server.v1_6_R1.ThreadServerApplication.run(SourceFile:5
    82)
    Caused by: java.lang.NullPointerException
            at me.sandkastle.craftablehorsearmor.Main.onItemEvent(Main.java:55)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 14 more
    >
    Joeisi TheGreenGamerHD please see error log.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  21. Offline

    Joeisi

    Something is null.

    Code:java
    1. if ((!p.hasPermission("cha.saddle")) && (e.getInventory().getResult().getTypeId() == 329)) {
     
  22. Offline

    SandKastle


    I am new to java, please explain?

    I know null means the absence of a value but does that mean its somewhere in this part

    Code:java
    1. (e.getInventory().getResult().getTypeId()
     
  23. Offline

    ZeusAllMighty11

    getResult() could be null
     
  24. Offline

    Joeisi

    CraftItemEvent e is probably null.
    Sometimes events are called multiple times. Make a catch at the beginning of your CIE event handler:

    Code:java
    1. if(e==null){
    2. return;
    3. }


    or getResult, like TheGreenGamerHD
     
  25. Offline

    SandKastle

    TheGreenGamerHD Joeisi actually no need to explain i know whats wrong, well its right then wrong if you understand me. So when i first try and craft the item it sets the result to null, then when i click the box again it generates the null error, which is why i had the close inventory part but that just made more errors, is their a workaround to this?


    Now this is what confuses me. I understood my problem before after some thinking but the workaround i do not understand.

    TheGreenGamerHD Joeisi you will understand what i said better if you try and do it yourself.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  26. Offline

    Joeisi

    Workaround:

    Code:java
    1. if(e == null){ //If the event is somehow null
    2. return; //Just ignore it
    3. }
    4. if(e.getInventory().getResult() == null){ //If we don't have a result
    5. return; //Just ignore that too
    6. }
     
  27. Offline

    SandKastle


    Thank you, it worked.
     
Thread Status:
Not open for further replies.

Share This Page