From 9c1a9769b29a508a2f4c81155e5c743e962a6554 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Tue, 13 Sep 2011 19:54:06 -0600 Subject: [PATCH] Update to new AllPay version --- lib/allpay | 2 +- .../MultiverseCore/MultiverseCore.java | 40 ++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/allpay b/lib/allpay index 5f40678a..18c55a90 160000 --- a/lib/allpay +++ b/lib/allpay @@ -1 +1 @@ -Subproject commit 5f40678ac750210a3121921af0c4e58e6516bfdb +Subproject commit 18c55a9070a5e64b2cb0737940290643f324fa7d diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index eef7533f..e894830b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -90,7 +90,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { private Configuration configMV = null; private WorldManager worldManager = new WorldManager(this); - + // Setup the block/player/entity listener. private MVPlayerListener playerListener = new MVPlayerListener(this); @@ -105,12 +105,12 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { // HashMap to contain information relating to the Players. private HashMap playerSessions; private GenericBank bank = null; - private AllPay banker = new AllPay(this, tag + " "); + private AllPay banker; protected MVConfigMigrator migrator = new MVCoreConfigMigrator(this); protected int pluginCount; private DestinationFactory destFactory; private SpoutInterface spoutInterface = null; - + private int allpayversion = 3; @Override public void onLoad() { @@ -130,6 +130,12 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { } public void onEnable() { + // Perform initial checks for AllPay + if (!this.validateAllpay()) { + this.getServer().getPluginManager().disablePlugin(this); + return; + } + this.banker = new AllPay(this, tag + " "); // Output a little snippet to show it's enabled. this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors()); this.checkServerProps(); @@ -147,7 +153,6 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { this.registerCommands(); this.playerSessions = new HashMap(); - // Start the Update Checker // updateCheck = new UpdateChecker(this.getDescription().getName(), this.getDescription().getVersion()); @@ -164,6 +169,29 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { } } + private boolean validateAllpay() { + try { + this.banker = new AllPay(this, "Verify"); + if (this.banker.getVersion() >= allpayversion) { + return true; + } else { + log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!"); + log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatable version of AllPay!"); + log.info(tag + " The Following Plugins MAY out of date!"); + log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher and another plugin has loaded v" + this.banker.getVersion() + "!"); + log.info(tag + AllPay.pluginsThatUseUs.toString()); + return false; + } + } catch (Throwable t) { + } + log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!"); + log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatable version of AllPay!"); + log.info(tag + " Check the logs for [AllPay] - Version ... for PLUGIN NAME to find the culprit! Then Yell at that dev!"); + log.info(tag + " Or update that plugin :P"); + log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher!"); + return false; + } + private void initializeDestinationFactory() { this.destFactory = new DestinationFactory(this); this.destFactory.registerDestinationType(WorldDestination.class, ""); @@ -206,7 +234,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { new DefaultConfig(getDataFolder(), "worlds.yml", this.migrator); // Now grab the Configuration Files. this.configMV = new Configuration(new File(getDataFolder(), "config.yml")); - + this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml")); // Now attempt to Load the configurations. @@ -292,7 +320,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { */ @Deprecated public boolean removeWorldFromConfig(String name) { - return this.worldManager.removeWorldFromConfig(name); + return this.worldManager.removeWorldFromConfig(name); } /**