Added an option to block conduit effects

This commit is contained in:
Matthew Miller 2019-01-02 14:25:43 +10:00
parent cd39387e7f
commit 9804c69044
3 changed files with 16 additions and 6 deletions

View File

@ -71,6 +71,7 @@ public abstract class WorldConfiguration {
public boolean itemDurability;
public boolean disableExpDrops;
public boolean blockPotionsAlways;
public boolean disableConduitEffects;
public boolean pumpkinScuba;
public boolean noPhysicsGravel;
public boolean noPhysicsSand;

View File

@ -164,6 +164,7 @@ public void loadConfiguration() {
}
}
blockPotionsAlways = getBoolean("gameplay.block-potions-overly-reliably", false);
disableConduitEffects = getBoolean("gameplay.disable-conduit-effects", false);
simulateSponge = getBoolean("simulation.sponge.enable", false);
spongeRadius = Math.max(1, getInt("simulation.sponge.radius", 3)) - 1;

View File

@ -26,6 +26,7 @@
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityPotionEffectEvent;
public class WorldRulesListener extends AbstractListener {
@ -40,17 +41,24 @@ public WorldRulesListener(WorldGuardPlugin plugin) {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSpawnEntity(final SpawnEntityEvent event) {
WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
// ================================================================
// EXP_DROPS flag
// ================================================================
if (event.getEffectiveType() == EntityType.EXPERIENCE_ORB) {
WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
if (config.disableExpDrops) {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPotionEffect(EntityPotionEffectEvent event) {
if (event.getCause() == EntityPotionEffectEvent.Cause.CONDUIT) {
WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getEntity().getWorld()));
if (config.disableConduitEffects) {
event.setCancelled(true);
}
}
}
}