@@ -30,9 +30,12 @@ public class OreGinPlugin extends JavaPlugin
3030 public static final String ORE_GIN_SAVES_DIRECTORY = "OreGinSaves" ;
3131 public static final int TICKS_PER_SECOND = 20 ; //The number of ticks per second
3232
33+ public static final String CITADEL_NAME = "Citadel" ; //The plugin name for 'Citadel'
34+
3335 public static int UPDATE_CYCLE ; //Update time in ticks
3436 public static int MAXIMUM_BLOCK_BREAKS_PER_CYCLE ; //The maximum number of block breaks per update cycle.
3537 public static int SAVE_CYCLE ; //The time between periodic saves in minutes
38+ public static boolean CITADEL_ENABLED ; //Whether the plugin 'Citadel' is enabled on this server
3639 public static Material OREGIN_UPGRADE_WAND ; //The wand used for creating and upgrading OreGins
3740 public static Material OREGIN_ACTIVATION_WAND ; //The wand used for powering OreGins
3841 public static Material OREGIN_REPAIR_WAND ; //The wand used for repairing OreGins
@@ -52,26 +55,36 @@ public class OreGinPlugin extends JavaPlugin
5255 */
5356 public void onEnable ()
5457 {
55- getLogger ().info (PLUGIN_NAME + " " + VERSION + " has been enabled!" );
56-
57- getConfig ().options ().copyDefaults (true );
58- Ore_Gin_Properties = new HashMap <Integer ,OreGinProperties >();
5958 initializeOreGinProperties ();
6059
61- oreGinMan = new OreGinManager (this );
62- oreGinListener = new OreGinListener (oreGinMan );
63- getServer ().getPluginManager ().registerEvents (oreGinListener , this );
64-
65- load (oreGinMan , getOreGinSavesFile ());
66- periodicSaving ();
60+ if (properPluginsLoaded ())
61+ {
62+ getLogger ().info (PLUGIN_NAME + " " + VERSION + " has been enabled!" );
63+
64+ getConfig ().options ().copyDefaults (true );
65+
66+ oreGinMan = new OreGinManager (this );
67+ oreGinListener = new OreGinListener (oreGinMan );
68+ getServer ().getPluginManager ().registerEvents (oreGinListener , this );
69+
70+ load (oreGinMan , getOreGinSavesFile ());
71+ periodicSaving ();
72+ }
73+ else
74+ {
75+ OreGinPlugin .sendConsoleMessage ("The Citadel config value is not correct for loaded plugins! Disabling OreGin now!" );
76+ getServer ().getPluginManager ().disablePlugin (this );
77+ }
6778 }
6879
6980 /**
7081 * Disabled Function
7182 */
7283 public void onDisable ()
7384 {
74- save (oreGinMan , getOreGinSavesFile ());
85+ if (oreGinMan != null )
86+ save (oreGinMan , getOreGinSavesFile ());
87+
7588 getLogger ().info (PLUGIN_NAME + " " + VERSION + " has been disabled!" );
7689 }
7790
@@ -85,9 +98,12 @@ public void onDisable()
8598 @ SuppressWarnings ("unchecked" )
8699 public void initializeOreGinProperties ()
87100 {
101+ Ore_Gin_Properties = new HashMap <Integer ,OreGinProperties >();
102+
88103 //Load general config values
89104 OreGinPlugin .UPDATE_CYCLE = getConfig ().getInt ("general.update_cycle" );
90105 OreGinPlugin .MAXIMUM_BLOCK_BREAKS_PER_CYCLE = getConfig ().getInt ("general.maximum_block_breaks_per_cycle" );
106+ OreGinPlugin .CITADEL_ENABLED = getConfig ().getBoolean ("general.citadel_enabled" );
91107 OreGinPlugin .SAVE_CYCLE = getConfig ().getInt ("general.save_cycle" );
92108 OreGinPlugin .OREGIN_UPGRADE_WAND = Material .valueOf (getConfig ().getString ("general.oregin_upgrade_wand" ));
93109 OreGinPlugin .OREGIN_ACTIVATION_WAND = Material .valueOf (getConfig ().getString ("general.oregin_activation_wand" ));
@@ -167,6 +183,14 @@ public String getOreGinPropertiesPathStart(int tierLevel)
167183 return "oregin_tier_properties.tier" + tierLevel + "." ;
168184 }
169185
186+ /**
187+ * Returns whether the proper plugins are loaded based on config values
188+ */
189+ public boolean properPluginsLoaded ()
190+ {
191+ return ( (getServer ().getPluginManager ().getPlugin (CITADEL_NAME ) != null && OreGinPlugin .CITADEL_ENABLED )
192+ || (getServer ().getPluginManager ().getPlugin (CITADEL_NAME ) == null && !OreGinPlugin .CITADEL_ENABLED ));
193+ }
170194
171195 /*
172196 ----------SAVING/LOADING LOGIC--------
0 commit comments