use of xyz.derkades.ublisk.utils.inventory.UInventory 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.inventory.UInventory in project Ublisk by Derkades.
the class Zoltar method talk.
@Override
public void talk(UPlayer player) {
QuestParticipant qp = player.getQuestParticipant(Quest.HAY_TRANSPORT, this);
UInventory inv = qp.getInventory();
if (qp.getProgress(QuestProgress.HAY_TRANSPORT_STARTED) && inv.contains(Material.HAY_BLOCK, 10)) {
inv.remove(Material.HAY_BLOCK, 10);
qp.sendMessage("There you are! That took you a while, didn't it? Anyway, thanks for helping.");
// Send a message
qp.sendCompletedMessage();
// Give reward experience
qp.giveRewardExp();
// Set the quest as completed for this player
qp.setQuestCompleted(true);
qp.sendMessage("Hold on! If you ever need to sell something, come to me I am always here to buy your goodies.");
} else {
qp.sendMessage("Hello, I'm the junk merchant.");
}
}
use of xyz.derkades.ublisk.utils.inventory.UInventory in project Ublisk by Derkades.
the class CustomItemCommand method onCommand.
@Override
protected void onCommand(UPlayer player, String[] args) {
UInventory inv = player.getInventory();
inv.addItem(new CustomItem("test"));
inv.addItem(new CustomItem("happy"));
inv.addItem(new CustomItem("sad"));
}
use of xyz.derkades.ublisk.utils.inventory.UInventory in project Ublisk by Derkades.
the class PlayerInteract method onInteract.
@EventHandler(ignoreCancelled = false)
public void onInteract(PlayerInteractEvent event) {
UPlayer player = new UPlayer(event);
Action action = event.getAction();
if (action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) {
UInventory inv = player.getInventory();
Material item = inv.getItemInMainHand().getType();
if (item == Material.CHEST && !player.isInBuilderMode()) {
new MainMenu(player).open();
event.setCancelled(true);
} else if (item == Material.END_CRYSTAL) {
player.openEnderchest();
event.setCancelled(true);
}
}
}
use of xyz.derkades.ublisk.utils.inventory.UInventory in project Ublisk by Derkades.
the class Merek method talk.
@Override
public void talk(UPlayer player) {
QuestParticipant qp = player.getQuestParticipant(Quest.INTRODUCTION, this);
UInventory inv = qp.getInventory();
if (inv.containsItems(new Item(Material.LOG, 10), new Item(Material.STRING, 16), new MoneyItem(MoneyItem.Type.DUST).setAmount(10))) {
qp.sendMessage("Great! Now go to Ulric to craft a weapon.");
} else if (inv.containsItems(new Item(Material.STRING, 16), new MoneyItem(MoneyItem.Type.DUST).setAmount(10))) {
qp.sendMessage("Finally get 10 wood logs at the saw");
} else if (inv.containsItems(new Item(Material.WOOL, 4), new MoneyItem(MoneyItem.Type.DUST).setAmount(10))) {
qp.sendMessage("Great job, now please break down your wool into 16 string by using the windmill.");
} else if (inv.contains(Material.GOLD_NUGGET, 10)) {
qp.sendMessage("Now bring me 4 wool by killing sheep.");
} else {
qp.sendMessage("What are you doing out here? You don't even have a weapon yet! I'll tell you what you'll need to make a weapon. First, get 10 gold dust by killing animals.");
}
}
Aggregations