mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Check PluginLib version before using it
This should help when admins have not updated the PluginLib but the plugin already needs a newer version
This commit is contained in:
parent
9cf1cdf762
commit
a51c180413
23
src/at/pcgamingfreaks/Minepacks/Bukkit/MagicValues.java
Normal file
23
src/at/pcgamingfreaks/Minepacks/Bukkit/MagicValues.java
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit;
|
||||
|
||||
public class MagicValues
|
||||
{
|
||||
public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.19-SNAPSHOT";
|
||||
}
|
@ -57,7 +57,7 @@ public class Minepacks extends JavaPlugin implements MinepacksPlugin
|
||||
{
|
||||
private static final int BUKKIT_PROJECT_ID = 83445;
|
||||
@SuppressWarnings("unused")
|
||||
private static final String JENKINS_URL = "https://ci.pcgamingfreaks.at", JENKINS_JOB_DEV = "Minepacks Dev", JENKINS_JOB_MASTER = "Minepacks", MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.19-SNAPSHOT";
|
||||
private static final String JENKINS_URL = "https://ci.pcgamingfreaks.at", JENKINS_JOB_DEV = "Minepacks Dev", JENKINS_JOB_MASTER = "Minepacks";
|
||||
private static Minepacks instance = null;
|
||||
|
||||
private Config config;
|
||||
@ -103,7 +103,7 @@ public void onEnable()
|
||||
}
|
||||
else[STANDALONE]*/
|
||||
// Not standalone so we should check the version of the PluginLib
|
||||
if(at.pcgamingfreaks.PluginLib.Bukkit.PluginLib.getInstance().getVersion().olderThan(new Version(MIN_PCGF_PLUGIN_LIB_VERSION)))
|
||||
if(at.pcgamingfreaks.PluginLib.Bukkit.PluginLib.getInstance().getVersion().olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION)))
|
||||
{
|
||||
getLogger().warning("You are using an outdated version of the PCGF PluginLib! Please update it!");
|
||||
setEnabled(false);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 GeorgH93
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -18,8 +18,10 @@
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit;
|
||||
|
||||
import at.pcgamingfreaks.BadRabbit.Bukkit.BadRabbit;
|
||||
import at.pcgamingfreaks.Version;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -32,17 +34,28 @@ public class MinepacksBadRabbit extends BadRabbit
|
||||
@Override
|
||||
protected @NotNull JavaPlugin createInstance() throws Exception
|
||||
{
|
||||
JavaPlugin newPluginInstance;
|
||||
if(Bukkit.getPluginManager().getPlugin("PCGF_PluginLib") == null)
|
||||
JavaPlugin newPluginInstance = null;
|
||||
Plugin pcgfPluginLib = Bukkit.getPluginManager().getPlugin("PCGF_PluginLib");
|
||||
if(pcgfPluginLib != null)
|
||||
{
|
||||
getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!");
|
||||
Class<?> standaloneClass = Class.forName("at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks");
|
||||
newPluginInstance = (JavaPlugin) standaloneClass.newInstance();
|
||||
if(new Version(pcgfPluginLib.getDescription().getVersion()).olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION)))
|
||||
{
|
||||
getLogger().info("PCGF-PluginLib to old! Switching to standalone mode!");
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().info("PCGF-PluginLib installed. Switching to normal mode!");
|
||||
newPluginInstance = new Minepacks();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().info("PCGF-PluginLib installed. Switching to normal mode!");
|
||||
newPluginInstance = new Minepacks();
|
||||
getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!");
|
||||
}
|
||||
if(newPluginInstance == null)
|
||||
{
|
||||
Class<?> standaloneClass = Class.forName("at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks");
|
||||
newPluginInstance = (JavaPlugin) standaloneClass.newInstance();
|
||||
}
|
||||
return newPluginInstance;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user