mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Fixed infinite Diet Cookie Glitch
This commit is contained in:
parent
6c18d368a1
commit
edade50abf
@ -41,6 +41,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -206,8 +207,17 @@ public final class SlimefunSetup {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
int amount = item.getAmount();
|
int amount = item.getAmount();
|
||||||
if (amount <= 1) item.setType(Material.AIR);
|
if (amount <= 1) {
|
||||||
item.setAmount(amount - 1);
|
if (e.getParentEvent().getHand() == EquipmentSlot.HAND) {
|
||||||
|
p.getInventory().setItemInMainHand(null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p.getInventory().setItemInOffHand(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.setAmount(amount - 1);
|
||||||
|
}
|
||||||
|
|
||||||
p.sendMessage(ChatColor.YELLOW + "You feel so light...");
|
p.sendMessage(ChatColor.YELLOW + "You feel so light...");
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user