use of au.com.mineauz.minigames.objects.MinigamePlayer 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", MenuUtility.getCreateMaterial(), rew), 42);
rewardMenu.addItem(new MenuItemRewardAdd("Add Item", MenuUtility.getCreateMaterial(), rew), 43);
final MenuItemCustom mic = new MenuItemCustom("Save Rewards", MenuUtility.getSaveMaterial());
final Location floc = loc;
mic.setClick(object -> {
mdata.saveRewardSign(MinigameUtils.createLocationID(floc), true);
mic.getContainer().getViewer().sendInfoMessage("Saved rewards for this sign.");
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<>();
for (RewardType item : rew.getRewards()) {
mi.add(item.getMenuItem());
}
List<String> des = new ArrayList<>();
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.objects.MinigamePlayer in project Minigames by AddstarMC.
the class SetRegionCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args != null) {
MinigamePlayer ply = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
RegionModule rmod = RegionModule.getMinigameModule(minigame);
if (args.length == 2) {
if (args[0].equalsIgnoreCase("select")) {
Location ploc = ply.getLocation();
ploc.setY(ploc.getY() - 1);
if (args[1].equals("1")) {
Location p2 = ply.getSelectionPoints()[1];
ply.clearSelection();
ply.setSelection(ploc, p2);
ply.sendInfoMessage(ChatColor.GRAY + "Point 1 selected");
} else {
Location p2 = ply.getSelectionPoints()[0];
ply.clearSelection();
ply.setSelection(p2, ploc);
ply.sendInfoMessage(ChatColor.GRAY + "Point 2 selected");
}
return true;
} else if (args[0].equalsIgnoreCase("create")) {
if (ply.hasSelection()) {
String name = args[1];
rmod.addRegion(name, new Region(name, ply.getSelectionPoints()[0], ply.getSelectionPoints()[1]));
ply.clearSelection();
ply.sendInfoMessage(ChatColor.GRAY + "Created new region for " + minigame.getName(false) + " named " + name);
} else {
ply.sendInfoMessage(ChatColor.RED + "You have not made a selection!");
}
return true;
} else if (args[0].equalsIgnoreCase("delete")) {
if (rmod.hasRegion(args[1])) {
rmod.removeRegion(args[1]);
ply.sendInfoMessage(ChatColor.GRAY + "Removed the region named " + args[1] + " from " + minigame.getName(false));
} else {
ply.sendInfoMessage(ChatColor.GRAY + "No region by the name " + args[1] + " was found in " + minigame.getName(false));
}
return true;
}
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("modify")) {
rmod.displayMenu(ply, null);
return true;
}
}
}
return false;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class SetBlockAction method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
Menu m = new Menu(3, "Set Block", player);
final MinigamePlayer fply = player;
m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), previous), m.getSize() - 9);
m.addItem(new MenuItemBlockData("Type", Material.STONE, new Callback<BlockData>() {
@Override
public void setValue(BlockData value) {
type.setFlag(value);
}
@Override
public BlockData getValue() {
return type.getFlag();
}
}));
m.addItem(useBlockData.getMenuItem("Use Specific BlockData", Material.ENDER_PEARL));
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class SwapBlockAction method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
Menu m = new Menu(3, "Swap Block", player);
m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), previous), m.getSize() - 9);
final MinigamePlayer fply = player;
m.addItem(new MenuItemBlockData("Match Block", Material.COBBLESTONE, new Callback<BlockData>() {
@Override
public void setValue(BlockData value) {
matchType.setFlag(value);
}
@Override
public BlockData getValue() {
return matchType.getFlag();
}
}));
m.addItem(matchData.getMenuItem("Match Block Use Data?", Material.ENDER_PEARL));
m.addItem(new MenuItemNewLine());
m.addItem(new MenuItemBlockData("To Block", Material.STONE, new Callback<BlockData>() {
@Override
public void setValue(BlockData value) {
toType.setFlag(value);
}
@Override
public BlockData getValue() {
return toType.getFlag();
}
}));
m.addItem(toData.getMenuItem("To Block Use Data?", Material.ENDER_PEARL));
m.addItem(keepAttachment.getMenuItem("Keep Attachment", Material.PISTON, MinigameUtils.stringToList("When on, and To Block Use Data is off;If the source and target block;types are both blocks that;attach to surfaces, this;attachment will be preserved")));
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class SetNodeCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
if (args != null) {
MinigamePlayer ply = Minigames.getPlugin().getPlayerManager().getMinigamePlayer((Player) sender);
RegionModule rmod = RegionModule.getMinigameModule(minigame);
if (args[0].equalsIgnoreCase("create") && args.length >= 2) {
if (!rmod.hasNode(args[1])) {
rmod.addNode(args[1], new Node(args[1], ply.getLocation()));
sender.sendMessage(ChatColor.GRAY + Main.getPlugin().getMessage("command.node.addedNode", args[1], minigame.getName(true)));
} else
sender.sendMessage(ChatColor.RED + Main.getPlugin().getMessage("command.node.nodeExists", args[1], minigame.getName(true)));
return true;
} else if (args[0].equalsIgnoreCase("modify")) {
rmod.displayMenu(ply, null);
return true;
} else if (args[0].equalsIgnoreCase("delete") && args.length >= 2) {
if (rmod.hasNode(args[1])) {
rmod.removeNode(args[1]);
sender.sendMessage(ChatColor.GRAY + "Removed a node called " + args[1] + " from " + minigame);
} else
sender.sendMessage(ChatColor.RED + "A node by the name " + args[1] + " doesn't exists in " + minigame);
return true;
}
}
return false;
}
Aggregations