From b298bedea09de373251e2616302088cbf384685a Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 26 Jun 2014 17:47:14 -0700 Subject: [PATCH] Set saturation level to food level with feed flag. --- .../worldguard/bukkit/FlagStateManager.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java index 180335e6..d818b7b4 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java @@ -19,19 +19,18 @@ package com.sk89q.worldguard.bukkit; -import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.GameMode; -import org.bukkit.World; -import org.bukkit.entity.Player; - import com.sk89q.worldedit.Vector; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.managers.RegionManager; +import org.bukkit.GameMode; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; /** * This processes per-player state information and is also meant to be used @@ -182,10 +181,12 @@ private void processFeed(ApplicableRegionSet applicable, Player player, if (feedDelay <= 0) { player.setFoodLevel(feedAmount > 0 ? maxHunger : minHunger); + player.setSaturation(player.getFoodLevel()); state.lastFeed = now; } else if (now - state.lastFeed > feedDelay * 1000) { // clamp health between minimum and maximum player.setFoodLevel(Math.min(maxHunger, Math.max(minHunger, player.getFoodLevel() + feedAmount))); + player.setSaturation(player.getFoodLevel()); state.lastFeed = now; } }