use of au.com.mineauz.minigames.menu.Callback in project Minigames by AddstarMC.
the class TeamScoreRangeCondition method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
Menu m = new Menu(3, "Team Score Range", player);
m.addItem(min.getMenuItem("Minimum Score", Material.STEP, 0, null));
m.addItem(max.getMenuItem("Maximum Score", Material.STONE, 0, null));
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));
m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
addInvertMenuItem(m);
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.menu.Callback 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.Callback 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.Callback in project Minigames by AddstarMC.
the class RewardsModule method createSubMenu.
private Menu createSubMenu(final Menu parent) {
final Menu submenu = new Menu(6, "Reward Settings", parent.getViewer());
scheme.addMenuItems(submenu);
submenu.addItem(RewardSchemes.newMenuItem("Reward Scheme", Material.PAPER, new Callback<Class<? extends RewardScheme>>() {
@Override
public void setValue(Class<? extends RewardScheme> value) {
scheme = RewardSchemes.createScheme(value);
// Update the menu
Menu menu = createSubMenu(parent);
menu.displayMenu(submenu.getViewer());
}
@Override
public Class<? extends RewardScheme> getValue() {
return scheme.getClass();
}
}), submenu.getSize() - 1);
submenu.addItem(new MenuItemBack(parent), submenu.getSize() - 9);
return submenu;
}
use of au.com.mineauz.minigames.menu.Callback 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;
}
Aggregations