Skip to content

Commit

Permalink
Merge pull request #14 from Grzybol/fixes3.2.1
Browse files Browse the repository at this point in the history
Fixes3.2.1
  • Loading branch information
Grzybol authored Mar 4, 2024
2 parents a2c5768 + 751b7e4 commit 69d77c3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>3.2.2-SNAPSHOT</version>
<version>3.2.5-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down
35 changes: 31 additions & 4 deletions src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,19 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
case "event":
if(sender.isOp()){
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " Usage /be event <duration> <h/m>");
}else{
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " You don't have permission to use that command!");
return true;
}
if(sender instanceof Player){
if(betterElo.isEventEnabled){
player = (Player) sender;
double points = dataManager.getPoints(player.getUniqueId().toString(), "event");
points = (double)Math.round(points*100)/100;
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + "Event active! Time left: "+formatTime(betterElo.getRemainingTimeForRewards("event")));
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + "Your rank: "+dataManager.getPlayerRank(player.getUniqueId().toString(), "event"));
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + "Your points: "+points);
}
else {
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + "Event is not active!");
}
}

default:
Expand Down Expand Up @@ -454,7 +464,24 @@ private String formatTime(long millis) {
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;
return String.format("%d days, %d hours, %d minutes, %d seconds", days, hours % 24, minutes % 60, seconds % 60);

StringBuilder formattedTime = new StringBuilder();

if (days > 0) {
formattedTime.append(days).append("d ");
}
if (hours % 24 > 0) {
formattedTime.append(hours % 24).append("h ");
}
if (minutes % 60 > 0) {
formattedTime.append(minutes % 60).append("m ");
}
if (seconds % 60 > 0 || formattedTime.length() == 0) {
formattedTime.append(seconds % 60).append("s");
}

return formattedTime.toString().trim(); // Usunięcie ewentualnych spacji na końcu
}


}
23 changes: 23 additions & 0 deletions src/main/java/betterbox/mine/game/betterelo/Placeholders.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public String onPlaceholderRequest(Player player, String identifier) {
return formatTime(betterElo.getRemainingTimeForRewards("weekly"));
case "monthly_tl":
return formatTime(betterElo.getRemainingTimeForRewards("monthly"));
case "event_tl":
if(betterElo.isEventEnabled) {
return formatTime(betterElo.getRemainingTimeForRewards("event"));
}else{
return "Event is not active!";
}
case "player_daily":
points = dataManager.getPoints(player.getUniqueId().toString(), "daily");
points = (double)Math.round(points*100)/100;
Expand All @@ -109,12 +115,26 @@ public String onPlaceholderRequest(Player player, String identifier) {
points = dataManager.getPoints(player.getUniqueId().toString(), "monthly");
points = (double)Math.round(points*100)/100;
return String.valueOf(points);
case "player_event":
if(betterElo.isEventEnabled) {
points = dataManager.getPoints(player.getUniqueId().toString(), "event");
points = (double)Math.round(points*100)/100;
return String.valueOf(points);
}else{
return "Event is not active!";
}
case "rank_daily":
return String.valueOf(dataManager.getPlayerRank(player.getUniqueId().toString(), "daily"));
case "rank_weekly":
return String.valueOf(dataManager.getPlayerRank(player.getUniqueId().toString(), "weekly"));
case "rank_monthly":
return String.valueOf(dataManager.getPlayerRank(player.getUniqueId().toString(), "monthly"));
case "rank_event":
if(betterElo.isEventEnabled) {
return String.valueOf(dataManager.getPlayerRank(player.getUniqueId().toString(), "event"));
}else{
return "Event is not active!";
}
default:
String result;
if ((result = processRankingPlaceholder(identifier, "", dataManager.playerPoints)) != null) {
Expand All @@ -126,6 +146,9 @@ public String onPlaceholderRequest(Player player, String identifier) {
} else if ((result = processRankingPlaceholder(identifier, "monthly_", dataManager.monthlyPayerPoints)) != null) {
return result;
}
else if ((result = processRankingPlaceholder(identifier, "event_", dataManager.monthlyPayerPoints)) != null&&betterElo.isEventEnabled) {
return result;
}
}
} else {
OfflinePlayer offlinePlayer = dataManager.getOfflinePlayer(identifier);
Expand Down

0 comments on commit 69d77c3

Please sign in to comment.