Browse Source

add option to toggle block generation effects

MasterCake 2 years ago
parent
commit
f0c3ac7ed3

+ 8 - 2
src/main/java/xyz/spaceio/customoregen/Events.java

@@ -31,6 +31,8 @@ public class Events implements Listener {
 	private Method legacyBlockPlaceMethod;
 	
 	private boolean enableStoneGenerator;
+	private boolean enableSoundEffect;
+	private boolean enableParticleEffect;
 	
 	public Events(CustomOreGen customOreGen) {
 		this.plugin = customOreGen;
@@ -48,6 +50,8 @@ public class Events implements Listener {
 			}
 		}
 		this.enableStoneGenerator = plugin.getConfig().getBoolean("enable-stone-generator");
+		this.enableSoundEffect = plugin.getConfig().getBoolean("enable-sound-effect");
+		this.enableParticleEffect = plugin.getConfig().getBoolean("enable-particle-effect");
 		
 		try {
 			Class.forName("org.bukkit.block.data.Levelled");
@@ -121,8 +125,10 @@ public class Events implements Listener {
 						b.getState().update(true);
 				}
 				
-				b.getWorld().playSound(b.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 2.6f + ((float) Math.random() - (float) Math.random()) * 0.8f);
-				b.getWorld().spawnParticle(Particle.SMOKE_LARGE, b.getLocation().getBlockX() + 0.5D, b.getLocation().getBlockY() + 0.25D, b.getLocation().getBlockZ() + 0.5D, 8, 0.5D, 0.25D, 0.5D, 0.0D);
+				if(enableSoundEffect)
+					b.getWorld().playSound(b.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 2.6f + ((float) Math.random() - (float) Math.random()) * 0.8f);
+				if(enableParticleEffect)
+					b.getWorld().spawnParticle(Particle.SMOKE_LARGE, b.getLocation().getBlockX() + 0.5D, b.getLocation().getBlockY() + 0.25D, b.getLocation().getBlockZ() + 0.5D, 8, 0.5D, 0.25D, 0.5D, 0.0D);
 				
 				plugin.getSkyblockAPICached().sendBlockAcknowledge(b);
 				//b.setData(winning.getDamage(), true);

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

@@ -11,6 +11,12 @@
 # Enable this when you also want random blocks from stone generators (lava floats on water vertically)
 enable-stone-generator: false
 
+# Enables the hiss sound effect when a block was generated
+enable-sound-effect: true
+
+# Enables the smoke particle effect when a block was generated
+enable-particle-effect: true
+
 generators:
   generator1:
     # default generator