use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class BankMenu method onOptionClick.
@Override
public boolean onOptionClick(OptionClickEvent event) {
UPlayer player = new UPlayer(event);
MoneyItem item = MoneyItem.fromItem(new Item(event.getItemStack()));
if (item == null) {
player.sendMessage(Message.ERROR_MENU);
return true;
}
UInventory inv = player.getInventory();
if (event.getName().contains("Deposit")) {
if (!inv.contains(item)) {
player.sendMessage(Message.INVENTORY_NOT_CONTAIN_MONEY_ITEM);
return false;
}
player.setMoney(player.getMoney() + item.getValue());
inv.remove(item);
} else {
if (player.getMoney() < item.getValue()) {
player.sendMessage(Message.NOT_ENOUGH_MONEY);
return false;
}
player.setMoney(player.getMoney() - item.getValue());
inv.addItem(item);
}
return false;
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class FriendsMenu method onOptionClick.
@Override
public boolean onOptionClick(OptionClickEvent event) {
UPlayer player = new UPlayer(event);
Material item = event.getItemStack().getType();
if (item == Material.SPECKLED_MELON) {
if (player.getSetting(Setting.FRIENDS_SHOW_HEALTH)) {
player.setSetting(Setting.FRIENDS_SHOW_HEALTH, false);
player.sendMessage(Message.FRIEND_HEALTH_DISABLED);
} else {
player.setSetting(Setting.FRIENDS_SHOW_HEALTH, true);
player.sendMessage(Message.FRIEND_HEALTH_ENABLED);
}
return false;
} else if (player.getFriends().isEmpty()) {
return false;
} else {
// Clicked item is a player
// OfflinePlayer friend = Ublisk.getOfflinePlayer(event.getName());
OfflinePlayer offlineFriend = player.getFriends().get(event.getPosition());
if (offlineFriend == null)
player.sendMessage("error");
UPlayer friend = new UPlayer(offlineFriend);
player.sendMessage(friend.getDisplayName(ChatColor.DARK_AQUA, true), new ComponentBuilder(" - ").color(ChatColor.DARK_GRAY).bold(true).create(), new ComponentBuilder("Remove friend").color(ChatColor.RED).italic(true).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend remove " + friend.getName())).create());
return true;
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class MainMenu method onOptionClick.
@Override
public boolean onOptionClick(OptionClickEvent event) {
String name = event.getName().toLowerCase();
final UPlayer player = new UPlayer(event.getPlayer());
if (name.equals("settings")) {
new SettingsMenu(player).open();
} else if (name.equals("voting")) {
new VotingMenu(player).open();
} else if (name.equals("friends")) {
new FriendsMenu(player).open();
} else if (name.equals("help")) {
new HelpMenu(player).open();
} else if (name.equals("bank")) {
new BankMenu(player).open();
} else {
player.sendMessage(Message.ERROR_MENU);
}
return false;
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class SettingsMenu method onOptionClick.
@Override
public boolean onOptionClick(OptionClickEvent event) {
String name = event.getName();
final UPlayer player = new UPlayer(event.getPlayer());
if (name.equalsIgnoreCase("back")) {
new MainMenu(player).open();
return false;
}
Setting setting = Setting.fromName(name);
// If setting is set to true, set to false and if set to false, set to true
player.setSetting(setting, !player.getSetting(setting));
String enabledDisabled;
if (player.getSetting(setting))
enabledDisabled = "enabled";
else
enabledDisabled = "disabled";
player.sendMessage(Ublisk.getPrefix("Settings") + name + " has been " + enabledDisabled + ".");
// Re-open menu to refresh settings
this.open();
return false;
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class VotingMenu method onOptionClick.
@Override
public boolean onOptionClick(OptionClickEvent event) {
String name = event.getName().toLowerCase();
UPlayer player = new UPlayer(event.getPlayer());
if (name.contains("points")) {
return false;
} else {
if (Voting.playerOpeningBox != null) {
player.sendMessage(Message.VOTE_BOX_BUSY);
return false;
} else if (!player.hasVotingPoints(3)) {
player.sendMessage(Message.VOTE_BOX_INSUFFICIENT_POINTS);
return false;
} else {
player.setVotingPoints(player.getVotingPoints() - 3);
// TODO Use UPlayer
Voting.openVotingBox(player.bukkit());
return true;
}
}
}
Aggregations