mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 20:17:55 +01:00
Various fixes for log commands
This commit is contained in:
parent
cb47f9f94b
commit
765f140121
@ -130,7 +130,7 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
return acted.toString();
|
||||
}
|
||||
}
|
||||
return String.valueOf(actorName);
|
||||
return String.valueOf(actedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,7 @@ public class Log {
|
||||
throw new IllegalArgumentException("pageNo cannot be less than 1: " + pageNo);
|
||||
}
|
||||
|
||||
int minimumEntries = ((pageNo * 5) - entries) + 1;
|
||||
int minimumEntries = ((pageNo * entries) - entries) + 1;
|
||||
if (set.size() < minimumEntries) {
|
||||
throw new IllegalStateException("Log does not contain that many entries. " +
|
||||
"Requested: " + minimumEntries + ", Log Count: " + set.size());
|
||||
@ -73,8 +73,8 @@ public class Log {
|
||||
return out;
|
||||
}
|
||||
|
||||
private static int getMaxPages(long size, int entries) {
|
||||
return (int) Math.ceil((double) size / entries);
|
||||
private static int getMaxPages(int size, int entries) {
|
||||
return (int) Math.ceil((double) size / (double) entries);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ -109,7 +109,7 @@ public class Log {
|
||||
public int getRecentMaxPages(UUID actor, int entriesPerPage) {
|
||||
return getMaxPages(content.stream()
|
||||
.filter(e -> e.getActor().equals(actor))
|
||||
.count(), entriesPerPage);
|
||||
.mapToInt(x -> 1).sum(), entriesPerPage);
|
||||
}
|
||||
|
||||
public SortedSet<ExtendedLogEntry> getUserHistory(UUID uuid) {
|
||||
@ -129,7 +129,7 @@ public class Log {
|
||||
.filter(e -> e.getType() == LogEntry.Type.USER)
|
||||
.filter(e -> e.getActed().isPresent())
|
||||
.filter(e -> e.getActed().get().equals(uuid))
|
||||
.count(), entriesPerPage);
|
||||
.mapToInt(x -> 1).sum(), entriesPerPage);
|
||||
}
|
||||
|
||||
public SortedSet<ExtendedLogEntry> getGroupHistory(String name) {
|
||||
@ -147,7 +147,7 @@ public class Log {
|
||||
return getMaxPages(content.stream()
|
||||
.filter(e -> e.getType() == LogEntry.Type.GROUP)
|
||||
.filter(e -> e.getActedName().equals(name))
|
||||
.count(), entriesPerPage);
|
||||
.mapToInt(x -> 1).sum(), entriesPerPage);
|
||||
}
|
||||
|
||||
public SortedSet<ExtendedLogEntry> getTrackHistory(String name) {
|
||||
@ -165,7 +165,7 @@ public class Log {
|
||||
return getMaxPages(content.stream()
|
||||
.filter(e -> e.getType() == LogEntry.Type.TRACK)
|
||||
.filter(e -> e.getActedName().equals(name))
|
||||
.count(), entriesPerPage);
|
||||
.mapToInt(x -> 1).sum(), entriesPerPage);
|
||||
}
|
||||
|
||||
public SortedSet<ExtendedLogEntry> getSearch(String query) {
|
||||
@ -181,7 +181,7 @@ public class Log {
|
||||
public int getSearchMaxPages(String query, int entriesPerPage) {
|
||||
return getMaxPages(content.stream()
|
||||
.filter(e -> e.matchesSearch(query))
|
||||
.count(), entriesPerPage);
|
||||
.mapToInt(x -> 1).sum(), entriesPerPage);
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
|
@ -95,7 +95,7 @@ public class LogGroupHistory extends SubCommand<Log> {
|
||||
long time = e.getValue().getTimestamp();
|
||||
Message.LOG_ENTRY.send(sender,
|
||||
e.getKey(),
|
||||
DateUtil.formatTimeShort(now - time),
|
||||
DateUtil.formatTimeBrief(now - time),
|
||||
e.getValue().getActorFriendlyString(),
|
||||
Character.toString(e.getValue().getType().getCode()),
|
||||
e.getValue().getActedFriendlyString(),
|
||||
|
@ -145,7 +145,7 @@ public class LogRecent extends SubCommand<Log> {
|
||||
long time = e.getValue().getTimestamp();
|
||||
Message.LOG_ENTRY.send(sender,
|
||||
e.getKey(),
|
||||
DateUtil.formatTimeShort(now - time),
|
||||
DateUtil.formatTimeBrief(now - time),
|
||||
e.getValue().getActorFriendlyString(),
|
||||
Character.toString(e.getValue().getType().getCode()),
|
||||
e.getValue().getActedFriendlyString(),
|
||||
|
@ -87,7 +87,7 @@ public class LogSearch extends SubCommand<Log> {
|
||||
long time = e.getValue().getTimestamp();
|
||||
Message.LOG_ENTRY.send(sender,
|
||||
e.getKey(),
|
||||
DateUtil.formatTimeShort(now - time),
|
||||
DateUtil.formatTimeBrief(now - time),
|
||||
e.getValue().getActorFriendlyString(),
|
||||
Character.toString(e.getValue().getType().getCode()),
|
||||
e.getValue().getActedFriendlyString(),
|
||||
|
@ -95,7 +95,7 @@ public class LogTrackHistory extends SubCommand<Log> {
|
||||
long time = e.getValue().getTimestamp();
|
||||
Message.LOG_ENTRY.send(sender,
|
||||
e.getKey(),
|
||||
DateUtil.formatTimeShort(now - time),
|
||||
DateUtil.formatTimeBrief(now - time),
|
||||
e.getValue().getActorFriendlyString(),
|
||||
Character.toString(e.getValue().getType().getCode()),
|
||||
e.getValue().getActedFriendlyString(),
|
||||
|
@ -125,7 +125,7 @@ public class LogUserHistory extends SubCommand<Log> {
|
||||
long time = e.getValue().getTimestamp();
|
||||
Message.LOG_ENTRY.send(sender,
|
||||
e.getKey(),
|
||||
DateUtil.formatTimeShort(now - time),
|
||||
DateUtil.formatTimeBrief(now - time),
|
||||
e.getValue().getActorFriendlyString(),
|
||||
Character.toString(e.getValue().getType().getCode()),
|
||||
e.getValue().getActedFriendlyString(),
|
||||
|
@ -72,7 +72,7 @@ public class InfoCommand extends SingleCommand {
|
||||
plugin.getContextManager().getStaticContextString().orElse("None"),
|
||||
plugin.getPlayerCount(),
|
||||
plugin.getUniqueConnections().size(),
|
||||
DateUtil.formatTimeShort((System.currentTimeMillis() - plugin.getStartTime()) / 1000L),
|
||||
DateUtil.formatTimeBrief((System.currentTimeMillis() - plugin.getStartTime()) / 1000L),
|
||||
plugin.getUserManager().getAll().size(),
|
||||
plugin.getGroupManager().getAll().size(),
|
||||
plugin.getTrackManager().getAll().size(),
|
||||
|
@ -62,7 +62,11 @@ public enum Message {
|
||||
LOG_INFO("&7&l[&bL&3P&7&l] &3{}", false),
|
||||
LOG_WARN("&7&l[&bLuck&3Perms&7&l] &c[WARN] {}", false),
|
||||
LOG_ERROR("&7&l[&bLuck&3Perms&7&l] &4[ERROR] {}", false),
|
||||
LOG("&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)&f: {}", true),
|
||||
LOG(
|
||||
"{PREFIX}&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)" + "\n" +
|
||||
"{PREFIX}&3LOG &3&l> &f{}",
|
||||
false
|
||||
),
|
||||
VERBOSE_LOG("&3VB &3&l> {}", true),
|
||||
EXPORT_LOG("&3EXPORT &3&l> &f{}", true),
|
||||
EXPORT_LOG_PROGRESS("&3EXPORT &3&l> &7{}", true),
|
||||
@ -390,7 +394,7 @@ public enum Message {
|
||||
|
||||
LOG_ENTRY(
|
||||
"{PREFIX}&b#{} &8(&7{} ago&8) &8(&e{}&8) [&a{}&8] (&b{}&8)" + "\n" +
|
||||
"{PERFIX}&7> &f{}",
|
||||
"{PREFIX}&7> &f{}",
|
||||
false
|
||||
),
|
||||
|
||||
|
@ -199,6 +199,35 @@ public class DateUtil {
|
||||
return time.toString().trim();
|
||||
}
|
||||
|
||||
public static String formatTimeBrief(long seconds) {
|
||||
if (seconds <= 0) {
|
||||
return "0s";
|
||||
}
|
||||
|
||||
long minute = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
long hour = minute / 60;
|
||||
minute = minute % 60;
|
||||
long day = hour / 24;
|
||||
hour = hour % 24;
|
||||
|
||||
StringBuilder time = new StringBuilder();
|
||||
if (day != 0) {
|
||||
time.append(day).append("d ");
|
||||
time.append(hour).append("h ");
|
||||
} else if (hour != 0) {
|
||||
time.append(hour).append("h ");
|
||||
time.append(minute).append("m ");
|
||||
} else if (minute != 0) {
|
||||
time.append(minute).append("m ");
|
||||
time.append(seconds).append("s");
|
||||
} else if (seconds != 0) {
|
||||
time.append(seconds).append("s");
|
||||
}
|
||||
|
||||
return time.toString().trim();
|
||||
}
|
||||
|
||||
private static String formatDateDiff(Calendar fromDate, Calendar toDate) {
|
||||
boolean future = false;
|
||||
if (toDate.equals(fromDate)) {
|
||||
|
Loading…
Reference in New Issue
Block a user