[Request] Scoreboard Countdown

Discussion in 'Archived: Plugin Requests' started by Funnycube, Jun 28, 2014.

  1. Offline

    Funnycube

    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
     
  2. Offline

    au2001

    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)
     
  3. Offline

    Funnycube

  4. Offline

    TyphoonTricks

    Btw au is my Dev he is like the best Dev ever ;)
     
    au2001 likes this.
  5. Offline

    au2001

    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).
     
  6. Offline

    Funnycube

  7. Offline

    Stealth2800

  8. Offline

    Funnycube

  9. Offline

    Alster551

    au2001 likes this.
  10. Offline

    jg31212

    when is the plugin going to be done au2001
     
  11. Offline

    au2001

    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
    1. ScoreboardManager manager = Bukkit.getScoreboardManager();
    2. Scoreboard scoreboard = manager.getMainScoreboard();
    3. Objective objective;
    4.  
    5. boolean ending = false;
    6. int timer = 3600;
    7. int seconds = (int) (System.currentTimeMillis()/1000);
    8.  
    9. public void onEnable () {
    10. getConfig().options().copyDefaults(true);
    11. saveDefaultConfig();
    12.  
    13. timer = getConfig().getInt("TimerSeconds");
    14.  
    15. Bukkit.getPluginManager().registerEvents(this, this);
    16.  
    17. String title = ChatColor.translateAlternateColorCodes('&', getConfig().getString("title"));
    18. objective = scoreboard.getObjective(title);
    19. if (objective == null) {
    20. objective = scoreboard.registerNewObjective(title, "dummy");
    21. }
    22. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    23.  
    24. run.runTaskTimerAsynchronously(this, 0, 1);
    25. }
    26.  
    27. public void update () {
    28. int i = getConfig().getStringList("lines").size();
    29. if (ending) {
    30. i = getConfig().getStringList("ending_lines").size();
    31. }
    32.  
    33. String prevminutes = "0" + ((timer+1) - ((timer+1) % 60)) / 60;
    34. if (prevminutes.length() > 2) prevminutes = prevminutes.substring(1);
    35.  
    36. String prevseconds = "0" + (timer+1) % 60;
    37. if (prevseconds.length() > 2) prevseconds = prevseconds.substring(1);
    38.  
    39. for (String line : getConfig().getStringList("lines")) {
    40. if (line.contains("\\{MINS\\}") || line.contains("\\{SECS\\}")) {
    41. String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", prevminutes).replaceAll("\\{SECS\\}", prevseconds));
    42. scoreboard.resetScores(name);
    43. }
    44. }
    45. for (String line : getConfig().getStringList("ending_lines")) {
    46. if (line.contains("\\{MINS\\}") || line.contains("\\{SECS\\}")) {
    47. String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", prevminutes).replaceAll("\\{SECS\\}", prevseconds));
    48. scoreboard.resetScores(name);
    49. }
    50. }
    51. String minutes = "0" + (timer - (timer % 60)) / 60;
    52. if (minutes.length() > 2) minutes = minutes.substring(1);
    53.  
    54. String seconds = "0" + timer % 60;
    55. if (seconds.length() > 2) seconds = seconds.substring(1);
    56.  
    57. if (!ending) {
    58. for (String line : getConfig().getStringList("lines")) {
    59. String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", minutes).replaceAll("\\{SECS\\}", seconds));
    60. Score score = objective.getScore(name);
    61. score.setScore(i);
    62. i--;
    63. }
    64. } else {
    65. for (String line : getConfig().getStringList("ending_lines")) {
    66. String name = ChatColor.translateAlternateColorCodes('&', line.replaceAll("\\{MINS\\}", minutes).replaceAll("\\{SECS\\}", seconds));
    67. Score score = objective.getScore(name);
    68. score.setScore(i);
    69. i--;
    70. }
    71. }
    72. }
    73.  
    74. BukkitRunnable run = new BukkitRunnable() {
    75. public void run() {
    76. if (System.currentTimeMillis()/1000 >= seconds+1) {
    77. timer--;
    78. seconds++;
    79. update();
    80. if (timer == 0 && ending) {
    81. timer = getConfig().getInt("TimerSeconds");
    82. ending = false;
    83. } else if (timer == 0 && !ending) {
    84. timer = getConfig().getInt("TimerCooldown");
    85. ending = true;
    86. for (String command : getConfig().getStringList("commands")) {
    87. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ChatColor.translateAlternateColorCodes('&', command));
    88. }
    89. }
    90. }
    91. }
    92. };


    EDIT: fixed, download link : http://shadowcasted.com/plugins/ScoreboardCountdown.jar
     
  12. Offline

    caderape

    You didnt applied the scoreboard. Player.setscoreboard(scoreboard)
     
  13. Offline

    au2001

    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)
     
  14. Offline

    Deleted user

    Last edited by a moderator: Jun 9, 2016

Share This Page