Add logging for the migration processes

This commit is contained in:
Luck 2016-08-23 15:18:20 +01:00
parent 9cd4e01d8e
commit e89444141b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
6 changed files with 803 additions and 284 deletions

View File

@ -28,7 +28,9 @@ import me.lucko.luckperms.commands.CommandResult;
import me.lucko.luckperms.commands.Predicate;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Constants;
import me.lucko.luckperms.constants.Permission;
import me.lucko.luckperms.data.LogEntry;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.utils.ArgumentChecker;
import net.alpenblock.bungeeperms.*;
@ -55,103 +57,90 @@ public class MigrationBungeePerms extends SubCommand<Object> {
return CommandResult.STATE_ERROR;
}
// Migrate all users.
log.info("BungeePerms Migration: Starting user migration.");
int userCount = 0;
for (User u : bp.getPermissionsManager().getBackEnd().loadUsers()) {
if (u.getUUID() == null) continue;
userCount++;
plugin.getDatastore().loadOrCreateUser(u.getUUID(), "null");
me.lucko.luckperms.users.User user = plugin.getUserManager().get(u.getUUID());
for (String perm : u.getPerms()) {
try {
user.setPermission(perm, true);
} catch (ObjectAlreadyHasException ignored) {}
}
for (Map.Entry<String, Server> e : u.getServers().entrySet()) {
for (String perm : e.getValue().getPerms()) {
try {
user.setPermission(perm, true, e.getKey());
} catch (ObjectAlreadyHasException ignored) {}
}
for (Map.Entry<String, World> we : e.getValue().getWorlds().entrySet()) {
for (String perm : we.getValue().getPerms()) {
try {
user.setPermission(perm, true, e.getKey(), we.getKey());
} catch (ObjectAlreadyHasException ignored) {}
}
}
}
for (String group : u.getGroupsString()) {
try {
user.setPermission("group." + group, true);
} catch (ObjectAlreadyHasException ignored) {}
}
String prefix = u.getPrefix();
String suffix = u.getSuffix();
if (prefix != null && !prefix.equals("")) {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
user.setPermission("prefix.100." + prefix, true);
} catch (ObjectAlreadyHasException ignored) {}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
user.setPermission("suffix.100." + suffix, true);
} catch (ObjectAlreadyHasException ignored) {}
}
plugin.getDatastore().saveUser(user);
plugin.getUserManager().cleanup(user);
}
log.info("BungeePerms Migration: Migrated " + userCount + " users.");
// Migrate all groups.
log.info("BungeePerms Migration: Starting group migration.");
int groupCount = 0;
for (Group g : bp.getPermissionsManager().getBackEnd().loadGroups()) {
groupCount ++;
// Make a LuckPerms group for the one being migrated
plugin.getDatastore().createAndLoadGroup(g.getName().toLowerCase());
me.lucko.luckperms.groups.Group group = plugin.getGroupManager().get(g.getName().toLowerCase());
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
// Migrate global perms
for (String perm : g.getPerms()) {
try {
group.setPermission(perm, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + perm + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate per-server perms
for (Map.Entry<String, Server> e : g.getServers().entrySet()) {
for (String perm : e.getValue().getPerms()) {
try {
group.setPermission(perm, true, e.getKey());
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + perm + " true " + e.getKey())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate per-world perms
for (Map.Entry<String, World> we : e.getValue().getWorlds().entrySet()) {
for (String perm : we.getValue().getPerms()) {
try {
group.setPermission(perm, true, e.getKey(), we.getKey());
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + perm + " true " + e.getKey() + " " + we.getKey())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
// Migrate any parent groups
for (String inherit : g.getInheritances()) {
try {
group.setPermission("group." + inherit, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("setinherit " + group)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate prefix and suffix
String prefix = g.getPrefix();
String suffix = g.getSuffix();
@ -159,22 +148,152 @@ public class MigrationBungeePerms extends SubCommand<Object> {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
group.setPermission("prefix.50." + prefix, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set prefix.50." + prefix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
group.setPermission("suffix.50." + suffix, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set suffix.50." + suffix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getDatastore().saveGroup(group);
}
log.info("BungeePerms Migration: Migrated " + groupCount + " groups");
// Migrate all users.
log.info("BungeePerms Migration: Starting user migration.");
int userCount = 0;
for (User u : bp.getPermissionsManager().getBackEnd().loadUsers()) {
if (u.getUUID() == null) continue;
userCount++;
// Make a LuckPerms user for the one being migrated.
plugin.getDatastore().loadOrCreateUser(u.getUUID(), "null");
me.lucko.luckperms.users.User user = plugin.getUserManager().get(u.getUUID());
// Migrate global perms
for (String perm : u.getPerms()) {
try {
user.setPermission(perm, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set " + perm + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate per-server perms
for (Map.Entry<String, Server> e : u.getServers().entrySet()) {
for (String perm : e.getValue().getPerms()) {
try {
user.setPermission(perm, true, e.getKey());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set " + perm + " true " + e.getKey())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate per-world perms
for (Map.Entry<String, World> we : e.getValue().getWorlds().entrySet()) {
for (String perm : we.getValue().getPerms()) {
try {
user.setPermission(perm, true, e.getKey(), we.getKey());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set " + perm + " true " + e.getKey() + " " + we.getKey())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
// Migrate groups
for (String group : u.getGroupsString()) {
try {
user.setPermission("group." + group, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + group)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
// Migrate prefix & suffix
String prefix = u.getPrefix();
String suffix = u.getSuffix();
if (prefix != null && !prefix.equals("")) {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
user.setPermission("prefix.100." + prefix, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set prefix.100." + prefix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
user.setPermission("suffix.100." + suffix, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set suffix.100." + suffix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getDatastore().saveUser(user);
plugin.getUserManager().cleanup(user);
}
log.info("BungeePerms Migration: Migrated " + userCount + " users.");
log.info("BungeePerms Migration: Success! Completed without any errors.");
return CommandResult.SUCCESS;
}

View File

@ -28,7 +28,9 @@ import me.lucko.luckperms.commands.CommandResult;
import me.lucko.luckperms.commands.Predicate;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Constants;
import me.lucko.luckperms.constants.Permission;
import me.lucko.luckperms.data.LogEntry;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import org.anjocaido.groupmanager.GlobalGroups;
import org.anjocaido.groupmanager.GroupManager;
@ -38,10 +40,7 @@ import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
public class MigrationGroupManager extends SubCommand<Object> {
@ -78,29 +77,56 @@ public class MigrationGroupManager extends SubCommand<Object> {
for (Group g : gg.getGroupList()) {
plugin.getDatastore().createAndLoadGroup(g.getName().toLowerCase());
me.lucko.luckperms.groups.Group group = plugin.getGroupManager().get(g.getName().toLowerCase());
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
for (String node : g.getPermissionList()) {
boolean value = true;
if (node.startsWith("!")) {
if (node.startsWith("!") || node.startsWith("-")) {
node = node.substring(1);
value = false;
} else if (node.startsWith("+")) {
node = node.substring(1);
value = true;
}
try {
group.setPermission(node, value);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + node + " " + value)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
for (String s : g.getInherits()) {
try {
group.setPermission("group." + s.toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("setinherit " + s.toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
Map<UUID, Map<String, Boolean>> users = new HashMap<>();
Map<String, Map<String, Boolean>> groups = new HashMap<>();
Map<UUID, Map<Map.Entry<String, String>, Boolean>> users = new HashMap<>();
Map<String, Map<Map.Entry<String, String>, Boolean>> groups = new HashMap<>();
WorldsHolder wh;
try {
@ -129,16 +155,19 @@ public class MigrationGroupManager extends SubCommand<Object> {
for (String node : g.getPermissionList()) {
boolean value = true;
if (node.startsWith("!")) {
if (node.startsWith("!") || node.startsWith("-")) {
node = node.substring(1);
value = false;
} else if (node.startsWith("+")) {
node = node.substring(1);
value = true;
}
groups.get(g.getName().toLowerCase()).put("global-" + world + "/" + node, value);
groups.get(g.getName().toLowerCase()).put(new AbstractMap.SimpleEntry<>(world, node), value);
}
for (String s : g.getInherits()) {
groups.get(g.getName().toLowerCase()).put("global-" + world + "/group." + s.toLowerCase(), true);
groups.get(g.getName().toLowerCase()).put(new AbstractMap.SimpleEntry<>(world, "group." + s.toLowerCase()), true);
}
}
@ -154,15 +183,18 @@ public class MigrationGroupManager extends SubCommand<Object> {
for (String node : user.getPermissionList()) {
boolean value = true;
if (node.startsWith("!")) {
if (node.startsWith("!") || node.startsWith("-")) {
node = node.substring(1);
value = false;
} else if (node.startsWith("+")) {
node = node.substring(1);
value = true;
}
users.get(uuid).put("global-" + world + "/" + node, value);
users.get(uuid).put(new AbstractMap.SimpleEntry<>(world, node), value);
}
users.get(uuid).put("global-" + world + "/group." + user.getGroupName().toLowerCase(), true);
users.get(uuid).put(new AbstractMap.SimpleEntry<>(world, "group." + user.getGroupName().toLowerCase()), true);
}
}
@ -170,33 +202,84 @@ public class MigrationGroupManager extends SubCommand<Object> {
log.info("GroupManager Migration: All existing GroupManager data has been processed. Now beginning the import process.");
log.info("GroupManager Migration: Found a total of " + users.size() + " users and " + groups.size() + " groups.");
for (Map.Entry<UUID, Map<String, Boolean>> e : users.entrySet()) {
for (Map.Entry<String, Map<Map.Entry<String, String>, Boolean>> e : groups.entrySet()) {
plugin.getDatastore().createAndLoadGroup(e.getKey());
me.lucko.luckperms.groups.Group group = plugin.getGroupManager().get(e.getKey());
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
for (Map.Entry<Map.Entry<String, String>, Boolean> n : e.getValue().entrySet()) {
// n.key.key = world
// n.key.value = node
// n.value = true/false
try {
group.setPermission("global-" + n.getKey().getKey() + "/" + n.getKey().getValue(), n.getValue());
if (n.getKey().getValue().startsWith("group.")) {
String groupName = n.getKey().getValue().substring(6);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("setinherit " + groupName + " global " + n.getKey().getKey())
.build().submit(plugin);
} else {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + n.getKey().getValue() + " " + n.getValue() + " global " + n.getKey().getKey())
.build().submit(plugin);
}
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getDatastore().saveGroup(group);
}
for (Map.Entry<UUID, Map<Map.Entry<String, String>, Boolean>> e : users.entrySet()) {
plugin.getDatastore().loadOrCreateUser(e.getKey(), "null");
me.lucko.luckperms.users.User user = plugin.getUserManager().get(e.getKey());
for (Map.Entry<String, Boolean> n : e.getValue().entrySet()) {
for (Map.Entry<Map.Entry<String, String>, Boolean> n : e.getValue().entrySet()) {
// n.key.key = world
// n.key.value = node
// n.value = true/false
try {
user.setPermission(n.getKey(), n.getValue());
} catch (ObjectAlreadyHasException ignored) {}
user.setPermission("global-" + n.getKey().getKey() + "/" + n.getKey().getValue(), n.getValue());
if (n.getKey().getValue().startsWith("group.")) {
String group = n.getKey().getValue().substring(6);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + group + " global " + n.getKey().getKey())
.build().submit(plugin);
} else {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set " + n.getKey().getValue() + " " + n.getValue() + " global " + n.getKey().getKey())
.build().submit(plugin);
}
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getDatastore().saveUser(user);
plugin.getUserManager().cleanup(user);
}
for (Map.Entry<String, Map<String, Boolean>> e : groups.entrySet()) {
plugin.getDatastore().createAndLoadGroup(e.getKey());
me.lucko.luckperms.groups.Group group = plugin.getGroupManager().get(e.getKey());
for (Map.Entry<String, Boolean> n : e.getValue().entrySet()) {
try {
group.setPermission(n.getKey(), n.getValue());
} catch (ObjectAlreadyHasException ignored) {}
}
plugin.getDatastore().saveGroup(group);
}
log.info("GroupManager Migration: Success! Completed without any errors.");
return CommandResult.SUCCESS;
}

View File

@ -28,7 +28,9 @@ import me.lucko.luckperms.commands.CommandResult;
import me.lucko.luckperms.commands.Predicate;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Constants;
import me.lucko.luckperms.constants.Permission;
import me.lucko.luckperms.data.LogEntry;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.users.User;
@ -119,6 +121,140 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
return CommandResult.FAILURE;
}
// Migrate all groups.
log.info("PermissionsEx Migration: Starting group migration.");
int groupCount = 0;
for (PermissionGroup group : manager.getGroupList()) {
groupCount ++;
final String name = group.getName().toLowerCase();
plugin.getDatastore().createAndLoadGroup(name);
Group lpGroup = plugin.getGroupManager().get(name);
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
try {
for (String node : group.getOwnPermissions(null)) {
boolean value = true;
if (node.startsWith("!")) {
node = node.substring(1);
value = false;
}
try {
lpGroup.setPermission(node, value);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("set " + node + " " + value)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
} catch (NullPointerException ignored) {
// Probably won't happen. I have no API docs on getOwnPermissions#null though.
}
if (worlds != null && !worlds.isEmpty()) {
for (String world : worlds) {
for (String node : group.getOwnPermissions(world)) {
boolean value = true;
if (node.startsWith("!")) {
node = node.substring(1);
value = false;
}
try {
lpGroup.setPermission(node, value, "global", world);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("set " + node + " " + value + " global " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
for (PermissionGroup g : group.getParents()) {
try {
lpGroup.setPermission("group." + g.getName().toLowerCase(), true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("setinherit " + g.getName().toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (worlds != null && !worlds.isEmpty()) {
for (String world : worlds) {
for (PermissionGroup g : group.getParents(world)) {
try {
lpGroup.setPermission("group." + g.getName().toLowerCase(), true, "global", world);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("setinherit " + g.getName().toLowerCase() + " global " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
String prefix = group.getOwnPrefix();
String suffix = group.getOwnSuffix();
if (prefix != null && !prefix.equals("")) {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
lpGroup.setPermission("prefix.50." + prefix, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("set prefix.50." + prefix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
lpGroup.setPermission("suffix.50." + suffix, true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpGroup).action("set suffix.50." + suffix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
log.info("PermissionsEx Migration: Migrated " + groupCount + " groups");
// Migrate all users
log.info("PermissionsEx Migration: Starting user migration.");
int userCount = 0;
@ -163,7 +299,15 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
try {
lpUser.setPermission(node, value);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpUser).action("set " + node + " " + value)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
} catch (NullPointerException ignored) {
// Probably won't happen. I have no API docs on getOwnPermissions#null though.
@ -180,7 +324,15 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
try {
lpUser.setPermission(node, value, "global", world);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpUser).action("set " + node + " " + value + " global " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
@ -188,7 +340,15 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
for (String s : user.getGroupNames()) {
try {
lpUser.setPermission("group." + s.toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpUser).action("addgroup " + s.toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (worlds != null && !worlds.isEmpty()) {
@ -196,7 +356,15 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
for (String s : user.getGroupNames(world)) {
try {
lpUser.setPermission("group." + s.toLowerCase(), true, "global", world);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpUser).action("addgroup " + s.toLowerCase() + " global " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
@ -208,14 +376,30 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
lpUser.setPermission("prefix.100." + prefix, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpUser).action("set prefix.100." + prefix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
lpUser.setPermission("suffix.100." + suffix, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(lpUser).action("set suffix.100." + suffix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getUserManager().cleanup(lpUser);
@ -223,84 +407,6 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
}
log.info("PermissionsEx Migration: Migrated " + userCount + " users.");
// Migrate all groups.
log.info("PermissionsEx Migration: Starting group migration.");
int groupCount = 0;
for (PermissionGroup group : manager.getGroupList()) {
groupCount ++;
final String name = group.getName().toLowerCase();
plugin.getDatastore().createAndLoadGroup(name);
Group lpGroup = plugin.getGroupManager().get(name);
try {
for (String node : group.getOwnPermissions(null)) {
boolean value = true;
if (node.startsWith("!")) {
node = node.substring(1);
value = false;
}
try {
lpGroup.setPermission(node, value);
} catch (ObjectAlreadyHasException ignored) {}
}
} catch (NullPointerException ignored) {
// Probably won't happen. I have no API docs on getOwnPermissions#null though.
}
if (worlds != null && !worlds.isEmpty()) {
for (String world : worlds) {
for (String node : group.getOwnPermissions(world)) {
boolean value = true;
if (node.startsWith("!")) {
node = node.substring(1);
value = false;
}
try {
lpGroup.setPermission(node, value, "global", world);
} catch (ObjectAlreadyHasException ignored) {}
}
}
}
for (PermissionGroup g : group.getParents()) {
try {
lpGroup.setPermission("group." + g.getName().toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
}
if (worlds != null && !worlds.isEmpty()) {
for (String world : worlds) {
for (PermissionGroup g : group.getParents(world)) {
try {
lpGroup.setPermission("group." + g.getName().toLowerCase(), true, "global", world);
} catch (ObjectAlreadyHasException ignored) {}
}
}
}
String prefix = group.getOwnPrefix();
String suffix = group.getOwnSuffix();
if (prefix != null && !prefix.equals("")) {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
lpGroup.setPermission("prefix.50." + prefix, true);
} catch (ObjectAlreadyHasException ignored) {}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
lpGroup.setPermission("suffix.50." + suffix, true);
} catch (ObjectAlreadyHasException ignored) {}
}
}
log.info("PermissionsEx Migration: Migrated " + groupCount + " groups");
log.info("PermissionsEx Migration: Success! Completed without any errors.");
return CommandResult.SUCCESS;
}

View File

@ -31,7 +31,9 @@ import me.lucko.luckperms.commands.CommandResult;
import me.lucko.luckperms.commands.Predicate;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Constants;
import me.lucko.luckperms.core.PermissionHolder;
import me.lucko.luckperms.data.LogEntry;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.users.User;
@ -155,6 +157,45 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
PowerfulPermsPlugin ppPlugin = (PowerfulPermsPlugin) plugin.getPlugin("PowerfulPerms");
PermissionManager pm = ppPlugin.getPermissionManager();
// Groups first.
log.info("PowerfulPerms Migration: Starting group migration.");
Map<Integer, Group> groups = pm.getGroups();
for (Group g : groups.values()) {
plugin.getDatastore().createAndLoadGroup(g.getName().toLowerCase());
final me.lucko.luckperms.groups.Group group = plugin.getGroupManager().get(g.getName().toLowerCase());
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
for (Permission p : g.getOwnPermissions()) {
applyPerm(group, p, plugin);
}
for (Group parent : g.getParents()) {
try {
group.setPermission("group." + parent.getName().toLowerCase(), true);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("setinherit " + parent.getName().toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getDatastore().saveGroup(group);
}
log.info("PowerfulPerms Migration: Group migration complete.");
// Now users.
log.info("PowerfulPerms Migration: Starting user migration.");
final Map<UUID, CountDownLatch> progress = new HashMap<>();
// Migrate all users and their groups
@ -170,7 +211,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
@Override
public void run() {
List<Permission> perms = this.getResult();
perms.forEach(p -> applyPerm(user, p));
perms.forEach(p -> applyPerm(user, p, plugin));
// Update the progress so the user can be saved and unloaded.
synchronized (progress) {
@ -216,11 +257,27 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
if (server == null) {
try {
user.setPermission("group." + g.getName().toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + g.getName().toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
} else {
try {
user.setPermission("group." + g.getName().toLowerCase(), true, server);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + g.getName().toLowerCase() + " " + server)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
});
@ -233,22 +290,54 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
if (server == null) {
try {
user.setPermission("group." + group.getName().toLowerCase(), true, g.getExpirationDate().getTime() / 1000L);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addtempgroup " + group.getName().toLowerCase() + " " + g.getExpirationDate().getTime() / 1000L)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
} else {
try {
user.setPermission("group." + group.getName().toLowerCase(), true, server, g.getExpirationDate().getTime() / 1000L);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addtempgroup " + group.getName().toLowerCase() + " " + g.getExpirationDate().getTime() / 1000L + " " + server)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
} else {
if (server == null) {
try {
user.setPermission("group." + group.getName().toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + group.getName().toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
} else {
try {
user.setPermission("group." + group.getName().toLowerCase(), true, server);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + group.getName().toLowerCase() + " " + server)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
});
@ -271,33 +360,9 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
}
}
// The user processes will run individually in separate threads.
// In the meantime, it's should be safe to load in the groups on this thread.
log.info("PowerfulPerms Migration: User migration is now running. Starting group migration.");
// Let's import groups. yay
Map<Integer, Group> groups = pm.getGroups();
for (Group g : groups.values()) {
plugin.getDatastore().createAndLoadGroup(g.getName().toLowerCase());
final me.lucko.luckperms.groups.Group group = plugin.getGroupManager().get(g.getName().toLowerCase());
for (Permission p : g.getOwnPermissions()) {
applyPerm(group, p);
}
for (Group parent : g.getParents()) {
try {
group.setPermission("group." + parent.getName().toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
}
plugin.getDatastore().saveGroup(group);
}
// All groups are now migrated, but there may still be some users being migrated.
// All groups are migrated, but there may still be some users being migrated.
// This block will wait for all users to be completed.
log.info("PowerfulPerms Migration: All groups are now migrated. Waiting for user migration to complete.");
log.info("PowerfulPerms Migration: This may take some time.");
log.info("PowerfulPerms Migration: Waiting for user migration to complete. This may take some time");
boolean sleep = true;
while (sleep) {
sleep = false;
@ -324,7 +389,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
return CommandResult.SUCCESS;
}
private void applyPerm(PermissionHolder holder, Permission p) {
private void applyPerm(PermissionHolder holder, Permission p, LuckPermsPlugin plugin) {
String node = p.getPermissionString();
boolean value = true;
if (node.startsWith("!")) {
@ -357,14 +422,26 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
if (expireAt == 0L) {
try {
holder.setPermission(node, value, server, world);
} catch (ObjectAlreadyHasException e) {
e.printStackTrace();
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + node + " " + value + " " + server + " " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
} else {
try {
holder.setPermission(node, value, server, world, expireAt);
} catch (ObjectAlreadyHasException e) {
e.printStackTrace();
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("settemp " + node + " " + value + " " + expireAt + " " + server + " " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
@ -372,21 +449,53 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
if (expireAt == 0L) {
try {
holder.setPermission(node, value, server);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + node + " " + value + " " + server)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
} else {
try {
holder.setPermission(node, value, server, expireAt);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("settemp " + node + " " + value + " " + expireAt + " " + server)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
} else {
if (expireAt == 0L) {
try {
holder.setPermission(node, value);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("set " + node + " " + value)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
} else {
try {
holder.setPermission(node, value, expireAt);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(holder).action("settemp " + node + " " + value + " " + expireAt)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}

View File

@ -28,7 +28,9 @@ import me.lucko.luckperms.commands.CommandResult;
import me.lucko.luckperms.commands.Predicate;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.constants.Constants;
import me.lucko.luckperms.constants.Permission;
import me.lucko.luckperms.data.LogEntry;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.tracks.Track;
@ -69,6 +71,84 @@ public class MigrationZPermissions extends SubCommand<Object> {
.map(String::toLowerCase)
.collect(Collectors.toList());
// Migrate all groups
log.info("zPermissions Migration: Starting group migration.");
for (String g : service.getAllGroups()) {
plugin.getDatastore().createAndLoadGroup(g.toLowerCase());
Group group = plugin.getGroupManager().get(g.toLowerCase());
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
for (Map.Entry<String, Boolean> e : service.getGroupPermissions(null, null, g).entrySet()) {
try {
group.setPermission(e.getKey(), e.getValue());
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + e.getKey() + " " + e.getValue())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (worlds != null && !worlds.isEmpty()) {
for (String world : worlds) {
for (Map.Entry<String, Boolean> e : service.getGroupPermissions(world, null, g).entrySet()) {
try {
group.setPermission(e.getKey(), e.getValue(), "global", world);
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(group).action("set " + e.getKey() + " true " + e.getValue() + " " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
plugin.getDatastore().saveGroup(group);
}
// Migrate all tracks
log.info("zPermissions Migration: Starting track migration.");
for (String t : service.getAllTracks()) {
plugin.getDatastore().createAndLoadTrack(t.toLowerCase());
Track track = plugin.getTrackManager().get(t.toLowerCase());
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(track).action("create")
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
track.setGroups(service.getTrackGroups(t));
for (String group : track.getGroups()) {
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(track).action("append " + group)
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
}
plugin.getDatastore().saveTrack(track);
}
// Migrate all users.
log.info("zPermissions Migration: Starting user migration.");
for (UUID u : service.getAllPlayersUUID()) {
@ -78,7 +158,15 @@ public class MigrationZPermissions extends SubCommand<Object> {
for (Map.Entry<String, Boolean> e : service.getPlayerPermissions(null, null, u).entrySet()) {
try {
user.setPermission(e.getKey(), e.getValue());
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set " + e.getKey() + " " + e.getValue())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (worlds != null && !worlds.isEmpty()) {
@ -86,7 +174,15 @@ public class MigrationZPermissions extends SubCommand<Object> {
for (Map.Entry<String, Boolean> e : service.getPlayerPermissions(world, null, u).entrySet()) {
try {
user.setPermission(e.getKey(), e.getValue(), "global", world);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set " + e.getKey() + " true " + e.getValue() + " " + world)
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
}
}
@ -94,10 +190,26 @@ public class MigrationZPermissions extends SubCommand<Object> {
for (String g : service.getPlayerAssignedGroups(u)) {
try {
user.setPermission("group." + g.toLowerCase(), true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("addgroup " + g.toLowerCase())
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
user.setPrimaryGroup(service.getPlayerPrimaryGroup(u));
try {
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("setprimarygroup " + service.getPlayerPrimaryGroup(u))
.build().submit(plugin);
} catch (Exception ex) {
ex.printStackTrace();
}
String prefix = service.getPlayerPrefix(u);
String suffix = service.getPlayerSuffix(u);
@ -106,56 +218,36 @@ public class MigrationZPermissions extends SubCommand<Object> {
prefix = ArgumentChecker.escapeCharacters(prefix);
try {
user.setPermission("prefix.100." + prefix, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set prefix.100." + prefix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
if (suffix != null && !suffix.equals("")) {
suffix = ArgumentChecker.escapeCharacters(suffix);
try {
user.setPermission("suffix.100." + suffix, true);
} catch (ObjectAlreadyHasException ignored) {}
LogEntry.build()
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
.acted(user).action("set suffix.100." + suffix + " true")
.build().submit(plugin);
} catch (Exception ex) {
if (!(ex instanceof ObjectAlreadyHasException)) {
ex.printStackTrace();
}
}
}
plugin.getUserManager().cleanup(user);
plugin.getDatastore().saveUser(user);
}
// Migrate all tracks
log.info("zPermissions Migration: Starting track migration.");
for (String t : service.getAllTracks()) {
plugin.getDatastore().createAndLoadTrack(t.toLowerCase());
Track track = plugin.getTrackManager().get(t.toLowerCase());
track.setGroups(service.getTrackGroups(t));
plugin.getDatastore().saveTrack(track);
}
// Migrate all groups
log.info("zPermissions Migration: Starting group migration.");
for (String g : service.getAllGroups()) {
plugin.getDatastore().createAndLoadGroup(g.toLowerCase());
Group group = plugin.getGroupManager().get(g.toLowerCase());
for (Map.Entry<String, Boolean> e : service.getGroupPermissions(null, null, g).entrySet()) {
try {
group.setPermission(e.getKey(), e.getValue());
} catch (ObjectAlreadyHasException ignored) {}
}
if (worlds != null && !worlds.isEmpty()) {
for (String world : worlds) {
for (Map.Entry<String, Boolean> e : service.getGroupPermissions(world, null, g).entrySet()) {
try {
group.setPermission(e.getKey(), e.getValue(), "global", world);
} catch (ObjectAlreadyHasException ignored) {}
}
}
}
plugin.getDatastore().saveGroup(group);
}
log.info("zPermissions Migration: Success! Completed without any errors.");
return CommandResult.SUCCESS;
}

View File

@ -44,6 +44,10 @@ public class LogEntry extends me.lucko.luckperms.api.LogEntry {
super();
}
public void submit(LuckPermsPlugin plugin) {
submit(plugin, null);
}
public void submit(LuckPermsPlugin plugin, Sender sender) {
plugin.getDatastore().logAction(this);
@ -58,11 +62,17 @@ public class LogEntry extends me.lucko.luckperms.api.LogEntry {
.collect(Collectors.toList());
senders.add(plugin.getConsoleSender());
if (sender == null) {
senders.stream()
.filter(s -> !plugin.getIgnoringLogs().contains(s.getUuid()))
.forEach(s -> Message.LOG.send(s, msg));
} else {
senders.stream()
.filter(s -> !plugin.getIgnoringLogs().contains(s.getUuid()))
.filter(s -> !s.getUuid().equals(sender.getUuid()))
.forEach(s -> Message.LOG.send(s, msg));
}
}
public static class LogEntryBuilder extends AbstractLogEntryBuilder<LogEntry, LogEntry.LogEntryBuilder> {