Various GUI & GUI API improvements.

* NEW: ActionGui: Added the GuiAction annotation.
* NEW: ConfirmDeleteMapGui: Updated to use the @GuiAction annotations.
* NEW: ExplorerGui: Added a default empty indicator.
* NEW: ExplorerGui: Updated to use the @GuiAction annotations.
* NEW: ExplorerGui: Added current page getters & setters.
* NEW: MapDetailGui: Updated to use the @GuiAction annotations.
* BUG: ActionGui: Fix event handler call if the method takes an 
  InventoryClickEvent as a parameter.
* BUG: ConfirmDeleteMapGui: Fix exception handling.
* BUG: ExplorerGui: Fix the hasData() method.
* BUG: ExplorerGui: Fix the empty indicator.
* BUG: ExplorerGui: Fix the keep*ScrollingSpace implementation.
* BUG: ExplorerGui: Fix item pickup when using coordinates.
* BUG: ExplorerGui: All callbacks can now take coordinates instead
  of data.
* OPT: ConfirmDeleteMapGui: Messages are now defined as constants.
* OPT: ConfirmDeleteMapGui: GUI's data is now final.
* OPT: MapDetailGui: Cleaned up GUI initialization a bit.
* OPT: MapListGui: Cleaned up ItemStack generation.
* OPT: MapDetailGui: Clarified UI tooltips.
This commit is contained in:
Adrien Prokopowicz 2015-09-19 13:35:33 +02:00
parent d25bf9bd0e
commit f29e972be6
6 changed files with 312 additions and 202 deletions

View File

@ -272,14 +272,14 @@ abstract public class ActionGui extends Gui
event.setCancelled(true);
callAction(actions.get(event.getRawSlot()));
callAction(actions.get(event.getRawSlot()), event);
}
/**
* Triggers the given action's event handler.
* @param action The action to trigger.
*/
private void callAction(Action action)
private void callAction(Action action, InventoryClickEvent event)
{
if(action == null) return;
@ -291,7 +291,14 @@ abstract public class ActionGui extends Gui
try
{
action.callback.invoke(this);
if(action.callback.getParameterCount() == 1)
{
action.callback.invoke(this, event);
}
else
{
action.callback.invoke(this);
}
}
catch (IllegalAccessException | IllegalArgumentException ex)
{
@ -304,6 +311,30 @@ abstract public class ActionGui extends Gui
}
}
/**
* Returns if the given method is a valid action handler.
* An action handler is valid only if it is accessible and parameter types matches.
* @param method The method to test
* @return true if the given method is valid, false otherwise.
*/
private boolean isActionHandlerValid(Method method)
{
if(method.getParameterCount() >= 2) return false;
if(method.getParameterCount() == 1)
if(method.getParameterTypes()[0] != InventoryClickEvent.class)
return false;
try
{
method.setAccessible(true);
}
catch(SecurityException ex)
{
return false;
}
return true;
}
/**
* Retrieves the event handler matching the given name from a class (or any of its parents).
*
@ -313,32 +344,38 @@ abstract public class ActionGui extends Gui
*/
private Method getActionHandler(Class<?> klass, String name)
{
Method callback;
do
{
try
GuiAction actionAnnotation;
String methodName;
for(Method method : klass.getDeclaredMethods())
{
try
actionAnnotation = method.getDeclaredAnnotation(GuiAction.class);
if(actionAnnotation == null) continue;
if(!(actionAnnotation.value() == null || actionAnnotation.value().isEmpty()))
{
callback = klass.getDeclaredMethod(ACTION_HANDLER_NAME + name, InventoryClickEvent.class);
if(actionAnnotation.value().equals(name))
if(isActionHandlerValid(method))
return method;
}
catch(NoSuchMethodException e)
else
{
callback = klass.getDeclaredMethod(ACTION_HANDLER_NAME + name);
methodName = method.getName();
if(methodName.equals(name))
if(isActionHandlerValid(method))
return method;
if(methodName.startsWith(ACTION_HANDLER_NAME))
if(methodName.substring(ACTION_HANDLER_NAME.length()).equals(name))
if(isActionHandlerValid(method))
return method;
}
callback.setAccessible(true);
break;
}
catch (Throwable ex)
{
callback = null;
klass = klass.getSuperclass();
}
klass = klass.getSuperclass();
} while (klass != null);
return callback;
return null;
}
/**

View File

@ -100,6 +100,8 @@ abstract public class ExplorerGui<T> extends ActionGui
this.data = data;
if(dataWidth > 0)
setDataShape(dataWidth, (int) Math.ceil((double) data.length / (double) dataWidth));
else
setDataShape(0, data.length);
}
/**
@ -134,7 +136,10 @@ abstract public class ExplorerGui<T> extends ActionGui
*/
protected boolean hasData()
{
return (data == null || data.length == 0) && (dataWidth == 0 && dataHeight == 0);
if(isData2D)
return dataWidth > 0 && dataHeight > 0;
else
return data != null && data.length > 0;
}
@Override
@ -161,7 +166,7 @@ abstract public class ExplorerGui<T> extends ActionGui
for (int i = 0; i < max; i++)
{
inventory.setItem(i, getViewItem(i + start));
inventory.setItem(i, getViewItem(getData(i + start)));
}
}
else
@ -183,11 +188,7 @@ abstract public class ExplorerGui<T> extends ActionGui
}
else
{
ItemStack emptyIndicator = getEmptyViewItem();
if(emptyIndicator != null)
{
action("", 22, emptyIndicator);
}
updateAction("__empty__", getEmptyViewItem());
}
if(hasActions()) super.populate(inventory);
@ -297,23 +298,23 @@ abstract public class ExplorerGui<T> extends ActionGui
*/
private void onActionPickup(InventoryClickEvent event)
{
int dataIndex = getDataIndex(event.getSlot());
ExplorerGuiEvent eventSlot = new ExplorerGuiEvent(this, event);
if(event.getClick().equals(ClickType.RIGHT))
{
onRightClick(getData(dataIndex));
onRightClick(eventSlot);
event.setCancelled(true);
return;
}
ItemStack pickedUpItem = getPickedUpItem(dataIndex);
ItemStack pickedUpItem = getPickedUpItem(eventSlot);
if(pickedUpItem == null || mode.equals(Mode.READONLY))
{
event.setCancelled(true);
return;
}
event.setCurrentItem(pickedUpItem);
GuiUtils.setItemLater(this, event.getSlot(), getViewItem(dataIndex));
GuiUtils.setItemLater(this, event.getSlot(), getViewItem(eventSlot));
}
/**
@ -363,8 +364,9 @@ abstract public class ExplorerGui<T> extends ActionGui
viewHeight = Math.min((int)Math.ceil((double)dataLength / (double)viewWidth),
MAX_INVENTORY_COLUMN_SIZE);
if(hasActions() || dataLength > MAX_INVENTORY_SIZE || keepHorizontalScrollingSpace)
viewHeight--;
if(viewHeight >= MAX_INVENTORY_COLUMN_SIZE)
if(hasActions() || dataLength > MAX_INVENTORY_SIZE || keepHorizontalScrollingSpace)
viewHeight--;
viewSize = viewWidth * viewHeight;
@ -379,11 +381,13 @@ abstract public class ExplorerGui<T> extends ActionGui
pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth);
pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight);
if((pageCountY > 1 && viewWidth == INVENTORY_ROW_SIZE) || keepVerticalScrollingSpace)
viewWidth--;
if((pageCountX > 1 && viewHeight == MAX_INVENTORY_COLUMN_SIZE) || keepHorizontalScrollingSpace)
viewHeight--;
if(viewWidth >= INVENTORY_ROW_SIZE)
if((pageCountY > 1 && viewWidth == INVENTORY_ROW_SIZE) || keepVerticalScrollingSpace)
viewWidth--;
if(viewHeight >= MAX_INVENTORY_COLUMN_SIZE)
if((pageCountX > 1 && viewHeight == MAX_INVENTORY_COLUMN_SIZE) || keepHorizontalScrollingSpace)
viewHeight--;
pageCountX = (int)Math.ceil((double)dataWidth / (double)viewWidth);
pageCountY = (int)Math.ceil((double)dataHeight / (double)viewHeight);
@ -399,39 +403,10 @@ abstract public class ExplorerGui<T> extends ActionGui
action("up", INVENTORY_ROW_SIZE - 1);
action("down", MAX_INVENTORY_SIZE - 1);
}
}
private void action_next()
{
next();
}
private void action_previous()
{
previous();
}
private void action_up()
{
up();
}
private void action_down()
{
down();
}
private int getDataIndex(int inventorySlot)
{
if(isData2D)
if(!hasData())
{
int column = currentPageX * viewWidth + inventorySlot % INVENTORY_ROW_SIZE;
int row = currentPageY * viewHeight + inventorySlot / INVENTORY_ROW_SIZE;
return row * dataWidth + column;
}
else
{
return currentPageX * viewSize + inventorySlot;
action("__empty__", 22);
}
}
@ -442,18 +417,20 @@ abstract public class ExplorerGui<T> extends ActionGui
return data[i];
}
/**
* Returns the stack to display at the given index.
*
* @param i The index.
* @return The stack.
*/
protected ItemStack getViewItem(int i)
private ItemStack getViewItem(ExplorerGuiEvent event)
{
return getViewItem(getData(i));
if(!event.isValid) return null;
if(isData2D)
{
return getViewItem(event.xData, event.yData);
}
else
{
return getViewItem(getData(event.posData));
}
}
/**
* Returns the stack to display at the given coordinates.
*
@ -463,7 +440,7 @@ abstract public class ExplorerGui<T> extends ActionGui
*/
protected ItemStack getViewItem(int x, int y)
{
return getViewItem(y * dataWidth + x);
return getViewItem(getData(y * dataWidth + x));
}
/**
@ -475,12 +452,32 @@ 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.
* Returns the item displayed in the center of the GUI if it is empty.
*
* @return The stack.
* @return The item.
*/
protected ItemStack getEmptyViewItem() { return null; }
protected ItemStack getEmptyViewItem()
{
return GuiUtils.makeItem(Material.BARRIER, "Empty", "There's nothing to see here");
}
private ItemStack getPickedUpItem(ExplorerGuiEvent event)
{
if(!event.isValid) return null;
if(isData2D)
{
return getPickedUpItem(event.xData, event.yData);
}
else
{
return getPickedUpItem(event.posData);
}
}
protected ItemStack getPickedUpItem(int x, int y)
{
return getViewItem(x,y);
}
private ItemStack getPickedUpItem(int dataIndex)
{
@ -496,7 +493,7 @@ abstract public class ExplorerGui<T> extends ActionGui
* mode.
*
* @param data The picked-up piece of data.
* @return The stack to pick-up ({@code null} to cancel the pick-up).
* @return The stack to pick-up (or {@code null} to cancel the pick-up).
*/
protected ItemStack getPickedUpItem(T data) { return getViewItem(data); }
@ -563,7 +560,27 @@ abstract public class ExplorerGui<T> extends ActionGui
icon.setItemMeta(meta);
return icon;
}
private void onRightClick(ExplorerGuiEvent event)
{
if(!event.isValid) return;
if(isData2D)
{
onRightClick(event.xData, event.yData);
}
else
{
onRightClick(getData(event.posData));
}
}
/**
* Triggered when the player right-clicks an item on the GUI.
* @param x The X position of the right-clicked data.
* @param y The Y position of the right-clicked data.
*/
protected void onRightClick(int x, int y) {}
/**
* Triggered when the player right-clicks an item on the GUI.
*
@ -572,7 +589,7 @@ abstract public class ExplorerGui<T> extends ActionGui
protected void onRightClick(T data) {}
/**
* Triggered when the player try to place an item inside the GUI.
* Triggered when the player tries to place an item inside the GUI.
*
* This will not place the item in the GUI, it's up to you to update the data and refresh
* the GUI if you need so.
@ -582,44 +599,69 @@ abstract public class ExplorerGui<T> extends ActionGui
*/
protected boolean onPutItem(ItemStack item) { return true; }
static private final class ExplorerGuiEvent
{
//2D Explorer
public final int xData;
public final int yData;
//1D Explorer
public final int posData;
public final boolean isValid;
public ExplorerGuiEvent(ExplorerGui gui, InventoryClickEvent event)
{
if(gui.isData2D)
{
xData = gui.currentPageX * gui.viewWidth + event.getSlot() % INVENTORY_ROW_SIZE;
yData = gui.currentPageY * gui.viewHeight + event.getSlot() / INVENTORY_ROW_SIZE;
posData = -1;
isValid = (xData < gui.dataWidth && xData >= 0 && yData < gui.dataHeight && yData >= 0);
}
else
{
xData = yData = -1;
posData = gui.currentPageX * gui.viewSize + event.getSlot();
isValid = (posData >= 0 && posData < gui.dataHeight);
}
}
}
/**
* Displays the next horizontal page, if possible.
*/
@GuiAction
public void next()
{
if(!canGoNext()) return;
currentPageX++;
refresh();
setCurrentPageX(currentPageX - 1);
}
/**
* Displays the previous horizontal page, if possible.
*/
@GuiAction
public void previous()
{
if(!canGoPrevious()) return;
currentPageX--;
refresh();
setCurrentPageX(currentPageX - 1);
}
/**
* Displays the previous vertical page, if possible.
*/
@GuiAction
public void up()
{
if(!canGoUp()) return;
currentPageY--;
refresh();
setCurrentPageY(currentPageY - 1);
}
/**
* Displays the next vertical page, if possible.
*/
@GuiAction
public void down()
{
if(!canGoDown()) return;
currentPageY++;
refresh();
setCurrentPageY(currentPageY + 1);
}
public boolean canGoNext()
@ -641,6 +683,35 @@ abstract public class ExplorerGui<T> extends ActionGui
{
return currentPageY < pageCountY - 1;
}
public int getCurrentPageX()
{
return currentPageX;
}
public void setCurrentPageX(int currentPageX)
{
setCurrentPage(currentPageX, currentPageY);
}
public int getCurrentPageY()
{
return currentPageY;
}
public void setCurrentPageY(int currentPageY)
{
setCurrentPage(currentPageX, currentPageY);
}
public void setCurrentPage(int currentPageX, int currentPageY)
{
if(currentPageX < 1 || currentPageX > pageCountX - 1) return;
if(currentPageY < 1 || currentPageY > pageCountY - 1) return;
this.currentPageX = currentPageX;
this.currentPageY = currentPageY;
refresh();
}
/**
* Returns the amount of horizontal pages.

View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2013 Moribus
* Copyright (C) 2015 ProkopyL <prokopylmc@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.moribus.imageonmap.guiproko.core;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface GuiAction
{
String value() default "";
}

View File

@ -36,34 +36,51 @@ public class ConfirmDeleteMapGui extends ActionGui
static private final int FIRST_SLOT_DELETE_BUTTON = 27;
static private final int SHIFT_CANCEL_BUTTON = 5;
/**
* The messages randomly displayed in the lore of the delete buttons.
*/
static private final String[] DELETE_MESSAGES = new String[]{
"Please", "I'm still alive", "Don't do that", "I'm still loving you", "I want to live",
"Please please", "Please please please", "What are you doing?!", "Nooooo!",
"Click and I'll be dead", "Why?", "Please don't do that", "Think about my family",
"Click, I don't like you anymore.", "I don't hate you.", "Click, I'm ready.",
"I'm a green button.", "I'm different.", "Thanks anyway.", "Excuse me.", "Get mad.",
"Sorry!", "My fault!", "I don't blame you.", "No hard feelings.",
"But I need to protect the humans!", "Noooo!", "I'm scared!", "What are you doing?",
"It burns.", "This is not good.", "Can't breathe.", "Thanks anyway.", "These things happen.",
"That was nobody's fault.", "I probably deserved it.", "I blame myself."
};
/**
* The messages randomly displayed in the lore of the cancel buttons.
*/
static private final String[] CANCEL_MESSAGES = new String[] {
"Yay!", "Still aliiiive!", "Click click click", "Yes do that", "I'm a red button.",
"Please click here", "The other button is ugly", "Save me", "This is the good choice",
"Click, I want to live!", "I'll be dead another day anyway", "Are you sure?",
"So you're still loving me?", "Please save me", "Take me with you.",
"Excuse me.", "Don't make lemonade.", "Sleep mode activated.", "Hybernating.",
"Your business is appreciated.", "Hey! It's me! Don't shoot!", "Wheee!", "Hurray!",
"You have excellent aim!", "Please please please"
};
/**
* The map being deleted.
*/
private ImageMap mapToDelete;
private final ImageMap mapToDelete;
/**
* The previously-viewed page of the list GUI.
* Used to be able to bring the user back to the same page.
*/
private int currentPage;
/**
* The messages randomly displayed in the lore of the delete buttons.
*/
private String[] deleteMessages;
/**
* The messages randomly displayed in the lore of the cancel buttons.
*/
private String[] cancelMessages;
private final int currentPage;
/**
* A source of randomness.
*
* Yes, this javadoc comment is REALLY useful. Trust me.
*/
private Random random = new Random();
private final Random random = new Random();
/**
@ -75,28 +92,6 @@ public class ConfirmDeleteMapGui extends ActionGui
{
this.mapToDelete = mapToDelete;
this.currentPage = currentPage;
deleteMessages = new String[]{
"Please", "I'm still alive", "Don't do that", "I'm still loving you", "I want to live",
"Please please", "Please please please", "What are you doing?!", "Nooooo!",
"Click and I'll be dead", "Why?", "Please don't do that", "Think about my family",
"Click, I don't like you anymore.", "I don't hate you.", "Click, I'm ready.",
"I'm a green button.", "I'm different.", "Thanks anyway.", "Excuse me.", "Get mad.",
"Sorry!", "My fault!", "I don't blame you.", "No hard feelings.",
"But I need to protect the humans!", "Noooo!", "I'm scared!", "What are you doing?",
"It burns.", "This is not good.", "Can't breathe.", "Thanks anyway.", "These things happen.",
"That was nobody's fault.", "I probably deserved it.", "I blame myself."
};
cancelMessages = new String[] {
"Yay!", "Still aliiiive!", "Click click click", "Yes do that", "I'm a red button.",
"Please click here", "The other button is ugly", "Save me", "This is the good choice",
"Click, I want to live!", "I'll be dead another day anyway", "Are you sure?",
"So you're still loving me?", "Please save me", "Take me with you.",
"Excuse me.", "Don't make lemonade.", "Sleep mode activated.", "Hybernating.",
"Your business is appreciated.", "Hey! It's me! Don't shoot!", "Wheee!", "Hurray!",
"You have excellent aim!", "Please please please"
};
}
@Override
@ -140,13 +135,13 @@ public class ConfirmDeleteMapGui extends ActionGui
private ItemStack createDeleteSubButton()
{
// Orange? Nooo. In the real world this is red. True story.
return createSubButton(DyeColor.ORANGE, ChatColor.RED + "Delete the map", deleteMessages);
return createSubButton(DyeColor.ORANGE, ChatColor.RED + "Delete the map", DELETE_MESSAGES);
}
private ItemStack createCancelSubButton()
{
// YES. Purple = lime. BECAUSE. Just accept it.
return createSubButton(DyeColor.PURPLE, ChatColor.GREEN + "Cancel", cancelMessages);
return createSubButton(DyeColor.PURPLE, ChatColor.GREEN + "Cancel", CANCEL_MESSAGES);
}
private ItemStack createSubButton(DyeColor color, String title, String[] messages)
@ -167,11 +162,13 @@ public class ConfirmDeleteMapGui extends ActionGui
return subButton;
}
@GuiAction
protected void action_cancel()
{
Gui.open(getPlayer(), new MapDetailGui(null /*mapToDelete, currentPage */));
Gui.open(getPlayer(), new MapDetailGui(mapToDelete)).setCurrentPageX(currentPage);
}
@GuiAction
protected void action_delete()
{
MapManager.clear(getPlayer().getInventory(), mapToDelete);
@ -183,8 +180,8 @@ public class ConfirmDeleteMapGui extends ActionGui
}
catch (MapManagerException ex)
{
PluginLogger.warning("A non-existent map was requested to be deleted", ex);
getPlayer().sendMessage(ChatColor.RED + "This map does not exists.");
PluginLogger.warning("Error while deleting map", ex);
getPlayer().sendMessage(ChatColor.RED + ex.getMessage());
}
Gui.open(getPlayer(), new MapListGui(/* currentPage */));

View File

@ -42,7 +42,7 @@ public class MapDetailGui extends ExplorerGui<Void>
Material partMaterial = Material.PAPER;
if((y % 2 == 0 && x % 2 == 0) || (y % 2 == 1 && x % 2 == 1))
partMaterial = Material.EMPTY_MAP;
ItemStack part = new ItemStack(partMaterial);
ItemMeta meta = part.getItemMeta();
@ -65,12 +65,20 @@ public class MapDetailGui extends ExplorerGui<Void>
{
return getViewItem(0, 0);
}
else return null;
else return super.getEmptyViewItem();
}
@GuiAction
private void delete()
{
Gui.open(getPlayer(), new ConfirmDeleteMapGui(map, getCurrentPageX()));
}
@Override
protected void onUpdate()
{
ItemStack back, rename, delete;
setTitle("Your maps » " + ChatColor.BLACK + map.getName());
setKeepHorizontalScrollingSpace(true);
@ -79,36 +87,21 @@ public class MapDetailGui extends ExplorerGui<Void>
else
setData(null); // Fallback to the empty view item.
ItemStack back = new ItemStack(Material.EMERALD);
ItemMeta meta = back.getItemMeta();
meta.setDisplayName(ChatColor.GREEN + "« Back");
meta.setLore(Collections.singletonList(
ChatColor.GRAY + "Go back to the list."
));
back.setItemMeta(meta);
ItemStack rename = new ItemStack(Material.BOOK_AND_QUILL);
meta = rename.getItemMeta();
meta.setDisplayName(ChatColor.BLUE + "Rename this image");
meta.setLore(Arrays.asList(
ChatColor.GRAY + "Click here to rename this image;",
ChatColor.GRAY + "this is used for your own organization."
));
rename.setItemMeta(meta);
ItemStack delete = new ItemStack(Material.BARRIER);
meta = delete.getItemMeta();
meta.setDisplayName(ChatColor.RED + "Delete this image");
meta.setLore(Arrays.asList(
back = GuiUtils.makeItem(Material.EMERALD,
ChatColor.GREEN + "« Back",
ChatColor.GRAY + "Go back to the list.");
rename = GuiUtils.makeItem(Material.BOOK_AND_QUILL,
ChatColor.BLUE + "Rename",
ChatColor.GRAY + "Renames this image");
delete = GuiUtils.makeItem(Material.BARRIER,
ChatColor.RED + "Delete",
ChatColor.GRAY + "Deletes this map " + ChatColor.WHITE + "forever" + ChatColor.GRAY + ".",
ChatColor.GRAY + "This action cannot be undone!",
"",
ChatColor.GRAY + "You will be asked to confirm your",
ChatColor.GRAY + "choice if you click here."
));
delete.setItemMeta(meta);
ChatColor.GRAY + "This action cannot be undone!");
action("rename", getSize() - 7, rename);
action("delete", getSize() - 6, delete);

View File

@ -38,56 +38,38 @@ public class MapListGui extends ExplorerGui<ImageMap>
@Override
protected ItemStack getViewItem(ImageMap map)
{
ItemStack icon = new ItemStack(Material.MAP);
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + map.getName());
String mapDescription;
if(map instanceof SingleMap)
mapDescription = "Single map";
else
mapDescription = "Poster map (" + ((PosterMap) map).getColumnCount() + "×" + ((PosterMap) map).getRowCount() + ")";
meta.setLore(Arrays.asList(
return GuiUtils.makeItem(Material.MAP,
ChatColor.GREEN + "" + ChatColor.BOLD + map.getName(),
ChatColor.WHITE + mapDescription,
"",
ChatColor.GRAY + "Map ID: " + map.getId(),
"",
ChatColor.GRAY + "» Left-click to get this map",
ChatColor.GRAY + "» Right-click for details and options"
));
GuiUtils.hideItemAttributes(meta);
icon.setItemMeta(meta);
return icon;
ChatColor.GRAY + "» Right-click for details and options");
}
@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(
return GuiUtils.makeItem(Material.BARRIER,
ChatColor.RED + "You don't have any map.",
ChatColor.GRAY + "Get started by creating a new one",
ChatColor.GRAY + "using " + ChatColor.WHITE + "/tomap <URL> [resize]" + ChatColor.GRAY + "!"
));
empty.setItemMeta(meta);
return empty;
ChatColor.GRAY + "using " + ChatColor.WHITE + "/tomap <URL>" + ChatColor.GRAY + "!");
}
@Override
protected void onRightClick(ImageMap data)
protected void onRightClick(ImageMap map)
{
Gui.open(getPlayer(), new MapDetailGui(data));
Gui.open(getPlayer(), new MapDetailGui(map));
}
@Override
@ -149,7 +131,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
if(mapPartLeft >= 0)
{
List<String> lore = meta.getLore();
lore.add("");
lore.add(ChatColor.BLUE + "Minecraft maps limits");