use of net.server.PlayerCoolDownValueHolder in project HeavenMS by ronancpl.
the class MapleCharacter method saveCooldowns.
public synchronized void saveCooldowns() {
List<PlayerCoolDownValueHolder> listcd = getAllCooldowns();
if (listcd.size() > 0) {
try {
Connection con = DatabaseConnection.getConnection();
deleteWhereCharacterId(con, "DELETE FROM cooldowns WHERE charid = ?");
try (PreparedStatement ps = con.prepareStatement("INSERT INTO cooldowns (charid, SkillID, StartTime, length) VALUES (?, ?, ?, ?)")) {
ps.setInt(1, getId());
for (PlayerCoolDownValueHolder cooling : listcd) {
ps.setInt(2, cooling.skillId);
ps.setLong(3, cooling.startTime);
ps.setLong(4, cooling.length);
ps.addBatch();
}
ps.executeBatch();
}
con.close();
} catch (SQLException se) {
se.printStackTrace();
}
}
}
use of net.server.PlayerCoolDownValueHolder in project HeavenMS by ronancpl.
the class MapleCharacter method getAllCooldowns.
public List<PlayerCoolDownValueHolder> getAllCooldowns() {
List<PlayerCoolDownValueHolder> ret = new ArrayList<>();
effLock.lock();
chrLock.lock();
try {
for (MapleCoolDownValueHolder mcdvh : coolDowns.values()) {
ret.add(new PlayerCoolDownValueHolder(mcdvh.skillId, mcdvh.startTime, mcdvh.length));
}
} finally {
chrLock.unlock();
effLock.unlock();
}
return ret;
}
use of net.server.PlayerCoolDownValueHolder in project HeavenMS by ronancpl.
the class MaplePacketCreator method addSkillInfo.
private static void addSkillInfo(final MaplePacketLittleEndianWriter mplew, MapleCharacter chr) {
// start of skills
mplew.write(0);
Map<Skill, MapleCharacter.SkillEntry> skills = chr.getSkills();
int skillsSize = skills.size();
// We don't want to include any hidden skill in this, so subtract them from the size list and ignore them.
for (Iterator<Entry<Skill, SkillEntry>> it = skills.entrySet().iterator(); it.hasNext(); ) {
Entry<Skill, MapleCharacter.SkillEntry> skill = it.next();
if (GameConstants.isHiddenSkills(skill.getKey().getId())) {
skillsSize--;
}
}
mplew.writeShort(skillsSize);
for (Iterator<Entry<Skill, SkillEntry>> it = skills.entrySet().iterator(); it.hasNext(); ) {
Entry<Skill, MapleCharacter.SkillEntry> skill = it.next();
if (GameConstants.isHiddenSkills(skill.getKey().getId())) {
continue;
}
mplew.writeInt(skill.getKey().getId());
mplew.writeInt(skill.getValue().skillevel);
addExpirationTime(mplew, skill.getValue().expiration);
if (skill.getKey().isFourthJob()) {
mplew.writeInt(skill.getValue().masterlevel);
}
}
mplew.writeShort(chr.getAllCooldowns().size());
for (PlayerCoolDownValueHolder cooling : chr.getAllCooldowns()) {
mplew.writeInt(cooling.skillId);
int timeLeft = (int) (cooling.length + cooling.startTime - System.currentTimeMillis());
mplew.writeShort(timeLeft / 1000);
}
}
Aggregations