mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 07:07:43 +01:00
Set saturation level to food level with feed flag.
This commit is contained in:
parent
fb5ae838d9
commit
b298bedea0
@ -19,19 +19,18 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit;
|
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.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
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
|
* 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) {
|
if (feedDelay <= 0) {
|
||||||
player.setFoodLevel(feedAmount > 0 ? maxHunger : minHunger);
|
player.setFoodLevel(feedAmount > 0 ? maxHunger : minHunger);
|
||||||
|
player.setSaturation(player.getFoodLevel());
|
||||||
state.lastFeed = now;
|
state.lastFeed = now;
|
||||||
} else if (now - state.lastFeed > feedDelay * 1000) {
|
} else if (now - state.lastFeed > feedDelay * 1000) {
|
||||||
// clamp health between minimum and maximum
|
// clamp health between minimum and maximum
|
||||||
player.setFoodLevel(Math.min(maxHunger, Math.max(minHunger, player.getFoodLevel() + feedAmount)));
|
player.setFoodLevel(Math.min(maxHunger, Math.max(minHunger, player.getFoodLevel() + feedAmount)));
|
||||||
|
player.setSaturation(player.getFoodLevel());
|
||||||
state.lastFeed = now;
|
state.lastFeed = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user