mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-18 14:11:30 +01:00
* Create and implement moisture-change flag * Fix imports * Add comment * Actually read the value from config. Closes #1879 --------- Co-authored-by: wizjany <wizjany@gmail.com>
This commit is contained in:
parent
0f3ea5045e
commit
cb011a88cf
@ -283,6 +283,7 @@ public void loadConfiguration() {
|
||||
disableSculkGrowth = getBoolean("dynamics.disable-sculk-growth", false);
|
||||
disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false);
|
||||
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
|
||||
disableSoilMoistureChange = getBoolean("dynamics.disable-soil-moisture-change", false);
|
||||
disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false);
|
||||
disableCopperBlockFade = getBoolean("dynamics.disable-copper-block-fade", false);
|
||||
allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
|
||||
|
@ -56,6 +56,7 @@
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.block.MoistureChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -726,4 +727,24 @@ public void onBlockExplode(BlockExplodeEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the moisture level of a block changes
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onMoistureChange(MoistureChangeEvent event) {
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (wcfg.disableSoilMoistureChange) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.MOISTURE_CHANGE))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ public abstract class WorldConfiguration {
|
||||
public boolean disableEndermanGriefing;
|
||||
public boolean disableSnowmanTrails;
|
||||
public boolean disableSoilDehydration;
|
||||
public boolean disableSoilMoistureChange;
|
||||
public boolean disableCoralBlockFade;
|
||||
public boolean disableCopperBlockFade;
|
||||
public Set<String> allowedSnowFallOver;
|
||||
|
@ -130,6 +130,7 @@ public final class Flags {
|
||||
public static final StateFlag COPPER_FADE = register(new StateFlag("copper-fade", true));
|
||||
public static final StateFlag WATER_FLOW = register(new StateFlag("water-flow", true));
|
||||
public static final StateFlag LAVA_FLOW = register(new StateFlag("lava-flow", true));
|
||||
public static final StateFlag MOISTURE_CHANGE = register(new StateFlag("moisture-change", true));
|
||||
|
||||
public static final RegistryFlag<WeatherType> WEATHER_LOCK = register(new RegistryFlag<>("weather-lock", WeatherType.REGISTRY));
|
||||
public static final StringFlag TIME_LOCK = register(new StringFlag("time-lock"));
|
||||
|
Loading…
Reference in New Issue
Block a user