Fix plugin not starting without PCGF PluginLib

This commit is contained in:
GeorgH93 2022-03-05 00:02:22 +01:00
parent a165ca9531
commit 2acff3673a
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
2 changed files with 11 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 GeorgH93 * Copyright (C) 2022 GeorgH93
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -36,6 +36,7 @@ public class MinepacksBadRabbit extends BadRabbit
{ {
JavaPlugin newPluginInstance = null; JavaPlugin newPluginInstance = null;
Plugin pcgfPluginLib = Bukkit.getPluginManager().getPlugin("PCGF_PluginLib"); Plugin pcgfPluginLib = Bukkit.getPluginManager().getPlugin("PCGF_PluginLib");
boolean standalone = true;
if(pcgfPluginLib != null) if(pcgfPluginLib != null)
{ {
if(new Version(pcgfPluginLib.getDescription().getVersion()).olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION))) if(new Version(pcgfPluginLib.getDescription().getVersion()).olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION)))
@ -45,18 +46,22 @@ public class MinepacksBadRabbit extends BadRabbit
else else
{ {
getLogger().info("PCGF-PluginLib installed. Switching to normal mode!"); getLogger().info("PCGF-PluginLib installed. Switching to normal mode!");
newPluginInstance = new Minepacks(); standalone = false;
} }
} }
else else
{ {
getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!"); getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!");
} }
if(newPluginInstance == null) if(standalone)
{ {
Class<?> standaloneClass = Class.forName("at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks"); Class<?> standaloneClass = Class.forName("at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks");
newPluginInstance = (JavaPlugin) standaloneClass.newInstance(); return (JavaPlugin) standaloneClass.newInstance();
}
else
{
Class<?> normalClass = Class.forName("at.pcgamingfreaks.Minepacks.Bukkit.Minepacks");
return (JavaPlugin) normalClass.newInstance();
} }
return newPluginInstance;
} }
} }

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
<revision>2.4.5</revision> <revision>2.4.5.1</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>