diff --git a/README.md b/README.md index 4d55f99..0881409 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Leukocyte provides various rules that can be applied within authorities. These r - `crafting` controls whether players can craft items - `fall_damage` controls whether players should receive fall damage - `hunger` controls whether players will become hungry + - `activate_death_protection` controls whether entities should activate death protection items such as totems of undying to avoid dying - `throw_items` controls whether players can throw items from their inventory - `pickup_items` controls whether items can be picked up by players or other entities - `unstable_tnt` controls tnt automatically igniting when placed diff --git a/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java b/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java index 6889144..0737197 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java @@ -33,6 +33,7 @@ public final class ProtectionRule { public static final ProtectionRule FREEZING_DAMAGE = register("freezing_damage"); public static final ProtectionRule LAVA_DAMAGE = register("lava_damage"); public static final ProtectionRule DAMAGE = register("damage"); + public static final ProtectionRule ACTIVATE_DEATH_PROTECTION = register("activate_death_protection"); public static final ProtectionRule THROW_ITEMS = register("throw_items"); public static final ProtectionRule PICKUP_ITEMS = register("pickup_items"); 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 af7336a..e0ec5be 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java @@ -24,6 +24,7 @@ import xyz.nucleoid.stimuli.event.block.CoralDeathEvent; import xyz.nucleoid.stimuli.event.block.DispenserActivateEvent; import xyz.nucleoid.stimuli.event.block.FluidRandomTickEvent; +import xyz.nucleoid.stimuli.event.entity.EntityActivateDeathProtectionEvent; import xyz.nucleoid.stimuli.event.entity.EntityShearEvent; import xyz.nucleoid.stimuli.event.entity.EntitySpawnEvent; import xyz.nucleoid.stimuli.event.entity.EntityUseEvent; @@ -96,6 +97,9 @@ public void applyTo(ProtectionRuleMap rules, EventRegistrar events) { return (player, source, amount) -> !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY) ? rule : EventResult.PASS; }); + this.forRule(events, rules.test(ProtectionRule.ACTIVATE_DEATH_PROTECTION)) + .applySimple(EntityActivateDeathProtectionEvent.EVENT, rule -> (player, source, stack) -> rule); + this.forRule(events, rules.test(ProtectionRule.THROW_ITEMS)) .applySimple(ItemThrowEvent.EVENT, rule -> (player, slot, stack) -> rule); this.forRule(events, rules.test(ProtectionRule.PICKUP_ITEMS))