Discussion in 'Spigot Plugin Development' started by ScoRpoyN, Apr 26, 2017.

  1. Code (Text):
          public void onWarp(PlayerInteractEvent e)
              Player p = e.getPlayer();
              ItemStack is = p.getItemInHand();

              Action a = e.getAction();
              if(p.getItemInHand().getType() == Material.COMPASS && is.getItemMeta().getDisplayName().contains("Arena")/*is.getItemMeta().getDisplayName().equalsIgnoreCase("┬žaArena Selector")*/)
                  if(a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK)
    I get this error:
    [18:54:51 ERROR]: Could not pass event InventoryCloseEvent to Play-IL v1.1.4
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleInventoryCloseEvent(CraftEventFactory.java:852) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1411) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PacketPlayInCloseWindow.a(PacketPlayInCloseWindow.java:18) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PacketPlayInCloseWindow.a(PacketPlayInCloseWindow.java:1) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_111]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_111]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_111]
    Caused by: java.lang.Error: Unresolved compilation problems:
    Syntax error, insert ") Statement" to complete IfStatement
    Syntax error, insert "}" to complete Statement
    Type mismatch: cannot convert from InventoryCloseEvent to boolean

    at GUIs.GUIs.onPlayerCloseInventory(GUIs.java:781) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_111]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    ... 16 more

    line 217 is:
    Code (Text):
    p.getItemInHand().getType() == Material.COMPASS && is.getItemMeta().getDisplayName().contains("Arena")/*is.getItemMeta().getDisplayName().equalsIgnoreCase("┬žaArena Selector")*/)
    • Funny Funny x 2
  2. lol you exported your project and ignored errors from your compiler? Never do that if you expect anything to work.

    Your errors (3):
    Code (Text):
    Caused by: java.lang.Error: Unresolved compilation problems:
    Syntax error, insert ") Statement" to complete IfStatement
    Syntax error, insert "}" to complete Statement
    Type mismatch: cannot convert from InventoryCloseEvent to boolean
    • Winner Winner x 1
  3. You need to verify that item in hand is NOT null before checking its type.

    Right after you do
    ItemStack is = p.getItemInHand()
    You need to do
    If (is == null)

    Sent from my iPhone using Tapatalk
    • Like Like x 1
  4. That's not even the issue. They forgot to close two statements and tried to convert an event to a boolean.

    Edit: OP, you need to learn basic Java before starting a project. At the very least, watch some tutorials on code conventions, because this drives me nuts:
    Code (Text):
    public method test()
    // code
    Make it like this:
    Code (Text):
    public method test() {
            // code
    #4 _diam, Apr 26, 2017
    Last edited: Apr 26, 2017
    • Agree Agree x 3
    • Optimistic Optimistic x 1
  5. I skimmed over the compile errors it seems, regardless not checking null is still part of his problem :D

    Sent from my iPhone using Tapatalk
    • Like Like x 2
  6. Not to mention that they check for an itemMeta and a displayName without null checks, and to top it off, all in one statement.
    • Agree Agree x 1
  7. Calm down. The way he's doing it is a perfectly fine way to declare methods. Also, its probably not his fault. The eclipse compiler literally allows people to compile code with errors. Just give him the solution instead of bickering over minutiae

    Sent from my Nexus 5 using Tapatalk
  8. Lol I'm completely calm. There's a difference between helping someone learn from their mistakes, and spoon-feeding someone their answers. I will not simply give this person the correct code, because that achieves literally nothing. They'll make the same mistakes later, and just make another post asking for help.

    Compilers point out code errors, so this person is clearly ignoring them, or has them manually disabled (their fault either way).
  9. Javac won't compile errors. Eclipsec will. There's nothing they can do about it.

    Also, if that's the game you want to play, there's a difference between helping someone fix errors in their code without spoonfeeding, and telling them that their just formatting their code wrong. That isn't of help to anyone

    Sent from my Nexus 5 using Tapatalk
  10. I've told OP that they have three errors, and I provided what they were as well. I only pointed out that they go learn the basics of Java before attempting a project, as a side note.

    What do you think this is? A power-struggle? I'm trying to help someone learn, and you're here criticizing me for doing nothing wrong... so if you've got nothing productive to say, please do everyone a favor and leave.
  11. You helped them in the first sentence, the tangent about K&R vs Allman does nothing

    Sent from my Nexus 5 using Tapatalk
    • Funny Funny x 1
  12. lol could you stop replying to all of my posts? You've been doing it on different threads for a good 45 minutes, and none of what you've said is helpful or productive at all. If you're looking for someone to start a flamewar with, I'm not your guy.
  13. One could argue that saying "you need to learn Java" is equally unhelpful. I for one don't really mind helping the newbies with a less than full understanding of the API and or Java. But rather than cluttering up their post with arguments why not just ignore the posts of those who are asking questions beneath a master programmer?

    Sent from my iPhone using Tapatalk
    • Optimistic Optimistic x 1
  14. I can't see how saying that they should learn the basics of Java isn't helpful though. If they had read up on the basics, they wouldn't have forgotten to close their brackets and wouldn't have tried to convert an event into a boolean.

    If nobody ever tells them to learn basic Java, they'll keep going around thinking they can code plugins, and they'll keep making mistakes that could, otherwise, have been easily avoided.
  15. Because in about the time it takes to say you need to learn Java you could have said.

    Java requires any time you have a opening brace { you also need a closing brace }, this is the source of your compiler errors

    Sent from my iPhone using Tapatalk
    • Agree Agree x 1
  16. A simple Java tutorial would've covered that issue, and would have helped avoid about a number of others on top of that.

    No need to jump on me just because I'm not spoon-feeding code or answering questions which they could have Googled in less than a minute.
  17. How is this even a bug....
    • Agree Agree x 1
  18. As I previously mentioned, eclipsec allows people to compile syntactically invalid code, and just adds exceptions at runtime. This is one of those times
  19. I just had an error in another class because i didn't finished the code but I'm still getting the error ;-;
  20. Post your new stack trace, or look through it and see which line in YOUR class is showing an error, then post that line with the error

    Sent from my iPhone using Tapatalk