use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class MatchBlockCondition method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
Menu m = new Menu(3, "Match Block", player);
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
final MenuItemCustom c = new MenuItemCustom("Auto Set Block", MinigameUtils.stringToList("Click here with a;block you wish to;match to."), Material.ITEM_FRAME);
m.addItem(c, m.getSize() - 1);
final MinigamePlayer ply = m.getViewer();
final MenuItemString btype = new MenuItemString("Block Type", Material.STONE, new Callback<String>() {
@Override
public void setValue(String value) {
if (Material.matchMaterial(value.toUpperCase()) != null)
type.setFlag(value.toUpperCase());
else
ply.sendMessage("No block found by that name!", "error");
}
@Override
public String getValue() {
return type.getFlag();
}
});
m.addItem(btype);
final MenuItemBoolean busedur = (MenuItemBoolean) useDur.getMenuItem("Use Data Values", Material.ENDER_PEARL);
m.addItem(busedur);
final MenuItemInteger bdur = (MenuItemInteger) dur.getMenuItem("Data Value", Material.PAPER, 0, 16);
m.addItem(bdur);
c.setClickItem(new InteractionInterface() {
@Override
public Object interact(Object object) {
ItemStack i = (ItemStack) object;
type.setFlag(i.getType().toString());
useDur.setFlag(true);
dur.setFlag(((Short) i.getDurability()).intValue());
bdur.updateDescription();
busedur.updateDescription();
btype.updateDescription();
return c.getItem();
}
});
addInvertMenuItem(m);
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class MenuItemConditionAdd method onClick.
@Override
public ItemStack onClick() {
Menu m = new Menu(6, "Conditions", getContainer().getViewer());
m.setPreviousPage(getContainer());
Map<String, Menu> cats = new HashMap<String, Menu>();
List<String> cons = new ArrayList<String>(Conditions.getAllConditionNames());
Collections.sort(cons);
for (String con : cons) {
if ((Conditions.getConditionByName(con).useInNodes() && nexec != null) || (Conditions.getConditionByName(con).useInRegions() && rexec != null)) {
String catname = Conditions.getConditionByName(con).getCategory();
if (catname == null)
catname = "misc conditions";
catname.toLowerCase();
Menu cat = null;
if (!cats.containsKey(catname)) {
cat = new Menu(6, MinigameUtils.capitalize(catname), getContainer().getViewer());
cats.put(catname, cat);
m.addItem(new MenuItemPage(MinigameUtils.capitalize(catname), Material.CHEST, cat));
cat.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), cat.getSize() - 9);
} else
cat = cats.get(catname);
MenuItemCustom c = new MenuItemCustom(MinigameUtils.capitalize(con), Material.PAPER);
final String fcon = con;
c.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
ConditionInterface condition = Conditions.getConditionByName(fcon);
if (rexec != null) {
rexec.addCondition(condition);
getContainer().addItem(new MenuItemCondition(MinigameUtils.capitalize(fcon), Material.PAPER, rexec, condition));
} else {
nexec.addCondition(condition);
getContainer().addItem(new MenuItemCondition(MinigameUtils.capitalize(fcon), Material.PAPER, nexec, condition));
}
getContainer().displayMenu(getContainer().getViewer());
return null;
}
});
cat.addItem(c);
}
}
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, getContainer()), m.getSize() - 9);
m.displayMenu(getContainer().getViewer());
return null;
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class MenuItemNodeExecutor method onClick.
@Override
public ItemStack onClick() {
final MinigamePlayer fviewer = getContainer().getViewer();
Menu m = new Menu(3, "Executor", fviewer);
final Menu ffm = m;
MenuItemCustom ca = new MenuItemCustom("Actions", Material.CHEST);
ca.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
Actions.displayMenu(fviewer, ex, ffm);
return null;
}
});
m.addItem(ca);
MenuItemCustom c2 = new MenuItemCustom("Conditions", Material.CHEST);
c2.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
Conditions.displayMenu(fviewer, ex, ffm);
return null;
}
});
m.addItem(c2);
m.addItem(new MenuItemNewLine());
m.addItem(new MenuItemInteger("Trigger Count", MinigameUtils.stringToList("Number of times this;node can be;triggered"), Material.STONE, ex.getTriggerCountCallback(), 0, null));
m.addItem(new MenuItemBoolean("Trigger Per Player", MinigameUtils.stringToList("Whether this node;is triggered per player;or just on count"), Material.ENDER_PEARL, ex.getIsTriggerPerPlayerCallback()));
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, getContainer()), m.getSize() - 9);
m.displayMenu(fviewer);
return null;
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class MinigameStats method createStatSelectMenu.
/**
* Creates a menu that allows you to select a statistic
* @param parent The parent menu
* @param statCallback The callback to be invoked when the statistic is chosen. Note: only the setValue() method will be called.
* @return The menu to display
*/
public static Menu createStatSelectMenu(final Menu parent, final Callback<MinigameStat> statCallback) {
final Menu submenu = new Menu(6, "Select Statistic", parent.getViewer());
for (final MinigameStat stat : getAllStats().values()) {
MenuItemCustom item = new MenuItemCustom(WordUtils.capitalizeFully(stat.getDisplayName()), Material.BOOK_AND_QUILL);
item.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
statCallback.setValue(stat);
parent.displayMenu(submenu.getViewer());
return null;
}
});
submenu.addItem(item);
}
submenu.addItem(new MenuItemBack(parent), submenu.getSize() - 9);
return submenu;
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class RegionModule method addEditMenuOptions.
@Override
public void addEditMenuOptions(Menu menu) {
final MenuItemCustom c = new MenuItemCustom("Regions and Nodes", Material.DIAMOND_BLOCK);
final Menu fmenu = menu;
c.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
displayMenu(c.getContainer().getViewer(), fmenu);
return null;
}
});
menu.addItem(c);
}
Aggregations