use of au.com.mineauz.minigames.menu.MenuItemList in project Minigames by AddstarMC.
the class ScoreboardDisplay method displayMenu.
public void displayMenu(MinigamePlayer player) {
final Menu setupMenu = new Menu(3, "Setup Scoreboard", player);
StatSettings settings = minigame.getSettings(stat);
final MenuItemCustom statisticChoice = new MenuItemCustom("Statistic", Material.BOOK_AND_QUILL);
statisticChoice.setDescription(Arrays.asList(ChatColor.GREEN + settings.getDisplayName()));
final MenuItemCustom fieldChoice = new MenuItemCustom("Statistic Field", Material.PAPER);
fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + field.getTitle()));
statisticChoice.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
Menu childMenu = MinigameStats.createStatSelectMenu(setupMenu, new Callback<MinigameStat>() {
@Override
public MinigameStat getValue() {
throw new UnsupportedOperationException();
}
@Override
public void setValue(MinigameStat value) {
stat = value;
StatSettings settings = minigame.getSettings(stat);
statisticChoice.setDescription(Arrays.asList(ChatColor.GREEN + settings.getDisplayName()));
// Check that the field is valid
StatValueField first = null;
boolean valid = false;
for (StatValueField sfield : settings.getFormat().getFields()) {
if (first == null) {
first = sfield;
}
if (sfield == field) {
valid = true;
break;
}
}
// Update the field
if (!valid) {
field = first;
fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + value.toString()));
}
}
});
childMenu.displayMenu(setupMenu.getViewer());
return null;
}
});
fieldChoice.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
StatSettings settings = minigame.getSettings(stat);
Menu childMenu = MinigameStats.createStatFieldSelectMenu(setupMenu, settings.getFormat(), new Callback<StatValueField>() {
@Override
public StatValueField getValue() {
throw new UnsupportedOperationException();
}
@Override
public void setValue(StatValueField value) {
field = value;
fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + value.getTitle()));
}
});
childMenu.displayMenu(setupMenu.getViewer());
return null;
}
});
setupMenu.addItem(statisticChoice);
setupMenu.addItem(fieldChoice);
List<String> sbotypes = new ArrayList<String>();
for (ScoreboardOrder o : ScoreboardOrder.values()) {
sbotypes.add(o.toString().toLowerCase());
}
setupMenu.addItem(new MenuItemList("Scoreboard Order", Material.ENDER_PEARL, new Callback<String>() {
@Override
public void setValue(String value) {
order = ScoreboardOrder.valueOf(value.toUpperCase());
}
@Override
public String getValue() {
return order.toString().toLowerCase();
}
}, sbotypes));
setupMenu.addItem(new MenuItemScoreboardSave("Create Scoreboard", Material.REDSTONE_TORCH_ON, this), setupMenu.getSize() - 1);
setupMenu.displayMenu(player);
}
use of au.com.mineauz.minigames.menu.MenuItemList in project Minigames by AddstarMC.
the class TeamsModule method addEditMenuOptions.
@Override
public void addEditMenuOptions(Menu menu) {
Menu m = new Menu(6, "Teams", menu.getViewer());
m.setPreviousPage(menu);
List<MenuItem> items = new ArrayList<MenuItem>();
List<String> teams = new ArrayList<String>(this.teams.size() + 1);
for (TeamColor t : this.teams.keySet()) {
teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
}
teams.add("None");
items.add(new MenuItemList("Default Winning Team", Material.PAPER, getDefaultWinnerCallback(), teams));
items.add(new MenuItemNewLine());
for (Team t : this.teams.values()) {
items.add(new MenuItemTeam(t.getChatColor() + t.getDisplayName(), t));
}
m.addItem(new MenuItemAddTeam("Add Team", getMinigame()), m.getSize() - 1);
m.addItems(items);
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, menu), m.getSize() - 9);
MenuItemPage p = new MenuItemPage("Team Options", Material.CHEST, m);
menu.addItem(p);
}
use of au.com.mineauz.minigames.menu.MenuItemList in project Minigames by AddstarMC.
the class WeatherTimeModule method addEditMenuOptions.
@Override
public void addEditMenuOptions(Menu menu) {
Menu m = new Menu(6, "Time and Weather", menu.getViewer());
m.addItem(new MenuItemBoolean("Use Custom Time", Material.WATCH, new Callback<Boolean>() {
@Override
public void setValue(Boolean value) {
useCustomTime.setFlag(value);
}
@Override
public Boolean getValue() {
return useCustomTime.getFlag();
}
}));
m.addItem(new MenuItemInteger("Time of Day", Material.WATCH, new Callback<Integer>() {
@Override
public void setValue(Integer value) {
time.setFlag(value.longValue());
}
@Override
public Integer getValue() {
return time.getFlag().intValue();
}
}, 0, 24000));
m.addItem(new MenuItemBoolean("Use Custom Weather", Material.WATER_BUCKET, new Callback<Boolean>() {
@Override
public void setValue(Boolean value) {
useCustomWeather.setFlag(value);
}
@Override
public Boolean getValue() {
return useCustomWeather.getFlag();
}
}));
m.addItem(new MenuItemList("Weather Type", Material.WATER_BUCKET, new Callback<String>() {
@Override
public void setValue(String value) {
weather.setFlag(WeatherType.valueOf(value.toUpperCase()));
}
@Override
public String getValue() {
return MinigameUtils.capitalize(weather.getFlag().toString());
}
}, MinigameUtils.stringToList("Clear;Downfall")));
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, menu), m.getSize() - 9);
menu.addItem(new MenuItemPage("Time and Weather Settings", Material.CHEST, m));
}
use of au.com.mineauz.minigames.menu.MenuItemList in project Minigames by AddstarMC.
the class PlayerHasItemCondition method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
Menu m = new Menu(3, "Player Has Item", player);
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
final MinigamePlayer fply = player;
m.addItem(new MenuItemString("Item", Material.STONE, new Callback<String>() {
@Override
public void setValue(String value) {
if (Material.getMaterial(value.toUpperCase()) != null)
type.setFlag(value.toUpperCase());
else
fply.sendMessage("Invalid Item!", "error");
}
@Override
public String getValue() {
return type.getFlag();
}
}));
m.addItem(useData.getMenuItem("Match Item Data", Material.ENDER_PEARL));
m.addItem(data.getMenuItem("Data Value", Material.EYE_OF_ENDER, 0, null));
m.addItem(new MenuItemList("Search Where", Material.COMPASS, new Callback<String>() {
@Override
public void setValue(String value) {
where.setFlag(value.toUpperCase());
}
@Override
public String getValue() {
return WordUtils.capitalizeFully(where.getFlag());
}
}, Arrays.asList("Anywhere", "Hotbar", "Main", "Armor", "Slot")));
m.addItem(slot.getMenuItem("Slot", Material.DIAMOND, 0, 35));
m.addItem(new MenuItemNewLine());
m.addItem(matchName.getMenuItem("Match Display Name", Material.NAME_TAG));
MenuItemString menuItem = (MenuItemString) name.getMenuItem("Display Name", Material.NAME_TAG, MinigameUtils.stringToList("The name to match.;Use % to do a wildcard match"));
menuItem.setAllowNull(true);
m.addItem(menuItem);
m.addItem(matchLore.getMenuItem("Match Lore", Material.BOOK));
menuItem = (MenuItemString) lore.getMenuItem("Lore", Material.BOOK, MinigameUtils.stringToList("The lore to match. Separate;with semi-colons;for new lines.;Use % to do a wildcard match"));
menuItem.setAllowNull(true);
m.addItem(menuItem);
addInvertMenuItem(m);
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.menu.MenuItemList in project Minigames by AddstarMC.
the class MatchTeamCondition method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
Menu m = new Menu(3, "Match Team", player);
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
List<String> teams = new ArrayList<String>();
for (TeamColor t : TeamColor.values()) teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
m.addItem(new MenuItemList("Team Color", Material.WOOL, new Callback<String>() {
@Override
public void setValue(String value) {
team.setFlag(value.toUpperCase().replace(" ", "_"));
}
@Override
public String getValue() {
return MinigameUtils.capitalize(team.getFlag().replace("_", " "));
}
}, teams));
addInvertMenuItem(m);
m.displayMenu(player);
return true;
}
Aggregations