mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-23 12:39:24 +08:00
Enable control of entity transformations in EssentialsProtect (#2836)
This allows users to prevent any of the following transformations: - Creeper charging - Villager infected by zombie villagers - Villager being cured - Villagers turning into witches - Pigs turning into zombie pigmen - Zombies turning into Drowned (and husks turning into Zombies) - Mooshrooms switching colors Configurations are in a new subsection, `protect.prevent.transformation`. All options are disabled by default. --- * Allow for control of transformations * Undid removal of villager checking * Undid removal of villager checking * Documentation for transformation configs Co-Authored-By: md678685 <1917406+md678685@users.noreply.github.com> * Removed duplicate configuration lines * Updated info about husks drowning * Changed config names Co-authored-by: md678685 <1917406+md678685@users.noreply.github.com>
This commit is contained in:
parent
0ebd64d314
commit
2549ed830f
@ -758,6 +758,22 @@ protect:
|
||||
# Monsters won't follow players.
|
||||
# permission essentials.protect.entitytarget.bypass disables this.
|
||||
entitytarget: false
|
||||
# Prevent certain transformations.
|
||||
transformation:
|
||||
# Prevent creepers becoming charged when struck by lightning.
|
||||
charged-creeper: false
|
||||
# Prevent villagers becoming zombie villagers.
|
||||
zombie-villager: false
|
||||
# Prevent zombie villagers being cured.
|
||||
villager: false
|
||||
# Prevent villagers becoming witches when struck by lightning.
|
||||
witch: false
|
||||
# Prevent pigs becoming zombie pigmen when struck by lightning.
|
||||
zombie-pigman: false
|
||||
# Prevent zombies turning into drowneds, and husks turning into zombies.
|
||||
drowned: false
|
||||
# Prevent mooshrooms changing colour when struck by lightning.
|
||||
mooshroom: false
|
||||
# Prevent the spawning of creatures.
|
||||
spawn:
|
||||
creeper: false
|
||||
|
@ -170,6 +170,29 @@ public class EssentialsProtectEntityListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityTransform(final EntityTransformEvent event) {
|
||||
final Entity entity = event.getEntity();
|
||||
final EntityTransformEvent.TransformReason reason = event.getTransformReason();
|
||||
if (reason == EntityTransformEvent.TransformReason.INFECTION && prot.getSettingBool(ProtectConfig.prevent_villager_infection)) {
|
||||
event.setCancelled(true);
|
||||
} else if (reason == EntityTransformEvent.TransformReason.CURED && prot.getSettingBool(ProtectConfig.prevent_villager_cure)) {
|
||||
event.setCancelled(true);
|
||||
} else if (reason == EntityTransformEvent.TransformReason.LIGHTNING) {
|
||||
if (entity instanceof Villager && prot.getSettingBool(ProtectConfig.prevent_villager_to_witch)) {
|
||||
event.setCancelled(true);
|
||||
} else if (entity instanceof Pig && prot.getSettingBool(ProtectConfig.prevent_pig_transformation)) {
|
||||
event.setCancelled(true);
|
||||
} else if (entity instanceof Creeper && prot.getSettingBool(ProtectConfig.prevent_creeper_charge)) {
|
||||
event.setCancelled(true);
|
||||
} else if (entity instanceof MushroomCow && prot.getSettingBool(ProtectConfig.prevent_mooshroom_switching)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (reason == EntityTransformEvent.TransformReason.DROWNED && prot.getSettingBool(ProtectConfig.prevent_zombie_drowning)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(final CreatureSpawnEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
|
@ -42,7 +42,14 @@ public enum ProtectConfig {
|
||||
prevent_villager_death("protect.prevent.villager-death", false),
|
||||
prevent_enderdragon_blockdmg("protect.prevent.enderdragon-blockdamage", true),
|
||||
prevent_entitytarget("protect.prevent.entitytarget", false),
|
||||
enderdragon_fakeexplosions("protect.enderdragon-fakeexplosions", false);
|
||||
enderdragon_fakeexplosions("protect.enderdragon-fakeexplosions", false),
|
||||
prevent_creeper_charge("protect.prevent.transformation.charged-creeper", false),
|
||||
prevent_villager_infection("protect.prevent.transformation.zombie-villager", false),
|
||||
prevent_villager_cure("protect.prevent.transformation.villager", false),
|
||||
prevent_villager_to_witch("protect.prevent.transformation.witch", false),
|
||||
prevent_pig_transformation("protect.prevent.transformation.zombie-pigman", false),
|
||||
prevent_zombie_drowning("protect.prevent.transformation.drowned", false),
|
||||
prevent_mooshroom_switching("protect.prevent.transformation.mooshroom", false);
|
||||
private final String configName;
|
||||
private final String defValueString;
|
||||
private final boolean defValueBoolean;
|
||||
|
Loading…
Reference in New Issue
Block a user