Null command exception with .broadcastMessage()?

Discussion in 'Plugin Development' started by ndoto, Mar 2, 2011.

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

    ndoto

    I'm trying to broadcast a message to my server. This is basically the code I have:

    Code:
    public static void shout(String msg, MyPlugin plugin) {
        plugin.getServer().broadcastMessage("Hey guys! " + msg);
    }
    
    However, it is not working, and in the stack trace it is giving me "[SEVERE] null org.bukkit.command.CommandException: Unhandled exception".

    I am using build 415 of Bukkit. I've searched the forums up and down and as far as I can tell I'm using the syntax that everyone else has used. I placed system.out.println() debug messages in the code, so I know for a fact it is the plugin.getServer().broadcastMessage() line that is actually causing the error. I also know from the debug messages that msg is correctly defined and isn't null. I have "public static MyPlugin plugin" defined in my MyPlugin class, within the base "public class MyPlugin extends JavaPlugin" method.

    Does anyone have any idea what's causing my code to error out? It's the only thing not working in the plugin right now, so it's super frustrating. :(
     
  2. Offline

    Cheesier

    On my server i have noticed that when i log in, it tells me the currently logged in players, but the names are all null. So maybe this is a bug with bukkit.
     
  3. Offline

    ndoto

    I figured out what I'd done wrong and solved it. Within my onCommand function in the main MyPlugin class I was passing "shout(msg, plugin)" but I needed to be passing "shout(msg, this)". Makes sense in hindsight, whoops. :)
     
Thread Status:
Not open for further replies.

Share This Page