From 16af1f230acece06cf4a93942dbc3274b28ceb84 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Thu, 9 Mar 2023 17:38:48 -0500 Subject: [PATCH] Add the coral death rule Fixes #46 --- README.md | 1 + src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java | 1 + .../leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 78251c8..9a442cb 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Leukocyte provides various rules that can be applied within authorities. These r - `fluid_flow` controls whether fluids flow - `ice_melt` controls whether ice and frosted ice melt - `snow_fall` controls whether snow can form on surfaces during snowfall + - `coral_death` controls whether coral and coral fan blocks can die - `throw_projectiles` controls whether players can throw eggs, snowballs, or tridents - `shear_entities` controls whether entities such as sheep and mooshrooms can be sheared by players and dispensers diff --git a/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java b/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java index 0527a2d..bf4479d 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java @@ -47,6 +47,7 @@ public final class ProtectionRule { public static final ProtectionRule FLUID_FLOW = register("fluid_flow"); public static final ProtectionRule ICE_MELT = register("ice_melt"); public static final ProtectionRule SNOW_FALL = register("snow_fall"); + public static final ProtectionRule CORAL_DEATH = register("coral_death"); public static final ProtectionRule SPAWN_ANIMALS = register("spawn_animals"); public static final ProtectionRule SPAWN_MONSTERS = register("spawn_monsters"); diff --git a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java index 87eadb4..b033292 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java @@ -19,6 +19,7 @@ import xyz.nucleoid.stimuli.event.block.BlockDropItemsEvent; import xyz.nucleoid.stimuli.event.block.BlockPlaceEvent; import xyz.nucleoid.stimuli.event.block.BlockUseEvent; +import xyz.nucleoid.stimuli.event.block.CoralDeathEvent; import xyz.nucleoid.stimuli.event.block.DispenserActivateEvent; import xyz.nucleoid.stimuli.event.entity.EntityShearEvent; import xyz.nucleoid.stimuli.event.entity.EntitySpawnEvent; @@ -197,5 +198,8 @@ private void applyWorldRules(ProtectionRuleMap rules, EventRegistrar events) { this.forRule(events, rules.test(ProtectionRule.SNOW_FALL)) .applySimple(SnowFallEvent.EVENT, rule -> (world, pos) -> rule); + + this.forRule(events, rules.test(ProtectionRule.CORAL_DEATH)) + .applySimple(CoralDeathEvent.EVENT, rule -> (world, pos, from, to) -> rule); } }