mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2025-02-18 04:21:19 +01:00
You can now destroy from your inventory a map, or all maps from a poster, by putting a map in the map list GUI.
* NEW: Remove a whole map (poster or single) from the inventory by putting a piece in the map list GUI.
This commit is contained in:
parent
0a79eee89b
commit
07bc9cf4a5
@ -134,8 +134,8 @@ public class MapListGui extends AbstractGui {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ItemStack stack, String action, ClickType clickType) {
|
||||
|
||||
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case "back":
|
||||
@ -188,6 +188,24 @@ public class MapListGui extends AbstractGui {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDeposit(Player player, ItemStack stack, ClickType clickType, InventoryClickEvent ev) {
|
||||
ev.setCancelled(true);
|
||||
|
||||
if (stack.getType() == Material.MAP && MapManager.managesMap(stack))
|
||||
{
|
||||
ImageMap map = MapManager.getMap(stack);
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
MapManager.clear(player.getInventory(), map);
|
||||
|
||||
// Deprecated? Yes. Alternatives? No, as usual...
|
||||
ev.setCursor(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage(Player player)
|
||||
{
|
||||
if(currentPage < lastPage) currentPage++;
|
||||
|
@ -61,7 +61,7 @@ abstract public class MapManager
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static public boolean managesMap(ItemStack item)
|
||||
{
|
||||
synchronized(playerMaps)
|
||||
@ -73,7 +73,7 @@ abstract public class MapManager
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static public ImageMap createMap(UUID playerUUID, short mapID) throws MapManagerException
|
||||
{
|
||||
ImageMap newMap = new SingleMap(playerUUID, mapID);
|
||||
@ -143,6 +143,45 @@ abstract public class MapManager
|
||||
{
|
||||
return getPlayerMapStore(playerUUID).getMap(mapId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ImageMap} this map belongs to.
|
||||
*
|
||||
* @param mapId The ID of the Minecraft map.
|
||||
* @return The {@link ImageMap}.
|
||||
*/
|
||||
static public ImageMap getMap(short mapId)
|
||||
{
|
||||
synchronized(playerMaps)
|
||||
{
|
||||
for(PlayerMapStore mapStore : playerMaps)
|
||||
{
|
||||
if(mapStore.managesMap(mapId))
|
||||
{
|
||||
for(ImageMap map : mapStore.getMapList())
|
||||
{
|
||||
if(map.managesMap(mapId))
|
||||
{
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ImageMap} this map belongs to.
|
||||
*
|
||||
* @param item The map, as an {@link ItemStack}.
|
||||
* @return The {@link ImageMap}.
|
||||
*/
|
||||
static public ImageMap getMap(ItemStack item)
|
||||
{
|
||||
return getMap(item.getDurability());
|
||||
}
|
||||
|
||||
static public void clear(Inventory inventory)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user