use of org.spongepowered.api.item.merchant.TradeOfferListMutator in project SpongeCommon by SpongePowered.
the class SpongeVillagerRegistry method addMutators.
@Override
public VillagerRegistry addMutators(Career career, int level, TradeOfferListMutator generator, TradeOfferListMutator... generators) {
checkArgument(level > 0, "Career level must be at least greater than zero!");
checkNotNull(career, "Career cannot be null!");
checkNotNull(generator, "Generator cannot be null!");
checkNotNull(generators, "Generators cannot be null!");
Multimap<Integer, TradeOfferListMutator> multimap = this.careerGeneratorMap.get(career);
List<TradeOfferListMutator> list = new ArrayList<>();
list.add(generator);
for (TradeOfferListMutator element : generators) {
list.add(checkNotNull(element, "TradeOfferListMutator cannot be null!"));
}
if (multimap == null) {
multimap = ArrayListMultimap.create(3, list.size());
this.careerGeneratorMap.put(career, multimap);
}
multimap.putAll(level, list);
return this;
}
use of org.spongepowered.api.item.merchant.TradeOfferListMutator in project SpongeCommon by SpongePowered.
the class SpongeVillagerRegistry method registerVanillaTrades.
static void registerVanillaTrades() {
VillagerRegistry instance = getInstance();
for (Career career : CareerRegistryModule.getInstance().getAll()) {
SpongeCareer spongeCareer = (SpongeCareer) career;
EntityVillager.ITradeList[][] careerLevels = EntityVillager.DEFAULT_TRADE_LIST_MAP[((SpongeProfession) spongeCareer.getProfession()).type][spongeCareer.type];
for (int level = 0; level < careerLevels.length; level++) {
EntityVillager.ITradeList[] offers = careerLevels[level];
ImmutableList.Builder<TradeOfferListMutator> builder = ImmutableList.builder();
for (int i = 0; i < offers.length; i++) {
builder.add(generatorFor(offers[i]));
}
instance.setMutators(career, level + 1, builder.build());
}
}
}
Aggregations