ERROR caused by: Java.lang.NullPointerException

Discussion in 'Spigot Plugin Development' started by Maximiliano, May 28, 2016.

Thread Status:
Not open for further replies.
  1. I try to dev a plugin but have this error and i dont know why it happens...

    Console error:
    Code (Text):
    [23:09:08] [Server thread/ERROR]: Could not pass event PlayerMoveEvent to VortexElytra v2.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java:608) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.PacketPlayInFlying.a(SourceFile:126) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_66]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_66]
        at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:721) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:660) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java:559) [spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_66]
    Caused by: java.lang.NullPointerException
        at io.github.maxmar628.vortexelytra.ElytraListener.onMove(ElytraListener.java:48) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_66]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_66]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.9.jar:git-Spigot-2038f4a-cd36f6f]
        ... 15 more
    Here the event when have the problem:
    Code (Text):
      @EventHandler(priority=EventPriority.MONITOR)
      public void onMove(PlayerMoveEvent paramPlayerMoveEvent) {
     
        Player p = paramPlayerMoveEvent.getPlayer();
        Location localLocation1 = p.getLocation().clone();
        if ((this.ve.getRing(p.getLocation())) || (this.ve.getRing(localLocation1))){
       
          Object localObject;
     
            localObject = this.ve.getRegion(localLocation1);
            if (((String)localObject).startsWith("v"))
            {
              int i = Integer.parseInt(((String)localObject).substring(1));
              if ((i >= 1) && (i <= this.ve.getConfig().getInt("Rings"))) {
                if (i == 1)
                {
                  if (!this.ve.getJumps().containsKey(p))
                  {
                    this.ve.getJumps().put(p, Integer.valueOf(1));
                    p.sendMessage(ChatColor.translateAlternateColorCodes('&', this.ve.getConfig().getString("Prefix")
                            + ChatColor.translateAlternateColorCodes('&', this.ve.getConfig().getString("Message_Counter").replace("%s", "1"))));

                    p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 0.0F);
                  }
                }
                else if (i == this.ve.getConfig().getInt("Rings")){
                if (((Integer)this.ve.getJumps().get(p)).equals(Integer.valueOf(i - 1))){
                    if (this.ve.getConfig().getBoolean("Win_Configuration.message.enabled")) {
                        p.sendMessage(ChatColor.translateAlternateColorCodes('&', this.ve.getConfig().getString("Prefix")
                                + ChatColor.translateAlternateColorCodes('&', this.ve.getConfig().getString("Win_Configuration.message.text"))));
                    }
                    for (String str : this.ve.getConfig().getStringList("Win_Configuration.commands")) {
                      this.ve.getServer().dispatchCommand(Bukkit.getConsoleSender(), str.replace("{player}", p.getName()));
                    }
                    p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 0.0F);
                    this.ve.getJumps().remove(p);
                  }
                }
                else if (((Integer)this.ve.getJumps().get(p)).equals(Integer.valueOf(i - 1))){
               
                  this.ve.getJumps().put(p, Integer.valueOf(i));
                  p.sendMessage(ChatColor.translateAlternateColorCodes('&', this.ve.getConfig().getString("Prefix")
                          + ChatColor.translateAlternateColorCodes('&', this.ve.getConfig().getString("Message_Counter").replace("%s", String.valueOf(i)))));
                              p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 0.0F);
                }
              }
            }
        }
      }
    The line with problem is this:
    Code (Text):
                if (((Integer)this.ve.getJumps().get(p)).equals(Integer.valueOf(i - 1))){    
    my config.yml is this:
    Code (Text):
    Prefix: '&6&lVortex&f&lElytra > &r'
    Message_Counter: '&6&lVortexElytra &e[&a%s/4&e]'
    Rings: 4
    Win_Configuration:
      commands:
      - 'eco give {player} 5'
      - 'give {player} 264 1'
      message:
        enabled: true
        text: '&aCongratulations you won!!'

    Any idea what is wrong?
     
    #1 Maximiliano, May 28, 2016
    Last edited: May 28, 2016
  2. You should probably learn to code before you decompile other plugins...
    That can't be the line you have an error. Everything that can be null in that line is already used beforehand, meaning an NPE would be thrown earlier than that.
     
    • Agree Agree x 3
    • Winner Winner x 1
  3. @Warren1001 before prejudge minimally read the console error, here mark line 48 line with the problem ... You have 1500 messages and I'm 100% sure that 90% of these are spam, as the comment you made in this post .. if you got something useful to contribute have no problems. Im not a child like u i have 24 years old and study architucture.. this is my hobby dude ;)
     
    #3 Maximiliano, May 28, 2016
    Last edited: May 28, 2016
    • Winner Winner x 2
    • Funny Funny x 1
  4. Architecture has NOTHING to do with programming..
     
  5. You can 2 two things. But btw Max is doing his hobby so he is requesting help, if you have something to contribute post it but don't judge his hobby or job. ;)
     
    • Agree Agree x 1
  6. @MrPlug this obviously decompiled code. No one names their variables with paramPlayerMoveEvent or localObject1 and casts unnecessarily
     
  7. If the author of the plugin wants to name their variables paramPlayerMoveEvent he can, because is his code. He isn't asking if his code is decompiled or why the variables has that names. He is asking for a solution of an error that he has with the development of the plugin. In my websites (TheExeLab) I don't have a guide about how to name variables.
     
    • Winner Winner x 1
  8. Strawman, he can name them that all he wants, but the point is no one does. It is clearly decompiled code, and this error was likely caused during decompilation, which someone pointed out. There's nothing wrong with them doing that, and it often helps to come to a solution.
    This is not the place for that, if you want to have a catfight, do it elsewhere than the Plugin Development forums.
    Wow, let me grab you a golden star. Nobody likes patronization and it automatically makes someone like me assume that you are
    a. A liar
    b. Immature
    c. Not someone worth helping
    Regardless of point c, I will still attempt to help you solve your problem.

    Are you 100% sure that
    Code (Java):
                else if (i == this.ve.getConfig().getInt("Rings")){
    is line 48 of ElytraListener.java?

    If so, the only thing that could be causing a NullPointerException is that
    Code (Java):
    getConfig()
    is returning null, seeing that you have called methods on the ve variable, which if it was null would have caused a NPE earlier (as pointed out by @Warren1001 ).
     
  9. I appreciate you making an alternate account and posting spam and hate on my resources. You certainly don't act like you're 24. My point is you could potentially be stealing someone else's work and that we will not help with. Also, I was trying to help as I told you that cannot be where the error is as it didn't make any sense. There is no need to get butthurt about you being unknowledgably about Java. Telling you to learn Java is actually helpful advice as you cannot write in a language that you do not understand... It's the same as your English. Your native language isn't English so you aren't particularly the best at it. But that code is clearly another plugin decompiled (meaning you didn't make it yourself, or if you did you would know how to fix it since it would have been YOUR plugin).
     
    • Winner Winner x 3
    • Optimistic Optimistic x 1
  10. @Warren1001 continued with the spaming.. 1rst this is my own dev. 2d im dont have 2 account, I do not understand what you mean. 3er dont auto leave Winner all time dude, and please stop spaming, im try to fix a problem, by people like you every day this forum becomes more junk and useless. I dont reply more because i dont need gain more messages and auto winners like u. If you do not got no intention to assist in this forum reservate comments and do not continue with spam. :)
     
    • Funny Funny x 1
  11. I will try to solve the problem alone, as he always did. Thanks to those who tried to help. I close the subject not to continue spamming! Im close the thread for stop the spaming from guy with out any interest on help
     
Thread Status:
Not open for further replies.