mirror of
https://github.com/ViaVersion/ViaRewind-Legacy-Support.git
synced 2025-01-24 21:21:50 +01:00
Merge pull request #36 from Foorcee/inventory
Fix "lapis lazuli may disappear when inventory is full?"
This commit is contained in:
commit
b0986504b1
@ -1,6 +1,7 @@
|
||||
package de.gerrygames.viarewind.legacysupport.listener;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -11,6 +12,8 @@ import org.bukkit.inventory.EnchantingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class EnchantingListener implements Listener {
|
||||
|
||||
private final boolean newMaterialNames = Material.getMaterial("LAPIS_LAZULI") != null;
|
||||
@ -54,6 +57,12 @@ public class EnchantingListener implements Listener {
|
||||
ItemStack item = inventory.getSecondary();
|
||||
if (item==null || item.getType()==Material.AIR) return;
|
||||
inventory.setSecondary(new ItemStack(Material.AIR));
|
||||
playerInventory.addItem(item);
|
||||
Map<Integer, ItemStack> remaining = playerInventory.addItem(item);
|
||||
if (!remaining.isEmpty()) {
|
||||
Location location = player.getLocation();
|
||||
for (ItemStack value : remaining.values()) {
|
||||
player.getWorld().dropItem(location, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user