Removes recipe log spam.

Fixes https://github.com/BentoBoxWorld/Greenhouses/issues/44
This commit is contained in:
tastybento 2020-01-30 09:52:53 -08:00
parent 85befc62db
commit be5f40b9c0
5 changed files with 81 additions and 72 deletions

View File

@ -22,6 +22,10 @@ public class Settings implements ConfigObject {
@ConfigComment("BentoBox GameModes that will use Greenhouses") @ConfigComment("BentoBox GameModes that will use Greenhouses")
@ConfigEntry(path = "greenhouses.game-modes") @ConfigEntry(path = "greenhouses.game-modes")
private List<String> gameModes = new ArrayList<>(); private List<String> gameModes = new ArrayList<>();
@ConfigComment("Show loaded recipe details during startup of server")
@ConfigEntry(path = "greenhouses.startup-log")
private boolean startupLog = false;
@ConfigComment("Weather and ecosystem settings") @ConfigComment("Weather and ecosystem settings")
@ConfigComment("How often it should snow in the g/h when the weather is raining, in seconds") @ConfigComment("How often it should snow in the g/h when the weather is raining, in seconds")
@ -108,6 +112,18 @@ public class Settings implements ConfigObject {
public int getMobTick() { public int getMobTick() {
return mobTick; return mobTick;
} }
/**
* @return the startupLog
*/
public boolean isStartupLog() {
return startupLog;
}
/**
* @param startupLog the startupLog to set
*/
public void setStartupLog(boolean startupLog) {
this.startupLog = startupLog;
}
/** /**
* @return the allowFlowOut * @return the allowFlowOut
*/ */

View File

@ -75,6 +75,10 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
this.priority = priority; this.priority = priority;
mobLimit = 9; // Default mobLimit = 9; // Default
} }
private void startupLog(String message) {
if (addon.getSettings().isStartupLog()) addon.log(message);
}
/** /**
* @param oldMaterial - material that will convert * @param oldMaterial - material that will convert
@ -85,7 +89,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
public void addConvBlocks(Material oldMaterial, Material newMaterial, double convChance, Material localMaterial) { public void addConvBlocks(Material oldMaterial, Material newMaterial, double convChance, Material localMaterial) {
double probability = Math.min(convChance/100 , 1D); double probability = Math.min(convChance/100 , 1D);
conversionBlocks.put(oldMaterial, new GreenhouseBlockConversions(oldMaterial, newMaterial, probability, localMaterial)); conversionBlocks.put(oldMaterial, new GreenhouseBlockConversions(oldMaterial, newMaterial, probability, localMaterial));
addon.log(" " + convChance + CHANCE_FOR + Util.prettifyText(oldMaterial.toString()) + " to convert to " + Util.prettifyText(newMaterial.toString())); startupLog(" " + convChance + CHANCE_FOR + Util.prettifyText(oldMaterial.toString()) + " to convert to " + Util.prettifyText(newMaterial.toString()));
} }
@ -96,7 +100,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
* @return true if add is successful * @return true if add is successful
*/ */
public boolean addMobs(EntityType mobType, int mobProbability, Material mobSpawnOn) { public boolean addMobs(EntityType mobType, int mobProbability, Material mobSpawnOn) {
addon.log(" " + mobProbability + CHANCE_FOR + Util.prettifyText(mobType.toString()) + " to spawn on " + Util.prettifyText(mobSpawnOn.toString())+ "."); startupLog(" " + mobProbability + CHANCE_FOR + Util.prettifyText(mobType.toString()) + " to spawn on " + Util.prettifyText(mobSpawnOn.toString())+ ".");
double probability = ((double)mobProbability/100); double probability = ((double)mobProbability/100);
double lastProb = mobTree.isEmpty() ? 0D : mobTree.lastKey(); double lastProb = mobTree.isEmpty() ? 0D : mobTree.lastKey();
// Add up all the probabilities in the list so far // Add up all the probabilities in the list so far
@ -129,7 +133,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString()); addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
return false; return false;
} }
addon.log(" " + plantProbability + CHANCE_FOR + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString())); startupLog(" " + plantProbability + CHANCE_FOR + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString()));
return true; return true;
} }
@ -139,7 +143,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
*/ */
public void addReqBlocks(Material blockMaterial, int blockQty) { public void addReqBlocks(Material blockMaterial, int blockQty) {
requiredBlocks.put(blockMaterial, blockQty); requiredBlocks.put(blockMaterial, blockQty);
addon.log(" " + blockMaterial + " x " + blockQty); startupLog(" " + blockMaterial + " x " + blockQty);
} }
// Check required blocks // Check required blocks
@ -398,9 +402,9 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
*/ */
public void setIcecoverage(int iceCoverage) { public void setIcecoverage(int iceCoverage) {
if (iceCoverage == 0) { if (iceCoverage == 0) {
addon.log(" No Ice Allowed"); startupLog(" No Ice Allowed");
} else if (iceCoverage > 0) { } else if (iceCoverage > 0) {
addon.log(" Ice > " + iceCoverage + "%"); startupLog(" Ice > " + iceCoverage + "%");
} }
this.iceCoverage = iceCoverage; this.iceCoverage = iceCoverage;
} }
@ -417,9 +421,9 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
*/ */
public void setLavacoverage(int lavaCoverage) { public void setLavacoverage(int lavaCoverage) {
if (lavaCoverage == 0) { if (lavaCoverage == 0) {
addon.log(" No Lava Allowed"); startupLog(" No Lava Allowed");
} else if (lavaCoverage > 0) { } else if (lavaCoverage > 0) {
addon.log(" Lava > " + lavaCoverage + "%"); startupLog(" Lava > " + lavaCoverage + "%");
} }
this.lavaCoverage = lavaCoverage; this.lavaCoverage = lavaCoverage;
} }
@ -464,9 +468,9 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
*/ */
public void setWatercoverage(int waterCoverage) { public void setWatercoverage(int waterCoverage) {
if (waterCoverage == 0) { if (waterCoverage == 0) {
addon.log(" No Water Allowed"); startupLog(" No Water Allowed");
} else if (waterCoverage > 0) { } else if (waterCoverage > 0) {
addon.log(" Water > " + waterCoverage + "%"); startupLog(" Water > " + waterCoverage + "%");
} }
this.waterCoverage = waterCoverage; this.waterCoverage = waterCoverage;
} }

View File

@ -124,7 +124,7 @@ public class RecipeManager {
BiomeRecipe b = new BiomeRecipe(addon, thisBiome, priority); BiomeRecipe b = new BiomeRecipe(addon, thisBiome, priority);
// Set the name // Set the name
b.setName(biomeType); b.setName(biomeType);
addon.log("Adding biome recipe for " + biomeType); if (addon.getSettings().isStartupLog()) addon.log("Adding biome recipe for " + biomeType);
// Set the permission // Set the permission
b.setPermission(biomeRecipeConfig.getString("permission","")); b.setPermission(biomeRecipeConfig.getString("permission",""));
// Set the icon // Set the icon

View File

@ -1,51 +1,33 @@
# Greenhouses Configuration
#
greenhouses: greenhouses:
# BentoBox GameModes that will use Greenhouses # BentoBox GameModes that will use Greenhouses
game-modes: game-modes:
- BSkyBlock - BSkyBlock
- AcidIsland - AcidIsland
- SkyGrid - SkyGrid
# Show loaded recipe details during startup of server
# Console message level. startup-log: false
# List the levels of debug or messages you want. # Weather and ecosystem settings
# 0 = no messages except for warnings or severe errors # How often it should snow in the g/h when the weather is raining, in seconds
# 1 = normal messages (default) snowspeed: 30.0
# 2 and higher - debug levels - no need to use these unless you want to try debug # Chance of any snow falling in a greenhouse when the snow tick occurs
debug: # (1.0 = always, 0.0 = never)
- 1 snowchance: 1.0
# How many blocks should get snow 1 = all of them, 0 = none, 0.1 = 1 in 10
### Permissions limits snowdensity: 0.1
# Set the maximum number of greenhouses a player can build # Biome activity
# using greenhouses.limit.<number> # How often should greenhouse biomes be checked to make sure they are still valid
# This is the default max. -1 is unlimited ecotick: 5
maxgreenhouses: -1 # How often should plants potentially grow in minutes if bonemeal is in the hopper
# To have extra greenhouses deleted upon login set the following to true planttick: 1
deleteextras: false # How often should blocks potentially convert, in minutes
# Example: dirt-> sand in desert greenhouse
### Weather and ecosystem settings blocktick: 2
# How often should mobs be potentially spawned in a greenhouse, in minutes
# How often it should snow in the g/h when the weather is raining, in seconds mobtick: 5
snowspeed: 30 # Default settings for greenhouse actions
# Chance of any snow falling in a greenhouse when the snow tick occurs # Allow lava or water to flow out of a greenhouse, e.g. through the door, floor
# (1.0 = always, 0.0 = never) allowflowout: false
snowchance: 1 # Allow lava or water to flow into a greenhouse, e.g., through the door
# How many blocks should get snow 1 = all of them, 0 = none, 0.1 = 1 in 10 allowflowin: false
snowdensity: 0.1
# Biome activity
# How often should greenhouse biomes be checked to make sure they are still valid
ecotick: 5
# How often should plants potentially grow in minutes if bonemeal is in the hopper
planttick: 1
# How often should blocks potentially convert, in minutes
# Example: dirt-> sand in desert greenhouse
blocktick: 2
# How often should mobs be potentially spawned in a greenhouse, in minutes
mobtick: 5
### Default settings for greenhouse actions
# Allow lava or water to flow out of a greenhouse, e.g. through the door, floor
allowflowout: false
# Allow lava or water to flow into a greenhouse, e.g., through the door
allowflowin: false

View File

@ -42,6 +42,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.greenhouses.Greenhouses; import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.Settings;
import world.bentobox.greenhouses.data.Greenhouse; import world.bentobox.greenhouses.data.Greenhouse;
import world.bentobox.greenhouses.managers.GreenhouseManager; import world.bentobox.greenhouses.managers.GreenhouseManager;
import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult; import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
@ -80,6 +81,8 @@ public class BiomeRecipeTest {
private GreenhouseMap map; private GreenhouseMap map;
@Mock @Mock
private BukkitScheduler scheduler; private BukkitScheduler scheduler;
@Mock
private Settings settings;
/** /**
* @throws java.lang.Exception * @throws java.lang.Exception
@ -108,16 +111,7 @@ public class BiomeRecipeTest {
when(block.getLocation()).thenReturn(location); when(block.getLocation()).thenReturn(location);
when(location.clone()).thenReturn(location); when(location.clone()).thenReturn(location);
when(location.add(any(Vector.class))).thenReturn(location); when(location.add(any(Vector.class))).thenReturn(location);
// Set up default recipe
br = new BiomeRecipe(addon, type, 0);
br.setIcecoverage(2); // 1%
br.setLavacoverage(1); // 1%
br.setWatercoverage(1); // 1%
br.addReqBlocks(Material.GRASS_BLOCK, 2);
br.setFriendlyName("name");
br.setName("name2");
br.setIcon(Material.ACACIA_BOAT);
br.setPermission("perm");
// Plugin // Plugin
when(addon.getPlugin()).thenReturn(plugin); when(addon.getPlugin()).thenReturn(plugin);
// Manager // Manager
@ -128,7 +122,20 @@ public class BiomeRecipeTest {
when(map.getGreenhouse(any(Location.class))).thenReturn(optionalGh); when(map.getGreenhouse(any(Location.class))).thenReturn(optionalGh);
// Bukkit Scheduler // Bukkit Scheduler
when(Bukkit.getScheduler()).thenReturn(scheduler); when(Bukkit.getScheduler()).thenReturn(scheduler);
// Settings
when(addon.getSettings()).thenReturn(settings);
when(settings.isStartupLog()).thenReturn(true);
// Set up default recipe
br = new BiomeRecipe(addon, type, 0);
br.setIcecoverage(2); // 1%
br.setLavacoverage(1); // 1%
br.setWatercoverage(1); // 1%
br.addReqBlocks(Material.GRASS_BLOCK, 2);
br.setFriendlyName("name");
br.setName("name2");
br.setIcon(Material.ACACIA_BOAT);
br.setPermission("perm");
} }
/** /**