use of de.Keyle.MyPet.api.skill.SkillInstance in project MyPet by xXKeyleXx.
the class MyPet method getSkillInfo.
public TagCompound getSkillInfo() {
TagCompound skillsNBT = new TagCompound();
Collection<SkillInstance> skillList = this.getSkills().getSkills();
if (skillList.size() > 0) {
for (SkillInstance skill : skillList) {
if (skill instanceof NBTStorage) {
NBTStorage storageSkill = (NBTStorage) skill;
TagCompound s = storageSkill.save();
if (s != null) {
skillsNBT.getCompoundData().put(skill.getName(), s);
}
}
}
}
return skillsNBT;
}
use of de.Keyle.MyPet.api.skill.SkillInstance in project MyPet by xXKeyleXx.
the class MyPetManager method activateMyPet.
// All ----------------------------------------------------------------------
public Optional<MyPet> activateMyPet(StoredMyPet storedMyPet) {
if (!storedMyPet.getOwner().isOnline()) {
return Optional.absent();
}
if (storedMyPet.getOwner().hasMyPet()) {
if (!deactivateMyPet(storedMyPet.getOwner(), true)) {
return Optional.absent();
}
}
MyPetLoadEvent event = new MyPetLoadEvent(storedMyPet);
Bukkit.getServer().getPluginManager().callEvent(event);
MyPet myPet = MyPetClass.getByMyPetType(storedMyPet.getPetType()).getNewMyPetInstance(storedMyPet.getOwner());
myPet.setUUID(storedMyPet.getUUID());
myPet.setPetName(storedMyPet.getPetName());
myPet.setRespawnTime(storedMyPet.getRespawnTime());
myPet.setWorldGroup(storedMyPet.getWorldGroup());
myPet.setInfo(storedMyPet.getInfo());
myPet.setLastUsed(storedMyPet.getLastUsed());
myPet.setWantsToRespawn(storedMyPet.wantsToRespawn());
myPet.getExperience().setExp(storedMyPet.getExp());
myPet.setSkilltree(storedMyPet.getSkilltree());
Collection<SkillInstance> skills = myPet.getSkills().getSkills();
if (skills.size() > 0) {
for (SkillInstance skill : skills) {
if (skill instanceof NBTStorage) {
NBTStorage storageSkill = (NBTStorage) skill;
if (storedMyPet.getSkillInfo().getCompoundData().containsKey(skill.getName())) {
storageSkill.load(storedMyPet.getSkillInfo().getAs(skill.getName(), TagCompound.class));
}
}
}
}
myPet.setHealth(storedMyPet.getHealth());
myPet.setSaturation(storedMyPet.getSaturation());
mActivePetsPlayer.put(myPet, myPet.getOwner());
return Optional.of(myPet);
}
Aggregations