Initial commit

This commit is contained in:
2021-09-25 01:56:42 +02:00
commit 5dd6cb44e5
27 changed files with 1366 additions and 0 deletions
@@ -0,0 +1,25 @@
package com.alttd.objects;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class LoadedVillagers {
private final static Map<UUID, VillagerType> loadedVillagers = new HashMap<>();
public static VillagerType getLoadedVillager(UUID uuid) {
return loadedVillagers.get(uuid);
}
public static void addLoadedVillager(UUID uuid, VillagerType villagerType) {
loadedVillagers.put(uuid, villagerType);
}
public static void removeLoadedVillager(UUID uuid) {
loadedVillagers.remove(uuid);
}
public static void clearLoadedVillagers() {
loadedVillagers.clear();
}
}
@@ -0,0 +1,59 @@
package com.alttd.objects;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class VillagerType {
private static final Set<VillagerType> villagerTypes = new HashSet<>();
public static Set<VillagerType> getVillagerTypes() {
return villagerTypes;
}
public static VillagerType getVillagerType(String name) {
return villagerTypes.stream().filter(villagerType -> villagerType.getName().equals(name)).findFirst().orElse(null);
}
public static void addVillagerType(VillagerType villagerType) {
villagerTypes.add(villagerType);
}
public static void clearVillagerTypes() {
villagerTypes.clear();
}
private final String name;
private final String displayName;
private final Set<ItemStack> buying;
private final Set<ItemStack> selling;
private final double priceModifier;
public VillagerType(String name, String displayName, Set<ItemStack> buying, Set<ItemStack> selling, double priceModifier) {
this.name = name;
this.displayName = displayName;
this.buying = buying;
this.selling = selling;
this.priceModifier = priceModifier;
}
public String getName() {
return name;
}
public String getDisplayName() {
return displayName;
}
public Set<ItemStack> getBuying() {
return buying;
}
public Set<ItemStack> getSelling() {
return selling;
}
public double getPriceModifier() {
return priceModifier;
}
}