diff --git a/src/com/pwn9/PwnPlantGrowth/BlockGrowListener.java b/src/com/pwn9/PwnPlantGrowth/BlockGrowListener.java index 2cf6596..bf6d787 100644 --- a/src/com/pwn9/PwnPlantGrowth/BlockGrowListener.java +++ b/src/com/pwn9/PwnPlantGrowth/BlockGrowListener.java @@ -26,268 +26,6 @@ static Calculate getCalcs(List> specialBlocks, String thisBlock, St return new Calculate(specialBlocks, thisBlock, curBiome, isDark); } - // called to run the calculations and determine what happens to the plant on the event - public String runCalcs(BlockGrowEvent e, String thisBlock, String curBiome, Boolean isDark) - { - String toLog = ""; - String frontLog = ", Biome: " + curBiome + ", Dark: " + isDark.toString() + ", "; - String darkLog = "Dark Settings: {"; - String groupLog = "Settings: {"; - // bool to catch if the biome is never declared in any config, therefor a bad biome and should not grow - boolean noBiome = true; - - int curGrowth = plugin.getConfig().getInt(thisBlock+".Growth"); - frontLog += "Default Growth: " + curGrowth + ", "; - int curDeath = plugin.getConfig().getInt(thisBlock+".Death"); - frontLog += "Default Death: " + curDeath + ", "; - - if ((plugin.getConfig().isSet(thisBlock+".BiomeGroup")) || (plugin.getConfig().getList(thisBlock+".Biome").isEmpty()) || (plugin.getConfig().getList(thisBlock+".Biome").contains(curBiome))) - { - // check the area to find if any of the special blocks are found - List> specialBlocks = specialBlockList(e); - List fBlocksFound = specialBlocks.get(0); - List wkBlocksFound = specialBlocks.get(1); - List uvBlocksFound = specialBlocks.get(2); - - // check the biome group settings - if (plugin.getConfig().isSet(thisBlock+".BiomeGroup")) - { - - // create list from the config setting - List groupList = plugin.getConfig().getList(thisBlock+".BiomeGroup"); - - groupLog += "BiomeGroup: " + groupList.toString() + ", "; - - // iterate through list and see if any of that list matches curBiome - boolean matches = false; - for (int i = 0; i < groupList.size(); i++) - { - - // check the biomegroup for this named group - if ((plugin.getConfig().getList("BiomeGroup."+groupList.get(i)) != null) && (plugin.getConfig().getList("BiomeGroup."+groupList.get(i)).contains(curBiome))) - { - matches = true; - noBiome = false; - groupLog += "Matches: " + groupList.get(i) + ", "; - - // reference the configs now to see if the config settings are set! - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".Growth")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".Growth"); - groupLog += "New Growth: " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".Death")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".Death"); - groupLog += "New Death: " + curDeath + ", "; - } - } - } - if (!matches) { - groupLog += "Matches: NULL, "; - } - } - else { - groupLog += "BiomeGroup: NULL, "; - } - - groupLog += "Specific Settings: {"; - - if (plugin.getConfig().getList(thisBlock+".Biome").contains(curBiome)) { - noBiome = false; - // override with individual settings - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".Growth")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+curBiome+".Growth"); - groupLog += "Growth for " + curBiome + ": " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".Death")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+curBiome+".Death"); - groupLog += "Death for " + curBiome + ": " + curDeath + ", "; - } - } - - // if there is fertilizer, grow this plant at the fertilizer rate - default 100% - // TODO: should fertilizer override dark settings or not - i think not for now - if (fBlocksFound.contains(PwnPlantGrowth.fertilizer)) - { - groupLog += PwnPlantGrowth.fertFound; - // set the current growth to the fertilizer rate - curGrowth = PwnPlantGrowth.frate; - } - groupLog += "}}, "; - - // See if there are special settings for dark growth - if (isDark) - { - // If uv is enabled and found, isDark remains false. - if (uvBlocksFound.contains(PwnPlantGrowth.uv)) - { - darkLog += PwnPlantGrowth.uvFound; - } - else - { - // default isDark config rates (if exist) - if (plugin.getConfig().isSet(thisBlock+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+".GrowthDark"); - darkLog += "Growth: " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(thisBlock+".DeathDark"); - darkLog += "Death: " + curDeath + ", "; - } - - // override default values with biome group values - if (plugin.getConfig().isSet(thisBlock+".BiomeGroup")) - { - - // create list from the config setting - List groupList = plugin.getConfig().getList(thisBlock+".BiomeGroup"); - - darkLog += "BiomeGroup: " + groupList.toString() + ", "; - - // iterate through list and see if any of that list matches curBiome - boolean matches = false; - for (int i = 0; i < groupList.size(); i++) { - - // check the biomegroup for this named group - if ((plugin.getConfig().getList("BiomeGroup."+groupList.get(i)) != null) && (plugin.getConfig().getList("BiomeGroup."+groupList.get(i)).contains(curBiome))) - { - - matches = true; - noBiome = false; - darkLog += "Matching: " + groupList.get(i) + ", "; - - // reference the configs now to see if the config settings are set! - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".GrowthDark"); - darkLog += "New Growth: " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".DeathDark"); - darkLog += "New Death: " + curDeath + ", "; - } - } - } - if (!matches) { - darkLog += "Matches: NULL, "; - } - } - else { - darkLog += "BiomeGroup: NULL, "; - } - - darkLog += "Specific Settings: {"; - - // per biome isDark rates (if exist) - if (plugin.getConfig().getList(thisBlock+".Biome").contains(curBiome)) { - noBiome = false; - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+curBiome+".GrowthDark"); - darkLog += "Growth for " + curBiome + ": " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+curBiome+".DeathDark"); - darkLog += "Death for " + curBiome + ": " + curDeath + ", "; - } - } - - darkLog += "}}, "; - } - } - - // cancel bad biomes here - if (noBiome) - { - e.setCancelled(true); - toLog += "RESULT: {Failed Growth: Bad Biome}"; - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - // TODO: make these configurable - if (thisBlock == "COCOA") { - e.getBlock().setType(Material.VINE); - } - else { - e.getBlock().setType(Material.DEAD_BUSH); - } - toLog += " {Plant Died, Rate: " + curDeath + "}"; - } - } - // Run the chance for growth here... - else if (!(PwnPlantGrowth.random(curGrowth))) - { - e.setCancelled(true); - toLog += "RESULT: {Failed Growth, Rate: " + curGrowth + "} "; - - if (wkBlocksFound.contains(PwnPlantGrowth.weedKiller)) - { - toLog += PwnPlantGrowth.wkFound; - } - else - { - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - // TODO: make these configurable - if (thisBlock == "COCOA") { - e.getBlock().setType(Material.VINE); - } - else { - e.getBlock().setType(Material.DEAD_BUSH); - } - toLog += " {Plant Died, Rate: " + curDeath + "}"; - } - } - } - else - { - toLog += "RESULT: {Plant Grew, Rate: " + curGrowth + "}"; - - } - } - else - { - e.setCancelled(true); - toLog += "RESULT: {Failed Growth: Bad Biome}"; - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - // TODO: make these configurable - if (thisBlock == "COCOA") { - Material replace = Material.VINE; - e.getBlock().setType(replace); - } - else { - e.getBlock().setType(Material.DEAD_BUSH); - } - toLog += " {Plant Died, Rate: " + curDeath + "}"; - } - } - - String midLog = ""; - if (isDark) { - midLog += darkLog; - } - else { - midLog += groupLog; - } - - return frontLog + midLog + ", "+ toLog; - } - // retrieve list of special blocks public List> specialBlockList(BlockGrowEvent e) { @@ -417,7 +155,6 @@ public void plantGrow(BlockGrowEvent e) if (curBlock != "AIR") { // run calcs - //toLog += runCalcs(e, curBlock, curBiome, isDark); Calculate cal = getCalcs(specialBlockList(e), curBlock, curBiome, isDark); toLog += cal.doLog; e.setCancelled(cal.isCancelled); diff --git a/src/com/pwn9/PwnPlantGrowth/BlockSpreadListener.java b/src/com/pwn9/PwnPlantGrowth/BlockSpreadListener.java index b1b6a2c..b74babf 100644 --- a/src/com/pwn9/PwnPlantGrowth/BlockSpreadListener.java +++ b/src/com/pwn9/PwnPlantGrowth/BlockSpreadListener.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.List; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -19,274 +18,12 @@ public BlockSpreadListener(PwnPlantGrowth plugin) plugin.getServer().getPluginManager().registerEvents(this, plugin); this.plugin = plugin; } - - // called to run the calculations and determine what happens to the plant on the event - public String runCalcs(BlockSpreadEvent e, String thisBlock, String curBiome, Boolean isDark) - { - - String toLog = ""; - String frontLog = ", Biome: " + curBiome + ", Dark: " + isDark.toString() + ", "; - String darkLog = "Dark Settings: {"; - String groupLog = "Settings: {"; - // bool to catch if the biome is never declared in any config, therefor a bad biome and should not grow - boolean noBiome = true; - - int curGrowth = plugin.getConfig().getInt(thisBlock+".Growth"); - frontLog += "Default Growth: " + curGrowth + ", "; - int curDeath = plugin.getConfig().getInt(thisBlock+".Death"); - frontLog += "Default Death: " + curDeath + ", "; - - if ((plugin.getConfig().getList(thisBlock+".Biome").contains(curBiome)) || - (plugin.getConfig().getList(thisBlock+".Biome").isEmpty()) || - (plugin.getConfig().isSet(thisBlock+".BiomeGroup"))) - { - // check the area to find if any of the special blocks are found - List> specialBlocks = specialBlockList(e); - List fBlocksFound = specialBlocks.get(0); - List wkBlocksFound = specialBlocks.get(1); - List uvBlocksFound = specialBlocks.get(2); - - // check the biome group settings - if (plugin.getConfig().isSet(thisBlock+".BiomeGroup")) - { - - // create list from the config setting - List groupList = plugin.getConfig().getList(thisBlock+".BiomeGroup"); - - groupLog += "BiomeGroup: " + groupList.toString() + ", "; - - // iterate through list and see if any of that list matches curBiome - boolean matches = false; - for (int i = 0; i < groupList.size(); i++) - { - - // check the biomegroup for this named group - if ((plugin.getConfig().getList("BiomeGroup."+groupList.get(i)) != null) && (plugin.getConfig().getList("BiomeGroup."+groupList.get(i)).contains(curBiome))) - { - - matches = true; - noBiome = false; - groupLog += "Matches: " + groupList.get(i) + ", "; - // reference the configs now to see if the config settings are set! - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".Growth")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".Growth"); - groupLog += "New Growth: " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".Death")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".Death"); - groupLog += "New Death: " + curDeath + ", "; - } - } - } - if (!matches) { - groupLog += "Matches: NULL, "; - } - } - else { - groupLog += "BiomeGroup: NULL, "; - } - - groupLog += "Specific Settings: {"; - - if (plugin.getConfig().getList(thisBlock+".Biome").contains(curBiome)) { - noBiome = false; - // override with individual settings - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".Growth")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+curBiome+".Growth"); - groupLog += "Growth for " + curBiome + ": " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".Death")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+curBiome+".Death"); - groupLog += "Death for " + curBiome + ": " + curDeath + ", "; - } - } - - // if there is fertilizer, grow this plant at the fertilizer rate - default 100% - // TODO: should fertilizer override dark settings or not - i think not for now - if (fBlocksFound.contains(PwnPlantGrowth.fertilizer)) - { - groupLog += PwnPlantGrowth.fertFound; - // set the current growth to the fertilizer rate - curGrowth = PwnPlantGrowth.frate; - } - groupLog += "}}, "; - - // See if there are special settings for dark growth - if (isDark) - { - // If uv is enabled and found, isDark remains false. - if (uvBlocksFound.contains(PwnPlantGrowth.uv)) - { - darkLog += PwnPlantGrowth.uvFound; - } - else - { - // default isDark config rates (if exist) - if (plugin.getConfig().isSet(thisBlock+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+".GrowthDark"); - darkLog += "Growth: " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(thisBlock+".DeathDark"); - darkLog += "Death: " + curDeath + ", "; - } - - // override default values with biome group values - if (plugin.getConfig().isSet(thisBlock+".BiomeGroup")) - { - - // create list from the config setting - List groupList = plugin.getConfig().getList(thisBlock+".BiomeGroup"); - - darkLog += "BiomeGroup: " + groupList.toString() + ", "; - - // iterate through list and see if any of that list matches curBiome - boolean matches = false; - for (int i = 0; i < groupList.size(); i++) { - - // check the biomegroup for this named group - if ((plugin.getConfig().getList("BiomeGroup."+groupList.get(i)) != null) && (plugin.getConfig().getList("BiomeGroup."+groupList.get(i)).contains(curBiome))) - { - - matches = true; - noBiome = false; - darkLog += "Matching: " + groupList.get(i) + ", "; - - // reference the configs now to see if the config settings are set! - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".GrowthDark"); - darkLog += "New Growth: " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+groupList.get(i)+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+groupList.get(i)+".DeathDark"); - darkLog += "New Death: " + curDeath + ", "; - } - } - } - if (!matches) { - darkLog += "Matches: NULL, "; - } - } - else { - darkLog += "BiomeGroup: NULL, "; - } - - darkLog += "Specific Settings: {"; - - // per biome isDark rates (if exist) - if (plugin.getConfig().getList(thisBlock+".Biome").contains(curBiome)) { - noBiome = false; - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(thisBlock+"."+curBiome+".GrowthDark"); - darkLog += "Growth for " + curBiome + ": " + curGrowth + ", "; - } - - if (plugin.getConfig().isSet(thisBlock+"."+curBiome+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(thisBlock+"."+curBiome+".DeathDark"); - darkLog += "Death for " + curBiome + ": " + curDeath + ", "; - } - } - - darkLog += "}}, "; - } - } - - // cancel bad biomes here - if (noBiome) - { - e.setCancelled(true); - toLog += "RESULT: {Failed Growth: Bad Biome}"; - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - // TODO: make these configurable - if (thisBlock == "COCOA") { - e.getBlock().setType(Material.VINE); - } - else { - e.getBlock().setType(Material.DEAD_BUSH); - } - toLog += " {Plant Died, Rate: " + curDeath + "}"; - } - } - // Run the chance for growth here... - else if (!(PwnPlantGrowth.random(curGrowth))) - { - e.setCancelled(true); - toLog += "RESULT: {Failed Growth, Rate: " + curGrowth + "} "; - - if (wkBlocksFound.contains(PwnPlantGrowth.weedKiller)) - { - toLog += PwnPlantGrowth.wkFound; - } - else - { - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - // TODO: make these configurable - if (thisBlock == "KELP") { - e.getBlock().setType(Material.SEAGRASS); - } - else { - e.getBlock().setType(Material.DEAD_BUSH); - } - toLog += " {Plant Died, Rate: " + curDeath + "}"; - } - } - } - else - { - toLog += "RESULT: {Plant Grew, Rate: " + curGrowth + "}"; - - } - } - else - { - // biome or biome group does not match, plant WILL NOT grow - but should have a chance to die? - e.setCancelled(true); - toLog += "RESULT: {Failed Growth: Bad Biome}"; - - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - // TODO: make these configurable - if (thisBlock == "KELP") { - e.getBlock().setType(Material.SEAGRASS); - } - else { - e.getBlock().setType(Material.DEAD_BUSH); - } - toLog += " {Plant Died, Rate: " + curDeath + "}"; - } - } - - String midLog = ""; - if (isDark) { - midLog += darkLog; - } - else { - midLog += groupLog; - } - - return frontLog + midLog + ", "+ toLog; + static Calculate getCalcs(List> specialBlocks, String thisBlock, String curBiome, Boolean isDark) + { + return new Calculate(specialBlocks, thisBlock, curBiome, isDark); } - + // retrieve list of special blocks public List> specialBlockList(BlockSpreadEvent e) { @@ -408,8 +145,13 @@ public void blockSpread(BlockSpreadEvent e) toLog += "Growing: " + sourceBlock; - toLog += runCalcs(e, sourceBlock, curBiome, isDark); - + Calculate cal = getCalcs(specialBlockList(e), sourceBlock, curBiome, isDark); + toLog += cal.doLog; + e.setCancelled(cal.isCancelled); + if (cal.replacement != null) { + e.getBlock().setType(cal.replacement); + } + // Log it if ((PwnPlantGrowth.logEnabled) && (PwnPlantGrowth.logPlantEnabled)) { diff --git a/src/com/pwn9/PwnPlantGrowth/StructureGrowListener.java b/src/com/pwn9/PwnPlantGrowth/StructureGrowListener.java index 4c81224..efa1758 100644 --- a/src/com/pwn9/PwnPlantGrowth/StructureGrowListener.java +++ b/src/com/pwn9/PwnPlantGrowth/StructureGrowListener.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.List; -import org.bukkit.Material; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -20,6 +19,11 @@ public StructureGrowListener(PwnPlantGrowth plugin) this.plugin = plugin; } + static Calculate getCalcs(List> specialBlocks, String thisBlock, String curBiome, Boolean isDark) + { + return new Calculate(specialBlocks, thisBlock, curBiome, isDark); + } + // retrieve list of special blocks public List> specialBlockList(StructureGrowEvent e) { @@ -125,13 +129,7 @@ public void structureGrow(StructureGrowEvent e) PwnPlantGrowth.logToFile("No tree configuration set in config for: " + curBlock); return; } - - // check the area to find if any of the special blocks are found - List> specialBlocks = specialBlockList(e); - List fBlocksFound = specialBlocks.get(0); - List wkBlocksFound = specialBlocks.get(1); - List uvBlocksFound = specialBlocks.get(2); - + // Setup boolean to see if event is in defined natural light or not Boolean isDark = false; @@ -153,177 +151,14 @@ public void structureGrow(StructureGrowEvent e) else { toLog += "Growing: " + curBlock; } - - // get this block's default values - int curGrowth = plugin.getConfig().getInt(curBlock+".Growth"); - int curDeath = plugin.getConfig().getInt(curBlock+".Death"); - - if ((plugin.getConfig().getList(curBlock+".Biome").contains(curBiome)) || - (plugin.getConfig().getList(curBlock+".Biome").isEmpty()) || - (plugin.getConfig().isSet(curBlock+".BiomeGroup"))) - { - - // override default values with biome group values - Might be able to modularize this, its - if (plugin.getConfig().isSet(curBlock+".BiomeGroup")) { - - // create list from the config setting - List groupList = plugin.getConfig().getList(curBlock+".BiomeGroup"); - - toLog += " BiomeGroup is set: " + groupList.toString() + " - "; - - // iterate through list and see if any of that list matches curBiome - for (int i = 0; i < groupList.size(); i++) { - - // check the biomegroup for this named group - if ((plugin.getConfig().getList("BiomeGroup."+groupList.get(i)) != null) && (plugin.getConfig().getList("BiomeGroup."+groupList.get(i)).contains(curBiome))) - { - toLog += "Matching BiomeGroup." + groupList.get(i) + " "; - - // reference the configs now to see if the config settings are set! - if (plugin.getConfig().isSet(curBlock+"."+groupList.get(i)+".Growth")) - { - curGrowth = plugin.getConfig().getInt(curBlock+"."+groupList.get(i)+".Growth"); - } - - if (plugin.getConfig().isSet(curBlock+"."+groupList.get(i)+".Death")) - { - curDeath = plugin.getConfig().getInt(curBlock+"."+groupList.get(i)+".Death"); - } - } - else - { - toLog += "Missing BiomeGroup." + groupList.get(i) + " "; - } - } - } - else { - toLog += " No BiomeGroup Found - "; - } - - // override default and BIOME GROUP values with per biome settings if they are set - if (plugin.getConfig().isSet(curBlock+"."+curBiome+".Growth")) - { - curGrowth = plugin.getConfig().getInt(curBlock+"."+curBiome+".Growth"); - } - - if (plugin.getConfig().isSet(curBlock+"."+curBiome+".Death")) { - curDeath = plugin.getConfig().getInt(curBlock+"."+curBiome+".Death"); - } - - - // if there is fertilizer, grow this plant at the fertilizer rate - default 100% - // TODO: should fertilizer override dark settings or not - i think not for now - if (fBlocksFound.contains(PwnPlantGrowth.fertilizer)) - { - toLog += PwnPlantGrowth.fertFound; - // set the current growth to the fertilizer rate - curGrowth = PwnPlantGrowth.frate; - } - - - // See if there are special settings for dark growth - if (isDark) - { - // If uv is enabled and found, isDark remains false. - if (uvBlocksFound.contains(PwnPlantGrowth.uv)) - { - toLog += PwnPlantGrowth.uvFound; - } - else - { - toLog += " In dark. "; - - // default isDark config rates (if exist) - if (plugin.getConfig().isSet(curBlock+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(curBlock+".GrowthDark"); - } - - if (plugin.getConfig().isSet(curBlock+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(curBlock+".DeathDark"); - } - - // override default values with biome group values - if (plugin.getConfig().isSet(curBlock+".BiomeGroup")) - { - - // create list from the config setting - List groupList = plugin.getConfig().getList(curBlock+".BiomeGroup"); - - toLog += " BiomeGroup is set: " + groupList.toString() + " - "; - - // iterate through list and see if any of that list matches curBiome - for (int i = 0; i < groupList.size(); i++) { - - // check the biomegroup for this named group - if ((plugin.getConfig().getList("BiomeGroup."+groupList.get(i)) != null) && (plugin.getConfig().getList("BiomeGroup."+groupList.get(i)).contains(curBiome))) - { - - toLog += "Matching BiomeGroup." + groupList.get(i) + " "; - - // reference the configs now to see if the config settings are set! - if (plugin.getConfig().isSet(curBlock+"."+groupList.get(i)+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(curBlock+"."+groupList.get(i)+".GrowthDark"); - } - - if (plugin.getConfig().isSet(curBlock+"."+groupList.get(i)+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(curBlock+"."+groupList.get(i)+".DeathDark"); - } - } - else - { - toLog += "Missing BiomeGroup." + groupList.get(i) + " "; - } - } - } - - // per biome isDark rates (if exist) override default and group rates - if (plugin.getConfig().isSet(curBlock+"."+curBiome+".GrowthDark")) - { - curGrowth = plugin.getConfig().getInt(curBlock+"."+curBiome+".GrowthDark"); - } - - if (plugin.getConfig().isSet(curBlock+"."+curBiome+".DeathDark")) - { - curDeath = plugin.getConfig().getInt(curBlock+"."+curBiome+".DeathDark"); - } - } - } - - if (!(PwnPlantGrowth.random(curGrowth))) - { - e.setCancelled(true); - toLog += " Failed (Rate: " + curGrowth + ") "; - - if (wkBlocksFound.contains(PwnPlantGrowth.weedKiller)) - { - toLog += PwnPlantGrowth.wkFound; - } - else - { - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - e.getLocation().getBlock().setType(Material.DEAD_BUSH); - toLog += " Died (Rate: " + curDeath + ")"; - } - } - } + + Calculate cal = getCalcs(specialBlockList(e), curBlock, curBiome, isDark); + toLog += cal.doLog; + e.setCancelled(cal.isCancelled); + if (cal.replacement != null) { + e.getLocation().getBlock().setType(cal.replacement); } - else - { - e.setCancelled(true); - toLog += " Failed: Bad Biome"; - // chance of death - if (PwnPlantGrowth.random(curDeath)) - { - e.getLocation().getBlock().setType(Material.DEAD_BUSH); - toLog += " Died (Rate: " + curDeath + ")"; - } - } + // log it if ((PwnPlantGrowth.logEnabled) && (PwnPlantGrowth.logTreeEnabled))