Update PM migration to support latest version
This commit is contained in:
parent
c2165e0196
commit
407ab43dd1
@ -44,7 +44,6 @@ import org.spongepowered.api.service.permission.PermissionService;
|
|||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
import org.spongepowered.api.service.permission.SubjectCollection;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -78,9 +77,9 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
PermissionService pmService;
|
PermissionService pmService;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class clazz = Class.forName("io.github.djxy.permissionmanager.PermissionService");
|
Object pmPlugin = pm.get().getInstance().get();
|
||||||
Field instance = clazz.getDeclaredField("instance");
|
Method method = pmPlugin.getClass().getDeclaredMethod("getPermissionService");
|
||||||
pmService = (PermissionService) instance.get(null);
|
pmService = (PermissionService) method.invoke(pmPlugin);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
@ -98,15 +97,6 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
// Migrate groups
|
// Migrate groups
|
||||||
log.log("Starting group migration.");
|
log.log("Starting group migration.");
|
||||||
|
|
||||||
// Forcefully load all groups.
|
|
||||||
try {
|
|
||||||
Method method = pmService.getGroupSubjects().getClass().getMethod("load");
|
|
||||||
method.invoke(pmService.getGroupSubjects());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicInteger groupCount = new AtomicInteger(0);
|
AtomicInteger groupCount = new AtomicInteger(0);
|
||||||
for (Subject pmGroup : pmService.getGroupSubjects().getAllSubjects()) {
|
for (Subject pmGroup : pmService.getGroupSubjects().getAllSubjects()) {
|
||||||
String pmName = MigrationUtils.standardizeName(pmGroup.getIdentifier());
|
String pmName = MigrationUtils.standardizeName(pmGroup.getIdentifier());
|
||||||
@ -123,15 +113,6 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
|
|
||||||
// Migrate users
|
// Migrate users
|
||||||
log.log("Starting user migration.");
|
log.log("Starting user migration.");
|
||||||
|
|
||||||
// Forcefully load all users.
|
|
||||||
try {
|
|
||||||
Method method = pmService.getUserSubjects().getClass().getMethod("load");
|
|
||||||
method.invoke(pmService.getUserSubjects());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicInteger userCount = new AtomicInteger(0);
|
AtomicInteger userCount = new AtomicInteger(0);
|
||||||
for (Subject pmUser : pmService.getUserSubjects().getAllSubjects()) {
|
for (Subject pmUser : pmService.getUserSubjects().getAllSubjects()) {
|
||||||
UUID uuid = Util.parseUuid(pmUser.getIdentifier());
|
UUID uuid = Util.parseUuid(pmUser.getIdentifier());
|
||||||
|
Loading…
Reference in New Issue
Block a user