From 6d2ea659a4504e817cd2f4950a5ac5601b605084 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 3 Mar 2018 20:43:41 +0000 Subject: [PATCH] Fix errors relating to sponge plugin parameter being an illegal argument (#810) --- .../luckperms/sponge/LPSpongeBootstrap.java | 19 ++++++++++++++---- .../luckperms/sponge/LPSpongePlugin.java | 20 +++++++++---------- .../sponge/messaging/BungeeMessenger.java | 4 ++-- .../event/LPSubjectDataUpdateEvent.java | 6 +++++- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java index e33c3c73..ae7e2bc4 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongeBootstrap.java @@ -52,7 +52,9 @@ import org.spongepowered.api.scheduler.SpongeExecutorService; import org.spongepowered.api.scheduler.SynchronousExecutor; import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Optional; import java.util.UUID; @@ -242,10 +244,19 @@ public class LPSpongeBootstrap implements LuckPermsBootstrap { @Override public File getDataDirectory() { - File serverRoot = getConfigPath().toFile().getParentFile().getParentFile(); - File dataDirectory = new File(serverRoot, "luckperms"); - dataDirectory.mkdirs(); - return dataDirectory; + Path serverRoot = getConfigPath().getParent().getParent(); + Path dataDirectory = serverRoot.resolve("luckperms"); + try { + Files.createDirectories(dataDirectory); + } catch (IOException e) { + e.printStackTrace(); + } + return dataDirectory.toFile(); + } + + @Override + public File getConfigDirectory() { + return this.configDirectory.toFile(); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index 2b8c6591..7fa4f97a 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -111,8 +111,8 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { @Override protected void registerPlatformListeners() { this.connectionListener = new SpongeConnectionListener(this); - this.bootstrap.getGame().getEventManager().registerListeners(this, this.connectionListener); - this.bootstrap.getGame().getEventManager().registerListeners(this, new SpongePlatformListener(this)); + this.bootstrap.getGame().getEventManager().registerListeners(this.bootstrap, this.connectionListener); + this.bootstrap.getGame().getEventManager().registerListeners(this.bootstrap, new SpongePlatformListener(this)); } @Override @@ -123,7 +123,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { @Override protected void registerCommands() { this.commandManager = new SpongeCommandExecutor(this); - this.bootstrap.getGame().getCommandManager().register(this, this.commandManager, "luckperms", "lp", "perm", "perms", "permission", "permissions"); + this.bootstrap.getGame().getCommandManager().register(this.bootstrap, this.commandManager, "luckperms", "lp", "perm", "perms", "permission", "permissions"); } @Override @@ -155,15 +155,15 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { getLogger().warn("Delaying LuckPerms PermissionService registration."); this.lateLoad = true; } else { - this.bootstrap.getGame().getServiceManager().setProvider(this, LPPermissionService.class, this.service); - this.bootstrap.getGame().getServiceManager().setProvider(this, PermissionService.class, this.service.sponge()); - this.bootstrap.getGame().getServiceManager().setProvider(this, LuckPermsService.class, this.service); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LPPermissionService.class, this.service); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, PermissionService.class, this.service.sponge()); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LuckPermsService.class, this.service); } } @Override protected void registerApiOnPlatform(LuckPermsApi api) { - this.bootstrap.getGame().getServiceManager().setProvider(this, LuckPermsApi.class, api); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LuckPermsApi.class, api); } @Override @@ -184,9 +184,9 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { public void lateEnable() { if (this.lateLoad) { getLogger().info("Providing late registration of PermissionService..."); - this.bootstrap.getGame().getServiceManager().setProvider(this, LPPermissionService.class, this.service); - this.bootstrap.getGame().getServiceManager().setProvider(this, PermissionService.class, this.service.sponge()); - this.bootstrap.getGame().getServiceManager().setProvider(this, LuckPermsService.class, this.service); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LPPermissionService.class, this.service); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, PermissionService.class, this.service.sponge()); + this.bootstrap.getGame().getServiceManager().setProvider(this.bootstrap, LuckPermsService.class, this.service); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/BungeeMessenger.java b/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/BungeeMessenger.java index aaf8ec41..bc2df14a 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/BungeeMessenger.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/messaging/BungeeMessenger.java @@ -61,7 +61,7 @@ public class BungeeMessenger implements Messenger, RawDataListener { } public void init() { - this.channel = this.plugin.getBootstrap().getGame().getChannelRegistrar().createRawChannel(this.plugin, CHANNEL); + this.channel = this.plugin.getBootstrap().getGame().getChannelRegistrar().createRawChannel(this.plugin.getBootstrap(), CHANNEL); this.channel.addListener(Platform.Type.SERVER, this); } @@ -87,7 +87,7 @@ public class BungeeMessenger implements Messenger, RawDataListener { this.channel.sendTo(p, buf -> buf.writeUTF(outgoingMessage.asEncodedString())); task.cancel(); - }).submit(this.plugin); + }).submit(this.plugin.getBootstrap()); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java index d1146e8d..3734c9b4 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/event/LPSubjectDataUpdateEvent.java @@ -62,6 +62,10 @@ public class LPSubjectDataUpdateEvent extends AbstractEvent implements SubjectDa .add(EventContextKeys.PLUGIN, this.plugin.getBootstrap().getPluginContainer()) .build(); - return Cause.builder().build(eventContext); + return Cause.builder() + .append(this.plugin.getService()) + .append(this.plugin.getService().sponge()) + .append(this.plugin.getBootstrap().getPluginContainer()) + .build(eventContext); } }