From b5cedf30334ee35c08e246f28137f9c156a7369d Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sat, 13 Jul 2019 00:56:04 +0200 Subject: [PATCH] Add auto updater for standalone builds --- pom.xml | 2 +- .../pcgamingfreaks/Minepacks/Bukkit/Minepacks.java | 13 +++++-------- .../Minepacks/Bukkit/MinepacksBadRabbit.java | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index a904cd2..366e85f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 at.pcgamingfreaks Minepacks - 2.0.8-RC1 + 2.0.8-RC2 scm:git:git@github.com:GeorgH93/Minepacks.git diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java index 07773a7..617a02e 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java @@ -57,12 +57,10 @@ public class Minepacks extends JavaPlugin implements MinepacksPlugin { private static final int BUKKIT_PROJECT_ID = 83445; - private static final String JENKINS_URL = "https://ci.pcgamingfreaks.at", JENKINS_JOB = "Minepacks V2", MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.14-SNAPSHOT"; + @SuppressWarnings("unused") + private static final String JENKINS_URL = "https://ci.pcgamingfreaks.at", JENKINS_JOB_DEV = "Minepacks V2", JENKINS_JOB_MASTER = "Minepacks", MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.14-SNAPSHOT"; private static Minepacks instance = null; - @SuppressWarnings("FieldCanBeLocal") // Field is set per reflection from the BadRabbit loader - private boolean useBukkitUpdater = false; - private Config config; private Language lang; private Database database; @@ -157,14 +155,13 @@ public void onDisable() public @Nullable Updater update(@Nullable at.pcgamingfreaks.Updater.Updater.UpdaterResponse output) { UpdateProvider updateProvider; - if(useBukkitUpdater) updateProvider = new BukkitUpdateProvider(BUKKIT_PROJECT_ID, getLogger()); + if(getDescription().getVersion().contains("Release")) updateProvider = new BukkitUpdateProvider(BUKKIT_PROJECT_ID, getLogger()); else { /*if[STANDALONE] - getLogger().warning("Auto-updates not available for your build config!"); - return null; + updateProvider = new JenkinsUpdateProvider(JENKINS_URL, JENKINS_JOB_MASTER, getLogger(), ".*-Standalone.*"); else[STANDALONE]*/ - updateProvider = new JenkinsUpdateProvider(JENKINS_URL, JENKINS_JOB, getLogger()); + updateProvider = new JenkinsUpdateProvider(JENKINS_URL, JENKINS_JOB_DEV, getLogger()); /*end[STANDALONE]*/ } Updater updater = new Updater(this, this.getFile(), true, updateProvider); diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java index 6978ad8..4821475 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java @@ -26,6 +26,7 @@ /** * Uses BadRabbit to initiate the plugin in normal or standalone mode depending on the users environment. */ +@SuppressWarnings("unused") public class MinepacksBadRabbit extends BadRabbit { @Override @@ -37,13 +38,11 @@ public class MinepacksBadRabbit extends BadRabbit getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!"); Class standaloneClass = Class.forName("at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks"); newPluginInstance = (JavaPlugin) standaloneClass.newInstance(); - getField(standaloneClass, "useBukkitUpdater").set(newPluginInstance, true); } else { getLogger().info("PCGF-PluginLib installed. Switching to normal mode!"); newPluginInstance = new Minepacks(); - getField(Minepacks.class, "useBukkitUpdater").set(newPluginInstance, true); } return newPluginInstance; }