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;
}
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)));
}
};
}
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);
}
}
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;
}
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);
}
Aggregations