mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2025-02-20 13:21:22 +01:00
Added an emptiness representation in the explorer GUI.
It's an item displayed on the center of the GUI if there isn't any data to display. * NEW: added an item displayed if the explorer GUI is empty. * NEW: implementation of this empty item in the list GUI. * NEW: small adjustments on the statistics (removed the last empty line from the lore) * BUG: the old method was still used to remove the item attributes (the one from the `gui` package).
This commit is contained in:
parent
e7acbb36c4
commit
34b3a66220
@ -141,6 +141,8 @@ abstract public class ExplorerGui<T> extends ActionGui
|
||||
updateAction("down", getPageItem("down", canGoDown()));
|
||||
}
|
||||
|
||||
if(data != null && data.length > 0)
|
||||
{
|
||||
if (!isData2D)
|
||||
{
|
||||
int start = currentPageX * viewSize;
|
||||
@ -167,6 +169,15 @@ abstract public class ExplorerGui<T> extends ActionGui
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack emptyIndicator = getEmptyViewItem();
|
||||
if(emptyIndicator != null)
|
||||
{
|
||||
action("", 22, emptyIndicator);
|
||||
}
|
||||
}
|
||||
|
||||
if(hasActions()) super.populate(inventory);
|
||||
}
|
||||
@ -192,20 +203,32 @@ abstract public class ExplorerGui<T> extends ActionGui
|
||||
return;
|
||||
}
|
||||
|
||||
if(affectsGui(event)) // The user clicked in its own inventory
|
||||
// The user clicked in the GUI
|
||||
if(affectsGui(event))
|
||||
{
|
||||
if(data != null && data.length > 0)
|
||||
{
|
||||
switch (event.getAction())
|
||||
{
|
||||
case PICKUP_ALL: case PICKUP_HALF: case PICKUP_ONE: case PICKUP_SOME:
|
||||
case HOTBAR_MOVE_AND_READD: case HOTBAR_SWAP:
|
||||
case PICKUP_ALL:
|
||||
case PICKUP_HALF:
|
||||
case PICKUP_ONE:
|
||||
case PICKUP_SOME:
|
||||
case HOTBAR_MOVE_AND_READD:
|
||||
case HOTBAR_SWAP:
|
||||
case MOVE_TO_OTHER_INVENTORY:
|
||||
onActionPickup(event); break;
|
||||
onActionPickup(event);
|
||||
break;
|
||||
|
||||
case PLACE_ALL: case PLACE_ONE: case PLACE_SOME:
|
||||
case PLACE_ALL:
|
||||
case PLACE_ONE:
|
||||
case PLACE_SOME:
|
||||
case SWAP_WITH_CURSOR:
|
||||
onActionPut(event); break;
|
||||
onActionPut(event);
|
||||
break;
|
||||
|
||||
case DROP_ALL_CURSOR: case DROP_ONE_CURSOR:
|
||||
case DROP_ALL_CURSOR:
|
||||
case DROP_ONE_CURSOR:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -213,6 +236,11 @@ abstract public class ExplorerGui<T> extends ActionGui
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY))
|
||||
onActionMove(event);
|
||||
@ -435,6 +463,13 @@ abstract public class ExplorerGui<T> extends ActionGui
|
||||
*/
|
||||
protected ItemStack getViewItem(T data) { return null; }
|
||||
|
||||
/**
|
||||
* Returns the stack displayed in the center of the GUI if it is empty.
|
||||
*
|
||||
* @return The stack.
|
||||
*/
|
||||
protected ItemStack getEmptyViewItem() { return null; }
|
||||
|
||||
|
||||
private ItemStack getPickedUpItem(int dataIndex)
|
||||
{
|
||||
|
@ -47,6 +47,22 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
"Poster map ("+map.getColumnCount()+"x"+map.getRowCount()+")", "#" + data.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getEmptyViewItem()
|
||||
{
|
||||
ItemStack empty = new ItemStack(Material.BARRIER);
|
||||
ItemMeta meta = empty.getItemMeta();
|
||||
|
||||
meta.setDisplayName(ChatColor.RED + "You don't have any map.");
|
||||
meta.setLore(Arrays.asList(
|
||||
ChatColor.GRAY + "Get started by creating a new one",
|
||||
ChatColor.GRAY + "using " + ChatColor.WHITE + "/tomap <URL> [resize]" + ChatColor.GRAY + "!"
|
||||
));
|
||||
|
||||
empty.setItemMeta(meta);
|
||||
return empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick(ImageMap data)
|
||||
{
|
||||
@ -124,12 +140,11 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
lore.add("");
|
||||
lore.add(getStatisticText("Current consumption", ((int) Math.rint(percentageUsed)) + " %"));
|
||||
lore.add(getStatisticText("Maps left", mapPartLeft));
|
||||
lore.add("");
|
||||
|
||||
meta.setLore(lore);
|
||||
}
|
||||
|
||||
fr.moribus.imageonmap.gui.core.GuiUtils.removeVanillaInfos(meta);
|
||||
GuiUtils.hideItemAttributes(meta);
|
||||
|
||||
statistics.setItemMeta(meta);
|
||||
action("", getSize() - 5, statistics);
|
||||
|
Loading…
Reference in New Issue
Block a user