Add config to disable villagers getting zapped to witches.

"weather.disable-villager-witchification"
This commit is contained in:
wizjany 2019-06-30 19:58:10 -04:00
parent aa8997aeca
commit 8ca01b37a4
4 changed files with 19 additions and 2 deletions

View File

@ -231,6 +231,7 @@ public void loadConfiguration() {
disableThunder = getBoolean("weather.disable-thunderstorm", false);
disableWeather = getBoolean("weather.disable-weather", false);
disablePigZap = getBoolean("weather.disable-pig-zombification", false);
disableVillagerZap = getBoolean("weather.disable-villager-witchification", false);
disableCreeperPower = getBoolean("weather.disable-powered-creepers", false);
alwaysRaining = getBoolean("weather.always-raining", false);
alwaysThundering = getBoolean("weather.always-thundering", false);

View File

@ -74,6 +74,7 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTransformEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.PigZapEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -715,10 +716,24 @@ public void onCreatePortal(PortalCreateEvent event) {
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityTransform(EntityTransformEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
final Entity entity = event.getEntity();
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
final EntityType type = entity.getType();
if (wcfg.disableVillagerZap && type == EntityType.VILLAGER
&& event.getTransformReason() == EntityTransformEvent.TransformReason.LIGHTNING) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPigZap(PigZapEvent event) {
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
final Entity entity = event.getEntity();
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
if (wcfg.disablePigZap) {
event.setCancelled(true);

View File

@ -263,7 +263,7 @@ public Component getComponent(int number) {
}
if (perms != null && entry.region.getFlag(Flags.TELE_LOC) != null && perms.mayTeleportTo(entry.region)) {
builder.append(TextComponent.space().append(TextComponent.of("[TP]", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for teleport")))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to teleport")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
"/rg tp -w " + world + " " + entry.region.getId()))));
}

View File

@ -134,6 +134,7 @@ public abstract class WorldConfiguration {
public boolean alwaysRaining;
public boolean alwaysThundering;
public boolean disablePigZap;
public boolean disableVillagerZap;
public boolean disableCreeperPower;
public boolean disableHealthRegain;
public boolean disableMushroomSpread;