mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 02:27:42 +01:00
Added food level support to godmode and /heal
This commit is contained in:
parent
920860c298
commit
e492b30178
@ -57,6 +57,7 @@
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PigZapEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@ -115,6 +116,7 @@ public void registerEvents() {
|
||||
registerEvent("ENDERMAN_PICKUP", Priority.High);
|
||||
registerEvent("ENDERMAN_PLACE", Priority.High);
|
||||
registerEvent("ENTITY_DEATH", Priority.High);
|
||||
registerEvent("FOOD_LEVEL_CHANGE", Priority.High);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -856,6 +858,16 @@ public void onEndermanPlace(EndermanPlaceEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(player)) {
|
||||
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
|
||||
|
@ -154,6 +154,7 @@ public static void heal(CommandContext args, WorldGuardPlugin plugin,
|
||||
|
||||
for (Player player : targets) {
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
|
||||
// Tell the user
|
||||
if (player.equals(sender)) {
|
||||
|
Loading…
Reference in New Issue
Block a user