Skip to content

Commit

Permalink
Removes recipe log spam.
Browse files Browse the repository at this point in the history
Fixes #44
  • Loading branch information
tastybento committed Jan 30, 2020
1 parent 85befc6 commit be5f40b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 72 deletions.
16 changes: 16 additions & 0 deletions src/main/java/world/bentobox/greenhouses/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class Settings implements ConfigObject {
@ConfigComment("BentoBox GameModes that will use Greenhouses")
@ConfigEntry(path = "greenhouses.game-modes")
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("How often it should snow in the g/h when the weather is raining, in seconds")
Expand Down Expand Up @@ -108,6 +112,18 @@ public int getBlockTick() {
public int getMobTick() {
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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public BiomeRecipe(Greenhouses addon, Biome type, int priority) {
this.priority = priority;
mobLimit = 9; // Default
}

private void startupLog(String message) {
if (addon.getSettings().isStartupLog()) addon.log(message);
}

/**
* @param oldMaterial - material that will convert
Expand All @@ -85,7 +89,7 @@ public BiomeRecipe(Greenhouses addon, Biome type, int priority) {
public void addConvBlocks(Material oldMaterial, Material newMaterial, double convChance, Material localMaterial) {
double probability = Math.min(convChance/100 , 1D);
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()));
}


Expand All @@ -96,7 +100,7 @@ public void addConvBlocks(Material oldMaterial, Material newMaterial, double con
* @return true if add is successful
*/
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 lastProb = mobTree.isEmpty() ? 0D : mobTree.lastKey();
// Add up all the probabilities in the list so far
Expand Down Expand Up @@ -129,7 +133,7 @@ public boolean addPlants(Material plantMaterial, int plantProbability, Material
addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
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;
}

Expand All @@ -139,7 +143,7 @@ public boolean addPlants(Material plantMaterial, int plantProbability, Material
*/
public void addReqBlocks(Material blockMaterial, int blockQty) {
requiredBlocks.put(blockMaterial, blockQty);
addon.log(" " + blockMaterial + " x " + blockQty);
startupLog(" " + blockMaterial + " x " + blockQty);
}

// Check required blocks
Expand Down Expand Up @@ -398,9 +402,9 @@ public void setFriendlyName(String friendlyName) {
*/
public void setIcecoverage(int iceCoverage) {
if (iceCoverage == 0) {
addon.log(" No Ice Allowed");
startupLog(" No Ice Allowed");
} else if (iceCoverage > 0) {
addon.log(" Ice > " + iceCoverage + "%");
startupLog(" Ice > " + iceCoverage + "%");
}
this.iceCoverage = iceCoverage;
}
Expand All @@ -417,9 +421,9 @@ public void setIcon(Material icon) {
*/
public void setLavacoverage(int lavaCoverage) {
if (lavaCoverage == 0) {
addon.log(" No Lava Allowed");
startupLog(" No Lava Allowed");
} else if (lavaCoverage > 0) {
addon.log(" Lava > " + lavaCoverage + "%");
startupLog(" Lava > " + lavaCoverage + "%");
}
this.lavaCoverage = lavaCoverage;
}
Expand Down Expand Up @@ -464,9 +468,9 @@ public void setType(Biome type) {
*/
public void setWatercoverage(int waterCoverage) {
if (waterCoverage == 0) {
addon.log(" No Water Allowed");
startupLog(" No Water Allowed");
} else if (waterCoverage > 0) {
addon.log(" Water > " + waterCoverage + "%");
startupLog(" Water > " + waterCoverage + "%");
}
this.waterCoverage = waterCoverage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private BiomeRecipe getBiomeRecipe(ConfigurationSection biomeRecipeConfig, Strin
BiomeRecipe b = new BiomeRecipe(addon, thisBiome, priority);
// Set the name
b.setName(biomeType);
addon.log("Adding biome recipe for " + biomeType);
if (addon.getSettings().isStartupLog()) addon.log("Adding biome recipe for " + biomeType);
// Set the permission
b.setPermission(biomeRecipeConfig.getString("permission",""));
// Set the icon
Expand Down
82 changes: 32 additions & 50 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,33 @@
# Greenhouses Configuration
#
greenhouses:
# BentoBox GameModes that will use Greenhouses
game-modes:
- BSkyBlock
- AcidIsland
- SkyGrid

# Console message level.
# List the levels of debug or messages you want.
# 0 = no messages except for warnings or severe errors
# 1 = normal messages (default)
# 2 and higher - debug levels - no need to use these unless you want to try debug
debug:
- 1

### Permissions limits
# Set the maximum number of greenhouses a player can build
# using greenhouses.limit.<number>
# This is the default max. -1 is unlimited
maxgreenhouses: -1
# To have extra greenhouses deleted upon login set the following to true
deleteextras: false

### Weather and ecosystem settings

# How often it should snow in the g/h when the weather is raining, in seconds
snowspeed: 30
# Chance of any snow falling in a greenhouse when the snow tick occurs
# (1.0 = always, 0.0 = never)
snowchance: 1
# How many blocks should get snow 1 = all of them, 0 = none, 0.1 = 1 in 10
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

# BentoBox GameModes that will use Greenhouses
game-modes:
- BSkyBlock
- AcidIsland
- SkyGrid
# Show loaded recipe details during startup of server
startup-log: false
# Weather and ecosystem settings
# How often it should snow in the g/h when the weather is raining, in seconds
snowspeed: 30.0
# Chance of any snow falling in a greenhouse when the snow tick occurs
# (1.0 = always, 0.0 = never)
snowchance: 1.0
# How many blocks should get snow 1 = all of them, 0 = none, 0.1 = 1 in 10
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import world.bentobox.bentobox.BentoBox;
import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.Settings;
import world.bentobox.greenhouses.data.Greenhouse;
import world.bentobox.greenhouses.managers.GreenhouseManager;
import world.bentobox.greenhouses.managers.GreenhouseManager.GreenhouseResult;
Expand Down Expand Up @@ -80,6 +81,8 @@ public class BiomeRecipeTest {
private GreenhouseMap map;
@Mock
private BukkitScheduler scheduler;
@Mock
private Settings settings;

/**
* @throws java.lang.Exception
Expand Down Expand Up @@ -108,16 +111,7 @@ public void setUp() throws Exception {
when(block.getLocation()).thenReturn(location);
when(location.clone()).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
when(addon.getPlugin()).thenReturn(plugin);
// Manager
Expand All @@ -128,7 +122,20 @@ public void setUp() throws Exception {
when(map.getGreenhouse(any(Location.class))).thenReturn(optionalGh);
// Bukkit 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");
}

/**
Expand Down

0 comments on commit be5f40b

Please sign in to comment.