use of au.com.mineauz.minigames.minigame.reward.RewardGroup in project Minigames by AddstarMC.
the class MenuItemRewardGroupAdd method checkValidEntry.
@Override
public void checkValidEntry(String entry) {
entry = entry.replace(" ", "_");
for (RewardGroup group : rewards.getGroups()) {
if (group.getName().equals(entry)) {
getContainer().getViewer().sendMessage("A reward group already exists by the name \"" + entry + "\"!", "error");
getContainer().cancelReopenTimer();
getContainer().displayMenu(getContainer().getViewer());
return;
}
}
RewardGroup group = rewards.addGroup(entry, RewardRarity.NORMAL);
MenuItemRewardGroup mrg = new MenuItemRewardGroup(entry + " Group", Material.CHEST, group, rewards);
getContainer().addItem(mrg);
getContainer().cancelReopenTimer();
getContainer().displayMenu(getContainer().getViewer());
}
use of au.com.mineauz.minigames.minigame.reward.RewardGroup 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;
}
Aggregations