Search in sources :

Example 1 with UInventory

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;
}
Also used : Item(xyz.derkades.ublisk.utils.inventory.Item) UPlayer(xyz.derkades.ublisk.utils.UPlayer) UInventory(xyz.derkades.ublisk.utils.inventory.UInventory)

Example 2 with UInventory

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.");
    }
}
Also used : QuestParticipant(xyz.derkades.ublisk.quest.QuestParticipant) UInventory(xyz.derkades.ublisk.utils.inventory.UInventory)

Example 3 with UInventory

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"));
}
Also used : CustomItem(xyz.derkades.ublisk.utils.inventory.CustomItem) UInventory(xyz.derkades.ublisk.utils.inventory.UInventory)

Example 4 with UInventory

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);
        }
    }
}
Also used : Action(org.bukkit.event.block.Action) UPlayer(xyz.derkades.ublisk.utils.UPlayer) UInventory(xyz.derkades.ublisk.utils.inventory.UInventory) Material(org.bukkit.Material) MainMenu(xyz.derkades.ublisk.iconmenus.MainMenu) EventHandler(org.bukkit.event.EventHandler)

Example 5 with UInventory

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.");
    }
}
Also used : QuestParticipant(xyz.derkades.ublisk.quest.QuestParticipant) MoneyItem(xyz.derkades.ublisk.money.MoneyItem) Item(xyz.derkades.ublisk.utils.inventory.Item) UInventory(xyz.derkades.ublisk.utils.inventory.UInventory) MoneyItem(xyz.derkades.ublisk.money.MoneyItem)

Aggregations

UInventory (xyz.derkades.ublisk.utils.inventory.UInventory)8 QuestParticipant (xyz.derkades.ublisk.quest.QuestParticipant)5 UPlayer (xyz.derkades.ublisk.utils.UPlayer)2 Item (xyz.derkades.ublisk.utils.inventory.Item)2 Material (org.bukkit.Material)1 EventHandler (org.bukkit.event.EventHandler)1 Action (org.bukkit.event.block.Action)1 MainMenu (xyz.derkades.ublisk.iconmenus.MainMenu)1 MoneyItem (xyz.derkades.ublisk.money.MoneyItem)1 CustomItem (xyz.derkades.ublisk.utils.inventory.CustomItem)1