use of au.com.mineauz.minigames.menu.Callback in project Minigames by AddstarMC.
the class GiveItemAction method displayMenu.
@Override
public boolean displayMenu(final MinigamePlayer player, Menu previous) {
Menu m = new Menu(3, "Give Item", player);
m.addItem(new MenuItemBack(previous), m.getSize() - 9);
MenuItemString n = (MenuItemString) name.getMenuItem("Name", Material.NAME_TAG);
n.setAllowNull(true);
m.addItem(n);
MenuItemString l = (MenuItemString) lore.getMenuItem("Lore", Material.PAPER, MinigameUtils.stringToList("Separate with semi-colons;for new lines"));
l.setAllowNull(true);
m.addItem(l);
m.addItem(new MenuItemString("Type", Material.STONE, new Callback<String>() {
@Override
public void setValue(String value) {
if (Material.getMaterial(value.toUpperCase()) != null) {
type.setFlag(value.toUpperCase());
} else
player.sendMessage("Invalid item type!", "error");
}
@Override
public String getValue() {
return type.getFlag();
}
}));
m.addItem(count.getMenuItem("Count", Material.STEP, 1, 64));
m.addItem(damage.getMenuItem("Damage", Material.COBBLESTONE, 0, null));
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.menu.Callback in project Minigames by AddstarMC.
the class SetTeamScoreAction method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
Menu m = new Menu(3, "Set Team Score", player);
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previous), m.getSize() - 9);
m.addItem(score.getMenuItem("Set Score Amount", Material.STONE, null, null));
List<String> teams = new ArrayList<>();
teams.add("None");
for (TeamColor team : TeamColor.values()) {
teams.add(MinigameUtils.capitalize(team.toString()));
}
m.addItem(new MenuItemList("Specific Team", MinigameUtils.stringToList("If 'None', the players;team will be used"), Material.PAPER, new Callback<String>() {
@Override
public void setValue(String value) {
team.setFlag(value.toUpperCase());
}
@Override
public String getValue() {
return MinigameUtils.capitalize(team.getFlag());
}
}, teams));
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.menu.Callback in project Minigames by AddstarMC.
the class RegionToolMode method onSetMode.
@Override
public void onSetMode(final MinigamePlayer player, MinigameTool tool) {
tool.addSetting("Region", "None");
final Menu m = new Menu(2, "Region Selection", player);
if (player.isInMenu()) {
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, player.getMenu()), m.getSize() - 9);
}
final MinigameTool ftool = tool;
m.addItem(new MenuItemString("Region Name", Material.PAPER, new Callback<String>() {
@Override
public void setValue(String value) {
ftool.changeSetting("Region", value);
}
@Override
public String getValue() {
return ftool.getSetting("Region");
}
}));
if (tool.getMinigame() != null) {
// Node selection menu
RegionModule module = RegionModule.getMinigameModule(tool.getMinigame());
Menu regionMenu = new Menu(6, "Regions", player);
List<MenuItem> items = new ArrayList<MenuItem>();
for (final Region region : module.getRegions()) {
MenuItemCustom item = new MenuItemCustom(region.getName(), Material.CHEST);
// Set the node and go back to the main menu
item.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
ftool.changeSetting("Region", region.getName());
m.displayMenu(player);
return object;
}
});
items.add(item);
}
regionMenu.addItems(items);
regionMenu.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), regionMenu.getSize() - 9);
m.addItem(new MenuItemPage("Edit Region", Material.CHEST, regionMenu));
}
m.displayMenu(player);
}
Aggregations