mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-05 02:19:30 +01:00
Added potion splash flag to prevent splash potions from affecting entities
This commit is contained in:
parent
a7d198893e
commit
583ea76e4b
@ -23,6 +23,7 @@
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.GlobalRegionManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -62,6 +63,7 @@
|
||||
import org.bukkit.event.entity.PigZapEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||
import org.bukkit.event.painting.PaintingBreakEvent;
|
||||
import org.bukkit.event.painting.PaintingPlaceEvent;
|
||||
@ -792,6 +794,21 @@ public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPotionSplash(PotionSplashEvent event) {
|
||||
GlobalRegionManager global = plugin.getGlobalRegionManager();
|
||||
int blockedEntities = 0;
|
||||
for (LivingEntity e : event.getAffectedEntities()) {
|
||||
if (!global.allows(DefaultFlag.POTION_SPLASH, e.getLocation(), e instanceof Player ? plugin.wrapPlayer((Player) e) : null)) {
|
||||
event.setIntensity(e, 0);
|
||||
++blockedEntities;
|
||||
}
|
||||
}
|
||||
if (blockedEntities == event.getAffectedEntities().size()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is invincible, via either god mode or region flag. If
|
||||
* the region denies invincibility, the player must have an extra permission
|
||||
|
@ -61,6 +61,7 @@ public final class DefaultFlag {
|
||||
public static final StateFlag EXP_DROPS = new StateFlag("exp-drops", true, RegionGroup.ALL);
|
||||
public static final StateFlag ENTRY = new StateFlag("entry", true);
|
||||
public static final StateFlag EXIT = new StateFlag("exit", true);
|
||||
public static final StateFlag POTION_SPLASH = new StateFlag("potion-splash", true);
|
||||
public static final StringFlag GREET_MESSAGE = new StringFlag("greeting", RegionGroup.ALL);
|
||||
public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell", RegionGroup.ALL);
|
||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter", RegionGroup.ALL);
|
||||
@ -93,7 +94,7 @@ public final class DefaultFlag {
|
||||
SNOW_FALL, SNOW_MELT, ICE_FORM, ICE_MELT,
|
||||
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD,
|
||||
FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
|
||||
TELE_LOC, SPAWN_LOC,
|
||||
TELE_LOC, SPAWN_LOC, POTION_SPLASH,
|
||||
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user