|
@ -156,13 +156,29 @@ public class MonTools implements Listener { |
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
public static void giveMap(Player p) { |
|
|
public static void giveMap(Player p) { |
|
|
|
|
|
// Get the player's inventory
|
|
|
PlayerInventory inv = p.getInventory(); |
|
|
PlayerInventory inv = p.getInventory(); |
|
|
|
|
|
// Get the value of the active slot
|
|
|
int slot = inv.getHeldItemSlot(); |
|
|
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); |
|
|
inv.setItem(slot, MonTools.mapitem); |
|
|
|
|
|
|
|
|
|
|
|
// Get the user's UUID
|
|
|
UUID UUID = p.getUniqueId(); |
|
|
UUID UUID = p.getUniqueId(); |
|
|
|
|
|
|
|
|
|
|
|
// Add the user's UUID to the mapusers array
|
|
|
if (!mapusers.contains(UUID)) { |
|
|
if (!mapusers.contains(UUID)) { |
|
|
mapusers.add(UUID); |
|
|
mapusers.add(UUID); |
|
|
} |
|
|
} |
|
|