Fix errors relating to sponge plugin parameter being an illegal argument (#810)

This commit is contained in:
Luck 2018-03-03 20:43:41 +00:00
parent 0d89840179
commit 6d2ea659a4
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 32 additions and 17 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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);
}
}