Solved Config? Countdown?

Discussion in 'Plugin Development' started by ProMCKingz, Dec 13, 2014.

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

    ProMCKingz

    Hey, this may be a simple solution but..
    Here is my current code which WORKS:
    Code:
    package me.promckingz.pigquest;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.scheduler.BukkitRunnable;
    
    import com.promckingz.pigquest.ChatUtils;
    
    public class LobbyCount extends BukkitRunnable{
       
        LobbyCount() { }
          
        static LobbyCount instance = new LobbyCount();
      
        public static LobbyCount getInstance() {
                return instance;
        }
       
        private static int tts;
       
        public void run(){
            tts = 60;
            while(true){
                if(GameState.isState(GameState.IN_LOBBY))
                    if(Game.canStart()){
                        ChatUtils.broadcast(ChatColor.GREEN + "Minimum players reached! Countdown is starting..");
                for(;tts >= 0; tts--){
                    if(!Game.canStart()){
                        ChatUtils.broadcast("Waiting for more players..");
                    }
                    if(tts == 0){
                        // TODO START GAME
                        break;
                    }
                   
                    if (tts % 10 ==0 || tts<10){
                        ChatUtils.broadcast(tts + " seconds until the game starts!");
                }
                   
                    try{
                        Thread.sleep(1000);
                    }catch(InterruptedException e){
                        e.printStackTrace();
                        Bukkit.getServer().broadcastMessage(ChatColor.RED + "PigQuest Will not function properly! Check console");
                    }
                }
            }
        }
        }
    }
    
    And I added a config section like so: Now the code does not function and gives me an error:
    Code:
    package me.promckingz.pigquest;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.scheduler.BukkitRunnable;
    
    import com.promckingz.pigquest.ChatUtils;
    
    public class LobbyCount extends BukkitRunnable{
       
        LobbyCount() { }
          
        static LobbyCount instance = new LobbyCount();
       
        Main settings = Main.getInstance();
      
        public static LobbyCount getInstance() {
                return instance;
        }
       
        private static int tts;
       
        public void run(){
            tts = settings.getConfig().getInt("countdown");
            while(true){
                if(GameState.isState(GameState.IN_LOBBY))
                    if(Game.canStart()){
                        ChatUtils.broadcast(ChatColor.GREEN + "Minimum players reached! Countdown is starting..");
                for(;tts >= 0; tts--){
                    if(!Game.canStart()){
                        ChatUtils.broadcast("Waiting for more players..");
                    }
                    if(tts == 0){
                        // TODO START GAME
                        break;
                    }
                   
                    if (tts % 10 ==0 || tts<10){
                        ChatUtils.broadcast(tts + " seconds until the game starts!");
                }
                   
                    try{
                        Thread.sleep(1000);
                    }catch(InterruptedException e){
                        e.printStackTrace();
                        Bukkit.getServer().broadcastMessage(ChatColor.RED + "PigQuest Will not function properly! Check console");
                    }
                }
            }
        }
        }
    }
    
    This is the error:
    Code:
    [23:30:31 WARN]: Exception in thread "Thread-8"
    [23:30:31 WARN]: java.lang.NullPointerException
    [23:30:31 WARN]:        at me.promckingz.pigquest.LobbyCount.ru
    :24)
    [23:30:31 WARN]:        at java.lang.Thread.run(Unknown Source)
     
  2. Offline

    Dragonphase

  3. Offline

    tcvs

    @ProMCKingz please also post your main class that has the Runnable being called.
     
  4. Offline

    ProMCKingz

    @tcvs
    Long Main class code (open)

    Code:
    package me.promckingz.pigquest;
    [code=java]    }
                    if (arena >= getConfig().getInt("Min-Players")) {
                        Game.setCanStart(Main.arena >= getConfig().getInt("Max-Players"));
                        Game.start();
                        GameState.setState(GameState.IN_GAME);
                    }
    import java.util.ArrayList;
    import java.util.HashMap;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {

    public static int arena = 0;

    public static HashMap<Player, ArrayList<Block>> InGame = new HashMap<Player, ArrayList<Block>>();
    SettingsManager settings = SettingsManager.getInstance();
    public int number = getConfig().getInt("Countdown");

    public void onEnable() {
    Game.setCanStart(false);
    Game.stop();
    InGame.clear();
    number = getConfig().getInt("Countdown");
    Bukkit.getServer().getPluginManager()
    .registerEvents(new PlayerQuit(this), this);
    Bukkit.getServer().getPluginManager()
    .registerEvents(new PlayerJoin(this), this);
    new Thread(new LobbyCount()).start();
    Bukkit.getServer().broadcastMessage(
    ChatColor.GREEN + "Pig Quest was enabled!");
    Bukkit.getServer().broadcastMessage(
    ChatColor.RED + "" + ChatColor.BOLD
    + "PigQuest is still in beta!");
    saveDefaultConfig();
    getServer().getPluginManager().registerEvents(new SignListener(), this);
    getConfig().options().copyDefaults(true);
    settings.setup(this);
    arena = 0;
    }

    public void onDisable() {
    arena = 0;
    number = getConfig().getInt("Countdown");
    }

    @SuppressWarnings("deprecation")
    public boolean onCommand(CommandSender sender, Command cmd,
    String commandLabel, String[] args) {

    final String prefix = ChatColor.LIGHT_PURPLE + ("[Pig Quest] ");
    Player p = (Player) sender;

    if (cmd.getName().equalsIgnoreCase("PigQuest")) {
    if (!sender.hasPermission("pigquest.command.main")) {
    sender.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission");
    return true;
    }
    if (args.length == 0) {
    String V = Bukkit.getServer().getBukkitVersion();
    p.sendMessage(prefix + ChatColor.AQUA + "PigQuest Made by:"
    + ChatColor.GREEN + "" + ChatColor.BOLD + " ProMCKingz");
    p.sendMessage(prefix + ChatColor.RED + "Version 1.0");
    p.sendMessage(prefix + ChatColor.DARK_PURPLE + V);
    p.sendMessage(prefix + ChatColor.GREEN + "/PigQuest Help");

    } else if (args[0].equalsIgnoreCase("help")) {
    if (p.hasPermission("PigQuest.command.help")) {
    p.sendMessage(ChatColor.LIGHT_PURPLE
    + " Made by: ---> " + ChatColor.GOLD
    + "ProMCKingz" + ChatColor.LIGHT_PURPLE
    + " <--- ");
    p.sendMessage(prefix + ChatColor.GREEN + "/PigQuest : "
    + ChatColor.GREEN + "Main Command");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Help : " + ChatColor.AQUA
    + "List all the commands");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Setspawn [team] : " + ChatColor.AQUA
    + "Sets spawn point for teams: " + ChatColor.RED
    + "Red, " + ChatColor.BLUE + "Blue, "
    + ChatColor.YELLOW + "Yellow, " + ChatColor.GREEN
    + "Green.");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Centre : " + ChatColor.AQUA
    + "Set the location where the Pigs spawn");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Join : " + ChatColor.AQUA
    + "Join the arena");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Setlobby : " + ChatColor.AQUA
    + "Sets lobby location");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Setleave : " + ChatColor.AQUA
    + "Sets quit and game end location");
    p.sendMessage(prefix + ChatColor.GREEN + "/PigQuest Kit : "
    + ChatColor.AQUA
    + "List of kits/Choose one of the kits");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Leave : " + ChatColor.AQUA
    + "Leave the game");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Team : " + ChatColor.AQUA
    + "Join a team");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Tell : " + ChatColor.AQUA
    + "In built messaging system");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Version : " + ChatColor.AQUA
    + "Get the version information");
    p.sendMessage(prefix + ChatColor.GREEN
    + "/PigQuest Reload : " + ChatColor.AQUA
    + "Reload the config");
    p.sendMessage(prefix + ChatColor.GREEN + "/PigQuest AFP : "
    + ChatColor.AQUA + "Add fake players");
    return true;
    }
    } else if (args[0].equalsIgnoreCase("reload")) {
    if (!sender.hasPermission("PigQuest.command.reload")) {
    sender.sendMessage(ChatColor.DARK_RED
    + "You do not have permission!");
    return true;
    }
    String person = p.getPlayer().getDisplayName();
    p.sendMessage(prefix + ChatColor.GREEN + "Was reloaded!");
    reloadConfig();
    Bukkit.getServer().broadcastMessage(
    prefix + ChatColor.GREEN + "Was reloaded by "
    + ChatColor.RED + person);
    } else if (args[0].equalsIgnoreCase("AFP")) {
    if (!sender.hasPermission("PigQuest.command.AFP")) {
    sender.sendMessage(ChatColor.DARK_RED
    + "You do not have permission!");
    return true;
    }
    if (!(args.length == 1)) {
    p.sendMessage(prefix + ChatColor.RED
    + "/pigquest AFP" + ChatColor.DARK_PURPLE + " | adds one more player to the game");
    } else if (args.length == 1) {
    p.sendMessage(prefix + ChatColor.GREEN + "Added one more player");
    InGame.put(p, null);
    }
    } else if (args[0].equalsIgnoreCase("version")) {
    if (!sender.hasPermission("PigQuest.command.version")) {
    p.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission!");
    return true;
    }
    p.sendMessage(ChatColor.GREEN + "PigQuest "
    + ChatColor.COLOR_CHAR + " version" + ChatColor.GREEN
    + " 1.0");
    p.sendMessage(ChatColor.COLOR_CHAR + " Website: "
    + ChatColor.GREEN + "https://ProMCKingzDev.enjin.com");
    p.sendMessage(ChatColor.COLOR_CHAR + " Author: "
    + ChatColor.GREEN + "ProMCKingz");
    // //////////////////////////////////////////////////////////////////////

    } else if (args[0].equalsIgnoreCase("join")) {
    if (!sender.hasPermission("PigQuest.join")) {
    p.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission!");
    return true;
    }
    if (arena < getConfig().getInt("Max-Players")) {
    if (!(settings.getData().contains("lobbyZ"))) {
    p.sendMessage(prefix + ChatColor.RED
    + "Lobby not set yet!");
    return true;
    }
    if (InGame.containsKey(p)) {
    p.sendMessage(prefix + ChatColor.RED
    + "You are already in the game!");
    return true;
    }
    if ((settings.getData().contains("lobbyZ")
    && settings.getData().contains("lobbyY") && settings
    .getData().contains("lobbyX"))) {
    } if (!InGame.containsKey(p)) {
    InGame.put(p, null);
    if (arena <= 0) {
    arena = 1;

    }if (arena < getConfig()
    .getInt("Max-Players")) {
    World w = Bukkit.getServer().getWorld(
    settings.getData().getString(
    "spawn.world"));
    double x = settings.getData().getDouble(
    "lobbyX");
    double y = settings.getData().getDouble(
    "lobbyY");
    double z = settings.getData().getDouble(
    "lobbyZ");
    p.teleport(new Location(w, x, y, z));
    GameState.setState(GameState.IN_LOBBY);
    p.sendMessage(prefix + ChatColor.GREEN
    + "Success! " + ChatColor.AQUA
    + "Joined lobby..");
    Bukkit.getServer().broadcastMessage(
    prefix
    + ChatColor.GOLD
    + p.getName()
    + ChatColor.GREEN
    + " joined the game "
    + ChatColor.BLUE
    + "["
    + arena
    + "/"
    + getConfig().getInt(
    "Max-Players") + " ]");
    } else
    p.sendMessage(prefix + ChatColor.RED
    + "The arena is full!");
    if (arena >= getConfig().getInt("Max-Players")) {
    arena = getConfig().getInt("Max-Players" + -1);
    p.sendMessage(prefix + ChatColor.RED
    + "The arena is full!");
    } else
    arena++;
    } else
    p.sendMessage(prefix + ChatColor.RED
    + "The arena is full!");
    }
    if (arena >= getConfig().getInt("Min-Players")) {
    Game.setCanStart(Main.arena >= getConfig().getInt("Max-Players"));
    Game.start();
    GameState.setState(GameState.IN_GAME);
    }
    // /////////////////////////////////////////////////////////////////////////////////////////////

    } else if (args[0].equalsIgnoreCase("leave")) {
    if (!sender.hasPermission("PigQuest.leave")) {
    p.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission!");
    return true;
    }
    if (!(settings.getData().contains("leaveZ"))) {
    p.sendMessage(prefix + ChatColor.RED
    + "leave point not set yet!");
    return true;
    }
    if ((settings.getData().contains("leaveZ"))) {
    if (arena <= 0) {
    arena = 0;
    }
    if (!InGame.containsKey(p)) {
    p.sendMessage(prefix + ChatColor.RED
    + "You are not in the game!");
    } else if (InGame.containsKey(p)) {
    InGame.remove(p);
    arena--;
    arena--;
    World w = Bukkit.getServer().getWorld(
    settings.getData().getString("leave.world"));
    double x = settings.getData().getDouble("leaveX");
    double y = settings.getData().getDouble("leaveY");
    double z = settings.getData().getDouble("leaveZ");
    p.teleport(new Location(w, x, y, z));
    p.sendMessage(prefix + ChatColor.GREEN + "Success! "
    + ChatColor.AQUA + "Left the game..");
    Bukkit.getServer().broadcastMessage(
    prefix + ChatColor.GOLD + p.getName()
    + ChatColor.RED + " left the game "
    + ChatColor.BLUE + "[" + arena + "/"
    + getConfig().getInt("Max-Players")
    + " ]");
    // /////////////////////////////////////////////////////////////////////////
    }
    }
    } else if (args[0].equalsIgnoreCase("Setlobby")) {
    if (!sender.hasPermission("PigQuest.command.setlobby")) {
    p.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission!");
    return true;
    }
    settings.getData().set("lobbyX", p.getLocation().getX());
    settings.getData().set("lobbyY", p.getLocation().getY());
    settings.getData().set("lobbyZ", p.getLocation().getZ());
    settings.saveData();
    double x = settings.getData().getDouble("lobbyX");
    double y = settings.getData().getDouble("lobbyY");
    double z = settings.getData().getDouble("lobbyZ");
    p.sendMessage(prefix + ChatColor.GREEN + "Success! "
    + ChatColor.AQUA + "Set Lobby at " + ChatColor.GOLD
    + "x: " + x + " " + ChatColor.GOLD + "y: " + y + " "
    + ChatColor.GOLD + "z: " + z);
    } else if (args[0].equalsIgnoreCase("Setleave")) {
    if (!sender.hasPermission("PigQuest.command.setleave")) {
    p.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission!");
    return true;
    }
    settings.getData().set("leave.world", p.getWorld().getName());
    settings.getData().set("leaveX", p.getLocation().getX());
    settings.getData().set("leaveY", p.getLocation().getY());
    settings.getData().set("leaveZ", p.getLocation().getZ());
    settings.saveData();
    double x = settings.getData().getDouble("leaveX");
    double y = settings.getData().getDouble("leaveY");
    double z = settings.getData().getDouble("leaveZ");
    p.sendMessage(prefix + ChatColor.GREEN + "Success! "
    + ChatColor.AQUA + "Set quit at " + ChatColor.GOLD
    + "x: " + x + " " + ChatColor.GOLD + "y: " + y + " "
    + ChatColor.GOLD + "z: " + z);
    } else if (args[0].equalsIgnoreCase("centre")) {
    if (!sender.hasPermission("PigQuest.command.centre")) {
    p.sendMessage(ChatColor.DARK_RED
    + "You do not have the permission!");
    return true;
    }
    p.sendMessage(prefix + ChatColor.GREEN + "Set centre!");
    settings.getData().set("centreX", p.getLocation().getX());
    settings.getData().set("centreY", p.getLocation().getY());
    settings.getData().set("centreZ", p.getLocation().getZ());
    settings.saveData();

    } else if (args[0].equalsIgnoreCase("tell")) {
    if (!sender.hasPermission("PigQuest.command.tell")) {
    sender.sendMessage(ChatColor.DARK_RED
    + "You do not have permission!");
    return true;
    }
    if (args.length == 1) {
    p.sendMessage(prefix + ChatColor.RED
    + "/pigquest tell [Player] [Message]");
    return true;
    }
    String message = ChatColor.GOLD + "";

    if (!(sender instanceof Player)) {
    ConsoleCommandSender pa = (ConsoleCommandSender) sender;
    if (args.length >= 2) {
    try {
    Player z = p.getServer().getPlayerExact(args[1]);
    for (int i = 1; i < args.length; i++) {
    message = message + args + " ";
    }
    z.sendMessage(prefix + "§6" + p.getName()
    + "✉ ->§b" + ChatColor.GREEN + " :"
    + message);
    pa.sendMessage(prefix + "§6" + z.getName()
    + "✉ ->§b" + ChatColor.GREEN + " :"
    + message);
    message = "";
    } catch (NullPointerException e) {
    p.sendMessage("§4Player is offline");
    }

    }

    return true;
    }
    if (!p.hasPermission("PigQuest.command.tell")) {
    p.sendMessage(prefix + "§cYou do not have permission!");
    return true;
    }

    if (args.length >= 2) {
    try {
    Player z = p.getServer().getPlayerExact(args[1]);
    for (int i = 1; i < args.length; i++) {
    message = message + args + " ";
    }
    z.sendMessage(prefix + "§6" + p.getName() + "✉ ->§b"
    + ChatColor.GREEN + " :" + message);
    p.sendMessage(prefix + "§6" + z.getName() + "✉ ->§b"
    + ChatColor.GREEN + " :" + message);
    message = "";
    } catch (NullPointerException e) {
    p.sendMessage("§4Player is offline");
    }

    return true;
    }

    } else if (args[0].equalsIgnoreCase("team")) {
    if (!sender.hasPermission("PigQuest.command.team")) {
    sender.sendMessage(ChatColor.DARK_RED
    + "You do not have permission!");
    return true;
    }
    if (args.length == 1) {
    p.sendMessage(prefix + ChatColor.RED
    + "/pigquest team [team]. " + ChatColor.AQUA
    + "Teams: Red, Blue, Green,Yellow");
    return true;
    }
    if (args[1].equalsIgnoreCase("red")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.RED
    + "Joined Team Red!");
    World redw = Bukkit.getServer().getWorld(
    settings.getData().getString("spawn.world"));
    Double redx = settings.getData()
    .getDouble("Spawn_RedX");
    Double redy = settings.getData()
    .getDouble("Spawn_RedY");
    Double redz = settings.getData()
    .getDouble("Spawn_RedZ");
    p.teleport(new Location(redw, redx, redy, redz));
    }
    } else if (args[1].equalsIgnoreCase("blue")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.BLUE
    + "Joined Team Blue!");
    World redw = Bukkit.getServer().getWorld(
    settings.getData().getString("spawn.world"));
    Double redx = settings.getData().getDouble(
    "Spawn_BlueX");
    Double redy = settings.getData().getDouble(
    "Spawn_BlueY");
    Double redz = settings.getData().getDouble(
    "Spawn_BlueZ");
    p.teleport(new Location(redw, redx, redy, redz));
    }
    } else if (args[1].equalsIgnoreCase("green")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.GREEN
    + "Joined Team Green!");
    World redw = Bukkit.getServer().getWorld(
    settings.getData().getString("spawn.world"));
    Double redx = settings.getData().getDouble(
    "Spawn_GreenX");
    Double redy = settings.getData().getDouble(
    "Spawn_GreenY");
    Double redz = settings.getData().getDouble(
    "Spawn_GreenZ");
    p.teleport(new Location(redw, redx, redy, redz));
    }
    } else if (args[1].equalsIgnoreCase("yellow")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.YELLOW
    + "Joined Team Yellow!");
    World redw = Bukkit.getServer().getWorld(
    settings.getData().getString("spawn.world"));
    Double redx = settings.getData().getDouble(
    "Spawn_YellowX");
    Double redy = settings.getData().getDouble(
    "Spawn_YellowY");
    Double redz = settings.getData().getDouble(
    "Spawn_YellowZ");
    p.teleport(new Location(redw, redx, redy, redz));
    return true;

    }
    } else
    p.sendMessage(prefix + ChatColor.RED + "Unknown team! "
    + ChatColor.GOLD + "Blue, Red, Green, Yellow");

    } else if (args[0].equalsIgnoreCase("setspawn")) {
    if (!sender.hasPermission("PigQuest.command.spawns")) {
    sender.sendMessage(ChatColor.DARK_RED
    + "You do not have permission!");
    return true;
    }
    if (args.length == 1) {
    p.sendMessage(prefix + ChatColor.RED
    + "/pigquest setspawn [team]. " + ChatColor.AQUA
    + "Teams: Red, Blue, Green,Yellow");
    return true;
    }
    if (args[1].equalsIgnoreCase("red")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.RED + "Set Red Spawn!");
    settings.getData().set("spawn.world",
    p.getLocation().getWorld().getName());
    settings.getData().set("Spawn_RedX",
    p.getLocation().getX());
    settings.getData().set("Spawn_RedY",
    p.getLocation().getY());
    settings.getData().set("Spawn_RedZ",
    p.getLocation().getZ());
    settings.getData().set("Spawn_RedF",
    p.getLocation().getDirection());
    settings.saveData();
    }
    } else if (args[1].equalsIgnoreCase("blue")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.BLUE
    + "Set Blue Spawn!");
    settings.getData().set("spawn.world",
    p.getLocation().getWorld().getName());
    settings.getData().set("Spawn_BlueX",
    p.getLocation().getX());
    settings.getData().set("Spawn_BlueY",
    p.getLocation().getY());
    settings.getData().set("Spawn_BlueZ",
    p.getLocation().getZ());
    settings.getData().set("Spawn_BlueF",
    p.getLocation().getDirection());
    settings.saveData();
    }
    } else if (args[1].equalsIgnoreCase("green")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.GREEN
    + "Set Green Spawn!");
    settings.getData().set("spawn.world",
    p.getLocation().getWorld().getName());
    settings.getData().set("Spawn_GreenX",
    p.getLocation().getX());
    settings.getData().set("Spawn_GreenY",
    p.getLocation().getY());
    settings.getData().set("Spawn_GreenZ",
    p.getLocation().getZ());
    settings.getData().set("Spawn_GreenF",
    p.getLocation().getDirection());
    settings.saveData();
    }
    } else if (args[1].equalsIgnoreCase("yellow")) {
    if (p.hasPermission("PigQuest.command.spawn")) {
    p.sendMessage(prefix + ChatColor.YELLOW
    + "Set Yellow Spawn!");
    settings.getData().set("spawn.world",
    p.getLocation().getWorld().getName());
    settings.getData().set("Spawn_YellowX",
    p.getLocation().getX());
    settings.getData().set("Spawn_YellowY",
    p.getLocation().getY());
    settings.getData().set("Spawn_YellowZ",
    p.getLocation().getZ());
    settings.saveData();
    return true;

    }
    } else
    p.sendMessage(prefix + ChatColor.RED + "Unknown team! "
    + ChatColor.GOLD + "Blue, Red, Green, Yellow");
    } else
    p.sendMessage(prefix + ChatColor.RED
    + "Unknown command! Use /pigquest help");
    }
    return true;
    }

    public static Main getInstance() {
    // TODO Auto-generated method stub
    return null;
    }
    }[/code]

    It is in the "join" arguments of the command.


    Code:
        }
                    if (arena >= getConfig().getInt("Min-Players")) {
                        Game.setCanStart(Main.arena >= getConfig().getInt("Max-Players"));
                        Game.start();
                        GameState.setState(GameState.IN_GAME);
                    }
     
  5. Offline

    tcvs

    @ProMCKingz Could you post it into pastebin this is very hard to read(Or make sure all your code is surrounded by the [code ]
     
  6. Offline

    ProMCKingz

    @tcvs

    Paste Bin Link [chest]


    Code may have issues, since it is in beta, and not debugged

    @Skionz
    Why won't it work though?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 27, 2017
  7. Offline

    Skionz

  8. You cannot set variables from outside a Runnable...
    They need to be final, use a getter and setter.

    Also there are some odd things going on with your code...
    Why are you using Thread.sleep? Just wait until the next loop... because you're using a repeating task right?
    This will be looping forever?
    while(true){
    Are you trying to make a repeating task inside a repeating task?
    I'm confused now.

    Just make a repeating task that loops every 2o ticks and gets and sets the time with a getter and setter.
     
    Last edited: Dec 14, 2014
  9. Offline

    ProMCKingz

    @XXLuigiMario
    I am trying to make it so that, when there is the minimum players, the timer will start from time set in config section "countdown".
    And it gives me that error. Without the config section, it works fine.
     
  10. Could you post your config?
     
  11. Offline

    ProMCKingz

    @XXLuigiMario
    PHP:
    #~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
    #][][][][][  Pig Quest ][][][][][      ONLY SUPPORTS ONE GAME CREATION FOR THE TIME
    #~#~#~#~#~#~  Config   ~#~#~#~#~#
    #            ~#~#~#~#~

    # Number of players in order to start game
    Players-To-Start3

    # Max players in game
    Max-Players2

    # Min players in game, else it is ended
    Min-Players2

    # Countdown time
    Countdown60
     
  12. Offline

    Jayke_

    Make countdown lowercase in the config, or match it in the code.
     
  13. Offline

    Dragonphase

    @Jayke_

    That won't make a difference.

    Why are you abusing statics?

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Dec 14, 2014
  14. Offline

    Jayke_

    @Dragonphase YML file path-fetching is case-sensitive....
     
  15. Offline

    Dragonphase

    @Jayke_

    Thus it does not matter what case his keys are. By replacing "Countdown" with "countdown" in his configuration, he would need to do the same within his code, which is pointless.
     
  16. Offline

    ProMCKingz

  17. Offline

    ReadySetPawn

    Don't use loops inside repeating tasks. I would recommend having a method that's called once the arena is occupied and have a while loop in there.
    You could do something like this:
    Code:
    int a = 500;
    
    while (game.canStart()){
    a = a - 1;
    if (a/50 instanceof Integer){
    Bukkit.getServer().broadcastMessage(a + " seconds left!")
    }
    }
    The NPE could be because the config isn't being accessed correctly or countdown doesn't have a value set for it.
     
  18. Offline

    ProMCKingz

    @ReadySetPawn
    What is a?
    It is meant to be time, and I would like it in a config
     
  19. Offline

    ReadySetPawn

    You could do: int a = config.getInt("countdown") * 50;
     
  20. Offline

    timbragg12

    @ProMCKingz Do you watch TheBCBroz tutorials by any chance?
     
  21. Offline

    Dragonphase

    @ProMCKingz

    There is no problem. My point is, it does not matter what case his keys are.
     
  22. Offline

    ProMCKingz

    Last edited by a moderator: Jun 29, 2016
  23. Offline

    mythbusterma

    @ProMCKingz

    You could make a friend that you like to hang out with and learn from, that'd be fun. Also, 10k people are dumb as bricks/ignorant as one, you shouldn't just follow them off the metaphorical cliff. Learning to write plugins isn't about having "FUN," and I don't even think his videos are very entertaining at all, except laughing at all the errors he makes, that doesn't ever get old.

    Why would you store them in a HashMap when you needed a List?
     
    Skionz likes this.
  24. Offline

    ProMCKingz

  25. Offline

    mythbusterma

  26. Offline

    timtower Administrator Administrator Moderator

    @ProMCKingz For what do you need the list? Wouldn't a set work?
    map.getKeys
     
    mythbusterma likes this.
  27. Offline

    ProMCKingz

    @timtower
    To get all the players in the hashmap.
     
  28. Offline

    timtower Administrator Administrator Moderator

    @ProMCKingz Hashmaps have methods for that already.
     
  29. Offline

    Skionz

    You shouldn't blindly do whatever he says. The only time you should watch his videos is when you are good enough at Java that you can recognize all of his mistakes and not follow them.
    As @mythbusterma, I couldn't have said it better myself.
     
  30. Offline

    mythbusterma

    @ProMCKingz

    But why do you need them in a List? You can iterate over a HashMap using Map#entrySet() Map#getKeys() and Map#getValues().

    You haven't made clear what you're doing, and this belongs in another thread anyway.
     
Thread Status:
Not open for further replies.

Share This Page