Browse Source

Improve map command- don't delete items

When you get a map it places the current item into the first available slot- if not free, it drops the item to the ground.
master
elliot 3 years ago
parent
commit
6c7adf2e42
  1. 16
      src/cx/sfy/LagAssist/MonTools.java

16
src/cx/sfy/LagAssist/MonTools.java

@ -156,13 +156,29 @@ public class MonTools implements Listener {
// }
public static void giveMap(Player p) {
// Get the player's inventory
PlayerInventory inv = p.getInventory();
// Get the value of the active slot
int slot = inv.getHeldItemSlot();
// Get the item that is in the user's active slot
ItemStack item = inv.getItem(slot)
if (inventory.firstEmpty() == -1){
// if inventory is full, drop it to the ground (item is an ItemStack)
player.getWorld().dropItem(player.getLocation().add(0, 1, 0), item);
} else{
// if there is a empty place, put it in
int newItemSlot = inventory.firstEmpty();
inventory.setItem(newItemSlot, item);
}
// Set the active slot to the map
inv.setItem(slot, MonTools.mapitem);
// Get the user's UUID
UUID UUID = p.getUniqueId();
// Add the user's UUID to the mapusers array
if (!mapusers.contains(UUID)) {
mapusers.add(UUID);
}

Loading…
Cancel
Save