diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/MagicValues.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/MagicValues.java new file mode 100644 index 0000000..a1a0a83 --- /dev/null +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/MagicValues.java @@ -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 . + */ + +package at.pcgamingfreaks.Minepacks.Bukkit; + +public class MagicValues +{ + public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.19-SNAPSHOT"; +} \ No newline at end of file diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java index b7a2300..95443d9 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java @@ -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); diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java index 4821475..9917e79 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/MinepacksBadRabbit.java @@ -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; }