Solved NullPointerException on t.sendMessage?

Discussion in 'Plugin Development' started by Mindlessmink, Sep 9, 2016.

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

    Mindlessmink

    Okay, I'm receiving a NullPointerException on a line where I only send a message, This is the console error:

    Code:
     
    19:16:23 [WARN] Exception in thread "Craft Scheduler Thread - 1"
    19:16:23 [WARN] org.apache.commons.lang.UnhandledException: Plugin MinkFreeze v1.0 generated an exception while executing task 38
    19:16:23 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
    19:16:23 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    19:16:23 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    19:16:23 at java.lang.Thread.run(Thread.java:745)
    19:16:23 Caused by: java.lang.NullPointerException
    19:16:23 at me.mindlessmink.minkfreeze.MinkFreeze$1.run(MinkFreeze.java:64)
    19:16:23 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
    19:16:23 at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    19:16:23 ... 3 more
    
    This is and or the Runnable it's in. line 64 is the t.sendMessage one:

    Code:
                  public void run() {
                     if (frozen.contains(t)){
                       t.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("frozen-message:").toString().replaceAll("%sender%", s.getName()).replaceAll("%reason%", b.toString())));
                     }
                   }
                 }, 0, 5 * 20);
    
    And I believe this has something to do with the config, So here it is anyway.

    Code:
    #############################
    #+-------------------------+#
    #|  MinkFreeze  |#
    #+-------------------------+#
    #############################
    frozen-message: "&4You have been frozen by %sender% for reason %reason%! Do &c&lNOT &clogout or you will be banned!"
    
     
  2. Offline

    AlvinB

    @Mindlessmink
    Remove the ":" and you should be fine.
     
  3. Offline

    Mindlessmink

    @AlvinB DERP... I'm so dumb, I've been looking over this for hours dude and I've just derped out over a colon. I cri ;-;
     
  4. Offline

    bwfcwalshy Retired Staff

    @Mindlessmink Why are you doing getString().toString()? You are making a string object from a string object?
     
  5. Offline

    Mindlessmink

    @bwfcwalshy yeah, Sometimes my Code doesn't let me use the .replaceAll method unless i use .toString. Event if it's retrieving a string from something.
     
Thread Status:
Not open for further replies.

Share This Page