Solved Error with first MiniGame plugin!

Discussion in 'Plugin Development' started by Mindlessmink, Aug 10, 2016.

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

    Mindlessmink

    I'm getting an error when I try /lobby when it doesen't exist, I have it save in the config, And it should say "Lobby has not yet been set" when it doesen't exist. Instead, It's giving me an internal error and pointing me at line 24 of my class LobbyCommand, Here is the class LobbyCommand. Not much code at all so I'll paste it here.
    Code:
    package core;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class LobbyCommand implements CommandExecutor {
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("lobby")) {
                if (sender instanceof Player) {
                    Player p = (Player)sender;
                    if (Core.settings.getConfig().getConfigurationSection("lobby") == null) {
                        p.sendMessage(ChatColor.translateAlternateColorCodes('&', Core.prefix + "&7 The lobby hasn't been set yet!"));
                        return true;
                    } else {
                    
                        World w = Bukkit.getServer().getWorld(Core.settings.getConfig().getString("lobby.world"));
                        double x = Core.settings.getConfig().getDouble("lobby.x");
                        double y = Core.settings.getConfig().getDouble("lobby.y");
                        double z = Core.settings.getConfig().getDouble("lobby.z");
                    p.teleport(new Location(w, x, y, z));
                        p.sendMessage(ChatColor.translateAlternateColorCodes('&', Core.prefix + "&7You have been teleported to &aToxicChase &dLobby&7!"));
                    }
    
                }
            }
            return false;
        }
    
    
    
    }
    
    this is my console log: https://gyazo.com/bf9e5fc5089028308357db780bee1319

    EDIT: Line 24 is World w = Bukkit.getServer().getWorld(Core.settings.getConfig().getString("lobby.world"));
     
    Last edited: Aug 10, 2016
  2. Offline

    Zombie_Striker

    @Mindlessmink
    Have you tried debugging? Does the "lobby" path return a null object?
     
  3. Offline

    Mindlessmink

    EDIT: @Zom

    @Zombie_Striker Never mind, I figured out my error, And it was a silly one too :p I updated the config and forgot to remove the old one. Thanks for replying.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 10, 2016
Thread Status:
Not open for further replies.

Share This Page