Refactor migration classes

This commit is contained in:
Luck 2016-10-23 20:42:25 +01:00
parent f722f4112d
commit 4d85930f5a
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
11 changed files with 67 additions and 100 deletions

View File

@ -129,5 +129,46 @@
<version>1.16.10</version>
<scope>provided</scope>
</dependency>
<!-- **************Migration Plugins************** -->
<dependency>
<groupId>org.tyrannyofheaven.bukkit</groupId>
<artifactId>zPermissions</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.23</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>net.gravitydevelopment.updater</groupId>
<artifactId>updater</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.cheesesoftware</groupId>
<artifactId>PowerfulPermsAPI</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.anjocaido</groupId>
<artifactId>GroupManager</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.bananaco</groupId>
<artifactId>bpermissions-api</artifactId>
<version>2.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands;
package me.lucko.luckperms.bukkit.migration;
import de.bananaco.bpermissions.api.*;
import me.lucko.luckperms.api.Logger;

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands;
package me.lucko.luckperms.bukkit.migration;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.common.LuckPermsPlugin;
@ -36,7 +36,6 @@ import org.anjocaido.groupmanager.data.User;
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;
@ -63,14 +62,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
// Migrate Global Groups
log.info("GroupManager Migration: Starting Global Group migration.");
GlobalGroups gg;
try {
gg = (GlobalGroups) GroupManager.class.getMethod("getGlobalGroups").invoke(gm);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
return CommandResult.FAILURE;
}
GlobalGroups gg = GroupManager.getGlobalGroups();
for (Group g : gg.getGroupList()) {
plugin.getDatastore().createAndLoadGroup(g.getName().toLowerCase()).getUnchecked();
@ -127,27 +119,14 @@ public class MigrationGroupManager extends SubCommand<Object> {
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 {
wh = (WorldsHolder) GroupManager.class.getMethod("getWorldsHolder").invoke(gm);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
return CommandResult.FAILURE;
}
WorldsHolder wh = gm.getWorldsHolder();
// Collect data for all users and groups.
log.info("GroupManager Migration: Starting user and group migration.");
for (String world : worlds) {
world = world.toLowerCase();
WorldDataHolder wdh;
try {
wdh = (WorldDataHolder) WorldsHolder.class.getMethod("getWorldData", String.class).invoke(wh, world);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
return CommandResult.FAILURE;
}
WorldDataHolder wdh = wh.getWorldData(world);
for (Group g : wdh.getGroupList()) {
groups.putIfAbsent(g.getName().toLowerCase(), new HashMap<>());

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands;
package me.lucko.luckperms.bukkit.migration;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.MetaUtils;
@ -40,7 +40,6 @@ import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@ -72,13 +71,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
.collect(Collectors.toList());
PermissionsEx pex = (PermissionsEx) plugin.getPlugin("PermissionsEx");
PermissionManager manager; // The compiler complains if you call the method directly, as Bukkit is not in this module.
try {
manager = (PermissionManager) PermissionsEx.class.getMethod("getPermissionsManager").invoke(pex);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
return CommandResult.FAILURE;
}
PermissionManager manager = pex.getPermissionsManager();
NativeInterface ni;
try {

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands;
package me.lucko.luckperms.bukkit.migration;
import com.github.cheesesoftware.PowerfulPermsAPI.*;
import com.google.common.util.concurrent.ListenableFuture;
@ -28,9 +28,9 @@ import com.zaxxer.hikari.HikariDataSource;
import lombok.Cleanup;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.*;
import me.lucko.luckperms.common.commands.migration.subcommands.utils.LPResultRunnable;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.core.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry;

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands;
package me.lucko.luckperms.bukkit.migration;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.MetaUtils;
@ -40,10 +40,6 @@ import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* <3 <3 zPermissions <3 <3
* Finally a permissions plugin with a decent API. *sigh*
*/
public class MigrationZPermissions extends SubCommand<Object> {
public MigrationZPermissions() {
super("zpermissions", "Migration from zPermissions", Permission.MIGRATION, Predicate.alwaysFalse(),

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands.utils;
package me.lucko.luckperms.bukkit.migration.utils;
import com.github.cheesesoftware.PowerfulPermsAPI.ResultRunnable;

View File

@ -121,6 +121,13 @@
<version>1.16.10</version>
<scope>provided</scope>
</dependency>
<!-- **************Migration Plugins************** -->
<dependency>
<groupId>net.alpenblock</groupId>
<artifactId>BungeePerms</artifactId>
<version>3.0-dev-52</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -20,7 +20,7 @@
* SOFTWARE.
*/
package me.lucko.luckperms.common.commands.migration.subcommands;
package me.lucko.luckperms.bungee.migration;
import me.lucko.luckperms.api.Logger;
import me.lucko.luckperms.api.MetaUtils;
@ -60,7 +60,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
log.info("BungeePerms Migration: Starting group migration.");
int groupCount = 0;
for (Group g : bp.getPermissionsManager().getBackEnd().loadGroups()) {
groupCount ++;
groupCount++;
// Make a LuckPerms group for the one being migrated
plugin.getDatastore().createAndLoadGroup(g.getName().toLowerCase()).getUnchecked();

View File

@ -95,53 +95,6 @@
<version>1.16.10</version>
<scope>provided</scope>
</dependency>
<!-- **************Migration Plugins************** -->
<dependency>
<groupId>org.tyrannyofheaven.bukkit</groupId>
<artifactId>zPermissions</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.23</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>net.gravitydevelopment.updater</groupId>
<artifactId>updater</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.cheesesoftware</groupId>
<artifactId>PowerfulPermsAPI</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.anjocaido</groupId>
<artifactId>GroupManager</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.alpenblock</groupId>
<artifactId>BungeePerms</artifactId>
<version>3.0-dev-52</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.bananaco</groupId>
<artifactId>bpermissions-api</artifactId>
<version>2.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -27,7 +27,6 @@ import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.MainCommand;
import me.lucko.luckperms.common.commands.Sender;
import me.lucko.luckperms.common.commands.SubCommand;
import me.lucko.luckperms.common.commands.migration.subcommands.*;
import me.lucko.luckperms.common.constants.Constants;
import me.lucko.luckperms.common.constants.Message;
@ -43,34 +42,33 @@ public class MigrationMainCommand extends MainCommand<Object> {
try {
Class.forName("org.anjocaido.groupmanager.GroupManager");
subCommands.add(new MigrationGroupManager());
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationGroupManager").newInstance());
} catch (Throwable ignored) {}
try {
Class.forName("ru.tehkode.permissions.bukkit.PermissionsEx");
subCommands.add(new MigrationPermissionsEx());
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationPermissionsEx").newInstance());
} catch (Throwable ignored) {}
try {
Class.forName("com.github.cheesesoftware.PowerfulPermsAPI.PowerfulPermsPlugin");
subCommands.add(new MigrationPowerfulPerms());
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationPowerfulPerms").newInstance());
} catch (Throwable ignored) {}
try {
Class.forName("org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService");
subCommands.add(new MigrationZPermissions());
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationZPermissions").newInstance());
} catch (Throwable ignored) {}
try {
Class.forName("net.alpenblock.bungeeperms.BungeePerms");
subCommands.add(new MigrationBungeePerms());
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bungee.migration.MigrationBungeePerms").newInstance());
} catch (Throwable ignored) {}
try {
Class.forName("de.bananaco.bpermissions.api.WorldManager");
subCommands.add(new MigrationBPermissions());
subCommands.add((SubCommand<Object>) Class.forName("me.lucko.luckperms.bukkit.migration.MigrationBPermissions").newInstance());
} catch (Throwable ignored) {}
}
@Override