refactor LogEntry & cleanup stream formatting

This commit is contained in:
Luck 2016-08-18 00:07:56 +01:00
parent ca9037461a
commit 84afbf26f8
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
49 changed files with 506 additions and 409 deletions

View File

@ -24,19 +24,20 @@ package me.lucko.luckperms.api;
import java.util.UUID; import java.util.UUID;
public final class LogEntry implements Comparable<LogEntry> { public class LogEntry implements Comparable<LogEntry> {
public static LogEntryBuilder builder() { public static LogEntryBuilder builder() {
return new LogEntryBuilder(); return new LogEntryBuilder();
} }
private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s"; private static final String FORMAT = "&8(&e%s&8) [&a%s&8] (&b%s&8) &7--> &f%s";
private final long timestamp; private long timestamp;
private final UUID actor; private UUID actor;
private final String actorName; private String actorName;
private final char type; private char type;
private final UUID acted; private UUID acted;
private final String actedName; private String actedName;
private final String action; private String action;
public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) { public LogEntry(long timestamp, UUID actor, String actorName, char type, UUID acted, String actedName, String action) {
if (actor == null) { if (actor == null) {
@ -61,6 +62,16 @@ public final class LogEntry implements Comparable<LogEntry> {
this.action = action; 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 @Override
public int compareTo(LogEntry o) { public int compareTo(LogEntry o) {
return Long.compare(timestamp, o.getTimestamp()); return Long.compare(timestamp, o.getTimestamp());
@ -109,6 +120,34 @@ public final class LogEntry implements Comparable<LogEntry> {
return action; 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 @Override
public String toString() { public String toString() {
return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" + return "LogEntry(timestamp=" + this.getTimestamp() + ", actor=" + this.getActor() + ", actorName=" +
@ -160,59 +199,116 @@ public final class LogEntry implements Comparable<LogEntry> {
return result; return result;
} }
public static class LogEntryBuilder { public static class LogEntryBuilder extends AbstractLogEntryBuilder<LogEntry, LogEntry.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) { @Override
this.timestamp = timestamp; protected LogEntry createObj() {
return this; return new LogEntry();
} }
public LogEntryBuilder actor(UUID actor) { @Override
this.actor = actor; protected LogEntryBuilder getThis() {
return this; return this;
} }
public LogEntryBuilder actorName(String actorName) {
this.actorName = actorName;
return this;
} }
public LogEntryBuilder type(char type) { public static abstract class AbstractLogEntryBuilder<T extends LogEntry, B extends AbstractLogEntryBuilder<T, B>> {
this.type = type; private T obj;
return this; private B thisObj;
public AbstractLogEntryBuilder() {
obj = createObj();
thisObj = getThis();
} }
public LogEntryBuilder acted(UUID acted) { protected abstract T createObj();
this.acted = acted; protected abstract B getThis();
return this;
public long getTimestamp() {
return obj.getTimestamp();
} }
public LogEntryBuilder actedName(String actedName) { public UUID getActor() {
this.actedName = actedName; return obj.getActor();
return this;
} }
public LogEntryBuilder action(String action) { public String getActorName() {
this.action = action; return obj.getActorName();
return this;
} }
public LogEntry build() { public char getType() {
return new LogEntry(timestamp, actor, actorName, type, acted, actedName, action); return obj.getType();
}
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 @Override
public String toString() { public String toString() {
return "LogEntry.LogEntryBuilder(timestamp=" + this.timestamp + ", actor=" + this.actor + ", actorName=" + return "LogEntry.LogEntryBuilder(timestamp=" + getTimestamp() + ", actor=" + getActor() + ", actorName=" +
this.actorName + ", type=" + this.type + ", acted=" + this.acted + ", actedName=" + this.actedName + getActorName() + ", type=" + getType() + ", acted=" + getActed() + ", actedName=" + getActedName() +
", action=" + this.action + ")"; ", action=" + getAction() + ")";
} }
} }

View File

@ -144,18 +144,28 @@ public class CommandManager {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<String> onTabComplete(Sender sender, List<String> args) { 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.size() <= 1) {
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) { 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) return mains.stream()
.filter(s -> s.startsWith(args.get(0).toLowerCase())).collect(Collectors.toList()); .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()) { if (!o.isPresent()) {
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -76,7 +76,10 @@ public abstract class MainCommand<T> {
return CommandResult.INVALID_ARGS; 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()) { if (!o.isPresent()) {
Message.COMMAND_NOT_RECOGNISED.send(sender); Message.COMMAND_NOT_RECOGNISED.send(sender);
@ -121,7 +124,7 @@ public abstract class MainCommand<T> {
protected abstract void cleanup(T t, LuckPermsPlugin plugin); 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 * @param plugin a link to the main plugin instance
* @return a list of strings * @return a list of strings
*/ */
@ -138,7 +141,10 @@ public abstract class MainCommand<T> {
return; 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) { if (subs.size() > 0) {
Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:"); Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:");
@ -168,20 +174,33 @@ public abstract class MainCommand<T> {
return objects; 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.size() == 2) {
if (args.get(1).equalsIgnoreCase("")) { 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) return subs.stream()
.filter(s -> s.toLowerCase().startsWith(args.get(1).toLowerCase())).collect(Collectors.toList()); .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()) { if (!o.isPresent()) {
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SingleMainCommand; import me.lucko.luckperms.commands.SingleMainCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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 me.lucko.luckperms.utils.ArgumentChecker;
import java.util.List; import java.util.List;
@ -62,7 +62,7 @@ public class CreateGroup extends SingleMainCommand {
} }
Message.CREATE_SUCCESS.send(sender, groupName); 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(); plugin.runUpdateTask();
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SingleMainCommand; import me.lucko.luckperms.commands.SingleMainCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -78,7 +78,7 @@ public class DeleteGroup extends SingleMainCommand {
} }
Message.DELETE_SUCCESS.send(sender, groupName); 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(); plugin.runUpdateTask();
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
@ -92,7 +92,8 @@ public class DeleteGroup extends SingleMainCommand {
return groups; 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(); return Collections.emptyList();

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.groups.Group;
import java.util.List; 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) { public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args, String label) {
group.clearNodes(); group.clearNodes();
Message.CLEAR_SUCCESS.send(sender, group.getName()); 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); save(group, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -74,24 +74,24 @@ public class GroupSetInherit extends SubCommand<Group> {
if (args.size() == 2) { if (args.size() == 2) {
group.setInheritGroup(group1, server); group.setInheritGroup(group1, server);
Message.GROUP_SETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), group1.getName(), 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) .action("setinherit " + group1.getName() + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
group.setInheritGroup(group1, server, world); group.setInheritGroup(group1, server, world);
Message.GROUP_SETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), group1.getName(), 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) .action("setinherit " + group1.getName() + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.setInheritGroup(group1); group.setInheritGroup(group1);
Message.GROUP_SETINHERIT_SUCCESS.send(sender, group.getName(), group1.getName()); 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()) .action("setinherit " + group1.getName())
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -76,24 +76,24 @@ public class GroupSetPermission extends SubCommand<Group> {
if (args.size() == 3) { if (args.size() == 3) {
group.setPermission(node, b, server); group.setPermission(node, b, server);
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, group.getName(), 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) .action("set " + node + " " + b + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(3).toLowerCase(); final String world = args.get(3).toLowerCase();
group.setPermission(node, b, server, world); group.setPermission(node, b, server, world);
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, group.getName(), 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) .action("set " + node + " " + b + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.setPermission(node, b); group.setPermission(node, b);
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, group.getName()); 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) .action("set " + node + " " + b)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -89,25 +89,25 @@ public class GroupSetTempInherit extends SubCommand<Group> {
group.setInheritGroup(group1, server, duration); group.setInheritGroup(group1, server, duration);
Message.GROUP_SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getName(), group1.getName(), server, Message.GROUP_SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getName(), group1.getName(), server,
DateUtil.formatDateDiff(duration)); DateUtil.formatDateDiff(duration));
LogEntryBuilder.get().actor(sender).acted(group) LogEntry.build().actor(sender).acted(group)
.action("settempinherit " + group1.getName() + " " + duration + " " + server) .action("settempinherit " + group1.getName() + " " + duration + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(3).toLowerCase(); final String world = args.get(3).toLowerCase();
group.setInheritGroup(group1, server, world, duration); group.setInheritGroup(group1, server, world, duration);
Message.GROUP_SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), group1.getName(), server, Message.GROUP_SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), group1.getName(), server,
world, DateUtil.formatDateDiff(duration)); world, DateUtil.formatDateDiff(duration));
LogEntryBuilder.get().actor(sender).acted(group) LogEntry.build().actor(sender).acted(group)
.action("settempinherit " + group1.getName() + " " + duration + " " + server + " " + world) .action("settempinherit " + group1.getName() + " " + duration + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.setInheritGroup(group1, duration); group.setInheritGroup(group1, duration);
Message.GROUP_SET_TEMP_INHERIT_SUCCESS.send(sender, group.getName(), group1.getName(), DateUtil.formatDateDiff(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) .action("settempinherit " + group1.getName() + " " + duration)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -92,25 +92,25 @@ public class GroupSetTempPermission extends SubCommand<Group> {
group.setPermission(node, b, server, duration); group.setPermission(node, b, server, duration);
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, group.getName(), server, Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, group.getName(), server,
DateUtil.formatDateDiff(duration)); DateUtil.formatDateDiff(duration));
LogEntryBuilder.get().actor(sender).acted(group) LogEntry.build().actor(sender).acted(group)
.action("settemp " + node + " " + b + " " + duration + " " + server) .action("settemp " + node + " " + b + " " + duration + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(4).toLowerCase(); final String world = args.get(4).toLowerCase();
group.setPermission(node, b, server, world, duration); group.setPermission(node, b, server, world, duration);
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, group.getName(), server, Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, group.getName(), server,
world, DateUtil.formatDateDiff(duration)); world, DateUtil.formatDateDiff(duration));
LogEntryBuilder.get().actor(sender).acted(group) LogEntry.build().actor(sender).acted(group)
.action("settemp " + node + " " + b + " " + duration + " " + server + " " + world) .action("settemp " + node + " " + b + " " + duration + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.setPermission(node, b, duration); group.setPermission(node, b, duration);
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, group.getName(), DateUtil.formatDateDiff(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) .action("settemp " + node + " " + b + " " + duration)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -68,24 +68,24 @@ public class GroupUnSetPermission extends SubCommand<Group> {
if (args.size() == 2) { if (args.size() == 2) {
group.unsetPermission(node, server); group.unsetPermission(node, server);
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), 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) .action("unset " + node + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
group.unsetPermission(node, server, world); group.unsetPermission(node, server, world);
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, group.getName(), 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) .action("unset " + node + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.unsetPermission(node); group.unsetPermission(node);
Message.UNSETPERMISSION_SUCCESS.send(sender, node, group.getName()); Message.UNSETPERMISSION_SUCCESS.send(sender, node, group.getName());
LogEntryBuilder.get().actor(sender).acted(group) LogEntry.build().actor(sender).acted(group)
.action("unset " + node) .action("unset " + node)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -63,24 +63,24 @@ public class GroupUnsetInherit extends SubCommand<Group> {
if (args.size() == 2) { if (args.size() == 2) {
group.unsetPermission("group." + groupName, server); group.unsetPermission("group." + groupName, server);
Message.GROUP_UNSETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), 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) .action("unsetinherit " + groupName + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
group.unsetPermission("group." + groupName, server, world); group.unsetPermission("group." + groupName, server, world);
Message.GROUP_UNSETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), 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) .action("unsetinherit " + groupName + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.unsetPermission("group." + groupName); group.unsetPermission("group." + groupName);
Message.GROUP_UNSETINHERIT_SUCCESS.send(sender, group.getName(), 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) .action("unsetinherit " + groupName)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -63,24 +63,24 @@ public class GroupUnsetTempInherit extends SubCommand<Group> {
if (args.size() == 2) { if (args.size() == 2) {
group.unsetPermission("group." + groupName, server, true); group.unsetPermission("group." + groupName, server, true);
Message.GROUP_UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server); 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) .action("unsettempinherit " + groupName + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
group.unsetPermission("group." + groupName, server, world, true); group.unsetPermission("group." + groupName, server, world, true);
Message.GROUP_UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getName(), groupName, server, world); 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) .action("unsettempinherit " + groupName + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.unsetPermission("group." + groupName, true); group.unsetPermission("group." + groupName, true);
Message.GROUP_UNSET_TEMP_INHERIT_SUCCESS.send(sender, group.getName(), groupName); 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) .action("unsettempinherit " + groupName)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -69,24 +69,24 @@ public class GroupUnsetTempPermission extends SubCommand<Group> {
if (args.size() == 2) { if (args.size() == 2) {
group.unsetPermission(node, server); group.unsetPermission(node, server);
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), 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) .action("unsettemp " + node + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
group.unsetPermission(node, server, world); group.unsetPermission(node, server, world);
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, group.getName(), 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) .action("unsettemp " + node + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
group.unsetPermission(node, true); group.unsetPermission(node, true);
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, group.getName()); 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) .action("unsettemp " + node)
.submit(plugin); .build().submit(plugin);
} }
save(group, sender, plugin); save(group, sender, plugin);

View File

@ -73,17 +73,28 @@ public class LogMainCommand extends MainCommand<Log> {
@Override @Override
protected List<String> onTabComplete(Sender sender, List<String> args, LuckPermsPlugin plugin) { 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.size() <= 1) {
if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) { 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) return subs.stream()
.filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList()); .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()) { if (!o.isPresent()) {
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SingleMainCommand; import me.lucko.luckperms.commands.SingleMainCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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 me.lucko.luckperms.utils.ArgumentChecker;
import java.util.List; import java.util.List;
@ -62,7 +62,7 @@ public class CreateTrack extends SingleMainCommand {
} }
Message.CREATE_SUCCESS.send(sender, trackName); 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(); plugin.runUpdateTask();
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -28,7 +28,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SingleMainCommand; import me.lucko.luckperms.commands.SingleMainCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.tracks.Track;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -72,7 +72,7 @@ public class DeleteTrack extends SingleMainCommand {
} }
Message.DELETE_SUCCESS.send(sender, trackName); 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(); plugin.runUpdateTask();
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }
@ -86,7 +86,9 @@ public class DeleteTrack extends SingleMainCommand {
return tracks; 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(); return Collections.emptyList();

View File

@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.*; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.tracks.Track; import me.lucko.luckperms.tracks.Track;
@ -64,9 +64,9 @@ public class TrackAppend extends SubCommand<Track> {
track.appendGroup(group); track.appendGroup(group);
Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), track.getName()); Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), track.getName());
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.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()) .action("append " + group.getName())
.submit(plugin); .build().submit(plugin);
save(track, sender, plugin); save(track, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} catch (ObjectAlreadyHasException e) { } catch (ObjectAlreadyHasException e) {

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.tracks.Track;
import java.util.List; 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) { public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List<String> args, String label) {
track.clearGroups(); track.clearGroups();
Message.TRACK_CLEAR.send(sender, track.getName()); 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); save(track, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.*; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.tracks.Track; import me.lucko.luckperms.tracks.Track;
@ -72,9 +72,9 @@ public class TrackInsert extends SubCommand<Track> {
track.insertGroup(group, pos - 1); track.insertGroup(group, pos - 1);
Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), track.getName(), pos); Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), track.getName(), pos);
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), group.getName())); 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) .action("insert " + group.getName() + " " + pos)
.submit(plugin); .build().submit(plugin);
save(track, sender, plugin); save(track, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} catch (ObjectAlreadyHasException e) { } catch (ObjectAlreadyHasException e) {

View File

@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.*; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.tracks.Track; import me.lucko.luckperms.tracks.Track;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -52,9 +52,9 @@ public class TrackRemove extends SubCommand<Track> {
track.removeGroup(groupName); track.removeGroup(groupName);
Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, track.getName()); Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, track.getName());
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups())); Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups()));
LogEntryBuilder.get().actor(sender).acted(track) LogEntry.build().actor(sender).acted(track)
.action("remove " + groupName) .action("remove " + groupName)
.submit(plugin); .build().submit(plugin);
save(track, sender, plugin); save(track, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} catch (ObjectLacksException e) { } catch (ObjectLacksException e) {

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
@ -74,24 +74,24 @@ public class UserAddGroup extends SubCommand<User> {
if (args.size() == 2) { if (args.size() == 2) {
user.addGroup(group, server); user.addGroup(group, server);
Message.USER_ADDGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, 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) .action("addgroup " + group.getName() + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
user.addGroup(group, server, world); user.addGroup(group, server, world);
Message.USER_ADDGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, 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) .action("addgroup " + group.getName() + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.addGroup(group); user.addGroup(group);
Message.USER_ADDGROUP_SUCCESS.send(sender, user.getName(), groupName); 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()) .action("addgroup " + group.getName())
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
@ -90,25 +90,25 @@ public class UserAddTempGroup extends SubCommand<User> {
user.addGroup(group, server, duration); user.addGroup(group, server, duration);
Message.USER_ADDTEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server, Message.USER_ADDTEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server,
DateUtil.formatDateDiff(duration)); DateUtil.formatDateDiff(duration));
LogEntryBuilder.get().actor(sender).acted(user) LogEntry.build().actor(sender).acted(user)
.action("addtempgroup " + group.getName() + " " + duration + " " + server) .action("addtempgroup " + group.getName() + " " + duration + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(3).toLowerCase(); final String world = args.get(3).toLowerCase();
user.addGroup(group, server, world, duration); user.addGroup(group, server, world, duration);
Message.USER_ADDTEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, Message.USER_ADDTEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server,
world, DateUtil.formatDateDiff(duration)); world, DateUtil.formatDateDiff(duration));
LogEntryBuilder.get().actor(sender).acted(user) LogEntry.build().actor(sender).acted(user)
.action("addtempgroup " + group.getName() + " " + duration + " " + server + " " + world) .action("addtempgroup " + group.getName() + " " + duration + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.addGroup(group, duration); user.addGroup(group, duration);
Message.USER_ADDTEMPGROUP_SUCCESS.send(sender, user.getName(), groupName, DateUtil.formatDateDiff(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) .action("addtempgroup " + group.getName() + " " + duration)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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 me.lucko.luckperms.users.User;
import java.util.List; import java.util.List;
@ -45,7 +45,7 @@ public class UserClear extends SubCommand<User> {
user.clearNodes(); user.clearNodes();
plugin.getUserManager().giveDefaults(user); plugin.getUserManager().giveDefaults(user);
Message.CLEAR_SUCCESS.send(sender, user.getName()); 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); save(user, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;

View File

@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.*; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import me.lucko.luckperms.groups.Group; 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_PROMOTE.send(sender, track.getName(), old, previousGroup.getName());
Message.USER_DEMOTE_SUCCESS_REMOVE.send(sender, user.getName(), old, previousGroup.getName(), 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)); 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() + ")") .action("demote " + track.getName() + "(from " + old + " to " + previousGroup.getName() + ")")
.submit(plugin); .build().submit(plugin);
save(user, sender, plugin); save(user, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -26,7 +26,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.*; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
import me.lucko.luckperms.groups.Group; 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_PROMOTE.send(sender, track.getName(), old, nextGroup.getName());
Message.USER_PROMOTE_SUCCESS_REMOVE.send(sender, user.getName(), old, nextGroup.getName(), 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)); 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() + ")") .action("promote " + track.getName() + "(from " + old + " to " + nextGroup.getName() + ")")
.submit(plugin); .build().submit(plugin);
save(user, sender, plugin); save(user, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -68,24 +68,24 @@ public class UserRemoveGroup extends SubCommand<User> {
if (args.size() == 2) { if (args.size() == 2) {
user.unsetPermission("group." + groupName, server); user.unsetPermission("group." + groupName, server);
Message.USER_REMOVEGROUP_SERVER_SUCCESS.send(sender, user.getName(), 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) .action("removegroup " + groupName + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
user.unsetPermission("group." + groupName, server, world); user.unsetPermission("group." + groupName, server, world);
Message.USER_REMOVEGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), 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) .action("removegroup " + groupName + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.unsetPermission("group." + groupName); user.unsetPermission("group." + groupName);
Message.USER_REMOVEGROUP_SUCCESS.send(sender, user.getName(), 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) .action("removegroup " + groupName)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -63,24 +63,24 @@ public class UserRemoveTempGroup extends SubCommand<User> {
if (args.size() == 2) { if (args.size() == 2) {
user.unsetPermission("group." + groupName, server, true); user.unsetPermission("group." + groupName, server, true);
Message.USER_REMOVETEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server); 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) .action("removetempgroup " + groupName + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
user.unsetPermission("group." + groupName, server, world, true); user.unsetPermission("group." + groupName, server, world, true);
Message.USER_REMOVETEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world); 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) .action("removetempgroup " + groupName + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.unsetPermission("group." + groupName, true); user.unsetPermission("group." + groupName, true);
Message.USER_REMOVETEMPGROUP_SUCCESS.send(sender, user.getName(), groupName); Message.USER_REMOVETEMPGROUP_SUCCESS.send(sender, user.getName(), groupName);
LogEntryBuilder.get().actor(sender).acted(user) LogEntry.build().actor(sender).acted(user)
.action("removetempgroup " + groupName) .action("removetempgroup " + groupName)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -77,24 +77,24 @@ public class UserSetPermission extends SubCommand<User> {
if (args.size() == 3) { if (args.size() == 3) {
user.setPermission(node, b, server); user.setPermission(node, b, server);
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, user.getName(), 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) .action("set " + node + " " + b + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(3).toLowerCase(); final String world = args.get(3).toLowerCase();
user.setPermission(node, b, server, world); user.setPermission(node, b, server, world);
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, bool, user.getName(), 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) .action("set " + node + " " + b + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.setPermission(node, b); user.setPermission(node, b);
Message.SETPERMISSION_SUCCESS.send(sender, node, bool, user.getName()); 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) .action("set " + node + " " + b)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -29,7 +29,7 @@ import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Permission; 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.groups.Group;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
@ -61,9 +61,9 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
user.setPrimaryGroup(group.getName()); user.setPrimaryGroup(group.getName());
Message.USER_PRIMARYGROUP_SUCCESS.send(sender, user.getName(), 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()) .action("setprimarygroup " + group.getName())
.submit(plugin); .build().submit(plugin);
save(user, sender, plugin); save(user, sender, plugin);
return CommandResult.SUCCESS; return CommandResult.SUCCESS;

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.ObjectAlreadyHasException;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -91,24 +91,24 @@ public class UserSetTempPermission extends SubCommand<User> {
if (args.size() == 4) { if (args.size() == 4) {
user.setPermission(node, b, server, duration); user.setPermission(node, b, server, duration);
Message.SETPERMISSION_TEMP_SERVER_SUCCESS.send(sender, node, bool, user.getName(), server, DateUtil.formatDateDiff(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) .action("settemp " + node + " " + b + " " + duration + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(4).toLowerCase(); final String world = args.get(4).toLowerCase();
user.setPermission(node, b, server, world, duration); user.setPermission(node, b, server, world, duration);
Message.SETPERMISSION_TEMP_SERVER_WORLD_SUCCESS.send(sender, node, bool, user.getName(), server, world, DateUtil.formatDateDiff(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) .action("settemp " + node + " " + b + " " + duration + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.setPermission(node, b, duration); user.setPermission(node, b, duration);
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, bool, user.getName(), DateUtil.formatDateDiff(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) .action("settemp " + node + " " + b + " " + duration)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -68,24 +68,24 @@ public class UserUnSetPermission extends SubCommand<User> {
if (args.size() == 2) { if (args.size() == 2) {
user.unsetPermission(node, server); user.unsetPermission(node, server);
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), 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) .action("unset " + node + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
user.unsetPermission(node, server, world); user.unsetPermission(node, server, world);
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, user.getName(), 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) .action("unset " + node + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.unsetPermission(node); user.unsetPermission(node);
Message.UNSETPERMISSION_SUCCESS.send(sender, node, user.getName()); Message.UNSETPERMISSION_SUCCESS.send(sender, node, user.getName());
LogEntryBuilder.get().actor(sender).acted(user) LogEntry.build().actor(sender).acted(user)
.action("unset " + node) .action("unset " + node)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -30,7 +30,7 @@ import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.constants.Patterns; import me.lucko.luckperms.constants.Patterns;
import me.lucko.luckperms.constants.Permission; 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.exceptions.ObjectLacksException;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.ArgumentChecker; import me.lucko.luckperms.utils.ArgumentChecker;
@ -69,24 +69,24 @@ public class UserUnsetTempPermission extends SubCommand<User> {
if (args.size() == 2) { if (args.size() == 2) {
user.unsetPermission(node, server, true); user.unsetPermission(node, server, true);
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), server); 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) .action("unsettemp " + node + " " + server)
.submit(plugin); .build().submit(plugin);
} else { } else {
final String world = args.get(2).toLowerCase(); final String world = args.get(2).toLowerCase();
user.unsetPermission(node, server, world, true); user.unsetPermission(node, server, world, true);
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, user.getName(), server, world); 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) .action("unsettemp " + node + " " + server + " " + world)
.submit(plugin); .build().submit(plugin);
} }
} else { } else {
user.unsetPermission(node, true); user.unsetPermission(node, true);
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, user.getName()); 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) .action("unsettemp " + node)
.submit(plugin); .build().submit(plugin);
} }
save(user, sender, plugin); save(user, sender, plugin);

View File

@ -331,7 +331,8 @@ public abstract class PermissionHolder {
if (temporary) { if (temporary) {
match = this.nodes.keySet().stream() 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(); .findFirst();
} else { } else {
if (this.nodes.containsKey(fNode)) { if (this.nodes.containsKey(fNode)) {

View File

@ -55,7 +55,11 @@ public class UuidCache {
public UUID getExternalUUID(UUID internal) { public UUID getExternalUUID(UUID internal) {
if (onlineMode) return 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; return external.isPresent() ? external.get() : internal;
} }

View 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();
}
}
}

View File

@ -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);
}
}

View File

@ -51,6 +51,11 @@ public class Group extends PermissionHolder implements Identifiable<String> {
this.name = name; this.name = name;
} }
@Override
public String getId() {
return name;
}
/** /**
* check to see if a group inherits a group * check to see if a group inherits a group
* @param group The group to check membership of * @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]) .map(s -> Patterns.DOT.split(s, 2)[1])
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public String getId() {
return name;
}
} }

View File

@ -31,14 +31,14 @@ public class UpdateTask implements Runnable {
@Override @Override
public void run() { public void run() {
// Reload all of the groups // Reload all groups
plugin.getDatastore().loadAllGroups(); plugin.getDatastore().loadAllGroups();
String defaultGroup = plugin.getConfiguration().getDefaultGroupName(); String defaultGroup = plugin.getConfiguration().getDefaultGroupName();
if (!plugin.getGroupManager().isLoaded(defaultGroup)) { if (!plugin.getGroupManager().isLoaded(defaultGroup)) {
plugin.getDatastore().createAndLoadGroup(defaultGroup); plugin.getDatastore().createAndLoadGroup(defaultGroup);
} }
// Reload all of the tracks // Reload all tracks
plugin.getDatastore().loadAllTracks(); plugin.getDatastore().loadAllTracks();
// Refresh all online users. // Refresh all online users.

View File

@ -385,7 +385,9 @@ public class FlatfileDatastore extends Datastore {
public boolean loadAllGroups() { public boolean loadAllGroups() {
String[] fileNames = groupsDir.list((dir, name) -> name.endsWith(".json")); String[] fileNames = groupsDir.list((dir, name) -> name.endsWith(".json"));
if (fileNames == null) return false; 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(); plugin.getGroupManager().unloadAll();
groups.forEach(this::loadGroup); groups.forEach(this::loadGroup);
@ -511,7 +513,9 @@ public class FlatfileDatastore extends Datastore {
public boolean loadAllTracks() { public boolean loadAllTracks() {
String[] fileNames = tracksDir.list((dir, name) -> name.endsWith(".json")); String[] fileNames = tracksDir.list((dir, name) -> name.endsWith(".json"));
if (fileNames == null) return false; 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(); plugin.getTrackManager().unloadAll();
tracks.forEach(this::loadTrack); tracks.forEach(this::loadTrack);

View File

@ -66,7 +66,7 @@ public class MySQLDatastore extends SQLDatastore {
hikari.addDataSourceProperty("password", password); hikari.addDataSourceProperty("password", password);
if (!setupTables(CREATETABLE_UUID, CREATETABLE_USERS, CREATETABLE_GROUPS, CREATETABLE_TRACKS, CREATETABLE_ACTION)) { 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(); shutdown();
} else { } else {
setAcceptingLogins(true); setAcceptingLogins(true);

View File

@ -47,7 +47,7 @@ public class SQLiteDatastore extends SQLDatastore {
@Override @Override
public void init() { public void init() {
if (!setupTables(CREATETABLE_UUID, CREATETABLE_USERS, CREATETABLE_GROUPS, CREATETABLE_TRACKS, CREATETABLE_ACTION)) { 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(); shutdown();
} else { } else {
setAcceptingLogins(true); setAcceptingLogins(true);

View File

@ -51,6 +51,11 @@ public class Track implements Identifiable<String> {
*/ */
private List<String> groups = Collections.synchronizedList(new ArrayList<>()); private List<String> groups = Collections.synchronizedList(new ArrayList<>());
@Override
public String getId() {
return name;
}
/** /**
* Gets an ordered list of the groups on this track * Gets an ordered list of the groups on this track
* @return am ordered {@link 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(); throw new ObjectLacksException();
} }
} }
@Override
public String getId() {
return name;
}
} }

View File

@ -35,7 +35,9 @@ public class TrackManager extends AbstractManager<String, Track> {
* @return a set of tracks that the groups could be a member of * @return a set of tracks that the groups could be a member of
*/ */
public Set<Track> getApplicableTracks(String group) { 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 @Override

View File

@ -75,6 +75,11 @@ public abstract class User extends PermissionHolder implements Identifiable<UUID
this.name = name; this.name = name;
} }
@Override
public UUID getId() {
return uuid;
}
/** /**
* Refresh and re-assign the users permissions * 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]) .map(s -> Patterns.DOT.split(s, 2)[1])
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public UUID getId() {
return uuid;
}
} }

View File

@ -43,7 +43,9 @@ public abstract class UserManager extends AbstractManager<UUID, User> {
@SuppressWarnings("OptionalGetWithoutIsPresent") @SuppressWarnings("OptionalGetWithoutIsPresent")
public User get(String name) { public User get(String name) {
try { 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) { } catch (NoSuchElementException e) {
return null; return null;
} }

View File

@ -45,8 +45,8 @@ public class SpongeListener extends AbstractListener {
@Listener @Listener
public void onClientAuth(ClientConnectionEvent.Auth e) { public void onClientAuth(ClientConnectionEvent.Auth e) {
if (!plugin.getDatastore().isAcceptingLogins()) { if (!plugin.getDatastore().isAcceptingLogins()) {
// Datastore is disabled, prevent players from joining the server /* Datastore is disabled, prevent players from joining the server
// Just don't load their data, they will be kicked at login Just don't load their data, they will be kicked at login */
return; return;
} }

View File

@ -26,7 +26,7 @@ import me.lucko.luckperms.LPSpongePlugin;
import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.util.Tristate; import org.spongepowered.api.util.Tristate;
import java.util.HashSet; import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -58,6 +58,6 @@ class SpongeUser extends User {
// Re-add all defined permissions for the user // Re-add all defined permissions for the user
final String world = player.getWorld().getName(); final String world = player.getWorld().getName();
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), world, null); 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())));
} }
} }

View File

@ -60,7 +60,7 @@ public class VersionUtil extends ClassTransformer {
} }
@Override @Override
public void configure(final Properties properties) { public void configure(Properties properties) {
assert properties != null; assert properties != null;
version = properties.getProperty("version"); version = properties.getProperty("version");
} }