public MyPetType getPetType() { return getMyPet().getPetType(); }
@Override public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) { EntityMyPet petEntity = null; Class<? extends MyPetMinecraftEntity> entityClass = entityClasses.get(pet.getPetType()); World world = ((CraftWorld) bukkitWorld).getHandle(); try { Constructor<?> ctor = entityClass.getConstructor(World.class, MyPet.class); Object obj = ctor.newInstance(world, pet); if (obj instanceof EntityMyPet) { petEntity = (EntityMyPet) obj; } } catch (Exception e) { MyPetApi.getLogger().info(ChatColor.RED + entityClass.getName() + " is no valid MyPet(Entity)!"); e.printStackTrace(); } return petEntity; }
public boolean canEat(ItemStack itemstack) { List<ConfigItem> foodList = MyPetApi.getMyPetInfo().getFood(myPet.getPetType()); for (ConfigItem foodItem : foodList) { if (foodItem.compare(itemstack)) { return true; } } return false; }
public Skilltree getRandomSkilltree(MyPet pet, Player p) { TreeMap<Double, Skilltree> skilltreeMap = new TreeMap<>(); List<Skilltree> skilltrees = new ArrayList<>(MyPetApi.getSkilltreeManager().getSkilltrees()); double totalWeight = 0; for (Skilltree skilltree : skilltrees) { if (skilltree.getMobTypes().contains(pet.getPetType()) && skilltree.checkRequirements(pet) && skilltree.getWeight() > 0) { skilltreeMap.put(totalWeight, skilltree); totalWeight += skilltree.getWeight(); } } double num = (1 - Util.getRandom().nextDouble()) * totalWeight; num = skilltreeMap.floorKey(num); return skilltreeMap.get(num); }
public double getExpByLevel(int level) { double exp; try { exp = cache.getExp(myPet.getWorldGroup(), myPet.getPetType(), level); } catch (ExperienceCache.LevelNotCalculatedException e) { exp = expCalculator.getExpByLevel(this.getMyPet(), level); cache.insertExp(myPet.getWorldGroup(), myPet.getPetType(), level, exp); } return exp; }
protected double uppdateExp(double exp, boolean quiet) { MyPetExpEvent expEvent = new MyPetExpEvent(myPet, exp); Bukkit.getServer().getPluginManager().callEvent(expEvent); if (expEvent.isCancelled()) { return 0; } int oldLvl = this.level; double oldExp = this.exp; this.exp += expEvent.getExp(); this.exp = Math.max(0, Math.min(maxExp, this.exp)); int lvl = cache.getLevel(myPet.getWorldGroup(), myPet.getPetType(), this.exp); if (lvl != 0) { this.level = lvl; } else { this.level = calculateLevel(); } if (oldLvl != this.level) { if (oldLvl < this.level) { Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelUpEvent(myPet, this.level, oldLvl, quiet)); } else { Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelDownEvent(myPet, this.level, oldLvl, quiet)); } } return this.exp - oldExp; }
public EntityMyPet(World world, MyPet myPet) { super(world); try { setSize(); this.myPet = myPet; this.petPathfinderSelector = new AIGoalSelector(); this.petTargetSelector = new AIGoalSelector(); this.walkSpeed = MyPetApi.getMyPetInfo().getSpeed(myPet.getPetType()); this.getAttributeInstance(GenericAttributes.d).setValue(walkSpeed); this.getAttributeInstance(GenericAttributes.b).setValue(32.0f); this.petNavigation = new VanillaNavigation(this); this.sitPathfinder = new Sit(this); this.getAttributeInstance(GenericAttributes.maxHealth).setValue(myPet.getMaxHealth()); this.setHealth((float) myPet.getHealth()); this.updateNameTag(); this.setPathfinder(); this.updateVisuals(); this.isMyPet = true; } catch (Exception e) { e.printStackTrace(); } }
command = command.replaceAll("%pet_level%", "" + myPet.getExperience().getLevel()); command = command.replaceAll("%pet_status%", "" + myPet.getStatus().name()); command = command.replaceAll("%pet_type%", myPet.getPetType().name()); command = command.replaceAll("%pet_uuid%", myPet.getUUID().toString()); command = command.replaceAll("%pet_world_group%", myPet.getWorldGroup());