public final class InventoryInterface extends Object
InventoryPanel
objects with an opening referenceConstructor and Description |
---|
InventoryInterface()
Generates a new seed and registers itself to an
InterfaceListener |
Modifier and Type | Method and Description |
---|---|
static InventoryInterface |
deserialize(Plugin p,
File f)
Reads an
InventoryInterface from a YAML file |
InventoryPanel |
find(Predicate<? super InventoryPanel> filter)
Searches for a specific
InventoryPanel used in this interface |
protected String |
generateSeed(int length)
Generates a new random
ChatColor seed for a panel or interface. |
InventoryPanel |
getLinkedPanel(MenuIcon icon)
Gets a linked
InventoryPanel from a MenuIcon object. |
InventoryPanel |
getPanelBySeed(String title)
Returns an
InventoryPanel based on its generated seed |
Collection<? extends InventoryPanel> |
getPanels()
Returns all
InventoryPanel objects controlled by this interface |
InventoryPanel |
getRootPanel()
Returns the root
InventoryPanel . |
protected String |
getSeed()
Returns the randomized
ChatColor seed made for this interface |
boolean |
isLinked(MenuIcon icon)
Determines if a
MenuIcon is linked to an InventoryPanel |
protected boolean |
isRoot(InventoryPanel panel)
Determines if a passed
InventoryPanel is the root panel |
protected void |
linkPanel(MenuIcon icon,
InventoryPanel panel)
Links a
MenuIcon to open an InventoryPanel |
InventoryPanel |
newPanel(int rows)
Creates and returns an
InventoryPanel for use as a menu |
InventoryPanel |
newPanel(String name,
int rows)
Creates and returns an
InventoryPanel for use as a menu |
void |
openInterface(Player p)
Opens the
InventoryInterface for a player. |
static void |
serialize(InventoryInterface ii,
File save)
Saves an
InventoryInterface to a specified File in YAML |
void |
setRootPanel(InventoryPanel panel)
Sets the root panel of this
InventoryInterface |
public InventoryInterface()
InterfaceListener
public InventoryPanel getRootPanel()
InventoryPanel
.InventoryPanel
public void openInterface(Player p)
InventoryInterface
for a player.p
- The Player
to open the interface forIllegalStateException
- if no root panel is setpublic InventoryPanel newPanel(String name, int rows)
InventoryPanel
for use as a menuname
- The name (title) for the InventoryPanel
rows
- The number of rows for the InventoryPanel
InventoryPanel
objectpublic InventoryPanel newPanel(int rows)
InventoryPanel
for use as a menurows
- The number of rows for the InventoryPanel
InventoryPanel
objectnewPanel(String, int)
public InventoryPanel getLinkedPanel(MenuIcon icon)
InventoryPanel
from a MenuIcon
object. If
the panel is not linked via InventoryPanel.linkIcon(MenuIcon)
,
this method will return null
.icon
- The MenuIcon
to find a link fromInventoryPanel
, or null
if there is no
linked panel.public Collection<? extends InventoryPanel> getPanels()
InventoryPanel
objects controlled by this interfaceInventoryPanel
objects in usepublic InventoryPanel find(Predicate<? super InventoryPanel> filter)
InventoryPanel
used in this interfacefilter
- A Predicate
<? super InventoryPanel>
to
search through active panels with.InventoryPanel
, or null
if
nothing matchespublic void setRootPanel(InventoryPanel panel)
InventoryInterface
panel
- The InventoryPanel
to setIllegalArgumentException
- if panel
is nullIllegalArgumentException
- if this interface did not make the panelpublic boolean isLinked(MenuIcon icon)
MenuIcon
is linked to an InventoryPanel
icon
- The MenuIcon
to checktrue
if the icon is linked to a panelpublic InventoryPanel getPanelBySeed(String title)
InventoryPanel
based on its generated seedtitle
- The overall title of the panel (All seeds and the name)InventoryPanel
, or null
if not foundprotected boolean isRoot(InventoryPanel panel)
InventoryPanel
is the root panelpanel
- The InventoryPanel
to comparetrue
if the passed panel object is the root panelprotected void linkPanel(MenuIcon icon, InventoryPanel panel)
MenuIcon
to open an InventoryPanel
icon
- The MenuIcon
to link to a panelpanel
- The InventoryPanel
to link toprotected String getSeed()
ChatColor
seed made for this interfaceInventoryInterface
protected final String generateSeed(int length)
ChatColor
seed for a panel or interface.
Note the format of the seed for the overall panel is:
<Custom panel title><Panel seed><Interface seed>
My new Panel&1&2&3&4&5&6
length
- The number of ChatColor
objects to usepublic static InventoryInterface deserialize(Plugin p, File f)
InventoryInterface
from a YAML filep
- The Plugin
associated with this File
f
- The File
to load fromInventoryInterface
IllegalArgumentException
- If a null parameter is providedpublic static void serialize(InventoryInterface ii, File save) throws IOException
InventoryInterface
to a specified File
in YAMLii
- The InventoryInterface
to savesave
- The File
to save toIOException
- If the method failed to save to the fileCopyright © 2017. All rights reserved.