diff --git a/pom.xml b/pom.xml
index a46454c..f534fec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
${build.version}-SNAPSHOT
- 1.3.0
+ 1.4.0
-LOCAL
diff --git a/src/main/java/world/bentobox/greenhouses/Greenhouses.java b/src/main/java/world/bentobox/greenhouses/Greenhouses.java
index f00601a..73e89f7 100644
--- a/src/main/java/world/bentobox/greenhouses/Greenhouses.java
+++ b/src/main/java/world/bentobox/greenhouses/Greenhouses.java
@@ -28,6 +28,21 @@ public class Greenhouses extends Addon {
public static final Flag GREENHOUSES = new Flag.Builder("GREENHOUSE", Material.GREEN_STAINED_GLASS)
.mode(Mode.BASIC)
.type(Type.PROTECTION).build();
+ private static Greenhouses instance;
+ private final Config config;
+
+ public static Greenhouses getInstance() {
+ return instance;
+ }
+
+ /**
+ * Constructor
+ */
+ public Greenhouses() {
+ super();
+ instance = this;
+ config = new Config<>(this, Settings.class);
+ }
/* (non-Javadoc)
* @see world.bentobox.bentobox.api.addons.Addon#onEnable()
@@ -36,13 +51,14 @@ public class Greenhouses extends Addon {
public void onEnable() {
saveDefaultConfig();
this.saveResource("biomes.yml", false);
- settings = new Config<>(this, Settings.class).loadConfigObject();
+ settings = config.loadConfigObject();
if (settings == null) {
// Settings did no load correctly. Disable.
logError("Settings did not load correctly - disabling Greenhouses - please check config.yml");
this.setState(State.DISABLED);
return;
}
+ config.saveConfigObject(settings);
// Load recipes
recipes = new RecipeManager(this);
// Load manager
diff --git a/src/main/java/world/bentobox/greenhouses/Settings.java b/src/main/java/world/bentobox/greenhouses/Settings.java
index 9ddd102..588331a 100644
--- a/src/main/java/world/bentobox/greenhouses/Settings.java
+++ b/src/main/java/world/bentobox/greenhouses/Settings.java
@@ -22,7 +22,7 @@ public class Settings implements ConfigObject {
@ConfigComment("BentoBox GameModes that will use Greenhouses")
@ConfigEntry(path = "greenhouses.game-modes")
private List gameModes = new ArrayList<>();
-
+
@ConfigComment("Show loaded recipe details during startup of server")
@ConfigEntry(path = "greenhouses.startup-log")
private boolean startupLog = false;
@@ -64,6 +64,10 @@ public class Settings implements ConfigObject {
@ConfigEntry(path = "greenhouses.allowflowin")
private boolean allowFlowIn;
+ @ConfigComment("Allow glowstone to be used as well as glass in roof and walls")
+ @ConfigEntry(path = "greenhouses.allowglowstone")
+ private boolean allowGlowstone = true;
+
/**
* @return the gameModes
*/
@@ -196,5 +200,17 @@ public class Settings implements ConfigObject {
public void setAllowFlowIn(boolean allowFlowIn) {
this.allowFlowIn = allowFlowIn;
}
+ /**
+ * @return the allowGlowstone
+ */
+ public boolean isAllowGlowstone() {
+ return allowGlowstone;
+ }
+ /**
+ * @param allowGlowstone the allowGlowstone to set
+ */
+ public void setAllowGlowstone(boolean allowGlowstone) {
+ this.allowGlowstone = allowGlowstone;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java b/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java
index 187c496..b730971 100644
--- a/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java
+++ b/src/main/java/world/bentobox/greenhouses/greenhouse/Roof.java
@@ -11,20 +11,21 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
+import world.bentobox.greenhouses.Greenhouses;
+
/**
* Contains the parameters of a greenhouse roof
* @author tastybento
*
*/
public class Roof extends MinMaxXZ {
- public static final List ROOF_BLOCKS;
+ private static final List ROOF_BLOCKS;
static {
List r = Arrays.stream(Material.values())
.filter(Material::isBlock) // Blocks only, no items
.filter(m -> m.name().contains("TRAPDOOR") // All trapdoors
|| m.name().contains("GLASS") // All glass blocks
- || m.equals(Material.HOPPER) // Hoppers
- || m.equals(Material.GLOWSTONE)) // Glowstone
+ || m.equals(Material.HOPPER)) // Hoppers
.collect(Collectors.toList());
ROOF_BLOCKS = Collections.unmodifiableList(r);
}
@@ -52,7 +53,7 @@ public class Roof extends MinMaxXZ {
// to be outside the greenhouse in this situation, so a check is done later to make sure the player is inside
int roofY = loc.getBlockY();
for (int y = roofY; y < world.getMaxHeight(); y++) {
- if (ROOF_BLOCKS.contains(world.getBlockAt(loc.getBlockX(),y,loc.getBlockZ()).getType())) {
+ if (roofBlocks(world.getBlockAt(loc.getBlockX(),y,loc.getBlockZ()).getType())) {
roofFound = true;
loc = new Location(world,loc.getBlockX(),y,loc.getBlockZ());
break;
@@ -65,10 +66,10 @@ public class Roof extends MinMaxXZ {
for (int z = loc.getBlockZ() - radius; z <= loc.getBlockZ() + radius && !roofFound; z++) {
if (!((x > loc.getBlockX() - radius && x < loc.getBlockX() + radius) && (z > loc.getBlockZ() - radius && z < loc.getBlockZ() + radius))) {
Block b = world.getBlockAt(x, roofY, z);
- if (!Walls.WALL_BLOCKS.contains(b.getType())) {
+ if (!Walls.wallBlocks(b.getType())) {
// Look up
for (int y = roofY; y < world.getMaxHeight() && !roofFound; y++) {
- if (ROOF_BLOCKS.contains(world.getBlockAt(x,y,z).getType())) {
+ if (roofBlocks(world.getBlockAt(x,y,z).getType())) {
roofFound = true;
loc = new Location(world,x,y,z);
}
@@ -129,7 +130,7 @@ public class Roof extends MinMaxXZ {
maxX = maxx.getBlockX()-1;
}
- while (ROOF_BLOCKS.contains(world.getBlockAt(minx).getType()) && limit < 200) {
+ while (roofBlocks(world.getBlockAt(minx).getType()) && limit < 200) {
limit++;
minx.subtract(new Vector(1,0,0));
}
@@ -137,7 +138,7 @@ public class Roof extends MinMaxXZ {
minX = minx.getBlockX() + 1;
}
- while (ROOF_BLOCKS.contains(world.getBlockAt(maxz).getType()) && limit < 300) {
+ while (roofBlocks(world.getBlockAt(maxz).getType()) && limit < 300) {
limit++;
maxz.add(new Vector(0,0,1));
}
@@ -145,7 +146,7 @@ public class Roof extends MinMaxXZ {
maxZ = maxz.getBlockZ() - 1;
}
- while (ROOF_BLOCKS.contains(world.getBlockAt(minz).getType()) && limit < 400) {
+ while (roofBlocks(world.getBlockAt(minz).getType()) && limit < 400) {
limit++;
minz.subtract(new Vector(0,0,1));
}
@@ -154,6 +155,15 @@ public class Roof extends MinMaxXZ {
}
}
+ /**
+ * Check if material is a roof material
+ * @param m - material
+ * @return true if roof material
+ */
+ public static boolean roofBlocks(Material m) {
+ return ROOF_BLOCKS.contains(m) || (m.equals(Material.GLOWSTONE) && Greenhouses.getInstance().getSettings().isAllowGlowstone());
+ }
+
/**
* @return the roofFound
*/
diff --git a/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java b/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java
index 1fe6598..1e68d63 100644
--- a/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java
+++ b/src/main/java/world/bentobox/greenhouses/greenhouse/Walls.java
@@ -10,16 +10,17 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
+import world.bentobox.greenhouses.Greenhouses;
+
public class Walls extends MinMaxXZ {
- public static final List WALL_BLOCKS;
+ private static final List WALL_BLOCKS;
static {
List w = Arrays.stream(Material.values())
.filter(Material::isBlock) // Blocks only, no items
.filter(m -> !m.name().contains("TRAPDOOR")) // No trap doors
.filter(m -> m.name().contains("DOOR") // All doors
|| m.name().contains("GLASS") // All glass blocks
- || m.equals(Material.HOPPER) // Hoppers
- || m.equals(Material.GLOWSTONE)) // Glowstone
+ || m.equals(Material.HOPPER)) // Hoppers
.collect(Collectors.toList());
WALL_BLOCKS = Collections.unmodifiableList(w);
}
@@ -147,6 +148,15 @@ public class Walls extends MinMaxXZ {
}
+ /**
+ * Check if material is a wall material
+ * @param m - material
+ * @return true if wall material
+ */
+ public static boolean wallBlocks(Material m) {
+ return WALL_BLOCKS.contains(m) || (m.equals(Material.GLOWSTONE) && Greenhouses.getInstance().getSettings().isAllowGlowstone());
+ }
+
/**
* @return the floor
*/
diff --git a/src/main/java/world/bentobox/greenhouses/managers/GreenhouseFinder.java b/src/main/java/world/bentobox/greenhouses/managers/GreenhouseFinder.java
index 0b9a69f..4e56bd1 100644
--- a/src/main/java/world/bentobox/greenhouses/managers/GreenhouseFinder.java
+++ b/src/main/java/world/bentobox/greenhouses/managers/GreenhouseFinder.java
@@ -19,6 +19,11 @@ public class GreenhouseFinder {
private final Set redGlass = new HashSet<>();
+ /**
+ * Find out if there is a greenhouse here
+ * @param location - start location
+ * @return GreenhouseResult class
+ */
public Set find(Location location) {
Set result = new HashSet<>();
redGlass.clear();
@@ -80,8 +85,8 @@ public class GreenhouseFinder {
} else {
// Check just the walls
if (y == roof.getHeight() || x == minX || x == maxX || z == minZ || z== maxZ) {
- if ((y != roof.getHeight() && !Walls.WALL_BLOCKS.contains(blockType))
- || (y == roof.getHeight() && !Roof.ROOF_BLOCKS.contains(blockType))) {
+ if ((y != roof.getHeight() && !Walls.wallBlocks(blockType))
+ || (y == roof.getHeight() && !Roof.roofBlocks(blockType))) {
//logger(2,"DEBUG: bad block found at " + x + "," + y+ "," + z + " " + blockType);
if (blockType == Material.AIR) {
airHole = true;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index c808a1d..9815e4f 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -31,3 +31,5 @@ greenhouses:
allowflowout: false
# Allow lava or water to flow into a greenhouse, e.g., through the door
allowflowin: false
+ # Allow glowstone to be used as well as glass in roof and walls
+ allowglowstone: true
\ No newline at end of file