summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Miller <mnmiller1@me.com>2015-10-02 14:17:15 +1000
committerMatthew Miller <mnmiller1@me.com>2015-10-02 14:17:15 +1000
commit80a7f49379bd2cbd0cf56bf8dc2694bfe460e5b7 (patch)
tree59be289e7b86cfc86dceb81291550ab6d29c87ea
parent8b2340e6c9b987a41cf2cabcd7cfe36f3987ce62 (diff)
downloadEssentials-80a7f49379bd2cbd0cf56bf8dc2694bfe460e5b7.tar
Essentials-80a7f49379bd2cbd0cf56bf8dc2694bfe460e5b7.tar.gz
Essentials-80a7f49379bd2cbd0cf56bf8dc2694bfe460e5b7.tar.lz
Essentials-80a7f49379bd2cbd0cf56bf8dc2694bfe460e5b7.tar.xz
Essentials-80a7f49379bd2cbd0cf56bf8dc2694bfe460e5b7.zip
Added base example module, and system to load it
-rw-r--r--build.gradle2
-rw-r--r--src/main/java/org/mcess/essentials/Essentials.java35
-rw-r--r--src/main/java/org/mcess/essentials/modules/Teleport.java30
3 files changed, 65 insertions, 2 deletions
diff --git a/build.gradle b/build.gradle
index f478ebf80..cc726c292 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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.+'
}
diff --git a/src/main/java/org/mcess/essentials/Essentials.java b/src/main/java/org/mcess/essentials/Essentials.java
index 3e2b13c75..728e6776c 100644
--- a/src/main/java/org/mcess/essentials/Essentials.java
+++ b/src/main/java/org/mcess/essentials/Essentials.java
@@ -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");
+ }
}
diff --git a/src/main/java/org/mcess/essentials/modules/Teleport.java b/src/main/java/org/mcess/essentials/modules/Teleport.java
new file mode 100644
index 000000000..68b6c6a25
--- /dev/null
+++ b/src/main/java/org/mcess/essentials/modules/Teleport.java
@@ -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;
+ }
+ }
+}