Search in sources :

Example 1 with TradeBuilder

use of gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder in project Nexus by ProjectEdenGG.

the class Pugmas20Command method getIngotsLeft.

private int getIngotsLeft(Pugmas20User user, List<TradeBuilder> trades, OreType oreType) {
    Optional<Integer> amount = trades.stream().map(tradeBuilder -> tradeBuilder.getIngredients().iterator().next()).filter(ingredient -> ingredient.getType() == oreType.getIngot().getType()).map(ItemStack::getAmount).findFirst();
    int tokensLeft = Math.abs(Pugmas20.checkDailyTokens(user, "themines_" + oreType.name(), 0));
    int perToken = amount.orElse(0);
    return tokensLeft * perToken;
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) AdventChest(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest) Pugmas20QuestStageHelper(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.Quests.Pugmas20QuestStageHelper) TabCompleteIgnore(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore) LightTheTree(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.LightTheTree) Pugmas20.isSecondChance(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isSecondChance) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) QuestStage(gg.projecteden.nexus.features.events.models.QuestStage) AdventMenu(gg.projecteden.nexus.features.events.y2020.pugmas20.menu.AdventMenu) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Pugmas20.showWaypoint(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint) Timespan(gg.projecteden.utils.TimeUtils.Timespan) Material(org.bukkit.Material) QuestNPC.getUnplayedToysList(gg.projecteden.nexus.features.events.y2020.pugmas20.models.QuestNPC.getUnplayedToysList) Env(gg.projecteden.utils.Env) Bukkit(org.bukkit.Bukkit) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) OreType(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.TheMines.OreType) OrnamentVendor(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor) Set(java.util.Set) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) TradeBuilder(gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Pugmas20.isPastPugmas(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isPastPugmas) TheMines(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.TheMines) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService) PugmasTreeType(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor.PugmasTreeType) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) MerchantNPC(gg.projecteden.nexus.features.events.y2020.pugmas20.models.Merchants.MerchantNPC) ArrayList(java.util.ArrayList) Environments(gg.projecteden.annotations.Environments) Ornament(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor.Ornament) Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) Train(gg.projecteden.nexus.features.events.y2020.pugmas20.Train) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) Listener(org.bukkit.event.Listener) TeleportCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause) Pugmas20(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20) ToyTesting(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.ToyTesting) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) District(gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest.District) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) Pugmas20.isBeforePugmas(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas) Pugmas20Quest(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.Quests.Pugmas20Quest) AdventChests(gg.projecteden.nexus.features.events.y2020.pugmas20.AdventChests) NoArgsConstructor(lombok.NoArgsConstructor) Pugmas20.showWaypoint(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint)

Example 2 with TradeBuilder

use of gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder in project Nexus by ProjectEdenGG.

the class Collector method loadTrades.

private static List<TradeBuilder> loadTrades() {
    return new ArrayList<>() {

        {
            // Fishing Loot
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.TIGER_TROUT.getGold() * 2)).ingredient(FishingLoot.TIGER_TROUT.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.SEA_CUCUMBER.getGold() * 2)).ingredient(FishingLoot.SEA_CUCUMBER.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.GLACIERFISH.getGold() * 2)).ingredient(FishingLoot.GLACIERFISH.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.CRIMSONFISH.getGold() * 2)).ingredient(FishingLoot.CRIMSONFISH.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.BLOBFISH.getGold() * 2)).ingredient(FishingLoot.BLOBFISH.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.STONEFISH.getGold() * 2)).ingredient(FishingLoot.STONEFISH.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.MIDNIGHT_CARP.getGold() * 2)).ingredient(FishingLoot.MIDNIGHT_CARP.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.SUNFISH.getGold() * 2)).ingredient(FishingLoot.SUNFISH.getItem()));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(FishingLoot.NAUTILUS_SHELL.getGold() * 2)).ingredient(FishingLoot.NAUTILUS_SHELL.getItem()));
            // Food
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(3)).ingredient(new ItemStack(Material.CAKE)));
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(3)).ingredient(new ItemStack(Material.PUMPKIN_PIE)));
            // Items
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(4)).ingredient(new ItemStack(Material.BONE_BLOCK)));
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(6)).ingredient(new ItemStack(Material.LEATHER_HORSE_ARMOR)));
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(5)).ingredient(new ItemStack(Material.ANVIL)));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(4)).ingredient(new ItemStack(Material.CAMPFIRE)));
            add(new TradeBuilder().result(Merchants.goldNugget.clone().amount(4)).ingredient(new ItemStack(Material.CROSSBOW)));
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(5)).ingredient(new ItemStack(Material.LECTERN)));
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(4)).ingredient(new ItemStack(Material.BOOKSHELF)));
            add(new TradeBuilder().result(Merchants.goldIngot.clone().amount(1)).ingredient(new ItemStack(Material.BOOK)));
        }
    };
}
Also used : TradeBuilder(gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder) ArrayList(java.util.ArrayList) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with TradeBuilder

use of gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder in project Nexus by ProjectEdenGG.

the class Collector method newTrades.

private static void newTrades() {
    List<TradeBuilder> choices = new ArrayList<>(possibleTrades);
    if (randomTrades == null)
        randomTrades = new ArrayList<>();
    // Remove current trades from choices
    if (!randomTrades.isEmpty()) {
        for (TradeBuilder trade : randomTrades) choices.remove(trade);
        randomTrades.clear();
    }
    // Pick new trades
    for (int i = 0; i < 4; i++) {
        TradeBuilder random = RandomUtils.randomElement(choices);
        choices.remove(random);
        randomTrades.add(random);
    }
}
Also used : TradeBuilder(gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder) ArrayList(java.util.ArrayList)

Example 4 with TradeBuilder

use of gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder in project Nexus by ProjectEdenGG.

the class Pugmas20Command method getIngotTradesLeft.

private List<String> getIngotTradesLeft(Pugmas20User user) {
    List<String> tradesLeft = new ArrayList<>();
    List<TradeBuilder> trades = MerchantNPC.THEMINES_SELLCRATE.getTrades(user);
    for (OreType oreType : OreType.values()) {
        int ingotsLeft = getIngotsLeft(user, trades, oreType);
        if (ingotsLeft > 0)
            tradesLeft.add("&e" + ingotsLeft + " &f" + camelCase(oreType));
    }
    return tradesLeft;
}
Also used : OreType(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.TheMines.OreType) TradeBuilder(gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder) ArrayList(java.util.ArrayList) Pugmas20.showWaypoint(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint)

Example 5 with TradeBuilder

use of gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder in project Nexus by ProjectEdenGG.

the class Merchants method openMerchant.

public static void openMerchant(Player player, int id) {
    MerchantNPC merchantNPC = MerchantNPC.getFromId(id);
    if (merchantNPC == null)
        return;
    Pugmas20UserService service = new Pugmas20UserService();
    Pugmas20User user = service.get(player);
    List<TradeBuilder> trades = merchantNPC.getTrades(user);
    if (trades.isEmpty()) {
        user.sendMessage(Pugmas20.PREFIX + "No trades available");
        return;
    }
    new MerchantBuilder(camelCase(merchantNPC.name())).trades(trades).open(player);
}
Also used : Pugmas20User(gg.projecteden.nexus.models.pugmas20.Pugmas20User) TradeBuilder(gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder) Pugmas20UserService(gg.projecteden.nexus.models.pugmas20.Pugmas20UserService) MerchantBuilder(gg.projecteden.nexus.utils.MerchantBuilder)

Aggregations

TradeBuilder (gg.projecteden.nexus.utils.MerchantBuilder.TradeBuilder)5 ArrayList (java.util.ArrayList)4 Pugmas20.showWaypoint (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint)2 OreType (gg.projecteden.nexus.features.events.y2020.pugmas20.quests.TheMines.OreType)2 Pugmas20User (gg.projecteden.nexus.models.pugmas20.Pugmas20User)2 Pugmas20UserService (gg.projecteden.nexus.models.pugmas20.Pugmas20UserService)2 ItemStack (org.bukkit.inventory.ItemStack)2 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 Environments (gg.projecteden.annotations.Environments)1 QuestStage (gg.projecteden.nexus.features.events.models.QuestStage)1 AdventChests (gg.projecteden.nexus.features.events.y2020.pugmas20.AdventChests)1 Pugmas20 (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20)1 Pugmas20.isBeforePugmas (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isBeforePugmas)1 Pugmas20.isPastPugmas (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isPastPugmas)1 Pugmas20.isSecondChance (gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.isSecondChance)1 Train (gg.projecteden.nexus.features.events.y2020.pugmas20.Train)1 AdventMenu (gg.projecteden.nexus.features.events.y2020.pugmas20.menu.AdventMenu)1 AdventChest (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest)1 District (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest.District)1 MerchantNPC (gg.projecteden.nexus.features.events.y2020.pugmas20.models.Merchants.MerchantNPC)1