mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
refactor LogEntry & cleanup stream formatting
This commit is contained in:
parent
ca9037461a
commit
84afbf26f8
@ -24,19 +24,20 @@ package me.lucko.luckperms.api;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class LogEntry implements Comparable<LogEntry> {
|
||||
public class LogEntry implements Comparable<LogEntry> {
|
||||
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";
|
||||
|
||||
private final long timestamp;
|
||||
private final UUID actor;
|
||||
private final String actorName;
|
||||
private final char type;
|
||||
private final UUID acted;
|
||||
private final String actedName;
|
||||
private final String action;
|
||||
private long timestamp;
|
||||
private UUID actor;
|
||||
private String actorName;
|
||||
private char type;
|
||||
private UUID acted;
|
||||
private String actedName;
|
||||
private String action;
|
||||
|
||||
public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) {
|
||||
if (actor == null) {
|
||||
@ -61,6 +62,16 @@ public final class LogEntry implements Comparable<LogEntry> {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
protected LogEntry() {
|
||||
this.timestamp = 0L;
|
||||
this.actor = null;
|
||||
this.actorName = null;
|
||||
this.type = Character.MIN_VALUE;
|
||||
this.acted = null;
|
||||
this.actedName = null;
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LogEntry o) {
|
||||
return Long.compare(timestamp, o.getTimestamp());
|
||||
@ -109,6 +120,34 @@ public final class LogEntry implements Comparable<LogEntry> {
|
||||
return action;
|
||||
}
|
||||
|
||||
void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
void setActor(UUID actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
void setActorName(String actorName) {
|
||||
this.actorName = actorName;
|
||||
}
|
||||
|
||||
void setType(char type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
void setActed(UUID acted) {
|
||||
this.acted = acted;
|
||||
}
|
||||
|
||||
void setActedName(String actedName) {
|
||||
this.actedName = actedName;
|
||||
}
|
||||
|
||||
void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" +
|
||||
@ -160,59 +199,116 @@ public final class LogEntry implements Comparable<LogEntry> {
|
||||
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 static class LogEntryBuilder extends AbstractLogEntryBuilder<LogEntry, LogEntry.LogEntryBuilder> {
|
||||
|
||||
public LogEntryBuilder timestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
@Override
|
||||
protected LogEntry createObj() {
|
||||
return new LogEntry();
|
||||
}
|
||||
|
||||
public LogEntryBuilder actor(UUID actor) {
|
||||
this.actor = actor;
|
||||
@Override
|
||||
protected LogEntryBuilder getThis() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public LogEntryBuilder actorName(String actorName) {
|
||||
this.actorName = actorName;
|
||||
return this;
|
||||
public static abstract class AbstractLogEntryBuilder<T extends LogEntry, B extends AbstractLogEntryBuilder<T, B>> {
|
||||
private T obj;
|
||||
private B thisObj;
|
||||
|
||||
public AbstractLogEntryBuilder() {
|
||||
obj = createObj();
|
||||
thisObj = getThis();
|
||||
}
|
||||
|
||||
public LogEntryBuilder type(char type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
protected abstract T createObj();
|
||||
protected abstract B getThis();
|
||||
|
||||
public long getTimestamp() {
|
||||
return obj.getTimestamp();
|
||||
}
|
||||
|
||||
public LogEntryBuilder acted(UUID acted) {
|
||||
this.acted = acted;
|
||||
return this;
|
||||
public UUID getActor() {
|
||||
return obj.getActor();
|
||||
}
|
||||
|
||||
public LogEntryBuilder actedName(String actedName) {
|
||||
this.actedName = actedName;
|
||||
return this;
|
||||
public String getActorName() {
|
||||
return obj.getActorName();
|
||||
}
|
||||
|
||||
public LogEntryBuilder action(String action) {
|
||||
this.action = action;
|
||||
return this;
|
||||
public char getType() {
|
||||
return obj.getType();
|
||||
}
|
||||
|
||||
public LogEntry build() {
|
||||
return new LogEntry(timestamp, actor, actorName, type, acted, actedName, action);
|
||||
public UUID getActed() {
|
||||
return obj.getActed();
|
||||
}
|
||||
|
||||
public String getActedName() {
|
||||
return obj.getActedName();
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return obj.getAction();
|
||||
}
|
||||
|
||||
public B timestamp(long timestamp) {
|
||||
obj.setTimestamp(timestamp);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B actor(UUID actor) {
|
||||
obj.setActor(actor);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B actorName(String actorName) {
|
||||
obj.setActorName(actorName);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B type(char type) {
|
||||
obj.setType(type);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B acted(UUID acted) {
|
||||
obj.setActed(acted);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B actedName(String actedName) {
|
||||
obj.setActedName(actedName);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public B action(String action) {
|
||||
obj.setAction(action);
|
||||
return thisObj;
|
||||
}
|
||||
|
||||
public T build() {
|
||||
if (getActor() == null) {
|
||||
throw new NullPointerException("actor");
|
||||
}
|
||||
if (getActorName() == null) {
|
||||
throw new NullPointerException("actorName");
|
||||
}
|
||||
if (getActedName() == null) {
|
||||
throw new NullPointerException("actedName");
|
||||
}
|
||||
if (getAction() == null) {
|
||||
throw new NullPointerException("action");
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@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 + ")";
|
||||
return "LogEntry.LogEntryBuilder(timestamp=" + getTimestamp() + ", actor=" + getActor() + ", actorName=" +
|
||||
getActorName() + ", type=" + getType() + ", acted=" + getActed() + ", actedName=" + getActedName() +
|
||||
", action=" + getAction() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,18 +144,28 @@ public class CommandManager {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> onTabComplete(Sender sender, List<String> args) {
|
||||
final List<MainCommand> mains = mainCommands.stream().filter(m -> m.isAuthorized(sender)).collect(Collectors.toList());
|
||||
final List<MainCommand> mains = mainCommands.stream()
|
||||
.filter(m -> m.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
||||
return mains.stream().map(MainCommand::getName).map(String::toLowerCase).collect(Collectors.toList());
|
||||
return mains.stream()
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return mains.stream().map(MainCommand::getName).map(String::toLowerCase)
|
||||
.filter(s -> s.startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
return mains.stream()
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.filter(s -> s.startsWith(args.get(0).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<MainCommand> o = mains.stream().filter(m -> m.getName().equalsIgnoreCase(args.get(0))).limit(1).findAny();
|
||||
Optional<MainCommand> o = mains.stream()
|
||||
.filter(m -> m.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
|
||||
if (!o.isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -76,7 +76,10 @@ public abstract class MainCommand<T> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Optional<SubCommand<T>> o = subCommands.stream().filter(s -> s.getName().equalsIgnoreCase(args.get(requiredArgsLength - 1))).limit(1).findAny();
|
||||
Optional<SubCommand<T>> o = subCommands.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(requiredArgsLength - 1)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
|
||||
if (!o.isPresent()) {
|
||||
Message.COMMAND_NOT_RECOGNISED.send(sender);
|
||||
@ -121,7 +124,7 @@ public abstract class MainCommand<T> {
|
||||
protected abstract void cleanup(T t, LuckPermsPlugin plugin);
|
||||
|
||||
/**
|
||||
* Get a list of objects for tab completion
|
||||
* Get a list of {@link T} objects for tab completion
|
||||
* @param plugin a link to the main plugin instance
|
||||
* @return a list of strings
|
||||
*/
|
||||
@ -138,7 +141,10 @@ public abstract class MainCommand<T> {
|
||||
return;
|
||||
}
|
||||
|
||||
List<SubCommand> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList());
|
||||
List<SubCommand> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (subs.size() > 0) {
|
||||
Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:");
|
||||
|
||||
@ -168,20 +174,33 @@ public abstract class MainCommand<T> {
|
||||
return objects;
|
||||
}
|
||||
|
||||
return objects.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
return objects.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
final List<SubCommand<T>> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList());
|
||||
final List<SubCommand<T>> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (args.size() == 2) {
|
||||
if (args.get(1).equalsIgnoreCase("")) {
|
||||
return subs.stream().map(SubCommand::getName).map(String::toLowerCase).collect(Collectors.toList());
|
||||
return subs.stream()
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return subs.stream().map(SubCommand::getName).map(String::toLowerCase)
|
||||
.filter(s -> s.toLowerCase().startsWith(args.get(1).toLowerCase())).collect(Collectors.toList());
|
||||
return subs.stream()
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.filter(s -> s.toLowerCase().startsWith(args.get(1).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<SubCommand<T>> o = subs.stream().filter(s -> s.getName().equalsIgnoreCase(args.get(1))).limit(1).findAny();
|
||||
Optional<SubCommand<T>> o = subs.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(1)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
|
||||
if (!o.isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
|
||||
import java.util.List;
|
||||
@ -62,7 +62,7 @@ public class CreateGroup extends SingleMainCommand {
|
||||
}
|
||||
|
||||
Message.CREATE_SUCCESS.send(sender, groupName);
|
||||
LogEntryBuilder.get().actor(sender).actedName(groupName).type('G').action("create").submit(plugin);
|
||||
LogEntry.build().actor(sender).actedName(groupName).type('G').action("create").build().submit(plugin);
|
||||
plugin.runUpdateTask();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
|
||||
@ -78,7 +78,7 @@ public class DeleteGroup extends SingleMainCommand {
|
||||
}
|
||||
|
||||
Message.DELETE_SUCCESS.send(sender, groupName);
|
||||
LogEntryBuilder.get().actor(sender).actedName(groupName).type('G').action("delete").submit(plugin);
|
||||
LogEntry.build().actor(sender).actedName(groupName).type('G').action("delete").build().submit(plugin);
|
||||
plugin.runUpdateTask();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
@ -92,7 +92,8 @@ public class DeleteGroup extends SingleMainCommand {
|
||||
return groups;
|
||||
}
|
||||
|
||||
return groups.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
return groups.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
@ -44,7 +44,7 @@ public class GroupClear extends SubCommand<Group> {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
|
||||
group.clearNodes();
|
||||
Message.CLEAR_SUCCESS.send(sender, group.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(group).action("clear").submit(plugin);
|
||||
LogEntry.build().actor(sender).acted(group).action("clear").build().submit(plugin);
|
||||
save(group, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -74,24 +74,24 @@ public class GroupSetInherit extends SubCommand<Group> {
|
||||
if (args.size() == 2) {
|
||||
group.setInheritGroup(group1, server);
|
||||
Message.GROUP_SETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), group1.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("setinherit " + group1.getName() + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
group.setInheritGroup(group1, server, world);
|
||||
Message.GROUP_SETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), group1.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("setinherit " + group1.getName() + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.setInheritGroup(group1);
|
||||
Message.GROUP_SETINHERIT_SUCCESS.send(sender, group.getName(), group1.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("setinherit " + group1.getName())
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -76,24 +76,24 @@ public class GroupSetPermission extends SubCommand<Group> {
|
||||
if (args.size() == 3) {
|
||||
group.setPermission(node, b, server);
|
||||
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, group.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("set " + node + " " + b + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(3).toLowerCase();
|
||||
group.setPermission(node, b, server, world);
|
||||
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, group.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("set " + node + " " + b + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.setPermission(node, b);
|
||||
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, group.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("set " + node + " " + b)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -89,25 +89,25 @@ public class GroupSetTempInherit extends SubCommand<Group> {
|
||||
group.setInheritGroup(group1, server, duration);
|
||||
Message.GROUP_SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getName(), group1.getName(), server,
|
||||
DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("settempinherit " + group1.getName() + " " + duration + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(3).toLowerCase();
|
||||
group.setInheritGroup(group1, server, world, duration);
|
||||
Message.GROUP_SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), group1.getName(), server,
|
||||
world, DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("settempinherit " + group1.getName() + " " + duration + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.setInheritGroup(group1, duration);
|
||||
Message.GROUP_SET_TEMP_INHERIT_SUCCESS.send(sender, group.getName(), group1.getName(), DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("settempinherit " + group1.getName() + " " + duration)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -92,25 +92,25 @@ public class GroupSetTempPermission extends SubCommand<Group> {
|
||||
group.setPermission(node, b, server, duration);
|
||||
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, group.getName(), server,
|
||||
DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("settemp " + node + " " + b + " " + duration + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(4).toLowerCase();
|
||||
group.setPermission(node, b, server, world, duration);
|
||||
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, group.getName(), server,
|
||||
world, DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("settemp " + node + " " + b + " " + duration + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.setPermission(node, b, duration);
|
||||
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, group.getName(), DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("settemp " + node + " " + b + " " + duration)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -68,24 +68,24 @@ public class GroupUnSetPermission extends SubCommand<Group> {
|
||||
if (args.size() == 2) {
|
||||
group.unsetPermission(node, server);
|
||||
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unset " + node + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
group.unsetPermission(node, server, world);
|
||||
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, group.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unset " + node + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.unsetPermission(node);
|
||||
Message.UNSETPERMISSION_SUCCESS.send(sender, node, group.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unset " + node)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -63,24 +63,24 @@ public class GroupUnsetInherit extends SubCommand<Group> {
|
||||
if (args.size() == 2) {
|
||||
group.unsetPermission("group." + groupName, server);
|
||||
Message.GROUP_UNSETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsetinherit " + groupName + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
group.unsetPermission("group." + groupName, server, world);
|
||||
Message.GROUP_UNSETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), groupName, server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsetinherit " + groupName + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.unsetPermission("group." + groupName);
|
||||
Message.GROUP_UNSETINHERIT_SUCCESS.send(sender, group.getName(), groupName);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsetinherit " + groupName)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -63,24 +63,24 @@ public class GroupUnsetTempInherit extends SubCommand<Group> {
|
||||
if (args.size() == 2) {
|
||||
group.unsetPermission("group." + groupName, server, true);
|
||||
Message.GROUP_UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsettempinherit " + groupName + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
group.unsetPermission("group." + groupName, server, world, true);
|
||||
Message.GROUP_UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), groupName, server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsettempinherit " + groupName + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.unsetPermission("group." + groupName, true);
|
||||
Message.GROUP_UNSET_TEMP_INHERIT_SUCCESS.send(sender, group.getName(), groupName);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsettempinherit " + groupName)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -69,24 +69,24 @@ public class GroupUnsetTempPermission extends SubCommand<Group> {
|
||||
if (args.size() == 2) {
|
||||
group.unsetPermission(node, server);
|
||||
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsettemp " + node + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
group.unsetPermission(node, server, world);
|
||||
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, group.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsettemp " + node + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
group.unsetPermission(node, true);
|
||||
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, group.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(group)
|
||||
LogEntry.build().actor(sender).acted(group)
|
||||
.action("unsettemp " + node)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(group, sender, plugin);
|
||||
|
@ -73,17 +73,28 @@ public class LogMainCommand extends MainCommand<Log> {
|
||||
|
||||
@Override
|
||||
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) {
|
||||
final List<SubCommand<Log>> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList());
|
||||
final List<SubCommand<Log>> subs = getSubCommands().stream()
|
||||
.filter(s -> s.isAuthorized(sender))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (args.size() <= 1) {
|
||||
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) {
|
||||
return subs.stream().map(SubCommand::getName).map(String::toLowerCase).collect(Collectors.toList());
|
||||
return subs.stream()
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return subs.stream().map(SubCommand::getName).map(String::toLowerCase)
|
||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
return subs.stream()
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<SubCommand<Log>> o = subs.stream().filter(s -> s.getName().equalsIgnoreCase(args.get(0))).limit(1).findAny();
|
||||
Optional<SubCommand<Log>> o = subs.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
|
||||
if (!o.isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
|
||||
import java.util.List;
|
||||
@ -62,7 +62,7 @@ public class CreateTrack extends SingleMainCommand {
|
||||
}
|
||||
|
||||
Message.CREATE_SUCCESS.send(sender, trackName);
|
||||
LogEntryBuilder.get().actor(sender).actedName(trackName).type('T').action("create").submit(plugin);
|
||||
LogEntry.build().actor(sender).actedName(trackName).type('T').action("create").build().submit(plugin);
|
||||
plugin.runUpdateTask();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SingleMainCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
|
||||
@ -72,7 +72,7 @@ public class DeleteTrack extends SingleMainCommand {
|
||||
}
|
||||
|
||||
Message.DELETE_SUCCESS.send(sender, trackName);
|
||||
LogEntryBuilder.get().actor(sender).actedName(trackName).type('T').action("delete").submit(plugin);
|
||||
LogEntry.build().actor(sender).actedName(trackName).type('T').action("delete").build().submit(plugin);
|
||||
plugin.runUpdateTask();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
@ -86,7 +86,9 @@ public class DeleteTrack extends SingleMainCommand {
|
||||
return tracks;
|
||||
}
|
||||
|
||||
return tracks.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList());
|
||||
return tracks.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
@ -64,9 +64,9 @@ public class TrackAppend extends SubCommand<Track> {
|
||||
track.appendGroup(group);
|
||||
Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), track.getName());
|
||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName()));
|
||||
LogEntryBuilder.get().actor(sender).acted(track)
|
||||
LogEntry.build().actor(sender).acted(track)
|
||||
.action("append " + group.getName())
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
save(track, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} catch (ObjectAlreadyHasException e) {
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
|
||||
import java.util.List;
|
||||
@ -44,7 +44,7 @@ public class TrackClear extends SubCommand<Track> {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
|
||||
track.clearGroups();
|
||||
Message.TRACK_CLEAR.send(sender, track.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(track).action("clear").submit(plugin);
|
||||
LogEntry.build().actor(sender).acted(track).action("clear").build().submit(plugin);
|
||||
save(track, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
@ -72,9 +72,9 @@ public class TrackInsert extends SubCommand<Track> {
|
||||
track.insertGroup(group, pos - 1);
|
||||
Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), track.getName(), pos);
|
||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName()));
|
||||
LogEntryBuilder.get().actor(sender).acted(track)
|
||||
LogEntry.build().actor(sender).acted(track)
|
||||
.action("insert " + group.getName() + " " + pos)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
save(track, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} catch (ObjectAlreadyHasException e) {
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -52,9 +52,9 @@ public class TrackRemove extends SubCommand<Track> {
|
||||
track.removeGroup(groupName);
|
||||
Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, track.getName());
|
||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups()));
|
||||
LogEntryBuilder.get().actor(sender).acted(track)
|
||||
LogEntry.build().actor(sender).acted(track)
|
||||
.action("remove " + groupName)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
save(track, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} catch (ObjectLacksException e) {
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.users.User;
|
||||
@ -74,24 +74,24 @@ public class UserAddGroup extends SubCommand<User> {
|
||||
if (args.size() == 2) {
|
||||
user.addGroup(group, server);
|
||||
Message.USER_ADDGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("addgroup " + group.getName() + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
user.addGroup(group, server, world);
|
||||
Message.USER_ADDGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("addgroup " + group.getName() + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.addGroup(group);
|
||||
Message.USER_ADDGROUP_SUCCESS.send(sender, user.getName(), groupName);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("addgroup " + group.getName())
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.users.User;
|
||||
@ -90,25 +90,25 @@ public class UserAddTempGroup extends SubCommand<User> {
|
||||
user.addGroup(group, server, duration);
|
||||
Message.USER_ADDTEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server,
|
||||
DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("addtempgroup " + group.getName() + " " + duration + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(3).toLowerCase();
|
||||
user.addGroup(group, server, world, duration);
|
||||
Message.USER_ADDTEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server,
|
||||
world, DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("addtempgroup " + group.getName() + " " + duration + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.addGroup(group, duration);
|
||||
Message.USER_ADDTEMPGROUP_SUCCESS.send(sender, user.getName(), groupName, DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("addtempgroup " + group.getName() + " " + duration)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -45,7 +45,7 @@ public class UserClear extends SubCommand<User> {
|
||||
user.clearNodes();
|
||||
plugin.getUserManager().giveDefaults(user);
|
||||
Message.CLEAR_SUCCESS.send(sender, user.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(user).action("clear").submit(plugin);
|
||||
LogEntry.build().actor(sender).acted(user).action("clear").build().submit(plugin);
|
||||
|
||||
save(user, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
@ -103,9 +103,9 @@ public class UserDemote extends SubCommand<User> {
|
||||
Message.USER_DEMOTE_SUCCESS_PROMOTE.send(sender, track.getName(), old, previousGroup.getName());
|
||||
Message.USER_DEMOTE_SUCCESS_REMOVE.send(sender, user.getName(), old, previousGroup.getName(), previousGroup.getName());
|
||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), previousGroup.getName(), old, true));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("demote " + track.getName() + "(from " + old + " to " + previousGroup.getName() + ")")
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
save(user, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
@ -103,9 +103,9 @@ public class UserPromote extends SubCommand<User> {
|
||||
Message.USER_PROMOTE_SUCCESS_PROMOTE.send(sender, track.getName(), old, nextGroup.getName());
|
||||
Message.USER_PROMOTE_SUCCESS_REMOVE.send(sender, user.getName(), old, nextGroup.getName(), nextGroup.getName());
|
||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), old, nextGroup.getName(), false));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("promote " + track.getName() + "(from " + old + " to " + nextGroup.getName() + ")")
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
save(user, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -68,24 +68,24 @@ public class UserRemoveGroup extends SubCommand<User> {
|
||||
if (args.size() == 2) {
|
||||
user.unsetPermission("group." + groupName, server);
|
||||
Message.USER_REMOVEGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("removegroup " + groupName + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
user.unsetPermission("group." + groupName, server, world);
|
||||
Message.USER_REMOVEGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("removegroup " + groupName + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.unsetPermission("group." + groupName);
|
||||
Message.USER_REMOVEGROUP_SUCCESS.send(sender, user.getName(), groupName);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("removegroup " + groupName)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -63,24 +63,24 @@ public class UserRemoveTempGroup extends SubCommand<User> {
|
||||
if (args.size() == 2) {
|
||||
user.unsetPermission("group." + groupName, server, true);
|
||||
Message.USER_REMOVETEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("removetempgroup " + groupName + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
user.unsetPermission("group." + groupName, server, world, true);
|
||||
Message.USER_REMOVETEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("removetempgroup " + groupName + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.unsetPermission("group." + groupName, true);
|
||||
Message.USER_REMOVETEMPGROUP_SUCCESS.send(sender, user.getName(), groupName);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("removetempgroup " + groupName)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -77,24 +77,24 @@ public class UserSetPermission extends SubCommand<User> {
|
||||
if (args.size() == 3) {
|
||||
user.setPermission(node, b, server);
|
||||
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, user.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("set " + node + " " + b + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(3).toLowerCase();
|
||||
user.setPermission(node, b, server, world);
|
||||
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, user.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("set " + node + " " + b + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.setPermission(node, b);
|
||||
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, user.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("set " + node + " " + b)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
@ -61,9 +61,9 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
|
||||
|
||||
user.setPrimaryGroup(group.getName());
|
||||
Message.USER_PRIMARYGROUP_SUCCESS.send(sender, user.getName(), group.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("setprimarygroup " + group.getName())
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
|
||||
save(user, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -91,24 +91,24 @@ public class UserSetTempPermission extends SubCommand<User> {
|
||||
if (args.size() == 4) {
|
||||
user.setPermission(node, b, server, duration);
|
||||
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, user.getName(), server, DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("settemp " + node + " " + b + " " + duration + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(4).toLowerCase();
|
||||
user.setPermission(node, b, server, world, duration);
|
||||
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, user.getName(), server, world, DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("settemp " + node + " " + b + " " + duration + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.setPermission(node, b, duration);
|
||||
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, user.getName(), DateUtil.formatDateDiff(duration));
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("settemp " + node + " " + b + " " + duration)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -68,24 +68,24 @@ public class UserUnSetPermission extends SubCommand<User> {
|
||||
if (args.size() == 2) {
|
||||
user.unsetPermission(node, server);
|
||||
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("unset " + node + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
user.unsetPermission(node, server, world);
|
||||
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, user.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("unset " + node + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.unsetPermission(node);
|
||||
Message.UNSETPERMISSION_SUCCESS.send(sender, node, user.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("unset " + node)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Patterns;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.data.LogEntryBuilder;
|
||||
import me.lucko.luckperms.data.LogEntry;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
import me.lucko.luckperms.utils.ArgumentChecker;
|
||||
@ -69,24 +69,24 @@ public class UserUnsetTempPermission extends SubCommand<User> {
|
||||
if (args.size() == 2) {
|
||||
user.unsetPermission(node, server, true);
|
||||
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), server);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("unsettemp " + node + " " + server)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
} else {
|
||||
final String world = args.get(2).toLowerCase();
|
||||
user.unsetPermission(node, server, world, true);
|
||||
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, user.getName(), server, world);
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("unsettemp " + node + " " + server + " " + world)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
} else {
|
||||
user.unsetPermission(node, true);
|
||||
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, user.getName());
|
||||
LogEntryBuilder.get().actor(sender).acted(user)
|
||||
LogEntry.build().actor(sender).acted(user)
|
||||
.action("unsettemp " + node)
|
||||
.submit(plugin);
|
||||
.build().submit(plugin);
|
||||
}
|
||||
|
||||
save(user, sender, plugin);
|
||||
|
@ -331,7 +331,8 @@ public abstract class PermissionHolder {
|
||||
|
||||
if (temporary) {
|
||||
match = this.nodes.keySet().stream()
|
||||
.filter(n -> n.contains("$")).filter(n -> Patterns.TEMP_DELIMITER.split(n)[0].equalsIgnoreCase(fNode))
|
||||
.filter(n -> n.contains("$"))
|
||||
.filter(n -> Patterns.TEMP_DELIMITER.split(n)[0].equalsIgnoreCase(fNode))
|
||||
.findFirst();
|
||||
} else {
|
||||
if (this.nodes.containsKey(fNode)) {
|
||||
|
@ -55,7 +55,11 @@ public class UuidCache {
|
||||
public UUID getExternalUUID(UUID internal) {
|
||||
if (onlineMode) return internal;
|
||||
|
||||
Optional<UUID> external = cache.entrySet().stream().filter(e -> e.getValue().equals(internal)).map(Map.Entry::getKey).findFirst();
|
||||
Optional<UUID> external = cache.entrySet().stream()
|
||||
.filter(e -> e.getValue().equals(internal))
|
||||
.map(Map.Entry::getKey)
|
||||
.findFirst();
|
||||
|
||||
return external.isPresent() ? external.get() : internal;
|
||||
}
|
||||
|
||||
|
118
common/src/main/java/me/lucko/luckperms/data/LogEntry.java
Normal file
118
common/src/main/java/me/lucko/luckperms/data/LogEntry.java
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.data;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.api.data.Callback;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.core.PermissionHolder;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
public class LogEntry extends me.lucko.luckperms.api.LogEntry {
|
||||
public static LogEntryBuilder build() {
|
||||
return new LogEntryBuilder();
|
||||
}
|
||||
|
||||
private LogEntry() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void submit(LuckPermsPlugin plugin) {
|
||||
plugin.getDatastore().logAction(this, Callback.empty());
|
||||
|
||||
final String msg = super.getFormatted();
|
||||
|
||||
plugin.getSenders().stream()
|
||||
.filter(Permission.LOG_NOTIFY::isAuthorized)
|
||||
.filter(s -> !plugin.getIgnoringLogs().contains(s.getUuid()))
|
||||
.forEach(s -> Message.LOG.send(s, msg));
|
||||
}
|
||||
|
||||
public static class LogEntryBuilder extends AbstractLogEntryBuilder<LogEntry, LogEntry.LogEntryBuilder> {
|
||||
|
||||
@Override
|
||||
protected LogEntry createObj() {
|
||||
return new LogEntry();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LogEntryBuilder getThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder actor(Sender actor) {
|
||||
super.actorName(actor.getName());
|
||||
super.actor(actor.getUuid());
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder type(String type) {
|
||||
super.type(type.toCharArray()[0]);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder type(Object object) {
|
||||
if (object instanceof User) {
|
||||
super.type('U');
|
||||
} else if (object instanceof Group) {
|
||||
super.type('G');
|
||||
} else if (object instanceof Track) {
|
||||
super.type('T');
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder acted(PermissionHolder acted) {
|
||||
if (acted instanceof User) {
|
||||
super.actedName(((User) acted).getName());
|
||||
super.acted(((User) acted).getUuid());
|
||||
super.type('U');
|
||||
} else if (acted instanceof Group) {
|
||||
super.actedName(((Group) acted).getName());
|
||||
super.type('G');
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder acted(Track track) {
|
||||
super.actedName(track.getName());
|
||||
super.type('T');
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogEntry build() {
|
||||
if (getTimestamp() == 0L) {
|
||||
super.timestamp(System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
|
||||
return super.build();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.data;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.data.Callback;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.constants.Message;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.core.PermissionHolder;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.tracks.Track;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LogEntryBuilder {
|
||||
private long timestamp = 0L;
|
||||
private UUID actor = null;
|
||||
private String actorName = null;
|
||||
private char type = Character.MIN_VALUE;
|
||||
private UUID acted = null;
|
||||
private String actedName = null;
|
||||
private String action = null;
|
||||
|
||||
public static LogEntryBuilder get() {
|
||||
return new LogEntryBuilder();
|
||||
}
|
||||
|
||||
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 actor(Sender actor) {
|
||||
this.actorName = actor.getName();
|
||||
this.actor = actor.getUuid();
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder type(char type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder type(String type) {
|
||||
this.type = type.toCharArray()[0];
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder type(Object object) {
|
||||
if (object instanceof User) {
|
||||
this.type = 'U';
|
||||
} else if (object instanceof Group) {
|
||||
this.type = 'G';
|
||||
} else if (object instanceof Track) {
|
||||
this.type = 'T';
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder acted(UUID acted) {
|
||||
this.acted = acted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder actedName(String actedName) {
|
||||
this.actedName = actedName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder acted(PermissionHolder acted) {
|
||||
if (acted instanceof User) {
|
||||
this.actedName = ((User) acted).getName();
|
||||
this.acted = ((User) acted).getUuid();
|
||||
this.type = 'U';
|
||||
} else if (acted instanceof Group) {
|
||||
this.actedName = ((Group) acted).getName();
|
||||
this.type = 'G';
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder acted(Track track) {
|
||||
this.actedName = track.getName();
|
||||
this.type = 'T';
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogEntryBuilder action(String action) {
|
||||
this.action = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Set<String> getEmpty() {
|
||||
Set<String> s = new HashSet<>();
|
||||
if (actor == null) {
|
||||
s.add("actor");
|
||||
}
|
||||
if (actorName == null) {
|
||||
s.add("actorname");
|
||||
}
|
||||
if (type == Character.MIN_VALUE) {
|
||||
s.add("type");
|
||||
}
|
||||
if (actedName == null) {
|
||||
s.add("actedname");
|
||||
}
|
||||
if (action == null) {
|
||||
s.add("action");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public void submit(LuckPermsPlugin plugin) {
|
||||
final LogEntry entry = build();
|
||||
plugin.getDatastore().logAction(entry, Callback.empty());
|
||||
|
||||
final String msg = entry.getFormatted();
|
||||
|
||||
plugin.getSenders().stream()
|
||||
.filter(Permission.LOG_NOTIFY::isAuthorized)
|
||||
.filter(s -> !plugin.getIgnoringLogs().contains(s.getUuid()))
|
||||
.forEach(s -> Message.LOG.send(s, msg));
|
||||
}
|
||||
|
||||
public LogEntry build() {
|
||||
if (timestamp == 0L) {
|
||||
timestamp = System.currentTimeMillis() / 1000;
|
||||
}
|
||||
|
||||
if (!getEmpty().isEmpty()) {
|
||||
throw new IllegalStateException("Missing values: " + getEmpty().toString());
|
||||
}
|
||||
|
||||
return new LogEntry(timestamp, actor, actorName, type, acted, actedName, action);
|
||||
}
|
||||
}
|
@ -51,6 +51,11 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* check to see if a group inherits a group
|
||||
* @param group The group to check membership of
|
||||
@ -309,9 +314,4 @@ public class Group extends PermissionHolder implements Identifiable<String> {
|
||||
.map(s -> Patterns.DOT.split(s, 2)[1])
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ public class UpdateTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Reload all of the groups
|
||||
// Reload all groups
|
||||
plugin.getDatastore().loadAllGroups();
|
||||
String defaultGroup = plugin.getConfiguration().getDefaultGroupName();
|
||||
if (!plugin.getGroupManager().isLoaded(defaultGroup)) {
|
||||
plugin.getDatastore().createAndLoadGroup(defaultGroup);
|
||||
}
|
||||
|
||||
// Reload all of the tracks
|
||||
// Reload all tracks
|
||||
plugin.getDatastore().loadAllTracks();
|
||||
|
||||
// Refresh all online users.
|
||||
|
@ -385,7 +385,9 @@ public class FlatfileDatastore extends Datastore {
|
||||
public boolean loadAllGroups() {
|
||||
String[] fileNames = groupsDir.list((dir, name) -> name.endsWith(".json"));
|
||||
if (fileNames == null) return false;
|
||||
List<String> groups = Arrays.stream(fileNames).map(s -> s.substring(0, s.length() - 5)).collect(Collectors.toList());
|
||||
List<String> groups = Arrays.stream(fileNames)
|
||||
.map(s -> s.substring(0, s.length() - 5))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
plugin.getGroupManager().unloadAll();
|
||||
groups.forEach(this::loadGroup);
|
||||
@ -511,7 +513,9 @@ public class FlatfileDatastore extends Datastore {
|
||||
public boolean loadAllTracks() {
|
||||
String[] fileNames = tracksDir.list((dir, name) -> name.endsWith(".json"));
|
||||
if (fileNames == null) return false;
|
||||
List<String> tracks = Arrays.stream(fileNames).map(s -> s.substring(0, s.length() - 5)).collect(Collectors.toList());
|
||||
List<String> tracks = Arrays.stream(fileNames)
|
||||
.map(s -> s.substring(0, s.length() - 5))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
plugin.getTrackManager().unloadAll();
|
||||
tracks.forEach(this::loadTrack);
|
||||
|
@ -66,7 +66,7 @@ public class MySQLDatastore extends SQLDatastore {
|
||||
hikari.addDataSourceProperty("password", password);
|
||||
|
||||
if (!setupTables(CREATETABLE_UUID, CREATETABLE_USERS, CREATETABLE_GROUPS, CREATETABLE_TRACKS, CREATETABLE_ACTION)) {
|
||||
plugin.getLog().severe("Error occurred whilst initialising the database. All connections are disallowed.");
|
||||
plugin.getLog().severe("Error occurred whilst initialising the database.");
|
||||
shutdown();
|
||||
} else {
|
||||
setAcceptingLogins(true);
|
||||
|
@ -47,7 +47,7 @@ public class SQLiteDatastore extends SQLDatastore {
|
||||
@Override
|
||||
public void init() {
|
||||
if (!setupTables(CREATETABLE_UUID, CREATETABLE_USERS, CREATETABLE_GROUPS, CREATETABLE_TRACKS, CREATETABLE_ACTION)) {
|
||||
plugin.getLog().severe("Error occurred whilst initialising the database. All connections are disallowed.");
|
||||
plugin.getLog().severe("Error occurred whilst initialising the database.");
|
||||
shutdown();
|
||||
} else {
|
||||
setAcceptingLogins(true);
|
||||
|
@ -51,6 +51,11 @@ public class Track implements Identifiable<String> {
|
||||
*/
|
||||
private List<String> groups = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an ordered list of the groups on this track
|
||||
* @return am ordered {@link List} of the groups on this track
|
||||
@ -201,9 +206,4 @@ public class Track implements Identifiable<String> {
|
||||
throw new ObjectLacksException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ public class TrackManager extends AbstractManager<String, Track> {
|
||||
* @return a set of tracks that the groups could be a member of
|
||||
*/
|
||||
public Set<Track> getApplicableTracks(String group) {
|
||||
return objects.values().stream().filter(t -> t.containsGroup(group)).collect(Collectors.toSet());
|
||||
return objects.values().stream()
|
||||
.filter(t -> t.containsGroup(group))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,6 +75,11 @@ public abstract class User extends PermissionHolder implements Identifiable<UUID
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh and re-assign the users permissions
|
||||
*/
|
||||
@ -320,9 +325,4 @@ public abstract class User extends PermissionHolder implements Identifiable<UUID
|
||||
.map(s -> Patterns.DOT.split(s, 2)[1])
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,9 @@ public abstract class UserManager extends AbstractManager<UUID, User> {
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
public User get(String name) {
|
||||
try {
|
||||
return objects.values().stream().filter(u -> u.getName().equalsIgnoreCase(name)).limit(1).findAny().get();
|
||||
return objects.values().stream()
|
||||
.filter(u -> u.getName().equalsIgnoreCase(name))
|
||||
.limit(1).findAny().get();
|
||||
} catch (NoSuchElementException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public class SpongeListener extends AbstractListener {
|
||||
@Listener
|
||||
public void onClientAuth(ClientConnectionEvent.Auth e) {
|
||||
if (!plugin.getDatastore().isAcceptingLogins()) {
|
||||
// Datastore is disabled, prevent players from joining the server
|
||||
// Just don't load their data, they will be kicked at login
|
||||
/* Datastore is disabled, prevent players from joining the server
|
||||
Just don't load their data, they will be kicked at login */
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import me.lucko.luckperms.LPSpongePlugin;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.util.Tristate;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -58,6 +58,6 @@ class SpongeUser extends User {
|
||||
// Re-add all defined permissions for the user
|
||||
final String world = player.getWorld().getName();
|
||||
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), world, null);
|
||||
local.entrySet().forEach(e -> player.getSubjectData().setPermission(new HashSet<>(), e.getKey(), Tristate.fromBoolean(e.getValue())));
|
||||
local.entrySet().forEach(e -> player.getSubjectData().setPermission(Collections.emptySet(), e.getKey(), Tristate.fromBoolean(e.getValue())));
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class VersionUtil extends ClassTransformer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(final Properties properties) {
|
||||
public void configure(Properties properties) {
|
||||
assert properties != null;
|
||||
version = properties.getProperty("version");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user