diff --git a/README.md b/README.md index f5320ed2..7739715d 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ You can add LuckPerms as a Maven dependency by adding the following to your proj me.lucko.luckperms luckperms-api - 2.1 + 2.3 ```` @@ -181,6 +181,7 @@ Additionally, you can use wildcards to grant users access to a selection of comm * **All user commands** - luckperms.user.* * **All group commands** - luckperms.group.* * **All track commands** - luckperms.track.* +* **All log commands** - luckperms.log.* ### General * /perms - n/a diff --git a/api/pom.xml b/api/pom.xml index 985de3da..5e0803e8 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -21,6 +21,19 @@ 1.8 + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar-no-fork + + + + diff --git a/api/src/main/java/me/lucko/luckperms/LuckPerms.java b/api/src/main/java/me/lucko/luckperms/LuckPerms.java index 3118f38e..9745bad0 100644 --- a/api/src/main/java/me/lucko/luckperms/LuckPerms.java +++ b/api/src/main/java/me/lucko/luckperms/LuckPerms.java @@ -22,8 +22,6 @@ package me.lucko.luckperms; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; import me.lucko.luckperms.api.LuckPermsApi; import java.util.Optional; @@ -31,12 +29,9 @@ import java.util.Optional; /** * Static access to LuckPerms */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class LuckPerms { - private static LuckPermsApi api = null; - /** * Gets an instance of {@link LuckPermsApi} * @return an api instance @@ -66,4 +61,8 @@ public final class LuckPerms { api = null; } + private LuckPerms() { + throw new UnsupportedOperationException("This class cannot be instantiated."); + } + } diff --git a/api/src/main/java/me/lucko/luckperms/api/LogEntry.java b/api/src/main/java/me/lucko/luckperms/api/LogEntry.java index de5f9694..6585913b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LogEntry.java +++ b/api/src/main/java/me/lucko/luckperms/api/LogEntry.java @@ -22,25 +22,44 @@ package me.lucko.luckperms.api; -import lombok.*; - import java.util.UUID; -@Getter -@Builder -@ToString -@EqualsAndHashCode -@AllArgsConstructor public final class LogEntry implements Comparable { + public static LogEntryBuilder builder() { + return new LogEntryBuilder(); + } private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s"; - @NonNull private final long timestamp; - @NonNull private final UUID actor; - @NonNull private final String actorName; - @NonNull private final char type; + private final long timestamp; + private final UUID actor; + private final String actorName; + private final char type; private final UUID acted; - @NonNull private final String actedName; - @NonNull private final String action; + private final String actedName; + private final String action; + + public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) { + if (actor == null) { + throw new NullPointerException("actor"); + } + if (actorName == null) { + throw new NullPointerException("actorName"); + } + if (actedName == null) { + throw new NullPointerException("actedName"); + } + if (action == null) { + throw new NullPointerException("action"); + } + + this.timestamp = timestamp; + this.actor = actor; + this.actorName = actorName; + this.type = type; + this.acted = acted; + this.actedName = actedName; + this.action = action; + } @Override public int compareTo(LogEntry o) { @@ -55,10 +74,146 @@ public final class LogEntry implements Comparable { public String getFormatted() { return String.format(FORMAT, - getActorName(), - Character.toString(getType()), - getActedName(), - getAction() + actorName, + Character.toString(type), + actedName, + action ); } + + public long getTimestamp() { + return timestamp; + } + + public UUID getActor() { + return actor; + } + + public String getActorName() { + return actorName; + } + + public char getType() { + return type; + } + + public UUID getActed() { + return acted; + } + + public String getActedName() { + return actedName; + } + + public String getAction() { + return action; + } + + @Override + public String toString() { + return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" + + this.getActorName() + ", type=" + this.getType() + ", acted=" + this.getActed() + ", actedName=" + + this.getActedName() + ", action=" + this.getAction() + ")"; + } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof LogEntry)) return false; + final LogEntry other = (LogEntry) o; + if (this.getTimestamp() != other.getTimestamp()) return false; + final Object this$actor = this.getActor(); + final Object other$actor = other.getActor(); + if (this$actor == null ? other$actor != null : !this$actor.equals(other$actor)) return false; + final Object this$actorName = this.getActorName(); + final Object other$actorName = other.getActorName(); + if (this$actorName == null ? other$actorName != null : !this$actorName.equals(other$actorName)) return false; + if (this.getType() != other.getType()) return false; + final Object this$acted = this.getActed(); + final Object other$acted = other.getActed(); + if (this$acted == null ? other$acted != null : !this$acted.equals(other$acted)) return false; + final Object this$actedName = this.getActedName(); + final Object other$actedName = other.getActedName(); + if (this$actedName == null ? other$actedName != null : !this$actedName.equals(other$actedName)) return false; + final Object this$action = this.getAction(); + final Object other$action = other.getAction(); + return this$action == null ? other$action == null : this$action.equals(other$action); + } + + @Override + public int hashCode() { + final int PRIME = 59; + int result = 1; + final long $timestamp = this.getTimestamp(); + result = result * PRIME + (int) ($timestamp >>> 32 ^ $timestamp); + final Object $actor = this.getActor(); + result = result * PRIME + ($actor == null ? 43 : $actor.hashCode()); + final Object $actorName = this.getActorName(); + result = result * PRIME + ($actorName == null ? 43 : $actorName.hashCode()); + result = result * PRIME + this.getType(); + final Object $acted = this.getActed(); + result = result * PRIME + ($acted == null ? 43 : $acted.hashCode()); + final Object $actedName = this.getActedName(); + result = result * PRIME + ($actedName == null ? 43 : $actedName.hashCode()); + final Object $action = this.getAction(); + result = result * PRIME + ($action == null ? 43 : $action.hashCode()); + return result; + } + + public static class LogEntryBuilder { + private long timestamp; + private UUID actor; + private String actorName; + private char type; + private UUID acted; + private String actedName; + private String action; + + public LogEntryBuilder timestamp(long timestamp) { + this.timestamp = timestamp; + return this; + } + + public LogEntryBuilder actor(UUID actor) { + this.actor = actor; + return this; + } + + public LogEntryBuilder actorName(String actorName) { + this.actorName = actorName; + return this; + } + + public LogEntryBuilder type(char type) { + this.type = type; + return this; + } + + public LogEntryBuilder acted(UUID acted) { + this.acted = acted; + return this; + } + + public LogEntryBuilder actedName(String actedName) { + this.actedName = actedName; + return this; + } + + public LogEntryBuilder action(String action) { + this.action = action; + return this; + } + + public LogEntry build() { + return new LogEntry(timestamp, actor, actorName, type, acted, actedName, action); + } + + @Override + public String toString() { + return "LogEntry.LogEntryBuilder(timestamp=" + this.timestamp + ", actor=" + this.actor + ", actorName=" + + this.actorName + ", type=" + this.type + ", acted=" + this.acted + ", actedName=" + this.actedName + + ", action=" + this.action + ")"; + } + } + } diff --git a/api/src/main/java/me/lucko/luckperms/api/data/Callback.java b/api/src/main/java/me/lucko/luckperms/api/data/Callback.java index d2331471..9087c97d 100644 --- a/api/src/main/java/me/lucko/luckperms/api/data/Callback.java +++ b/api/src/main/java/me/lucko/luckperms/api/data/Callback.java @@ -22,8 +22,6 @@ package me.lucko.luckperms.api.data; -import lombok.NonNull; - import java.util.function.Consumer; public interface Callback { @@ -34,11 +32,17 @@ public interface Callback { return t -> {}; } - static Callback of(@NonNull Runnable runnable) { + static Callback of(Runnable runnable) { + if (runnable == null) { + throw new NullPointerException("runnable"); + } return t -> runnable.run(); } - static Callback of(@NonNull Consumer consumer) { + static Callback of(Consumer consumer) { + if (consumer == null) { + throw new NullPointerException("consumer"); + } return consumer::accept; } diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 13e3a241..531bd8c5 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -119,5 +119,12 @@ 1.7.9 compile + + + org.projectlombok + lombok + 1.16.10 + provided + diff --git a/bungee/pom.xml b/bungee/pom.xml index b765770a..f5300648 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -112,6 +112,13 @@ 1.7.9 compile + + + org.projectlombok + lombok + 1.16.10 + provided + diff --git a/common/pom.xml b/common/pom.xml index 37e7df71..b249f75a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -60,6 +60,13 @@ 19.0 provided + + + org.projectlombok + lombok + 1.16.10 + provided + diff --git a/common/src/main/java/me/lucko/luckperms/commands/log/subcommands/LogUserHistory.java b/common/src/main/java/me/lucko/luckperms/commands/log/subcommands/LogUserHistory.java index 6fec3d20..5d0ff6aa 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/log/subcommands/LogUserHistory.java +++ b/common/src/main/java/me/lucko/luckperms/commands/log/subcommands/LogUserHistory.java @@ -45,11 +45,11 @@ public class LogUserHistory extends SubCommand { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List args, String label) { String user = args.get(0); - final int[] page = {-999}; + int page = -999; if (args.size() == 2) { try { - page[0] = Integer.parseInt(args.get(1)); + page = Integer.parseInt(args.get(1)); } catch (NumberFormatException e) { // invalid page return showLog(-1, null, null, null); @@ -58,11 +58,11 @@ public class LogUserHistory extends SubCommand { UUID uuid = Util.parseUuid(user); if (uuid != null) { - if (page[0] == -999) { - page[0] = log.getUserHistoryMaxPages(uuid); + if (page == -999) { + page = log.getUserHistoryMaxPages(uuid); } - return showLog(page[0], uuid, sender, log); + return showLog(page, uuid, sender, log); } @@ -81,11 +81,11 @@ public class LogUserHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - if (page[0] == -999) { - page[0] = log.getUserHistoryMaxPages(uuid1); + if (page == -999) { + page = log.getUserHistoryMaxPages(uuid1); } - return showLog(page[0], uuid1, sender, log); + return showLog(page, uuid1, sender, log); } Message.USER_INVALID_ENTRY.send(sender, user); diff --git a/common/src/main/java/me/lucko/luckperms/storage/Datastore.java b/common/src/main/java/me/lucko/luckperms/storage/Datastore.java index 6730db01..f3db32b9 100644 --- a/common/src/main/java/me/lucko/luckperms/storage/Datastore.java +++ b/common/src/main/java/me/lucko/luckperms/storage/Datastore.java @@ -90,7 +90,7 @@ public abstract class Datastore { /* These methods will schedule the operation to run async. The callback will be ran when the task is complete. - Callbacks are ran on the main Bukkit server thread (if applicable) + Callbacks are ran on the main server thread (except on BungeeCord) */ public void logAction(LogEntry entry, Callback callback) { doAsync(() -> { diff --git a/pom.xml b/pom.xml index 59795305..22c6ab76 100644 --- a/pom.xml +++ b/pom.xml @@ -38,14 +38,4 @@ https://repo.spongepowered.org/maven - - - - - org.projectlombok - lombok - 1.16.10 - provided - - diff --git a/sponge/pom.xml b/sponge/pom.xml index 0f3c0809..f11bf52a 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -142,5 +142,12 @@ 1.1.0 provided + + + org.projectlombok + lombok + 1.16.10 + provided +