Fix Sponge PEX migration
This commit is contained in:
parent
f1606ac51b
commit
f32ed5db89
@ -65,10 +65,10 @@ import org.spongepowered.api.command.CommandManager;
|
|||||||
import org.spongepowered.api.config.ConfigDir;
|
import org.spongepowered.api.config.ConfigDir;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
|
import org.spongepowered.api.event.Order;
|
||||||
import org.spongepowered.api.event.game.state.GamePostInitializationEvent;
|
import org.spongepowered.api.event.game.state.GamePostInitializationEvent;
|
||||||
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||||
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
|
||||||
import org.spongepowered.api.plugin.Dependency;
|
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
import org.spongepowered.api.plugin.PluginContainer;
|
||||||
import org.spongepowered.api.scheduler.AsynchronousExecutor;
|
import org.spongepowered.api.scheduler.AsynchronousExecutor;
|
||||||
@ -90,17 +90,7 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Plugin(id = "luckperms",
|
@Plugin(id = "luckperms", name = "LuckPerms", version = VersionData.VERSION, authors = {"Luck"}, description = "A permissions plugin")
|
||||||
name = "LuckPerms",
|
|
||||||
version = VersionData.VERSION,
|
|
||||||
authors = {"Luck"},
|
|
||||||
description = "A permissions plugin",
|
|
||||||
dependencies = {
|
|
||||||
// Needed for migration.
|
|
||||||
@Dependency(id = "permissionsex", optional = true),
|
|
||||||
@Dependency(id = "permissionmanager", optional = true)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
public class LPSpongePlugin implements LuckPermsPlugin {
|
public class LPSpongePlugin implements LuckPermsPlugin {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -125,6 +115,8 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
private LPTimings timings;
|
private LPTimings timings;
|
||||||
|
|
||||||
|
private boolean lateLoad = false;
|
||||||
|
|
||||||
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
|
private final Set<UUID> ignoringLogs = ConcurrentHashMap.newKeySet();
|
||||||
private LPConfiguration configuration;
|
private LPConfiguration configuration;
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
@ -145,7 +137,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
private DebugHandler debugHandler;
|
private DebugHandler debugHandler;
|
||||||
private SpongeSenderFactory senderFactory;
|
private SpongeSenderFactory senderFactory;
|
||||||
|
|
||||||
@Listener
|
@Listener(order = Order.FIRST)
|
||||||
public void onEnable(GamePreInitializationEvent event) {
|
public void onEnable(GamePreInitializationEvent event) {
|
||||||
log = LogFactory.wrap(logger);
|
log = LogFactory.wrap(logger);
|
||||||
debugHandler = new DebugHandler();
|
debugHandler = new DebugHandler();
|
||||||
@ -156,7 +148,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
configuration = new SpongeConfig(this);
|
configuration = new SpongeConfig(this);
|
||||||
|
|
||||||
// register events
|
// register events
|
||||||
Sponge.getEventManager().registerListeners(this, new SpongeListener(this));
|
game.getEventManager().registerListeners(this, new SpongeListener(this));
|
||||||
|
|
||||||
// initialise datastore
|
// initialise datastore
|
||||||
storage = StorageFactory.getInstance(this, "h2");
|
storage = StorageFactory.getInstance(this, "h2");
|
||||||
@ -198,7 +190,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// register commands
|
// register commands
|
||||||
getLog().info("Registering commands...");
|
getLog().info("Registering commands...");
|
||||||
CommandManager cmdService = Sponge.getCommandManager();
|
CommandManager cmdService = game.getCommandManager();
|
||||||
SpongeCommand commandManager = new SpongeCommand(this);
|
SpongeCommand commandManager = new SpongeCommand(this);
|
||||||
cmdService.register(this, commandManager, "luckperms", "perms", "lp", "permissions", "p", "perm");
|
cmdService.register(this, commandManager, "luckperms", "perms", "lp", "permissions", "p", "perm");
|
||||||
|
|
||||||
@ -218,13 +210,20 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// register the PermissionService with Sponge
|
// register the PermissionService with Sponge
|
||||||
getLog().info("Registering PermissionService...");
|
getLog().info("Registering PermissionService...");
|
||||||
Sponge.getServiceManager().setProvider(this, PermissionService.class, (service = new LuckPermsService(this)));
|
|
||||||
|
if (game.getPluginManager().getPlugin("permissionsex").isPresent()) {
|
||||||
|
getLog().warn("Detected PermissionsEx - assuming it's loaded for migration.");
|
||||||
|
getLog().warn("Delaying LuckPerms PermissionService registration.");
|
||||||
|
lateLoad = true;
|
||||||
|
} else {
|
||||||
|
game.getServiceManager().setProvider(this, PermissionService.class, (service = new LuckPermsService(this)));
|
||||||
|
}
|
||||||
|
|
||||||
// register with the LP API
|
// register with the LP API
|
||||||
getLog().info("Registering API...");
|
getLog().info("Registering API...");
|
||||||
apiProvider = new ApiProvider(this);
|
apiProvider = new ApiProvider(this);
|
||||||
ApiHandler.registerProvider(apiProvider);
|
ApiHandler.registerProvider(apiProvider);
|
||||||
Sponge.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
|
game.getServiceManager().setProvider(this, LuckPermsApi.class, apiProvider);
|
||||||
|
|
||||||
// schedule update tasks
|
// schedule update tasks
|
||||||
int mins = getConfiguration().getSyncTime();
|
int mins = getConfiguration().getSyncTime();
|
||||||
@ -243,6 +242,12 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
getLog().info("Successfully loaded.");
|
getLog().info("Successfully loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Listener(order = Order.LATE)
|
||||||
|
public void onLateEnable(GamePreInitializationEvent event) {
|
||||||
|
getLog().info("Providing late registration of PermissionService...");
|
||||||
|
game.getServiceManager().setProvider(this, PermissionService.class, (service = new LuckPermsService(this)));
|
||||||
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onDisable(GameStoppingServerEvent event) {
|
public void onDisable(GameStoppingServerEvent event) {
|
||||||
getLog().info("Closing datastore...");
|
getLog().info("Closing datastore...");
|
||||||
@ -371,7 +376,7 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getService(Class clazz) {
|
public Object getService(Class clazz) {
|
||||||
return Sponge.getServiceManager().provideUnchecked(clazz);
|
return game.getServiceManager().provideUnchecked(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user