BarAPI Countdown

Discussion in 'Plugin Development' started by Prorockband, Mar 25, 2015.

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

    Prorockband

    So i'm trying to get a countdown using the BarAPI and the countdown works correctly but the message isn't updating with the correct number of seconds left, Its always stuck at 10. Its correctly decrementing seconds. Not sure whats wrong, any help would be greatly appreciated!

    Code:
    				public void run() {
    					if(seconds > 0) {
    						for(Player players : Bukkit.getServer().getOnlinePlayers()) {
    							BarAPI.setMessage(players, "§b§lTime Until Game Starts: §f§l" + Math.round(seconds) + " §b§lSeconds", (float) ((seconds / constSeconds) * 100.0));
    						}
    						seconds--;
    						Bukkit.broadcastMessage("" + seconds);
    					} else {
    						for(Player players : Bukkit.getServer().getOnlinePlayers()) {
    							players.sendMessage(AQUA + "§lGAME STARTING!");
    							players.sendMessage(AQUA + "§lAll players, prepare now!");
    
    							BarAPI.removeBar(players);
    							cancel();
    						}
    						Bukkit.broadcastMessage("§aGame has been successfully started!");
    
    					}
    				}
    			}.runTaskTimer(this, 0L, 20L);
    
     
  2. Offline

    Funergy

    @Prorockband That would mostly be a problem with BarApi itself.
    Have you set the time it will stay on the boss bar?
     
Thread Status:
Not open for further replies.

Share This Page