Help on getting offline player

Discussion in 'Plugin Development' started by kelson8--, Jul 19, 2014.

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

    kelson8--

    Can anyone help me with getting an offline player when i do the command on an offline player it says "An internal error occurred while attempting to perform this command"

    Code:java
    1. }
    2. if(player == null){
    3. sender.sendMessage("That player is not online!");
    4. return true;
    5. }
    6. if(cmd.getName().equalsIgnoreCase("location")){
    7. if (args.length == 0) {
    8. Location loc = player.getLocation();
    9. sender.sendMessage("The world you are in is '" + player.getWorld().getName() + "'" +
    10. " \nthe coords are " + ChatColor.YELLOW + "\nX: " + loc.getBlockX() + " \nY: " + loc.getBlockY() + " \nZ: " + loc.getBlockZ());
    11. }else if(args.length == 1){
    12. if(player.isOnline()){
    13. @SuppressWarnings("deprecation")
    14. Player targetPlayer = player.getServer().getPlayer(args[0]);
    15. Location loc1 = targetPlayer.getLocation();
    16. sender.sendMessage("The world " + targetPlayer.getName() + " is in is " + "'" + targetPlayer.getWorld().getName() + "'" + "\nThe coords are" + ChatColor.YELLOW + "\nX: " + loc1.getBlockX() + "\nY: " + loc1.getBlockY() + "\nZ: " + loc1.getBlockZ());
    17. }
    18. }
    19. }
     
  2. Offline

    Necrodoom

    getPlayer would get an online player. You are looking for the offlinePlayer methods.
     
  3. Offline

    Zettelkasten

    kelson8 It doesn't just say "An internal error ..." but also prints an error message with stack trace, right? Please post it.
     
  4. Offline

    kelson8--

    [19:10:24] [Server thread/INFO]: kelson8 issued server command: /location offline
    [19:10:24] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'location' in plugin Kelsons-Plugin v1.0.3
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[Spigot-1.7.9.jar:git-Spigot-1483]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[Spigot-1.7.9.jar:git-Spigot-1483]
    at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:726) ~[Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:999) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:830) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:65) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:180) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.ServerConnection.c(ServerConnection.java:81) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:720) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:283) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:583) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:489) [Spigot-1.7.9.jar:git-Spigot-1483]
    at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [Spigot-1.7.9.jar:git-Spigot-1483]
    Caused by: java.lang.NullPointerException
    at me.Kelson.Commands.onCommand(Commands.java:167) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[Spigot-1.7.9.jar:git-Spigot-1483]
    ... 13 more
     
  5. Offline

    TnT

    Locked. Unfortunately you have found the wrong forums for support for the software you use. For support for software other than Bukkit/CraftBukkit, seek help on the forums where you found the software. :)
     
Thread Status:
Not open for further replies.

Share This Page