use of de.Keyle.MyPet.entity.InactiveMyPet in project MyPet by xXKeyleXx.
the class SqLiteRepository method resultSetToMyPet.
// Pets ------------------------------------------------------------------------------------------------------------
private List<StoredMyPet> resultSetToMyPet(MyPetPlayer owner, ResultSet resultSet, boolean next) {
List<StoredMyPet> pets = new ArrayList<>();
try {
while (!next || resultSet.next()) {
next = true;
InactiveMyPet pet = new InactiveMyPet(owner);
pet.setUUID(UUID.fromString(resultSet.getString("uuid")));
pet.setWorldGroup(resultSet.getString("world_group"));
pet.setExp(resultSet.getDouble("exp"));
pet.setHealth(resultSet.getDouble("health"));
pet.setRespawnTime(resultSet.getInt("respawn_time"));
pet.setPetName(new String(resultSet.getBytes("name"), StandardCharsets.UTF_8));
pet.setPetType(MyPetType.valueOf(resultSet.getString("type")));
pet.setLastUsed(resultSet.getLong("last_used"));
pet.setSaturation(resultSet.getDouble("hunger"));
pet.wantsToRespawn = resultSet.getBoolean("wants_to_spawn");
String skillTreeName = resultSet.getString("skilltree");
if (skillTreeName != null) {
Skilltree skilltree = MyPetApi.getSkilltreeManager().getSkilltree(skillTreeName);
if (skilltree != null) {
pet.setSkilltree(skilltree);
}
}
pet.setSkills(TagStream.readTag(resultSet.getBytes("skills"), true));
pet.setInfo(TagStream.readTag(resultSet.getBytes("info"), true));
List<RepositoryMyPetConverterService> converters = MyPetApi.getServiceManager().getServices(RepositoryMyPetConverterService.class);
for (RepositoryMyPetConverterService converter : converters) {
converter.convert(pet);
}
pets.add(pet);
}
} catch (SQLException | IOException e) {
e.printStackTrace();
}
return pets;
}
use of de.Keyle.MyPet.entity.InactiveMyPet in project MyPet by xXKeyleXx.
the class NbtRepository method getAllMyPets.
// Pets ------------------------------------------------------------------------------------------------------------
@Override
public List<StoredMyPet> getAllMyPets() {
List<MyPetPlayer> playerList = getAllMyPetPlayers();
Map<UUID, MyPetPlayer> owners = new HashMap<>();
for (MyPetPlayer player : playerList) {
owners.put(player.getInternalUUID(), player);
}
List<StoredMyPet> pets = new ArrayList<>();
for (UUID petUUID : petTags.keySet()) {
TagCompound petTag = petTags.get(petUUID);
if (petTag.containsKeyAs("Internal-Owner-UUID", TagString.class)) {
UUID ownerUUID = UUID.fromString(petTag.getAs("Internal-Owner-UUID", TagString.class).getStringData());
if (owners.containsKey(ownerUUID)) {
InactiveMyPet myPet = new InactiveMyPet(owners.get(ownerUUID));
myPet.load(petTag);
pets.add(myPet);
}
}
}
return pets;
}
Aggregations