Plugin category: Fun Suggested name: ScoreboardCountdown What I want: A custom scoreboard with: ----------------------- TITLE: Drop Party Blank Line: Line 2: Starting in: Line 3: {Timer} Blank Line Line 5:Custom Text When the timer reaches the end make it run a/some command(s) and change Line 2 To say "Ending In" Then when that timer ends reset back to the begining without any commands. Config: Timer Till DropParty Starts In seconds: 3600 Timer Till DropParty Ends In seconds: 300 Comands Ran at DropParty: - /Test - /Test 2 Custom Text: - &bFancy &dText Ideas for commands: Just a reload command /countdownsb reload Ideas for permissions: countdownsb.reload When I'd like it by: ASAP, Thanks Heaps Any Questions post a comment with Funnycube
Funnycube I'll try to make that as soon as I finish the minigame I'm working on right now (about 1 hour or 2)
Funnycube TyphoonTricks I can't code for an hour or so... I'm almost done, I edited a little bit the config you sent to make it even more customizable. I also removed the command to reload because it's useless, just use /rl (or /reload).
jg31212 Well, I have a problem, the scoreboard isn't showing on the side but all the rest is working. If any one know why, please tell me! Here's the code: Code:java ScoreboardManager manager = Bukkit.getScoreboardManager();Scoreboard scoreboard = manager.getMainScoreboard();Objective objective; boolean ending = false;int timer = 3600;int seconds = (int) (System.currentTimeMillis()/1000); public void onEnable () {getConfig().options().copyDefaults(true);saveDefaultConfig(); timer = getConfig().getInt("TimerSeconds"); Bukkit.getPluginManager().registerEvents(this, this); String title = ChatColor.translateAlternateColorCodes('&', getConfig().getString("title"));objective = scoreboard.getObjective(title);if (objective == null) {objective = scoreboard.registerNewObjective(title, "dummy");}objective.setDisplaySlot(DisplaySlot.SIDEBAR); run.runTaskTimerAsynchronously(this, 0, 1);} public void update () {int i = getConfig().getStringList("lines").size();if (ending) {i = getConfig().getStringList("ending_lines").size();} String prevminutes = "0" + ((timer+1) - ((timer+1) % 60)) / 60;if (prevminutes.length() > 2) prevminutes = prevminutes.substring(1); String prevseconds = "0" + (timer+1) % 60;if (prevseconds.length() > 2) prevseconds = prevseconds.substring(1); for (String line : getConfig().getStringList("lines")) {if (line.contains("\\{MINS\\}") || line.contains("\\{SECS\\}")) {String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", prevminutes).replaceAll("\\{SECS\\}", prevseconds));scoreboard.resetScores(name);}}for (String line : getConfig().getStringList("ending_lines")) {if (line.contains("\\{MINS\\}") || line.contains("\\{SECS\\}")) {String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", prevminutes).replaceAll("\\{SECS\\}", prevseconds));scoreboard.resetScores(name);}}String minutes = "0" + (timer - (timer % 60)) / 60;if (minutes.length() > 2) minutes = minutes.substring(1); String seconds = "0" + timer % 60;if (seconds.length() > 2) seconds = seconds.substring(1); if (!ending) {for (String line : getConfig().getStringList("lines")) {String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", minutes).replaceAll("\\{SECS\\}", seconds));Score score = objective.getScore(name);score.setScore(i);i--;}} else {for (String line : getConfig().getStringList("ending_lines")) {String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", minutes).replaceAll("\\{SECS\\}", seconds));Score score = objective.getScore(name);score.setScore(i);i--;}}} BukkitRunnable run = new BukkitRunnable() {public void run() {if (System.currentTimeMillis()/1000 >= seconds+1) {timer--;seconds++;update();if (timer == 0 && ending) {timer = getConfig().getInt("TimerSeconds");ending = false;} else if (timer == 0 && !ending) {timer = getConfig().getInt("TimerCooldown");ending = true;for (String command : getConfig().getStringList("commands")) {Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ChatColor.translateAlternateColorCodes('&', command));}}}}}; EDIT: fixed, download link : http://shadowcasted.com/plugins/ScoreboardCountdown.jar
caderape I was doing that but I removed it because I found the getMainScoreboard() method wich will get the scoreboard applyed to the players. This isn't the problem (still tryied it but didn't change anything)
au2001 Don't use the main scoreboard. Create a new one. Who knows what you're messing around with on the main scoreboard. Also, calling Bukkit API in async tasks is bad. Funnycube Annnnd done http://zombiekiller753.com/plugins/downloads/DPScoreboard.jar EDIT by Moderator: merged posts, please use the edit button instead of double posting.