Skip to content

Commit 51f0e9b

Browse files
author
MrTwiggy
committed
Updated Citadel Jar and added the ability to function without Citadel
being installed.
1 parent 9944946 commit 51f0e9b

File tree

10 files changed

+44
-21
lines changed

10 files changed

+44
-21
lines changed

Referenced Jars/Citadel.jar

-99 Bytes
Binary file not shown.
46 Bytes
Binary file not shown.
-11 Bytes
Binary file not shown.
Binary file not shown.
582 Bytes
Binary file not shown.

config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ general:
22
update_cycle: 5
33
maximum_block_breaks_per_cycle: 500
44
save_cycle: 10
5+
citadel_enabled: true
56
max_tiers: 7
67
oregin_upgrade_wand: YELLOW_FLOWER
78
oregin_activation_wand: RED_ROSE

plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name: OreGin
22
main: com.github.MrTwiggy.OreGin.OreGinPlugin
33
author: MrTwiggy
44
version: 0.1
5-
depend: [Citadel]
5+
softdepend: [Citadel]

src/com/github/MrTwiggy/OreGin/OreGin.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ else if (OreGinPlugin.INDESTRUCTIBLE.contains(blockType))
338338
}
339339
else
340340
{
341-
if (!isReinforced(block))
341+
if ((OreGinPlugin.CITADEL_ENABLED && !isReinforced(block))
342+
|| !OreGinPlugin.CITADEL_ENABLED)
342343
{
343344
if (oreGinProperties.getRetrieveValuables() && OreGinPlugin.VALUABLES.contains(blockType))
344345
{

src/com/github/MrTwiggy/OreGin/OreGinListener.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,16 @@ public void oreGinBroken(BlockBreakEvent event)
105105
if (oreGinMan.oreGinLightExistsAt(destroyed.getLocation()))
106106
oreGin = oreGinMan.getOreGin(destroyed.getRelative(BlockFace.DOWN).getLocation());
107107

108-
if (!isReinforced(oreGin.getLocation().getBlock()) &&
109-
!isReinforced(oreGin.getLocation().getBlock().getRelative(BlockFace.UP)))
108+
event.setCancelled(true);
109+
110+
if ( (OreGinPlugin.CITADEL_ENABLED && !isReinforced(oreGin.getLocation().getBlock())
111+
&& !isReinforced(oreGin.getLocation().getBlock().getRelative(BlockFace.UP)))
112+
|| !OreGinPlugin.CITADEL_ENABLED)
110113
{
111-
event.setCancelled(true);
112114
ItemStack dropItem = new ItemStack(Material.DISPENSER, 1);
113115
oreGin.destroyOreGin(dropItem);
114116
oreGinMan.removeOreGin(oreGin);
115117
}
116-
else if (isReinforced(oreGin.getLocation().getBlock()) ||
117-
isReinforced(oreGin.getLocation().getBlock().getRelative(BlockFace.UP)))
118-
{
119-
event.setCancelled(true);
120-
}
121118
}
122119
}
123120
}

src/com/github/MrTwiggy/OreGin/OreGinPlugin.java

+35-11
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)