mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Remove console only commands - closes #137
This commit is contained in:
parent
a152cc47c7
commit
2e16844141
@ -29,7 +29,6 @@ import de.bananaco.bpermissions.api.Permission;
|
|||||||
import de.bananaco.bpermissions.api.World;
|
import de.bananaco.bpermissions.api.World;
|
||||||
import de.bananaco.bpermissions.api.WorldManager;
|
import de.bananaco.bpermissions.api.WorldManager;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
@ -37,6 +36,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.core.model.PermissionHolder;
|
import me.lucko.luckperms.common.core.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -50,6 +50,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
|
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
|
||||||
|
|
||||||
@ -177,31 +178,35 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting bPermissions migration.");
|
||||||
|
|
||||||
WorldManager worldManager = WorldManager.getInstance();
|
WorldManager worldManager = WorldManager.getInstance();
|
||||||
if (worldManager == null) {
|
if (worldManager == null) {
|
||||||
log.severe("bPermissions Migration: Error -> bPermissions is not loaded.");
|
log.accept("Error -> bPermissions is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("bPermissions Migration: Forcing the plugin to load all data. This could take a while.");
|
log.accept("Forcing the plugin to load all data. This could take a while.");
|
||||||
for (World world : worldManager.getAllWorlds()) {
|
for (World world : worldManager.getAllWorlds()) {
|
||||||
Set<String> users = getUsers(world);
|
Set<String> users = getUsers(world);
|
||||||
if (users == null) {
|
if (users == null) {
|
||||||
log.severe("bPermissions Migration: Couldn't get a list of users.");
|
log.accept("Couldn't get a list of users.");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
users.forEach(s -> world.loadOne(s, CalculableType.USER));
|
users.forEach(s -> world.loadOne(s, CalculableType.USER));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate one world at a time.
|
// Migrate one world at a time.
|
||||||
log.info("bPermissions Migration: Starting world migration.");
|
log.accept("Starting world migration.");
|
||||||
for (World world : worldManager.getAllWorlds()) {
|
for (World world : worldManager.getAllWorlds()) {
|
||||||
log.info("bPermissions Migration: Migrating world: " + world.getName());
|
log.accept("Migrating world: " + world.getName());
|
||||||
|
|
||||||
// Migrate all groups
|
// Migrate all groups
|
||||||
log.info("bPermissions Migration: Starting group migration in world " + world.getName() + ".");
|
log.accept("Starting group migration in world " + world.getName() + ".");
|
||||||
int groupCount = 0;
|
int groupCount = 0;
|
||||||
for (Calculable group : world.getAll(CalculableType.GROUP)) {
|
for (Calculable group : world.getAll(CalculableType.GROUP)) {
|
||||||
groupCount++;
|
groupCount++;
|
||||||
@ -225,10 +230,10 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
migrateHolder(plugin, world, group, lpGroup);
|
migrateHolder(plugin, world, group, lpGroup);
|
||||||
plugin.getStorage().saveGroup(lpGroup);
|
plugin.getStorage().saveGroup(lpGroup);
|
||||||
}
|
}
|
||||||
log.info("bPermissions Migration: Migrated " + groupCount + " groups in world " + world.getName() + ".");
|
log.accept("Migrated " + groupCount + " groups in world " + world.getName() + ".");
|
||||||
|
|
||||||
// Migrate all users
|
// Migrate all users
|
||||||
log.info("bPermissions Migration: Starting user migration in world " + world.getName() + ".");
|
log.accept("Starting user migration in world " + world.getName() + ".");
|
||||||
int userCount = 0;
|
int userCount = 0;
|
||||||
for (Calculable user : world.getAll(CalculableType.USER)) {
|
for (Calculable user : world.getAll(CalculableType.USER)) {
|
||||||
userCount++;
|
userCount++;
|
||||||
@ -242,7 +247,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
log.info("bPermissions Migration: Unable to migrate user " + user.getName() + ". Unable to get UUID.");
|
log.accept("Unable to migrate user " + user.getName() + ". Unable to get UUID.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,10 +261,10 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
|||||||
plugin.getUserManager().cleanup(lpUser);
|
plugin.getUserManager().cleanup(lpUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("bPermissions Migration: Migrated " + userCount + " users in world " + world.getName() + ".");
|
log.accept("Migrated " + userCount + " users in world " + world.getName() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("bPermissions Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit.migration;
|
package me.lucko.luckperms.bukkit.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.Arg;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
@ -30,6 +29,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -49,6 +49,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MigrationGroupManager extends SubCommand<Object> {
|
public class MigrationGroupManager extends SubCommand<Object> {
|
||||||
@ -60,9 +61,14 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting GroupManager migration.");
|
||||||
|
|
||||||
if (!plugin.isPluginLoaded("GroupManager")) {
|
if (!plugin.isPluginLoaded("GroupManager")) {
|
||||||
log.severe("GroupManager Migration: Error -> GroupManager is not loaded.");
|
log.accept("Error -> GroupManager is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +79,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
GroupManager gm = (GroupManager) plugin.getPlugin("GroupManager");
|
GroupManager gm = (GroupManager) plugin.getPlugin("GroupManager");
|
||||||
|
|
||||||
// Migrate Global Groups
|
// Migrate Global Groups
|
||||||
log.info("GroupManager Migration: Starting Global Group migration.");
|
log.accept("Starting Global Group migration.");
|
||||||
GlobalGroups gg = GroupManager.getGlobalGroups();
|
GlobalGroups gg = GroupManager.getGlobalGroups();
|
||||||
|
|
||||||
for (Group g : gg.getGroupList()) {
|
for (Group g : gg.getGroupList()) {
|
||||||
@ -135,7 +141,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
WorldsHolder wh = gm.getWorldsHolder();
|
WorldsHolder wh = gm.getWorldsHolder();
|
||||||
|
|
||||||
// Collect data for all users and groups.
|
// Collect data for all users and groups.
|
||||||
log.info("GroupManager Migration: Starting user and group migration.");
|
log.accept("Starting user and group migration.");
|
||||||
for (String world : worlds) {
|
for (String world : worlds) {
|
||||||
world = world.toLowerCase();
|
world = world.toLowerCase();
|
||||||
|
|
||||||
@ -196,8 +202,8 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("GroupManager Migration: All existing GroupManager data has been processed. Now beginning the import process.");
|
log.accept("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.");
|
log.accept("Found a total of " + users.size() + " users and " + groups.size() + " groups.");
|
||||||
|
|
||||||
for (Map.Entry<String, Map<Map.Entry<String, String>, Boolean>> e : groups.entrySet()) {
|
for (Map.Entry<String, Map<Map.Entry<String, String>, Boolean>> e : groups.entrySet()) {
|
||||||
plugin.getStorage().createAndLoadGroup(e.getKey()).join();
|
plugin.getStorage().createAndLoadGroup(e.getKey()).join();
|
||||||
@ -290,7 +296,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
|||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("GroupManager Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit.migration;
|
package me.lucko.luckperms.bukkit.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
import me.lucko.luckperms.api.PlatformType;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
@ -32,6 +31,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
@ -48,6 +48,7 @@ import ru.tehkode.permissions.bukkit.PermissionsEx;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MigrationPermissionsEx extends SubCommand<Object> {
|
public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||||
@ -60,15 +61,20 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting PermissionsEx migration.");
|
||||||
|
|
||||||
if (!plugin.isPluginLoaded("PermissionsEx")) {
|
if (!plugin.isPluginLoaded("PermissionsEx")) {
|
||||||
log.severe("PermissionsEx Migration: Error -> PermissionsEx is not loaded.");
|
log.accept("Error -> PermissionsEx is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getType() != PlatformType.BUKKIT) {
|
if (plugin.getType() != PlatformType.BUKKIT) {
|
||||||
// Sponge uses a completely different version of PEX.
|
// Sponge uses a completely different version of PEX.
|
||||||
log.severe("PEX import is not supported on this platform.");
|
log.accept("PEX import is not supported on this platform.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +96,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Migrate all groups.
|
// Migrate all groups.
|
||||||
log.info("PermissionsEx Migration: Starting group migration.");
|
log.accept("Starting group migration.");
|
||||||
|
|
||||||
int maxGroupWeight = 0;
|
int maxGroupWeight = 0;
|
||||||
int groupCount = 0;
|
int groupCount = 0;
|
||||||
@ -229,10 +235,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("PermissionsEx Migration: Migrated " + groupCount + " groups");
|
log.accept("Migrated " + groupCount + " groups");
|
||||||
|
|
||||||
// Migrate all users
|
// Migrate all users
|
||||||
log.info("PermissionsEx Migration: Starting user migration.");
|
log.accept("Starting user migration.");
|
||||||
int userCount = 0;
|
int userCount = 0;
|
||||||
maxGroupWeight++;
|
maxGroupWeight++;
|
||||||
for (PermissionUser user : manager.getUsers()) {
|
for (PermissionUser user : manager.getUsers()) {
|
||||||
@ -248,7 +254,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (u == null) {
|
if (u == null) {
|
||||||
log.severe("Unable to get a UUID for user identifier: " + user.getIdentifier());
|
log.accept("Unable to get a UUID for user identifier: " + user.getIdentifier());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,8 +396,8 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
plugin.getStorage().saveUser(lpUser);
|
plugin.getStorage().saveUser(lpUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("PermissionsEx Migration: Migrated " + userCount + " users.");
|
log.accept("Migrated " + userCount + " users.");
|
||||||
log.info("PermissionsEx Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import com.github.cheesesoftware.PowerfulPermsAPI.ResultRunnable;
|
|||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.api.data.Callback;
|
import me.lucko.luckperms.api.data.Callback;
|
||||||
import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable;
|
import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
@ -43,6 +42,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.core.model.PermissionHolder;
|
import me.lucko.luckperms.common.core.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
@ -64,6 +64,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
|
import static me.lucko.luckperms.common.constants.Permission.MIGRATION;
|
||||||
|
|
||||||
@ -187,17 +188,22 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
try {
|
try {
|
||||||
return run(plugin, args);
|
return run(plugin, sender, args);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandResult run(LuckPermsPlugin plugin, List<String> args) {
|
private CommandResult run(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting PowerfulPerms migration.");
|
||||||
|
|
||||||
if (!plugin.isPluginLoaded("PowerfulPerms")) {
|
if (!plugin.isPluginLoaded("PowerfulPerms")) {
|
||||||
log.severe("PowerfulPerms Migration: Error -> PowerfulPerms is not loaded.");
|
log.accept("Error -> PowerfulPerms is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +214,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
final String dbTable = args.get(4);
|
final String dbTable = args.get(4);
|
||||||
|
|
||||||
// Find a list of UUIDs
|
// Find a list of UUIDs
|
||||||
log.info("PowerfulPerms Migration: Getting a list of UUIDs to migrate.");
|
log.accept("Getting a list of UUIDs to migrate.");
|
||||||
|
|
||||||
@Cleanup HikariDataSource hikari = new HikariDataSource();
|
@Cleanup HikariDataSource hikari = new HikariDataSource();
|
||||||
hikari.setMaximumPoolSize(2);
|
hikari.setMaximumPoolSize(2);
|
||||||
@ -227,7 +233,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Cleanup ResultSet tables = meta.getTables(null, null, dbTable, null);
|
@Cleanup ResultSet tables = meta.getTables(null, null, dbTable, null);
|
||||||
if (!tables.next()) {
|
if (!tables.next()) {
|
||||||
log.severe("PowerfulPerms Migration: Error - Couldn't find table.");
|
log.accept("Error - Couldn't find table.");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -235,9 +241,9 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
columnPs.setString(1, dbTable);
|
columnPs.setString(1, dbTable);
|
||||||
@Cleanup ResultSet columnRs = columnPs.executeQuery();
|
@Cleanup ResultSet columnRs = columnPs.executeQuery();
|
||||||
|
|
||||||
log.info("Found table: " + dbTable);
|
log.accept("Found table: " + dbTable);
|
||||||
while (columnRs.next()) {
|
while (columnRs.next()) {
|
||||||
log.info("" + columnRs.getString("COLUMN_NAME") + " - " + columnRs.getString("COLUMN_TYPE"));
|
log.accept("" + columnRs.getString("COLUMN_NAME") + " - " + columnRs.getString("COLUMN_TYPE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cleanup PreparedStatement preparedStatement = connection.prepareStatement("SELECT `uuid` FROM " + dbTable);
|
@Cleanup PreparedStatement preparedStatement = connection.prepareStatement("SELECT `uuid` FROM " + dbTable);
|
||||||
@ -254,17 +260,17 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uuids.isEmpty()) {
|
if (uuids.isEmpty()) {
|
||||||
log.severe("PowerfulPerms Migration: Error - Unable to find any UUIDs to migrate.");
|
log.accept("Error - Unable to find any UUIDs to migrate.");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("PowerfulPerms Migration: Found " + uuids.size() + " uuids. Starting migration.");
|
log.accept("Found " + uuids.size() + " uuids. Starting migration.");
|
||||||
|
|
||||||
PowerfulPermsPlugin ppPlugin = (PowerfulPermsPlugin) plugin.getPlugin("PowerfulPerms");
|
PowerfulPermsPlugin ppPlugin = (PowerfulPermsPlugin) plugin.getPlugin("PowerfulPerms");
|
||||||
PermissionManager pm = ppPlugin.getPermissionManager();
|
PermissionManager pm = ppPlugin.getPermissionManager();
|
||||||
|
|
||||||
// Groups first.
|
// Groups first.
|
||||||
log.info("PowerfulPerms Migration: Starting group migration.");
|
log.accept("Starting group migration.");
|
||||||
Map<Integer, Group> groups = pm.getGroups(); // All versions
|
Map<Integer, Group> groups = pm.getGroups(); // All versions
|
||||||
for (Group g : groups.values()) {
|
for (Group g : groups.values()) {
|
||||||
plugin.getStorage().createAndLoadGroup(g.getName().toLowerCase()).join();
|
plugin.getStorage().createAndLoadGroup(g.getName().toLowerCase()).join();
|
||||||
@ -298,10 +304,10 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
|
|
||||||
plugin.getStorage().saveGroup(group);
|
plugin.getStorage().saveGroup(group);
|
||||||
}
|
}
|
||||||
log.info("PowerfulPerms Migration: Group migration complete.");
|
log.accept("Group migration complete.");
|
||||||
|
|
||||||
// Now users.
|
// Now users.
|
||||||
log.info("PowerfulPerms Migration: Starting user migration.");
|
log.accept("Starting user migration.");
|
||||||
final Map<UUID, CountDownLatch> progress = new HashMap<>();
|
final Map<UUID, CountDownLatch> progress = new HashMap<>();
|
||||||
|
|
||||||
// Migrate all users and their groups
|
// Migrate all users and their groups
|
||||||
@ -468,7 +474,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
log.info("PowerfulPerms Migration: Error");
|
log.accept("Error");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -480,7 +486,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
log.info("PowerfulPerms Migration: Error");
|
log.accept("Error");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,7 +494,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
|
|
||||||
// All groups are 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.
|
// This block will wait for all users to be completed.
|
||||||
log.info("PowerfulPerms Migration: Waiting for user migration to complete. This may take some time");
|
log.accept("Waiting for user migration to complete. This may take some time");
|
||||||
boolean sleep = true;
|
boolean sleep = true;
|
||||||
while (sleep) {
|
while (sleep) {
|
||||||
sleep = false;
|
sleep = false;
|
||||||
@ -511,7 +517,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We done.
|
// We done.
|
||||||
log.info("PowerfulPerms Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit.migration;
|
package me.lucko.luckperms.bukkit.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.NodeFactory;
|
import me.lucko.luckperms.common.core.NodeFactory;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
@ -48,24 +48,29 @@ import org.tyrannyofheaven.bukkit.zPermissions.model.PermissionEntity;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class MigrationZPermissions extends SubCommand<Object> {
|
public class MigrationZPermissions extends SubCommand<Object> {
|
||||||
|
|
||||||
public MigrationZPermissions() {
|
public MigrationZPermissions() {
|
||||||
super("zpermissions", "Migration from zPermissions", Permission.MIGRATION, Predicates.alwaysFalse(), null);
|
super("zpermissions", "Migration from zPermissions", Permission.MIGRATION, Predicates.alwaysFalse(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting zPermissions migration.");
|
||||||
|
|
||||||
if (!plugin.isPluginLoaded("zPermissions")) {
|
if (!plugin.isPluginLoaded("zPermissions")) {
|
||||||
log.severe("zPermissions Migration: Error -> zPermissions is not loaded.");
|
log.accept("Error -> zPermissions is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZPermissionsService service = (ZPermissionsService) plugin.getService(ZPermissionsService.class);
|
ZPermissionsService service = (ZPermissionsService) plugin.getService(ZPermissionsService.class);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
log.severe("zPermissions Migration: Error -> zPermissions is not loaded.");
|
log.accept("Error -> zPermissions is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +86,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Migrate all groups
|
// Migrate all groups
|
||||||
log.info("zPermissions Migration: Starting group migration.");
|
log.accept("Starting group migration.");
|
||||||
for (String g : service.getAllGroups()) {
|
for (String g : service.getAllGroups()) {
|
||||||
plugin.getStorage().createAndLoadGroup(g.toLowerCase()).join();
|
plugin.getStorage().createAndLoadGroup(g.toLowerCase()).join();
|
||||||
Group group = plugin.getGroupManager().getIfLoaded(g.toLowerCase());
|
Group group = plugin.getGroupManager().getIfLoaded(g.toLowerCase());
|
||||||
@ -93,7 +98,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Migrate all tracks
|
// Migrate all tracks
|
||||||
log.info("zPermissions Migration: Starting track migration.");
|
log.accept("Starting track migration.");
|
||||||
for (String t : service.getAllTracks()) {
|
for (String t : service.getAllTracks()) {
|
||||||
plugin.getStorage().createAndLoadTrack(t.toLowerCase()).join();
|
plugin.getStorage().createAndLoadTrack(t.toLowerCase()).join();
|
||||||
Track track = plugin.getTrackManager().getIfLoaded(t.toLowerCase());
|
Track track = plugin.getTrackManager().getIfLoaded(t.toLowerCase());
|
||||||
@ -102,7 +107,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Migrate all users.
|
// Migrate all users.
|
||||||
log.info("zPermissions Migration: Starting user migration.");
|
log.accept("Starting user migration.");
|
||||||
for (UUID u : service.getAllPlayersUUID()) {
|
for (UUID u : service.getAllPlayersUUID()) {
|
||||||
plugin.getStorage().loadUser(u, "null").join();
|
plugin.getStorage().loadUser(u, "null").join();
|
||||||
User user = plugin.getUserManager().get(u);
|
User user = plugin.getUserManager().get(u);
|
||||||
@ -120,7 +125,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
|||||||
plugin.getStorage().saveUser(user);
|
plugin.getStorage().saveUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("zPermissions Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bungee.migration;
|
package me.lucko.luckperms.bungee.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.api.MetaUtils;
|
import me.lucko.luckperms.api.MetaUtils;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
@ -30,6 +29,7 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.data.LogEntry;
|
import me.lucko.luckperms.common.data.LogEntry;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
@ -43,6 +43,7 @@ import net.alpenblock.bungeeperms.World;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BungeePerms is actually pretty nice. huh.
|
* BungeePerms is actually pretty nice. huh.
|
||||||
@ -54,16 +55,20 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting BungeePerms migration.");
|
||||||
|
|
||||||
BungeePerms bp = BungeePerms.getInstance();
|
BungeePerms bp = BungeePerms.getInstance();
|
||||||
if (bp == null) {
|
if (bp == null) {
|
||||||
log.severe("BungeePerms Migration: Error -> BungeePerms is not loaded.");
|
log.accept("Error -> BungeePerms is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate all groups.
|
// Migrate all groups.
|
||||||
log.info("BungeePerms Migration: Starting group migration.");
|
log.accept("Starting group migration.");
|
||||||
int groupCount = 0;
|
int groupCount = 0;
|
||||||
for (Group g : bp.getPermissionsManager().getBackEnd().loadGroups()) {
|
for (Group g : bp.getPermissionsManager().getBackEnd().loadGroups()) {
|
||||||
groupCount++;
|
groupCount++;
|
||||||
@ -182,10 +187,10 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
|||||||
plugin.getStorage().saveGroup(group);
|
plugin.getStorage().saveGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("BungeePerms Migration: Migrated " + groupCount + " groups");
|
log.accept("Migrated " + groupCount + " groups");
|
||||||
|
|
||||||
// Migrate all users.
|
// Migrate all users.
|
||||||
log.info("BungeePerms Migration: Starting user migration.");
|
log.accept("Starting user migration.");
|
||||||
int userCount = 0;
|
int userCount = 0;
|
||||||
for (User u : bp.getPermissionsManager().getBackEnd().loadUsers()) {
|
for (User u : bp.getPermissionsManager().getBackEnd().loadUsers()) {
|
||||||
if (u.getUUID() == null) continue;
|
if (u.getUUID() == null) continue;
|
||||||
@ -298,8 +303,8 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
|||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("BungeePerms Migration: Migrated " + userCount + " users.");
|
log.accept("Migrated " + userCount + " users.");
|
||||||
log.info("BungeePerms Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,4 +35,8 @@ public abstract class BaseCommand<T, S> extends Command<T, S> {
|
|||||||
|
|
||||||
public abstract String getUsage();
|
public abstract String getUsage();
|
||||||
|
|
||||||
|
public boolean shouldDisplay() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -214,6 +214,10 @@ public class CommandManager {
|
|||||||
mainCommands.stream()
|
mainCommands.stream()
|
||||||
.filter(c -> c.isAuthorized(sender))
|
.filter(c -> c.isAuthorized(sender))
|
||||||
.forEach(c -> {
|
.forEach(c -> {
|
||||||
|
if (!c.shouldDisplay()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
String permission = (String) c.getPermission().map(p -> ((Permission) p).getExample()).orElse("None");
|
String permission = (String) c.getPermission().map(p -> ((Permission) p).getExample()).orElse("None");
|
||||||
FancyMessage msg = new FancyMessage("> ").color(ChatColor.getByChar('3')).then().text(String.format(c.getUsage(), label)).color(ChatColor.getByChar('a'))
|
FancyMessage msg = new FancyMessage("> ").color(ChatColor.getByChar('3')).then().text(String.format(c.getUsage(), label)).color(ChatColor.getByChar('a'))
|
||||||
|
@ -149,12 +149,6 @@ public abstract class MainCommand<T> extends BaseCommand<Void, T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUsage(Sender sender, String label) {
|
public void sendUsage(Sender sender, String label) {
|
||||||
/*
|
|
||||||
if (getSubCommands().isEmpty()) {
|
|
||||||
Util.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label));
|
|
||||||
return;
|
|
||||||
*/
|
|
||||||
|
|
||||||
List<Command> subs = getSubCommands().stream()
|
List<Command> subs = getSubCommands().stream()
|
||||||
.filter(s -> s.isAuthorized(sender))
|
.filter(s -> s.isAuthorized(sender))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -29,8 +29,8 @@ import me.lucko.luckperms.common.commands.CommandResult;
|
|||||||
import me.lucko.luckperms.common.commands.MainCommand;
|
import me.lucko.luckperms.common.commands.MainCommand;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -95,6 +95,7 @@ public class MigrationMainCommand extends MainCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Command<Object, ?>> commands = null;
|
private List<Command<Object, ?>> commands = null;
|
||||||
|
private boolean display = true;
|
||||||
|
|
||||||
public MigrationMainCommand() {
|
public MigrationMainCommand() {
|
||||||
super("Migration", "Migration commands", "/%s migration", 1, null);
|
super("Migration", "Migration commands", "/%s migration", 1, null);
|
||||||
@ -106,6 +107,17 @@ public class MigrationMainCommand extends MainCommand<Object> {
|
|||||||
public synchronized Optional<List<Command<Object, ?>>> getChildren() {
|
public synchronized Optional<List<Command<Object, ?>>> getChildren() {
|
||||||
if (commands == null) {
|
if (commands == null) {
|
||||||
commands = getAvailableCommands();
|
commands = getAvailableCommands();
|
||||||
|
|
||||||
|
// Add dummy command to show in the list.
|
||||||
|
if (commands.isEmpty()) {
|
||||||
|
display = false;
|
||||||
|
commands.add(new SubCommand<Object>("No available plugins to migrate from", "No available plugins to migrate from.", Permission.MIGRATION, Predicates.alwaysFalse(), null) {
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
|
return CommandResult.SUCCESS;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.of(commands);
|
return Optional.of(commands);
|
||||||
@ -118,17 +130,13 @@ public class MigrationMainCommand extends MainCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuthorized(Sender sender) {
|
public boolean isAuthorized(Sender sender) {
|
||||||
return sender.getUuid().equals(Constants.CONSOLE_UUID);
|
return sender.hasPermission(Permission.MIGRATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Void v, List<String> args, String label) throws CommandException {
|
public boolean shouldDisplay() {
|
||||||
if (!sender.getUuid().equals(Constants.CONSOLE_UUID)) {
|
getSubCommands();
|
||||||
Message.MIGRATION_NOT_CONSOLE.send(sender);
|
return display;
|
||||||
return CommandResult.NO_PERMISSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.execute(plugin, sender, v, args, label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,14 +22,12 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands.misc;
|
package me.lucko.luckperms.common.commands.misc;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.Arg;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
|
||||||
import me.lucko.luckperms.common.constants.Message;
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
@ -46,6 +44,7 @@ import java.nio.file.Files;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class ExportCommand extends SingleCommand {
|
public class ExportCommand extends SingleCommand {
|
||||||
private static void write(BufferedWriter writer, String s) {
|
private static void write(BufferedWriter writer, String s) {
|
||||||
@ -102,7 +101,7 @@ public class ExportCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ExportCommand() {
|
public ExportCommand() {
|
||||||
super("Export", "Export data to a file", "/%s export <file>", Permission.MIGRATION, Predicates.not(1),
|
super("Export", "Export data to a file", "/%s export <file>", Permission.EXPORT, Predicates.not(1),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("file", true, "the file to export to")
|
Arg.create("file", true, "the file to export to")
|
||||||
)
|
)
|
||||||
@ -111,12 +110,7 @@ public class ExportCommand extends SingleCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> Message.EXPORT_LOG.send(sender, s);
|
||||||
|
|
||||||
if (!sender.getUuid().equals(Constants.CONSOLE_UUID)) {
|
|
||||||
Message.MIGRATION_NOT_CONSOLE.send(sender);
|
|
||||||
return CommandResult.NO_PERMISSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
File f = new File(plugin.getMainDir(), args.get(0));
|
File f = new File(plugin.getMainDir(), args.get(0));
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
@ -138,10 +132,10 @@ public class ExportCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (FileWriter fWriter = new FileWriter(f, true); BufferedWriter writer = new BufferedWriter(fWriter)) {
|
try (FileWriter fWriter = new FileWriter(f, true); BufferedWriter writer = new BufferedWriter(fWriter)) {
|
||||||
log.info("Export: Starting export process.");
|
log.accept("Starting export process.");
|
||||||
|
|
||||||
// Export Groups
|
// Export Groups
|
||||||
log.info("Export: Exporting all groups.");
|
log.accept("Exporting all groups.");
|
||||||
|
|
||||||
// Create the groups first
|
// Create the groups first
|
||||||
for (Group group : plugin.getGroupManager().getAll().values()) {
|
for (Group group : plugin.getGroupManager().getAll().values()) {
|
||||||
@ -155,10 +149,10 @@ public class ExportCommand extends SingleCommand {
|
|||||||
write(writer, nodeToString(node, group.getName(), true));
|
write(writer, nodeToString(node, group.getName(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("Export: Exported " + groupCount + " groups.");
|
log.accept("Exported " + groupCount + " groups.");
|
||||||
|
|
||||||
// Export tracks
|
// Export tracks
|
||||||
log.info("Export: Exporting all tracks.");
|
log.accept("Exporting all tracks.");
|
||||||
|
|
||||||
// Create the tracks first
|
// Create the tracks first
|
||||||
for (Track track : plugin.getTrackManager().getAll().values()) {
|
for (Track track : plugin.getTrackManager().getAll().values()) {
|
||||||
@ -172,13 +166,13 @@ public class ExportCommand extends SingleCommand {
|
|||||||
write(writer, "/luckperms track " + track.getName() + " append " + group);
|
write(writer, "/luckperms track " + track.getName() + " append " + group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("Export: Exported " + trackCount + " tracks.");
|
log.accept("Exported " + trackCount + " tracks.");
|
||||||
|
|
||||||
// Export users
|
// Export users
|
||||||
log.info("Export: Exporting all users. Finding a list of unique users to export.");
|
log.accept("Exporting all users. Finding a list of unique users to export.");
|
||||||
Storage ds = plugin.getStorage();
|
Storage ds = plugin.getStorage();
|
||||||
Set<UUID> users = ds.getUniqueUsers().join();
|
Set<UUID> users = ds.getUniqueUsers().join();
|
||||||
log.info("Export: Found " + users.size() + " unique users to export.");
|
log.accept("Found " + users.size() + " unique users to export.");
|
||||||
|
|
||||||
int userCount = 0;
|
int userCount = 0;
|
||||||
for (UUID uuid : users) {
|
for (UUID uuid : users) {
|
||||||
@ -206,7 +200,7 @@ public class ExportCommand extends SingleCommand {
|
|||||||
|
|
||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
}
|
}
|
||||||
log.info("Export: Exported " + userCount + " users.");
|
log.accept("Exported " + userCount + " users.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writer.flush();
|
writer.flush();
|
||||||
@ -222,9 +216,4 @@ public class ExportCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAuthorized(Sender sender) {
|
|
||||||
return sender.getUuid().equals(Constants.CONSOLE_UUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ public enum Message {
|
|||||||
OP_DISABLED("&bThe vanilla OP system is disabled on this server.", false),
|
OP_DISABLED("&bThe vanilla OP system is disabled on this server.", false),
|
||||||
OP_DISABLED_SPONGE("&2Server Operator status has no effect when a permission plugin is installed. Please edit user data directly.", true),
|
OP_DISABLED_SPONGE("&2Server Operator status has no effect when a permission plugin is installed. Please edit user data directly.", true),
|
||||||
LOG("&3LOG &3&l> {0}", true),
|
LOG("&3LOG &3&l> {0}", true),
|
||||||
|
EXPORT_LOG("&3EXPORT &3&l> &f{0}", true),
|
||||||
|
MIGRATION_LOG("&3MIGRATION &3&l> &f{0}", true),
|
||||||
|
|
||||||
COMMAND_NOT_RECOGNISED("Command not recognised.", true),
|
COMMAND_NOT_RECOGNISED("Command not recognised.", true),
|
||||||
COMMAND_NO_PERMISSION("You do not have permission to use this command!", true),
|
COMMAND_NO_PERMISSION("You do not have permission to use this command!", true),
|
||||||
@ -413,9 +415,7 @@ public enum Message {
|
|||||||
),
|
),
|
||||||
|
|
||||||
IMPORT_END_ERROR_CONTENT("&b(Import) &b-> &c{0}", true),
|
IMPORT_END_ERROR_CONTENT("&b(Import) &b-> &c{0}", true),
|
||||||
IMPORT_END_ERROR_FOOTER("&b(Import) &7<------------------------------------------>", true),
|
IMPORT_END_ERROR_FOOTER("&b(Import) &7<------------------------------------------>", true);
|
||||||
|
|
||||||
MIGRATION_NOT_CONSOLE("Migration must be performed from the Console.", true);
|
|
||||||
|
|
||||||
private static String format(String s, Object... objects) {
|
private static String format(String s, Object... objects) {
|
||||||
for (int i = 0, objsLength = objects.length; i < objsLength; i++) {
|
for (int i = 0, objsLength = objects.length; i < objsLength; i++) {
|
||||||
|
@ -40,6 +40,8 @@ public enum Permission {
|
|||||||
SEARCH(list("search"), Type.NONE),
|
SEARCH(list("search"), Type.NONE),
|
||||||
VERBOSE(list("verbose"), Type.NONE),
|
VERBOSE(list("verbose"), Type.NONE),
|
||||||
IMPORT(list("import"), Type.NONE),
|
IMPORT(list("import"), Type.NONE),
|
||||||
|
EXPORT(list("export"), Type.NONE),
|
||||||
|
MIGRATION(list("migration"), Type.NONE),
|
||||||
|
|
||||||
CREATE_GROUP(list("creategroup"), Type.NONE),
|
CREATE_GROUP(list("creategroup"), Type.NONE),
|
||||||
DELETE_GROUP(list("deletegroup"), Type.NONE),
|
DELETE_GROUP(list("deletegroup"), Type.NONE),
|
||||||
@ -148,9 +150,7 @@ public enum Permission {
|
|||||||
SPONGE_OPTION_INFO(list("option.info"), Type.SPONGE),
|
SPONGE_OPTION_INFO(list("option.info"), Type.SPONGE),
|
||||||
SPONGE_OPTION_SET(list("option.set"), Type.SPONGE),
|
SPONGE_OPTION_SET(list("option.set"), Type.SPONGE),
|
||||||
SPONGE_OPTION_UNSET(list("option.unset"), Type.SPONGE),
|
SPONGE_OPTION_UNSET(list("option.unset"), Type.SPONGE),
|
||||||
SPONGE_OPTION_CLEAR(list("option.clear"), Type.SPONGE),
|
SPONGE_OPTION_CLEAR(list("option.clear"), Type.SPONGE);
|
||||||
|
|
||||||
MIGRATION(list("migration"), Type.NONE);
|
|
||||||
|
|
||||||
private static final String IDENTIFIER = "luckperms.";
|
private static final String IDENTIFIER = "luckperms.";
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.sponge.migration;
|
package me.lucko.luckperms.sponge.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
import me.lucko.luckperms.common.core.model.User;
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
@ -44,6 +44,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static me.lucko.luckperms.sponge.migration.MigrationUtils.migrateSubject;
|
import static me.lucko.luckperms.sponge.migration.MigrationUtils.migrateSubject;
|
||||||
|
|
||||||
@ -54,11 +55,15 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting PermissionManager migration.");
|
||||||
|
|
||||||
Optional<PluginContainer> pm = Sponge.getPluginManager().getPlugin("permissionmanager");
|
Optional<PluginContainer> pm = Sponge.getPluginManager().getPlugin("permissionmanager");
|
||||||
if (!pm.isPresent()) {
|
if (!pm.isPresent()) {
|
||||||
log.severe("PermissionManager Migration: Error -> PermissionManager is not loaded.");
|
log.accept("Error -> PermissionManager is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +80,7 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Migrate groups
|
// Migrate groups
|
||||||
log.info("PermissionManager Migration: Starting group migration.");
|
log.accept("Starting group migration.");
|
||||||
|
|
||||||
// Forcefully load all groups.
|
// Forcefully load all groups.
|
||||||
try {
|
try {
|
||||||
@ -97,10 +102,10 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
migrateSubject(pmGroup, group);
|
migrateSubject(pmGroup, group);
|
||||||
plugin.getStorage().saveGroup(group);
|
plugin.getStorage().saveGroup(group);
|
||||||
}
|
}
|
||||||
log.info("PermissionManager Migration: Migrated " + groupCount + " groups");
|
log.accept("Migrated " + groupCount + " groups");
|
||||||
|
|
||||||
// Migrate users
|
// Migrate users
|
||||||
log.info("PermissionManager Migration: Starting user migration.");
|
log.accept("Starting user migration.");
|
||||||
|
|
||||||
// Forcefully load all users.
|
// Forcefully load all users.
|
||||||
try {
|
try {
|
||||||
@ -115,7 +120,7 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
userCount++;
|
userCount++;
|
||||||
UUID uuid = Util.parseUuid(pmUser.getIdentifier());
|
UUID uuid = Util.parseUuid(pmUser.getIdentifier());
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
log.severe("PermissionManager Migration: Error -> Could not parse UUID for user: " + pmUser.getIdentifier());
|
log.accept("Error -> Could not parse UUID for user: " + pmUser.getIdentifier());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +132,8 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("PermissionManager Migration: Migrated " + userCount + " users.");
|
log.accept("Migrated " + userCount + " users.");
|
||||||
log.info("PermissionManager Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.sponge.migration;
|
package me.lucko.luckperms.sponge.migration;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Logger;
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.SubCommand;
|
import me.lucko.luckperms.common.commands.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
|
import me.lucko.luckperms.common.constants.Message;
|
||||||
import me.lucko.luckperms.common.constants.Permission;
|
import me.lucko.luckperms.common.constants.Permission;
|
||||||
import me.lucko.luckperms.common.core.model.Group;
|
import me.lucko.luckperms.common.core.model.Group;
|
||||||
import me.lucko.luckperms.common.core.model.Track;
|
import me.lucko.luckperms.common.core.model.Track;
|
||||||
@ -51,6 +51,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static me.lucko.luckperms.sponge.migration.MigrationUtils.migrateSubject;
|
import static me.lucko.luckperms.sponge.migration.MigrationUtils.migrateSubject;
|
||||||
|
|
||||||
@ -61,12 +62,17 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
|
||||||
final Logger log = plugin.getLog();
|
Consumer<String> log = s -> {
|
||||||
|
Message.MIGRATION_LOG.send(sender, s);
|
||||||
|
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
|
||||||
|
};
|
||||||
|
log.accept("Starting PermissionsEx migration.");
|
||||||
|
|
||||||
final LuckPermsService lpService = ((LPSpongePlugin) plugin).getService();
|
final LuckPermsService lpService = ((LPSpongePlugin) plugin).getService();
|
||||||
|
|
||||||
Optional<PluginContainer> pex = Sponge.getPluginManager().getPlugin("permissionsex");
|
Optional<PluginContainer> pex = Sponge.getPluginManager().getPlugin("permissionsex");
|
||||||
if (!pex.isPresent()) {
|
if (!pex.isPresent()) {
|
||||||
log.severe("PermissionsEx Migration: Error -> PermissionsEx is not loaded.");
|
log.accept("Error -> PermissionsEx is not loaded.");
|
||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +92,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
Map<String, TreeMap<Integer, String>> tracks = new HashMap<>();
|
Map<String, TreeMap<Integer, String>> tracks = new HashMap<>();
|
||||||
|
|
||||||
// Migrate groups
|
// Migrate groups
|
||||||
log.info("PermissionsEx Migration: Starting group migration.");
|
log.accept("Starting group migration.");
|
||||||
int groupCount = 0;
|
int groupCount = 0;
|
||||||
for (Subject pexGroup : pexService.getGroupSubjects().getAllSubjects()) {
|
for (Subject pexGroup : pexService.getGroupSubjects().getAllSubjects()) {
|
||||||
groupCount++;
|
groupCount++;
|
||||||
@ -115,10 +121,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
log.info("PermissionsEx Migration: Migrated " + groupCount + " groups");
|
log.accept("Migrated " + groupCount + " groups");
|
||||||
|
|
||||||
// Migrate tracks
|
// Migrate tracks
|
||||||
log.info("PermissionsEx Migration: Starting track migration.");
|
log.accept("Starting track migration.");
|
||||||
for (Map.Entry<String, TreeMap<Integer, String>> e : tracks.entrySet()) {
|
for (Map.Entry<String, TreeMap<Integer, String>> e : tracks.entrySet()) {
|
||||||
plugin.getStorage().createAndLoadTrack(e.getKey()).join();
|
plugin.getStorage().createAndLoadTrack(e.getKey()).join();
|
||||||
Track track = plugin.getTrackManager().getIfLoaded(e.getKey());
|
Track track = plugin.getTrackManager().getIfLoaded(e.getKey());
|
||||||
@ -131,16 +137,16 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("PermissionsEx Migration: Migrated " + tracks.size() + " tracks");
|
log.accept("Migrated " + tracks.size() + " tracks");
|
||||||
|
|
||||||
// Migrate users
|
// Migrate users
|
||||||
log.info("PermissionsEx Migration: Starting user migration.");
|
log.accept("Starting user migration.");
|
||||||
int userCount = 0;
|
int userCount = 0;
|
||||||
for (Subject pexUser : pexService.getUserSubjects().getAllSubjects()) {
|
for (Subject pexUser : pexService.getUserSubjects().getAllSubjects()) {
|
||||||
userCount++;
|
userCount++;
|
||||||
UUID uuid = Util.parseUuid(pexUser.getIdentifier());
|
UUID uuid = Util.parseUuid(pexUser.getIdentifier());
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
log.severe("PermissionsEx Migration: Error -> Could not parse UUID for user: " + pexUser.getIdentifier());
|
log.accept("Error -> Could not parse UUID for user: " + pexUser.getIdentifier());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +158,8 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
plugin.getUserManager().cleanup(user);
|
plugin.getUserManager().cleanup(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("PermissionsEx Migration: Migrated " + userCount + " users.");
|
log.accept("Migrated " + userCount + " users.");
|
||||||
log.info("PermissionsEx Migration: Success! Completed without any errors.");
|
log.accept("Success! Completed without any errors.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user