@@ -30,9 +30,12 @@ public class OreGinPlugin extends JavaPlugin
30
30
public static final String ORE_GIN_SAVES_DIRECTORY = "OreGinSaves" ;
31
31
public static final int TICKS_PER_SECOND = 20 ; //The number of ticks per second
32
32
33
+ public static final String CITADEL_NAME = "Citadel" ; //The plugin name for 'Citadel'
34
+
33
35
public static int UPDATE_CYCLE ; //Update time in ticks
34
36
public static int MAXIMUM_BLOCK_BREAKS_PER_CYCLE ; //The maximum number of block breaks per update cycle.
35
37
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
36
39
public static Material OREGIN_UPGRADE_WAND ; //The wand used for creating and upgrading OreGins
37
40
public static Material OREGIN_ACTIVATION_WAND ; //The wand used for powering OreGins
38
41
public static Material OREGIN_REPAIR_WAND ; //The wand used for repairing OreGins
@@ -52,26 +55,36 @@ public class OreGinPlugin extends JavaPlugin
52
55
*/
53
56
public void onEnable ()
54
57
{
55
- getLogger ().info (PLUGIN_NAME + " " + VERSION + " has been enabled!" );
56
-
57
- getConfig ().options ().copyDefaults (true );
58
- Ore_Gin_Properties = new HashMap <Integer ,OreGinProperties >();
59
58
initializeOreGinProperties ();
60
59
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
+ }
67
78
}
68
79
69
80
/**
70
81
* Disabled Function
71
82
*/
72
83
public void onDisable ()
73
84
{
74
- save (oreGinMan , getOreGinSavesFile ());
85
+ if (oreGinMan != null )
86
+ save (oreGinMan , getOreGinSavesFile ());
87
+
75
88
getLogger ().info (PLUGIN_NAME + " " + VERSION + " has been disabled!" );
76
89
}
77
90
@@ -85,9 +98,12 @@ public void onDisable()
85
98
@ SuppressWarnings ("unchecked" )
86
99
public void initializeOreGinProperties ()
87
100
{
101
+ Ore_Gin_Properties = new HashMap <Integer ,OreGinProperties >();
102
+
88
103
//Load general config values
89
104
OreGinPlugin .UPDATE_CYCLE = getConfig ().getInt ("general.update_cycle" );
90
105
OreGinPlugin .MAXIMUM_BLOCK_BREAKS_PER_CYCLE = getConfig ().getInt ("general.maximum_block_breaks_per_cycle" );
106
+ OreGinPlugin .CITADEL_ENABLED = getConfig ().getBoolean ("general.citadel_enabled" );
91
107
OreGinPlugin .SAVE_CYCLE = getConfig ().getInt ("general.save_cycle" );
92
108
OreGinPlugin .OREGIN_UPGRADE_WAND = Material .valueOf (getConfig ().getString ("general.oregin_upgrade_wand" ));
93
109
OreGinPlugin .OREGIN_ACTIVATION_WAND = Material .valueOf (getConfig ().getString ("general.oregin_activation_wand" ));
@@ -167,6 +183,14 @@ public String getOreGinPropertiesPathStart(int tierLevel)
167
183
return "oregin_tier_properties.tier" + tierLevel + "." ;
168
184
}
169
185
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
+ }
170
194
171
195
/*
172
196
----------SAVING/LOADING LOGIC--------
0 commit comments