Add auto updater for standalone builds

This commit is contained in:
GeorgH93 2019-07-13 00:56:04 +02:00
parent 18d2cd4534
commit b5cedf3033
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 7 additions and 11 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>Minepacks</artifactId>
<version>2.0.8-RC1</version>
<version>2.0.8-RC2</version>
<scm>
<connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>

View File

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

View File

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