mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-10 20:40:16 +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
|
@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)
|
switch (action)
|
||||||
{
|
{
|
||||||
case "back":
|
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)
|
private void nextPage(Player player)
|
||||||
{
|
{
|
||||||
if(currentPage < lastPage) currentPage++;
|
if(currentPage < lastPage) currentPage++;
|
||||||
|
@ -144,6 +144,45 @@ abstract public class MapManager
|
|||||||
return getPlayerMapStore(playerUUID).getMap(mapId);
|
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)
|
static public void clear(Inventory inventory)
|
||||||
{
|
{
|
||||||
for(int i = 0, c = inventory.getSize(); i < c; i++)
|
for(int i = 0, c = inventory.getSize(); i < c; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user