Quellcode durchsuchen

add config option for enabling stone generators

Setting enable-stone-generator to true will enable random generated
blocks for stone generators (lava floats on water vertically)

closes #40
MasterCake vor 4 Jahren
Ursprung
Commit
46aee3f71a
2 geänderte Dateien mit 17 neuen und 1 gelöschten Zeilen
  1. 3 0
      src/main/resources/config.yml
  2. 14 1
      src/xyz/spaceio/customoregen/Events.java

+ 3 - 0
src/main/resources/config.yml

@@ -8,6 +8,9 @@
 
 # Note: If the Island's owner is offline, the cobblestone generator would be choose the first Generator-Config.
 
+# Enable this when you also want random blocks from stone generators (lava floats on water vertically)
+enable-stone-generator: false
+
 generators:
   generator1:
     # default generator

+ 14 - 1
src/xyz/spaceio/customoregen/Events.java

@@ -28,8 +28,14 @@ public class Events implements Listener {
 	private boolean useLegacyBlockPlaceMethod;
 	private Method legacyBlockPlaceMethod;
 	
+	private boolean enableStoneGenerator;
+	
 	public Events(CustomOreGen customOreGen) {
 		this.plugin = customOreGen;
+		load();
+	}
+	
+	public void load() {
 		this.useLegacyBlockPlaceMethod = Arrays.stream(Block.class.getMethods()).anyMatch(method -> method.getName() == "setTypeIdAndData");
 		if(this.useLegacyBlockPlaceMethod) {
 			try {
@@ -39,6 +45,7 @@ public class Events implements Listener {
 				e.printStackTrace();
 			}
 		}
+		this.enableStoneGenerator = plugin.getConfig().getBoolean("enable-stone-generator");
 	}
 
 	@SuppressWarnings("deprecation")
@@ -50,12 +57,18 @@ public class Events implements Listener {
 		
 		Type fromType = this.getType(event.getBlock());
 		
-		if (fromType != null && event.getFace() != BlockFace.DOWN) {
+		if (fromType != null) {
+			if (!enableStoneGenerator) {
+				if(event.getFace() == BlockFace.DOWN) {
+					return;
+				}
+			}
 			Block b = event.getToBlock();
 			Type toType = this.getType(event.getToBlock());
 			
 			Location fromLoc = b.getLocation();
 			
+
 			// fix for (lava -> water)
 			if (fromType == Type.LAVA || fromType == Type.LAVA_STAT) {
 				if(!isSurroundedByWater(fromLoc)){