Lobby Plugin Error NEED HELP

Discussion in 'Plugin Development' started by debs101, Jul 25, 2013.

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

    debs101

    So I had this person make a plugin for me where if I do /lobby I go to specified cords. The problem is that when I do /lobby after a server restart, It says internal error on the game. I got the error code on console and here is the link: http://pastebin.com/FHqW5p2Z The only way to fix this for now it to either do /reload and it will work or that i have to do /setlobby or reload the plugin. Please help me as fast as you can. If you need to talk to me more and want to see the plugin come to my server at mc.universaldiamondzgaming.com Thank you in advance.
     
  2. does it teleport you into an other world?
    you get some errors with WE teleport and Multiverse teleport
     
  3. Offline

    debs101

    nope i stay in the same place and it says internal error
     
  4. "Caused by: java.lang.NullPointerException"

    can you post the code of the plugin?
     
  5. Offline

    Eats_Rainbows

    I know what the error is. The person who made you the plugin didn't make the locations save over restart/reload. So everytime you restart/reload it loses the location data that is why you get the error because the location is null.
     
    Taketheword likes this.
  6. I made the same error in a plugin a few weeks ago, i saved the config befor i loaded it :rolleyes:
     
  7. Offline

    debs101

    uhhh how can i exactly?
    uhh ok i'll tell him that

    So guys what is the fix to it?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  8. Offline

    psanker

    That is an impressive stack trace. I needed to say it.
     
  9. Offline

    debs101

    Solution anyone ;)
     
  10. we need to see the code
     
  11. Offline

    debs101

    what program do i need to get the code?
     
  12. you can ask him for the code
     
  13. Offline

    debs101

    awww man ok wait can i give u the link of the download?

    Link is given by The_Doctor_123: https://forums.bukkit.org/threads/lobby-plugin.160421/#post-1763299

    I will give this link to the plugin producer once he comes on which will be a few hours.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  14. Offline

    The_Doctor_123

    Ah, yes, I am quite stumped as to why it is not working. Here is the full src(1 Class):

    Code:
    package com.yahoo.brettbutcher98.LobbyPlugin;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin {
       
        public Location loc = new Location(null, 0, 0, 0);
       
        @Override
        public void onEnable()
        {
            getConfig().options().copyDefaults(true);
            saveConfig();
            loc.setX(getConfig().getInt("Lobby.x"));
            loc.setY(getConfig().getInt("Lobby.y"));
            loc.setZ(getConfig().getInt("Lobby.z"));
            loc.setPitch((float) getConfig().getDouble("Lobby.Pitch"));
            loc.setYaw((float) getConfig().getDouble("Lobby.Yaw"));
            loc.setWorld(Bukkit.getWorld(getConfig().getString("Lobby.World")));
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
            if (cmd.getName().equalsIgnoreCase("lobby"))
            {
                if (args.length != 0)
                {
                    if (args[0].equalsIgnoreCase("reload") && sender.hasPermission("lobby.set"))
                    {
                        loc.setX(getConfig().getInt("Lobby.x"));
                        loc.setY(getConfig().getInt("Lobby.y"));
                        loc.setZ(getConfig().getInt("Lobby.z"));
                        loc.setPitch((float) getConfig().getDouble("Lobby.Pitch"));
                        loc.setYaw((float) getConfig().getDouble("Lobby.Yaw"));
                        loc.setWorld(Bukkit.getWorld(getConfig().getString("Lobby.World")));
                        sender.sendMessage(ChatColor.GREEN + "Config Reloaded!");
                    }
                }
                else
                {
                    sender.sendMessage(colorize(getConfig().getString("LobbyTeleportMessage")));
                    Bukkit.getPlayer(sender.getName()).teleport(loc); // Line of error.
                }
                return true;
            }
            else if (cmd.getName().equalsIgnoreCase("setlobby"))
            {
                sender.sendMessage(colorize(getConfig().getString("LobbySetMessage")));
                loc = Bukkit.getPlayer(sender.getName()).getLocation();
                getConfig().set("Lobby.x", loc.getBlockX());
                getConfig().set("Lobby.y", loc.getBlockY());
                getConfig().set("Lobby.z", loc.getBlockZ());
                getConfig().set("Lobby.Yaw", loc.getYaw());
                getConfig().set("Lobby.Pitch", loc.getPitch());
                getConfig().set("Lobby.World", loc.getWorld().getName());
                saveConfig();
                return true;
            }
            return false;
        }
       
        public String colorize(String string)
        {
            string = string.replace("&", "§");
            return string;
            }
    }
    
    The issue seems to be that it works for the first like hour or so after a reload/startup and then it just throws NullPointerExceptions pointing to the teleport line.
     
  15. Offline

    soulofw0lf

    just a complete side point here..
    Bukkit.getPlayer(sender.getName()).teleport(loc)
    i think i'm a fan of the second way...
    sender.teleport(loc)
     
  16. Offline

    The_Doctor_123

    I'm not a fan of errors, though. (The method does not exist.)
     
  17. Offline

    soulofw0lf

    you are correct i'm way too tired apparently to be helping people on here
    if (sender instance of Player){
    Player player = (Player)sender;
    player.teleport(loc);
    } else {
    System.out.print("Silly console, programs are not allowed to teleport");
    }
     
  18. Offline

    The_Doctor_123

    For the sake of only needing the player object on one line of code, I had done what I did.
     
  19. Offline

    Lambo993

    Code:java
    1. package com.yahoo.brettbutcher98.LobbyPlugin;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class Main extends JavaPlugin {
    12.  
    13. public Location loc = new Location(null, 0, 0, 0);
    14.  
    15. @Override
    16. public void onEnable()
    17. {
    18. getConfig().options().copyDefaults(true);
    19. saveConfig();
    20. loc.setX(getConfig().getInt("Lobby.x"));
    21. loc.setY(getConfig().getInt("Lobby.y"));
    22. loc.setZ(getConfig().getInt("Lobby.z"));
    23. loc.setPitch((float) getConfig().getDouble("Lobby.Pitch"));
    24. loc.setYaw((float) getConfig().getDouble("Lobby.Yaw"));
    25. loc.setWorld(Bukkit.getWorld(getConfig().getString("Lobby.World")));
    26. }
    27.  
    28. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    29. {
    30. if (cmd.getName().equalsIgnoreCase("lobby"))
    31. {
    32. if (!(sender instanceof Player))
    33. {
    34. sender.sendMessage("You can't use /lobby on console");
    35. return true;
    36. }
    37. if (args.length != 0)
    38. {
    39. if (args[0].equalsIgnoreCase("reload") && sender.hasPermission("lobby.set"))
    40. {
    41. loc.setX(getConfig().getInt("Lobby.x"));
    42. loc.setY(getConfig().getInt("Lobby.y"));
    43. loc.setZ(getConfig().getInt("Lobby.z"));
    44. loc.setPitch((float) getConfig().getDouble("Lobby.Pitch"));
    45. loc.setYaw((float) getConfig().getDouble("Lobby.Yaw"));
    46. loc.setWorld(Bukkit.getWorld(getConfig().getString("Lobby.World")));
    47. sender.sendMessage(ChatColor.GREEN + "Config Reloaded!");
    48. }
    49. }
    50. else
    51. {
    52. sender.sendMessage(colorize(getConfig().getString("LobbyTeleportMessage")));
    53. Player player = (Player)sender;
    54. player.teleport(loc);
    55. }
    56. return true;
    57. }
    58. else if (cmd.getName().equalsIgnoreCase("setlobby"))
    59. {
    60. if (!(sender instanceof Player))
    61. {
    62. sender.sendMessage("You can't use /setlobby on console");
    63. return true;
    64. }
    65. sender.sendMessage(colorize(getConfig().getString("LobbySetMessage")));
    66. Player player = (Player)sender;
    67. loc = player.getLocation();
    68. getConfig().set("Lobby.x", loc.getBlockX());
    69. getConfig().set("Lobby.y", loc.getBlockY());
    70. getConfig().set("Lobby.z", loc.getBlockZ());
    71. getConfig().set("Lobby.Yaw", loc.getYaw());
    72. getConfig().set("Lobby.Pitch", loc.getPitch());
    73. getConfig().set("Lobby.World", loc.getWorld().getName());
    74. saveConfig();
    75. return true;
    76. }
    77. return false;
    78. }
    79.  
    80. public String colorize(String string)
    81. {
    82. string = string.replace("&", "§");
    83. return string;
    84. }
    85. }

    fixed it
     
  20. Offline

    The_Doctor_123

    How is that fixed? Looks like you just caught the console from executing the commands and slapped on this:

    Code:
    Player player = (Player)sender
    player.teleport(loc);
    
    Instead of this:

    Code:
    Bukkit.getPlayer(sender.getName()).teleport(loc);
    
    They both provide the same functionality.
     
  21. Offline

    Lambo993

    no i tested it
    the error has been fixed if used
    Code:
    Player player = (player)sender;
    player.teleport(loc);
     
  22. Offline

    The_Doctor_123

    That would be impossible, they should do EXACTLY the same thing. Also, you see, the error takes time to kick in. It takes about an hour from reload/startup to receive it.
     
  23. Offline

    ISHLCMinecraft

    Look, if you trying to get a player from sender's name, it will return null.
    You can cast the sender object to player and it will work.
    So, use that line instead your line:
    ((Player) sender).teleport(loc)
     
  24. Offline

    Garris0n

    Is it me or does it look like your plugin caused an error with every plugin on the server listening to a teleport event?
     
  25. Offline

    debs101

    lol yes it did :p
     
  26. Offline

    The_Doctor_123

    How? It works every time I use "Bukkit.getPlayer(sender.getName())." I even tested the plugin on my server before uploading, and it worked fine. For the third time, I'm going to say this: It takes time for the errors to start happening after a reload/startup.


    I saw at least 2 plugins it conflicted with in the error, and I don't think debs copied the whole thing.
     
  27. Offline

    debs101

    Ok great news guys! Lambo re did the code and got it fixed! The problem was the message not saving wen doing /lobby. So he just put in the message I wanted. Everythings good now. Thanks for all your help! :D
     
  28. Offline

    debs101

    Nvm still not solved. Turns out lambo has a hack code in it which he tried to hack my server. The issue still continues.
     
  29. Offline

    Garris0n

    ...what? o,o
     
  30. Offline

    debs101

    yup
     
Thread Status:
Not open for further replies.

Share This Page