[Problem] NullPointerException

Discussion in 'Spigot Plugin Development' started by Hugmanrique, May 9, 2015.

Thread Status:
Not open for further replies.
  1. Hi, Im new to Bukkit, this code isn't working:
    Code (Text):
    public class randomhub extends JavaPlugin {
        public void onEnable(){
            this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
        public boolean onCommand(CommandSender sender, Command cmd,String label, String[] args){
            if (!(sender instanceof Player)){
                sender.sendMessage("La consola no puede hacer esto");
                return false;
            Player p = (Player) sender;
            if (label.equalsIgnoreCase("iraquarklobby")){
                ByteArrayDataOutput out = ByteStreams.newDataOutput();
                p.sendPluginMessage(this, "HubMagic", out.toByteArray());
                return true;
            }return false;
    In my IDE I don't have any errors.
    Running the command iraquarklobby makes a crash:
    Code (Text):
    org.bukkit.command.CommandException: Unhandled exception executing command 'iraquarklobby' in plugin RandomHub v1.0.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-1.7.9-R0.2-205-g6a8d903]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) ~[spigot.jar:git-Spigot-1.7.9-R0.2-205-g6a8d903]
        at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767) ~[spigot.jar:git-Spigot-1.7.9-R0.2-205-g6a8d903]
        at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerConnection.java:1043) [spigot.jar:git-Spigot-1.7.9-R0.2-205-g6a8d903]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:880) [spigot.jar:git-Spigot-1.7.9-R0.2-205-g6a8d903]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:2 [spigot.jar:git-Spigot-1.7.9-R0.2-205-g6a8d903]
        at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat.java:65) [spigot.jar]
  2. If I had to guess, based on the code, ByteStreams.newDataOutput() is returning null. The other two objects, player and label shouldn't be null, and would be programmer error. It's also possibly an api issue, so it might not be your fault either. I could know more if you provided the entire stacktrace, can you please provide it?
    • Like Like x 1
  3. You messed around with your PMCs..
    You try to send the command "ConnectHub" to the Sub-Channel "HubMagic" of "Bungeecord"

    The command & the sub-channel don't exist..
    Please read the documentin again (or maybe use my API "BungeeBridge";))
  4. That's the only entire stacktrace I have found, what do you refer?
  5. I'm using the HubMagic plugin in my bungeecord, so it should work
  6. Did you do everything like specified in the documention of "HubMagic"?
    • Winner Winner x 1
  7. Thank you!!! Please lock the post
Thread Status:
Not open for further replies.