ERROR IN CONSOLE !! help

Discussion in 'Plugin Development' started by PeterXonwiiXx, Nov 22, 2015.

Thread Status:
Not open for further replies.
  1. i tried making arrows explosive but didnt work welll this is my code
    Code:
    [16:54:08 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'teleportbow' in plugin TeleportBow v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_65]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_65]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
    Caused by: java.lang.NullPointerException
            at me.peterxonwiixx.teleport.TeleportCommand.onCommand(TeleportCommand.java:21) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            ... 15 more
     
  2. Offline

    RoflFrankoc

    Can you give us the code please?
     
  3. Offline

    CraftCreeper6

    Zombie_Striker likes this.
  4. line 10-42
    Code:
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
            if ((sender instanceof Player)) {
                Player player = (Player) sender;
    
                if (player.hasPermission("Teleport.bow")) {
    
                    if (args.length != 1) {
    
                        if (!bow.players.contains(player.getName())) {
                            sender.sendMessage(((bow) getConfig()).getString("Enabled"));
                        } else {
                            bow.players.remove(player.getName());
                            sender.sendMessage(((bow) getConfig()).getString("Disabled"));
                        }
                    }
    
                } else {
                    sender.sendMessage(((bow) getConfig()).getString("nopermission"));
                }
    
            } else {
                sender.sendMessage(((bow) getConfig()).getString("noplayer"));
            }
            return true;
        }
    
        private Object getConfig() {
            return null;
        }
    
    }
     
  5. Offline

    Scimiguy

    Either config is null, or your string is null when you get it from the config
     
  6. Offline

    RoflFrankoc

    Are you sure you did not forget to save the config after adding the user into the config?
     
  7. Offline

    teej107

  8. Offline

    mcdorli

    Hmm? Take a picture please.
     
  9. Code:
    package me.peterxonwiixx.teleport;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class TeleportCommand implements CommandExecutor {
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
            if ((sender instanceof Player)) {
                Player player = (Player) sender;
    
                if (cmd.getName().equalsIgnoreCase("teleportbow"))
                    ;
                if (player.hasPermission("Teleport.bow")) {
    
                    if (args.length != 1) {
    
                        if (!bow.players.contains(player.getName())) {
                            sender.sendMessage(((bow) getConfig()).getString("enabled"));
                        } else {
                            bow.players.remove(player.getName());
                            sender.sendMessage(((bow) getConfig()).getString("disabled"));
                        }
                    }
    
                } else {
                    sender.sendMessage(((bow) getConfig()).getString("nopermission"));
                }
    
            } else {
                sender.sendMessage(((bow) getConfig()).getString("noplayer"));
            }
            return true;
        }
    
        private Object getConfig() {
            return null;
        }
    
    }
     
  10. Offline

    mcdorli

    Maybe you changed something, run it again
     
  11. Code:
    [17:06:17 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'teleportbow' in plugin TeleportBow v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_65]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_65]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
    Caused by: java.lang.NullPointerException
            at me.peterxonwiixx.teleport.TeleportCommand.onCommand(TeleportCommand.java:23) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24]
            ... 15 more
    >

    Code:
    package me.peterxonwiixx.teleport;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class TeleportCommand implements CommandExecutor {
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
            if ((sender instanceof Player)) {
                Player player = (Player) sender;
    
                if (cmd.getName().equalsIgnoreCase("teleportbow"))
                    ;
                if (player.hasPermission("Teleport.bow")) {
    
                    if (args.length != 1) {
    
                        if (!bow.players.contains(player.getName())) {
                            sender.sendMessage(((bow) getConfig()).getString("enabled"));
                        } else {
                            bow.players.remove(player.getName());
                            sender.sendMessage(((bow) getConfig()).getString("disabled"));
                        }
                    }
    
                } else {
                    sender.sendMessage(((bow) getConfig()).getString("nopermission"));
                }
    
            } else {
                sender.sendMessage(((bow) getConfig()).getString("noplayer"));
            }
            return true;
        }
    
        private Object getConfig() {
            return null;
        }
    
    }
    thahts what i got,the error might be sender.sendMessage(((bow) getConfig()).getString("enabled")); if i got it good
     
  12. Offline

    mcdorli

    Do you know how casting works? Because you're currently casting getConfig with bow, wich makes literally no sense.
    And please, post a screenshot from your whole screen, while you're looking at the config (I need the whole screen)

    Edit: wait wait wait, why do you have that getConfig method in the class? Of course it throws a nullpointerexception, getConfig always returns a null

    Edit2.: I see, you wanted to use it, and it howed an error, and you pressed the firsg button availabke in eclipse, you need an instance of the main class, and then do instance.getConfig(), and remove that getConfig method
     
  13. how do i set a instace :/
     
  14. Offline

    mcdorli

    The best way is to learn java. But you need to create a Main type field and use the cobstructor, to pass an instance of the main class, by using the this keyword, and in the constructor set the instance to the main instance you got
     
    teej107 likes this.
  15. Offline

    teej107

    Lol.
     
    Zombie_Striker likes this.
  16. Offline

    mcdorli

    Not easy to use thge bukkit website with a tablet from 2012
     
  17. Offline

    Scimiguy

    @mcdorli
    With the forums being the piece of crap they are, I'll agree.
    Because the forum developers didn't set a fixed size for ad elements, the page jumps around all the time while it's loading, and constantly closes the keyboard if you try to type.
    Do you have these issues too? Because they make it a nightmare to comment while on any portable device
     
  18. Offline

    mcdorli

    es, I do, tapatalk is crap too, you don't see what is new.
     
Thread Status:
Not open for further replies.

Share This Page