From 219d485835de79d3ef8c193ce29422bf28132c61 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 17 Jan 2014 09:25:22 +1100 Subject: [PATCH] Make the yaml reconnect handler a module --- module/reconnect-yaml/nb-configuration.xml | 31 +++++++++++++++++++ module/reconnect-yaml/pom.xml | 20 ++++++++++++ .../module/reconnect/yaml/PluginYaml.java | 13 ++++++++ .../reconnect/yaml}/YamlReconnectHandler.java | 2 +- .../src/main/resources/plugin.yml | 4 +++ .../main/java/net/md_5/bungee/BungeeCord.java | 10 +----- .../net/md_5/bungee/module/ModuleManager.java | 4 ++- 7 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 module/reconnect-yaml/nb-configuration.xml create mode 100644 module/reconnect-yaml/pom.xml create mode 100644 module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/PluginYaml.java rename {proxy/src/main/java/net/md_5/bungee/reconnect => module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml}/YamlReconnectHandler.java (98%) create mode 100644 module/reconnect-yaml/src/main/resources/plugin.yml diff --git a/module/reconnect-yaml/nb-configuration.xml b/module/reconnect-yaml/nb-configuration.xml new file mode 100644 index 00000000..7e465924 --- /dev/null +++ b/module/reconnect-yaml/nb-configuration.xml @@ -0,0 +1,31 @@ + + + + + + project + NEW_LINE + NEW_LINE + NEW_LINE + true + true + true + true + true + true + true + true + true + true + + diff --git a/module/reconnect-yaml/pom.xml b/module/reconnect-yaml/pom.xml new file mode 100644 index 00000000..54c8b480 --- /dev/null +++ b/module/reconnect-yaml/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + + net.md-5 + bungeecord-module + 1.7-SNAPSHOT + ../pom.xml + + + net.md-5 + bungeecord-module-reconnect-yaml + 1.7-SNAPSHOT + jar + + reconnect_yaml + Provides reconnect location functionality in locations.yml + diff --git a/module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/PluginYaml.java b/module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/PluginYaml.java new file mode 100644 index 00000000..63a87b58 --- /dev/null +++ b/module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/PluginYaml.java @@ -0,0 +1,13 @@ +package net.md_5.bungee.module.reconnect.yaml; + +import net.md_5.bungee.api.plugin.Plugin; + +public class PluginYaml extends Plugin +{ + + @Override + public void onEnable() + { + getProxy().setReconnectHandler( new YamlReconnectHandler() ); + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/reconnect/YamlReconnectHandler.java b/module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/YamlReconnectHandler.java similarity index 98% rename from proxy/src/main/java/net/md_5/bungee/reconnect/YamlReconnectHandler.java rename to module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/YamlReconnectHandler.java index 6f036b73..a7c79668 100644 --- a/proxy/src/main/java/net/md_5/bungee/reconnect/YamlReconnectHandler.java +++ b/module/reconnect-yaml/src/main/java/net/md_5/bungee/module/reconnect/yaml/YamlReconnectHandler.java @@ -1,4 +1,4 @@ -package net.md_5.bungee.reconnect; +package net.md_5.bungee.module.reconnect.yaml; import net.md_5.bungee.api.AbstractReconnectHandler; import java.io.File; diff --git a/module/reconnect-yaml/src/main/resources/plugin.yml b/module/reconnect-yaml/src/main/resources/plugin.yml new file mode 100644 index 00000000..88ab2724 --- /dev/null +++ b/module/reconnect-yaml/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: ${project.name} +main: net.md_5.bungee.module.reconnect.yaml.PluginYaml +version: ${describe} +description: ${project.description} diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index cbcd64c5..7f2c4e1c 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -6,7 +6,6 @@ import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.log.BungeeLogger; -import net.md_5.bungee.reconnect.YamlReconnectHandler; import net.md_5.bungee.scheduler.BungeeScheduler; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.gson.Gson; @@ -196,14 +195,7 @@ public class BungeeCord extends ProxyServer pluginsFolder.mkdir(); pluginManager.detectPlugins( pluginsFolder ); config.load(); - for ( ListenerInfo info : config.getListeners() ) - { - if ( !info.isForceDefault() && reconnectHandler == null ) - { - reconnectHandler = new YamlReconnectHandler(); - break; - } - } + isRunning = true; pluginManager.loadAndEnablePlugins(); diff --git a/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java b/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java index 607e6ff4..abcc36bf 100644 --- a/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java +++ b/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java @@ -79,9 +79,11 @@ public class ModuleManager defaults.add( "jenkins://cmd_list" ); defaults.add( "jenkins://cmd_send" ); defaults.add( "jenkins://cmd_server" ); + case 1: + defaults.add( "jenkins://reconnect_yaml" ); } config.put( "modules", defaults ); - config.put( "version", 1 ); + config.put( "version", 2 ); try ( FileWriter wr = new FileWriter( configFile ) ) {