diff --git a/pom.xml b/pom.xml index d83b70d..60612a7 100644 --- a/pom.xml +++ b/pom.xml @@ -147,7 +147,7 @@ org.spigotmc spigot-api - 1.20.1-R0.1-SNAPSHOT + 1.20.2-R0.1-SNAPSHOT provided diff --git a/src/main/java/dev/heliosares/auxprotect/core/commands/LookupCommand.java b/src/main/java/dev/heliosares/auxprotect/core/commands/LookupCommand.java index a384002..c3dd8b4 100644 --- a/src/main/java/dev/heliosares/auxprotect/core/commands/LookupCommand.java +++ b/src/main/java/dev/heliosares/auxprotect/core/commands/LookupCommand.java @@ -11,6 +11,7 @@ import dev.heliosares.auxprotect.spigot.AuxProtectSpigot; import dev.heliosares.auxprotect.utils.*; import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtectAPI; +import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.Bukkit; import java.sql.SQLException; @@ -381,11 +382,13 @@ public class LookupCommand extends Command { return; } String name = users.stream().findAny().orElse(null); - sender.sendMessage(PlayTimeSolver.solvePlaytime(rs, + for (BaseComponent[] line : PlayTimeSolver.solvePlaytime(rs, params_.getAfter(), params_.getBefore() == Long.MAX_VALUE ? System.currentTimeMillis() : params_.getBefore(), name, - plugin.getSenderAdapter(name) != null)); + plugin.getSenderAdapter(name) != null)) { + sender.sendMessage(line); + } return; } else if (params_.hasFlag(Flag.ACTIVITY)) { String uuid = sender.getUniqueId().toString(); diff --git a/src/main/java/dev/heliosares/auxprotect/utils/PlayTimeSolver.java b/src/main/java/dev/heliosares/auxprotect/utils/PlayTimeSolver.java index d2e045c..07ffcd4 100644 --- a/src/main/java/dev/heliosares/auxprotect/utils/PlayTimeSolver.java +++ b/src/main/java/dev/heliosares/auxprotect/utils/PlayTimeSolver.java @@ -15,21 +15,21 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; public class PlayTimeSolver { - public static BaseComponent[] solvePlaytime(List entries, long startTimeMillis, long stopTimeMillis, String player, final boolean currentlyOnline) { + public static BaseComponent[][] solvePlaytime(List entries, long startTimeMillis, long stopTimeMillis, String player, final boolean currentlyOnline) { ComponentBuilder message = new ComponentBuilder().append("", FormatRetention.NONE); final int limitDays = 60; final int hours = (int) Math.ceil((stopTimeMillis - startTimeMillis) / 3600000D); if (hours - 1 > limitDays * 24) { message.append(Language.L.COMMAND__LOOKUP__PLAYTIME__TOOLONG.translate(limitDays)); - return message.create(); + return new BaseComponent[][]{message.create()}; } StringBuilder line = new StringBuilder(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH); line.append(String.valueOf((char) 65293).repeat(6)).append(ChatColor.RESET); message.append(line + " " + Language.L.COMMAND__LOOKUP__PLAYTIME__HEADER.translate(player, Language.getOptionalS(player)) + " " + line); - message.append("\n"); LocalDateTime startTime = Instant.ofEpochMilli(startTimeMillis).atZone(ZoneId.systemDefault()).toLocalDateTime() .withMinute(0).withSecond(0).withNano(0); long firstTime = startTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); @@ -100,6 +100,10 @@ public class PlayTimeSolver { newLogin = newLogout = false; } } + List components = new ArrayList<>(); + components.add(message.create()); + message = new ComponentBuilder(); + DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("ddMMM"); DateTimeFormatter formatterDateTime = DateTimeFormatter.ofPattern("ddMMM hh a"); for (int i = 0; i < startTime.getHour(); i++) { @@ -128,9 +132,11 @@ public class PlayTimeSolver { if (time.getHour() == 23) { message.append(" " + time.format(formatterDate)).color(ChatColor.BLUE).event((HoverEvent) null); - message.append(" (" + (Math.round(hourCount * 10.0) / 10.0) + "h)\n").color(ChatColor.GRAY) + message.append(" (" + (Math.round(hourCount * 10.0) / 10.0) + "h)").color(ChatColor.GRAY) .event((HoverEvent) null); hourCount = 0; + components.add(message.create()); + message = new ComponentBuilder(); } } for (int i = counter.length; ; i++) { @@ -141,6 +147,7 @@ public class PlayTimeSolver { message.append(" " + startTime.plusHours(hours).format(formatterDate)).color(ChatColor.BLUE); message.append(" (" + (Math.round(hourCount * 10.0) / 10.0) + "h)").color(ChatColor.GRAY) .event((HoverEvent) null); - return message.create(); + components.add(message.create()); + return components.toArray(new BaseComponent[0][0]); } } \ No newline at end of file