Caused by: java.lang.NullPointerException: Name is null

Discussion in 'Spigot Plugin Development' started by JavoxDub, Aug 9, 2018.

  1. Hello guys!

    As you see in the title of this thread, I'm having that error. After looking thousands of possible solutions, I haven't resolved this. Can anyone help me? Here is the error.

    Code (Text):
    [23:32:24 ERROR]: Could not pass event AsyncPlayerChatEvent to MentionPlus v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1084) [spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1022) [spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39) [spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_181]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_181]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_181]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_181]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
    Caused by: java.lang.NullPointerException: Name is null
            at java.lang.Enum.valueOf(Unknown Source) ~[?:1.8.0_181]
            at org.bukkit.Sound.valueOf(Sound.java:1) ~[spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            at com.javoxdub.mentionplus.Events.callPlayer(Events.java:81) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8-R0.1-SNAPSHOT.jar:git-Spigot-21fe707-e1ebe52]
            ... 11 more
     
  2. Firestar311

    Supporter

    Could you provide your code?

    However, From the looks of the error, you are trying to get a sound from a null string, on line 81 of your Events class
     
  3. You passed a null string to Sound.valueOf
     
  4. Sure, here is it the Sound part of the Events class.

    Code (Java):
            message = message.replaceFirst("@(?i)" + player.getName(), this.plugin.getConfig().getString("options.player")).replaceAll("@%player%", "@" + player.getName());
            e.setMessage(ChatColor.translateAlternateColorCodes('&', message));
            if (this.plugin.getConfig().getBoolean("config.sounds")) {
              player.playSound(player.getLocation(), Sound.valueOf(sound), 10.0F, 1.0F);
            }
     
  5. Firestar311

    Supporter

    Does the config path have a value? You should check for null and wrap it in a try-catch and provide a default value