1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-08 15:46:54 +02:00

Added base example module, and system to load it

This commit is contained in:
Matthew Miller
2015-10-02 14:17:15 +10:00
parent 8b2340e6c9
commit 80a7f49379
3 changed files with 65 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ dependencies {
compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.findbugs:jsr305:1.3.9'
compile 'com.me4502:ModularFramework:1.1.5'
compile 'com.me4502:ModularFramework:1.2.1'
testCompile 'org.mockito:mockito-core:2.+'
testCompile 'junit:junit:4.+'
}

View File

@@ -1,9 +1,42 @@
package org.mcess.essentials;
import com.google.inject.Inject;
import com.me4502.modularframework.ModuleController;
import com.me4502.modularframework.ShadedModularFramework;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.service.config.DefaultConfig;
import java.io.File;
@Plugin(id = "Essentials", name = "Essentials")
public class Essentials {
ModuleController moduleController;
@Inject
@DefaultConfig(sharedRoot = false)
private File mainConfig;
private File configurationDirectory;
@Listener
public void onInitialize(GameStartedServerEvent event) {
moduleController = ShadedModularFramework.registerModuleController(this, event.getGame());
configurationDirectory = new File(mainConfig.getParent(), "modules");
configurationDirectory.mkdir();
moduleController.setConfigurationDirectory(configurationDirectory);
discoverModules();
moduleController.enableModules((moduleWrapper) -> true); //Enable all for now.
}
public void discoverModules() {
//List all the modules that exist.
moduleController.registerModule("org.mcess.essentials.modules.Teleport");
}
}

View File

@@ -0,0 +1,30 @@
package org.mcess.essentials.modules;
import com.me4502.modularframework.module.Module;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandException;
import org.spongepowered.api.util.command.CommandResult;
import org.spongepowered.api.util.command.CommandSource;
import org.spongepowered.api.util.command.args.CommandContext;
import org.spongepowered.api.util.command.spec.CommandExecutor;
import org.spongepowered.api.util.command.spec.CommandSpec;
@Module(moduleName = "Teleport", onEnable = "onInitialize")
public class Teleport {
public void onInitialize() {
CommandSpec myCommandSpec = CommandSpec.builder()
.description(Texts.of("Teleport to a player"))
.permission("essentials.teleport")
.executor(new TeleportCommand())
.build();
}
private class TeleportCommand implements CommandExecutor {
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
return null;
}
}
}