Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
🥭 user friendly time
Browse files Browse the repository at this point in the history
  • Loading branch information
Belikhun committed May 20, 2022
1 parent 5731a9b commit 98d1e4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void begin(BossBar bar) {

@Override
public void update(BossBar bar, double remain) {
String message = String.format("&r&a%s&r sau &b%.3fs", title, remain);
String message = String.format("&r&a%s&r sau %s", title, CountInstance.readableTime(remain));
bar.setTitle(Countdown.colorize(message));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ public void begin(BossBar bar) {
@Override
public void update(BossBar bar, double remain) {
ChatColor textColor = ChatColor.of("#ffabc0");
ChatColor numberColor = ChatColor.of("#abcfff");

String message = (reason != null)
? String.format("&r%s&lTắt Máy Chủ&r sau %s%.3fs &7(%s)", textColor, numberColor, remain, reason)
: String.format("&r%s&lTắt Máy Chủ&r sau %s%.3fs", textColor, numberColor, remain);
? String.format("&r%s&lTắt Máy Chủ&r sau %s &7(%s)", textColor, remain, reason)
: String.format("&r%s&lTắt Máy Chủ&r sau %s", textColor, CountInstance.readableTime(remain));

bar.setTitle(Countdown.colorize(message));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;

import net.md_5.bungee.api.ChatColor;

public class CountInstance {
public static ChatColor timeColor = ChatColor.of("#abcfff");
public static ArrayList<CountInstance> instances = new ArrayList<>();

public BossBar bar;
Expand Down Expand Up @@ -106,6 +109,12 @@ public void run() {
}, 5000);
}

public static String readableTime(double seconds) {
return (seconds > 120d)
? String.format("%s%.1fm&r", timeColor, (seconds / 60d))
: String.format("%s%.3fs&r", seconds);
}

public static void handlePlayerJoin(Player player) {
for (CountInstance instace : instances)
instace.bar.addPlayer(player);
Expand Down

0 comments on commit 98d1e4d

Please sign in to comment.