use of com.platymuus.bukkit.permissions.PermissionsPlugin in project LuckPerms by lucko.
the class MigrationPermissionsBukkit method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
ProgressLogger log = new ProgressLogger("PermissionsBukkit");
log.addListener(plugin.getConsoleSender());
log.addListener(sender);
log.log("Starting.");
if (!Bukkit.getPluginManager().isPluginEnabled("PermissionsBukkit")) {
log.logError("Plugin not loaded.");
return CommandResult.STATE_ERROR;
}
PermissionsPlugin permissionsBukkit = (PermissionsPlugin) Bukkit.getPluginManager().getPlugin("PermissionsBukkit");
FileConfiguration config = permissionsBukkit.getConfig();
// Migrate all groups
log.log("Starting group migration.");
AtomicInteger groupCount = new AtomicInteger(0);
ConfigurationSection groupsSection = config.getConfigurationSection("groups");
Iterators.iterate(groupsSection.getKeys(false), key -> {
final String groupName = MigrationUtils.standardizeName(key);
Group lpGroup = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
// migrate data
if (groupsSection.isConfigurationSection(key)) {
migrate(lpGroup, groupsSection.getConfigurationSection(key));
}
plugin.getStorage().saveGroup(lpGroup).join();
log.logAllProgress("Migrated {} groups so far.", groupCount.incrementAndGet());
});
log.log("Migrated " + groupCount.get() + " groups");
// Migrate all users
log.log("Starting user migration.");
AtomicInteger userCount = new AtomicInteger(0);
ConfigurationSection usersSection = config.getConfigurationSection("users");
Iterators.iterate(usersSection.getKeys(false), key -> {
UUID uuid = BukkitMigrationUtils.lookupUuid(log, key);
if (uuid == null) {
return;
}
User lpUser = plugin.getStorage().loadUser(uuid, null).join();
// migrate data
if (usersSection.isConfigurationSection(key)) {
migrate(lpUser, usersSection.getConfigurationSection(key));
}
plugin.getUserManager().cleanup(lpUser);
plugin.getStorage().saveUser(lpUser);
log.logProgress("Migrated {} users so far.", userCount.incrementAndGet());
});
log.log("Migrated " + userCount.get() + " users.");
log.log("Success! Migration complete.");
return CommandResult.SUCCESS;
}
Aggregations