Search in sources :

Example 1 with PlayerCoolDownValueHolder

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();
        }
    }
}
Also used : PlayerCoolDownValueHolder(net.server.PlayerCoolDownValueHolder) SQLException(java.sql.SQLException) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 2 with PlayerCoolDownValueHolder

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;
}
Also used : PlayerCoolDownValueHolder(net.server.PlayerCoolDownValueHolder) ArrayList(java.util.ArrayList)

Example 3 with PlayerCoolDownValueHolder

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);
    }
}
Also used : SkillEntry(client.MapleCharacter.SkillEntry) Skill(client.Skill) MobSkill(server.life.MobSkill) SkillEntry(client.MapleCharacter.SkillEntry) SummonAttackEntry(net.server.channel.handlers.SummonDamageHandler.SummonAttackEntry) Entry(java.util.Map.Entry) MapleFamilyEntry(client.MapleFamilyEntry) BuddylistEntry(client.BuddylistEntry) PlayerCoolDownValueHolder(net.server.PlayerCoolDownValueHolder) Point(java.awt.Point)

Aggregations

PlayerCoolDownValueHolder (net.server.PlayerCoolDownValueHolder)3 BuddylistEntry (client.BuddylistEntry)1 SkillEntry (client.MapleCharacter.SkillEntry)1 MapleFamilyEntry (client.MapleFamilyEntry)1 Skill (client.Skill)1 Point (java.awt.Point)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 SummonAttackEntry (net.server.channel.handlers.SummonDamageHandler.SummonAttackEntry)1 MobSkill (server.life.MobSkill)1 DatabaseConnection (tools.DatabaseConnection)1