use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class RewardSign method signUse.
@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
Location loc = sign.getLocation();
if (!MinigameUtils.isMinigameTool(player.getPlayer().getInventory().getItemInMainHand())) {
String label = sign.getLine(2).toLowerCase();
if (player.isInMinigame()) {
if (!player.hasTempClaimedReward(label)) {
if (mdata.hasRewardSign(loc)) {
Rewards rew = mdata.getRewardSign(loc);
for (RewardType r : rew.getReward()) {
r.giveReward(player);
}
}
player.addTempClaimedReward(label);
}
} else {
if (!player.hasClaimedReward(label)) {
if (mdata.hasRewardSign(loc)) {
Rewards rew = mdata.getRewardSign(loc);
for (RewardType r : rew.getReward()) {
r.giveReward(player);
}
player.updateInventory();
}
player.addClaimedReward(label);
}
}
} else if (player.getPlayer().hasPermission("minigame.tool")) {
Rewards rew = null;
if (!mdata.hasRewardSign(loc)) {
mdata.addRewardSign(loc);
}
rew = mdata.getRewardSign(loc);
Menu rewardMenu = new Menu(5, getName(), player);
rewardMenu.addItem(new MenuItemRewardGroupAdd("Add Group", Material.ITEM_FRAME, rew), 42);
rewardMenu.addItem(new MenuItemRewardAdd("Add Item", Material.ITEM_FRAME, rew), 43);
final MenuItemCustom mic = new MenuItemCustom("Save Rewards", Material.REDSTONE_TORCH_ON);
final Location floc = loc;
mic.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
mdata.saveRewardSign(MinigameUtils.createLocationID(floc), true);
mic.getContainer().getViewer().sendMessage("Saved rewards for this sign.", null);
mic.getContainer().getViewer().getPlayer().closeInventory();
return null;
}
});
rewardMenu.addItem(mic, 44);
List<String> list = new ArrayList<String>();
for (RewardRarity r : RewardRarity.values()) {
list.add(r.toString());
}
List<MenuItem> mi = new ArrayList<MenuItem>();
for (RewardType item : rew.getRewards()) {
mi.add(item.getMenuItem());
}
List<String> des = new ArrayList<String>();
des.add("Double Click to edit");
for (RewardGroup group : rew.getGroups()) {
MenuItemRewardGroup rwg = new MenuItemRewardGroup(group.getName() + " Group", des, Material.CHEST, group, rew);
mi.add(rwg);
}
rewardMenu.addItems(mi);
rewardMenu.displayMenu(player);
}
return true;
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class HierarchyRewardScheme method addMenuItems.
@Override
public void addMenuItems(final Menu menu) {
menu.addItem(new MenuItemList("Comparison Type", Material.REDSTONE_COMPARATOR, getConfigurationTypeCallback(), Lists.transform(Arrays.asList(Comparison.values()), Functions.toStringFunction())));
menu.addItem(enableRewardsOnLoss.getMenuItem("Award On Loss", Material.LEVER, MinigameUtils.stringToList("When on, awards will still;be given to losing;players")));
menu.addItem(lossUsesSecondary.getMenuItem("Losers Get Secondary", Material.LEVER, MinigameUtils.stringToList("When on, the losers;will only get the;secondary reward")));
menu.addItem(new MenuItemNewLine());
MenuItemCustom primary = new MenuItemCustom("Primary Rewards", Material.CHEST);
primary.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
showRewardsMenu(primaryRewards, menu.getViewer(), menu);
return null;
}
});
MenuItemCustom secondary = new MenuItemCustom("Secondary Rewards", Material.CHEST);
secondary.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
showRewardsMenu(secondaryRewards, menu.getViewer(), menu);
return null;
}
});
menu.addItem(primary);
menu.addItem(secondary);
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class MinigameStats method createStatFieldSelectMenu.
/**
* Creates a menu that allows you to select a statistic field
* @param parent The parent menu
* @param format The format to define the fields available
* @param callback The callback to be invoked when the field is chosen. Note: only the setValue() method will be called.
* @return The menu to display
*/
public static Menu createStatFieldSelectMenu(final Menu parent, StatFormat format, final Callback<StatValueField> callback) {
final Menu submenu = new Menu(6, "Select Statistic Field", parent.getViewer());
for (final StatValueField field : format.getFields()) {
MenuItemCustom item = new MenuItemCustom(WordUtils.capitalizeFully(field.name()), Material.PAPER);
item.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
callback.setValue(field);
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 MinigameTool method openMenu.
public void openMenu(MinigamePlayer player) {
Menu men = new Menu(2, "Set Tool Mode", player);
final MenuItemCustom miselect = new MenuItemCustom("Select", MinigameUtils.stringToList("Selects and area;or points visually"), Material.DIAMOND_BLOCK);
final MenuItemCustom mideselect = new MenuItemCustom("Deselect", MinigameUtils.stringToList("Deselects an;area or points"), Material.GLASS);
final MinigamePlayer fply = player;
miselect.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
if (mode != null) {
mode.select(fply, minigame, TeamsModule.getMinigameModule(minigame).getTeam(team));
}
return miselect.getItem();
}
});
mideselect.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
if (mode != null) {
mode.deselect(fply, minigame, TeamsModule.getMinigameModule(minigame).getTeam(team));
}
return mideselect.getItem();
}
});
men.addItem(mideselect, men.getSize() - 1);
men.addItem(miselect, men.getSize() - 2);
List<String> teams = new ArrayList<String>(TeamColor.values().length + 1);
for (TeamColor col : TeamColor.values()) teams.add(MinigameUtils.capitalize(col.toString().replace("_", " ")));
teams.add("None");
men.addItem(new MenuItemToolTeam("Team", Material.PAPER, new Callback<String>() {
@Override
public void setValue(String value) {
setTeam(TeamColor.matchColor(value.replace(" ", "_")));
}
@Override
public String getValue() {
if (getTeam() != null)
return MinigameUtils.capitalize(getTeam().toString().replace("_", " "));
return "None";
}
}, teams), men.getSize() - 3);
for (ToolMode m : ToolModes.getToolModes()) {
men.addItem(new MenuItemToolMode(m.getDisplayName(), MinigameUtils.stringToList(m.getDescription()), m.getIcon(), m));
}
men.displayMenu(player);
}
use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.
the class NodeToolMode method onSetMode.
@Override
public void onSetMode(final MinigamePlayer player, MinigameTool tool) {
tool.addSetting("Node", "None");
final Menu m = new Menu(2, "Node 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("Node Name", Material.PAPER, new Callback<String>() {
@Override
public void setValue(String value) {
ftool.changeSetting("Node", value);
}
@Override
public String getValue() {
return ftool.getSetting("Node");
}
}));
if (tool.getMinigame() != null) {
// Node selection menu
RegionModule module = RegionModule.getMinigameModule(tool.getMinigame());
Menu nodeMenu = new Menu(6, "Nodes", player);
List<MenuItem> items = new ArrayList<MenuItem>();
for (final Node node : module.getNodes()) {
MenuItemCustom item = new MenuItemCustom(node.getName(), Material.STONE_BUTTON);
// Set the node and go back to the main menu
item.setClick(new InteractionInterface() {
@Override
public Object interact(Object object) {
ftool.changeSetting("Node", node.getName());
m.displayMenu(player);
return object;
}
});
items.add(item);
}
nodeMenu.addItems(items);
nodeMenu.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), nodeMenu.getSize() - 9);
m.addItem(new MenuItemPage("Edit Node", Material.STONE_BUTTON, nodeMenu));
}
m.displayMenu(player);
}
Aggregations