package eu.univento.lobby.utils; import eu.univento.core.api.player.CustomPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import java.util.HashMap; /** * @author joethei * @version 1.0 */ public class PetManager { private static HashMap pets = new HashMap<>(); public static HashMap getPets() { return pets; } public static boolean hasPet(CustomPlayer p) { return pets.containsKey(p); } public static Entity getPet(CustomPlayer p) { return pets.get(p); } public static void removePet(CustomPlayer p) { pets.get(p).remove(); } public static void setPet(CustomPlayer p, EntityType e) { if(hasPet(p)) { removePet(p); } new Pets().createPet(p, e); } public static void setName(CustomPlayer p, String name) { if(hasPet(p)) { getPet(p).setCustomName(name); } } public static String getName(CustomPlayer p) { if(hasPet(p)) { return getPet(p).getCustomName(); }else { return null; } } public static void clearPets() { pets.values().forEach(Entity::remove); } }