Search in sources :

Example 1 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleCharacter method getActiveStatupsFromSourceid.

private List<Pair<MapleBuffStat, Integer>> getActiveStatupsFromSourceid(int sourceid) {
    // already under effLock & chrLock
    List<Pair<MapleBuffStat, Integer>> ret = new ArrayList<>();
    for (Entry<MapleBuffStat, MapleBuffStatValueHolder> bel : buffEffects.get(sourceid).entrySet()) {
        Integer bsrcid = bel.getValue().effect.getBuffSourceId();
        MapleBuffStat mbs = bel.getKey();
        MapleBuffStatValueHolder mbsvh = effects.get(bel.getKey());
        if (mbsvh != null && mbsvh.effect.getBuffSourceId() == bsrcid) {
            ret.add(new Pair<>(mbs, mbsvh.value));
        } else {
            ret.add(new Pair<>(mbs, 0));
        }
    }
    Collections.sort(ret, new Comparator<Pair<MapleBuffStat, Integer>>() {

        @Override
        public int compare(Pair<MapleBuffStat, Integer> p1, Pair<MapleBuffStat, Integer> p2) {
            return p1.getLeft().compareTo(p2.getLeft());
        }
    });
    return ret;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Pair(tools.Pair)

Example 2 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleCharacter method Hide.

public void Hide(boolean hide, boolean login) {
    if (isGM() && hide != this.hidden) {
        if (!hide) {
            this.hidden = false;
            announce(MaplePacketCreator.getGMEffect(0x10, (byte) 0));
            List<MapleBuffStat> dsstat = Collections.singletonList(MapleBuffStat.DARKSIGHT);
            getMap().broadcastGMMessage(this, MaplePacketCreator.cancelForeignBuff(id, dsstat), false);
            getMap().broadcastMessage(this, MaplePacketCreator.spawnPlayerMapObject(this), false);
            for (MapleSummon ms : this.getSummonsValues()) {
                getMap().broadcastNONGMMessage(this, MaplePacketCreator.spawnSummon(ms, false), false);
            }
            updatePartyMemberHP();
        } else {
            this.hidden = true;
            announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
            if (!login) {
                getMap().broadcastMessage(this, MaplePacketCreator.removePlayerFromMap(getId()), false);
            }
            getMap().broadcastGMMessage(this, MaplePacketCreator.spawnPlayerMapObject(this), false);
            List<Pair<MapleBuffStat, Integer>> ldsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
            getMap().broadcastGMMessage(this, MaplePacketCreator.giveForeignBuff(id, ldsstat), false);
            for (MapleMonster mon : this.getControlledMonsters()) {
                mon.setController(null);
                mon.setControllerHasAggro(false);
                mon.setControllerKnowsAboutAggro(false);
                mon.getMap().updateMonsterController(mon);
            }
        }
        announce(MaplePacketCreator.enableActions());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleSummon(server.maps.MapleSummon) MapleMonster(server.life.MapleMonster) Pair(tools.Pair)

Example 3 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleCharacter method handleOrbconsume.

public void handleOrbconsume() {
    int skillid = isCygnus() ? DawnWarrior.COMBO : Crusader.COMBO;
    Skill combo = SkillFactory.getSkill(skillid);
    List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.COMBO, 1));
    setBuffedValue(MapleBuffStat.COMBO, 1);
    client.announce(MaplePacketCreator.giveBuff(skillid, combo.getEffect(getSkillLevel(combo)).getDuration() + (int) ((getBuffedStarttime(MapleBuffStat.COMBO) - System.currentTimeMillis())), stat));
    getMap().broadcastMessage(this, MaplePacketCreator.giveForeignBuff(getId(), stat), false);
}
Also used : MobSkill(server.life.MobSkill) Point(java.awt.Point) Pair(tools.Pair)

Example 4 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleCharacter method saveToDB.

public synchronized void saveToDB(boolean notAutosave) {
    if (!loggedIn)
        return;
    Calendar c = Calendar.getInstance();
    if (notAutosave)
        FilePrinter.print(FilePrinter.SAVING_CHARACTER, "Attempting to save " + name + " at " + c.getTime().toString());
    else
        FilePrinter.print(FilePrinter.AUTOSAVING_CHARACTER, "Attempting to autosave " + name + " at " + c.getTime().toString());
    Connection con = null;
    try {
        con = DatabaseConnection.getConnection();
        con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
        con.setAutoCommit(false);
        PreparedStatement ps;
        ps = con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, gachaexp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpMpUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, mountlevel = ?, mountexp = ?, mounttiredness= ?, equipslots = ?, useslots = ?, setupslots = ?, etcslots = ?,  monsterbookcover = ?, vanquisherStage = ?, dojoPoints = ?, lastDojoStage = ?, finishedDojoTutorial = ?, vanquisherKills = ?, matchcardwins = ?, matchcardlosses = ?, matchcardties = ?, omokwins = ?, omoklosses = ?, omokties = ?, dataString = ?, fquest = ?, jailexpire = ? WHERE id = ?", Statement.RETURN_GENERATED_KEYS);
        if (gmLevel < 1 && level > 199) {
            ps.setInt(1, isCygnus() ? 120 : 200);
        } else {
            ps.setInt(1, level);
        }
        ps.setInt(2, fame);
        ps.setInt(3, str);
        ps.setInt(4, dex);
        ps.setInt(5, luk);
        ps.setInt(6, int_);
        ps.setInt(7, Math.abs(exp.get()));
        ps.setInt(8, Math.abs(gachaexp.get()));
        ps.setInt(9, hp);
        ps.setInt(10, mp);
        ps.setInt(11, maxhp);
        ps.setInt(12, maxmp);
        StringBuilder sps = new StringBuilder();
        for (int i = 0; i < remainingSp.length; i++) {
            sps.append(remainingSp[i]);
            sps.append(",");
        }
        String sp = sps.toString();
        ps.setString(13, sp.substring(0, sp.length() - 1));
        ps.setInt(14, remainingAp);
        ps.setInt(15, gmLevel);
        ps.setInt(16, skinColor.getId());
        ps.setInt(17, gender);
        ps.setInt(18, job.getId());
        ps.setInt(19, hair);
        ps.setInt(20, face);
        if (map == null || (cashshop != null && cashshop.isOpened())) {
            ps.setInt(21, mapid);
        } else {
            if (map.getForcedReturnId() != 999999999) {
                ps.setInt(21, map.getForcedReturnId());
            } else {
                ps.setInt(21, getHp() < 1 ? map.getReturnMapId() : map.getId());
            }
        }
        ps.setInt(22, meso.get());
        ps.setInt(23, hpMpApUsed);
        if (map == null || map.getId() == 610020000 || map.getId() == 610020001) {
            // reset to first spawnpoint on those maps
            ps.setInt(24, 0);
        } else {
            MaplePortal closest = map.findClosestPlayerSpawnpoint(getPosition());
            if (closest != null) {
                ps.setInt(24, closest.getId());
            } else {
                ps.setInt(24, 0);
            }
        }
        prtLock.lock();
        try {
            if (party != null) {
                ps.setInt(25, party.getId());
            } else {
                ps.setInt(25, -1);
            }
        } finally {
            prtLock.unlock();
        }
        ps.setInt(26, buddylist.getCapacity());
        if (messenger != null) {
            ps.setInt(27, messenger.getId());
            ps.setInt(28, messengerposition);
        } else {
            ps.setInt(27, 0);
            ps.setInt(28, 4);
        }
        if (maplemount != null) {
            ps.setInt(29, maplemount.getLevel());
            ps.setInt(30, maplemount.getExp());
            ps.setInt(31, maplemount.getTiredness());
        } else {
            ps.setInt(29, 1);
            ps.setInt(30, 0);
            ps.setInt(31, 0);
        }
        for (int i = 1; i < 5; i++) {
            ps.setInt(i + 31, getSlots(i));
        }
        monsterbook.saveCards(getId());
        ps.setInt(36, bookCover);
        ps.setInt(37, vanquisherStage);
        ps.setInt(38, dojoPoints);
        ps.setInt(39, dojoStage);
        ps.setInt(40, finishedDojoTutorial ? 1 : 0);
        ps.setInt(41, vanquisherKills);
        ps.setInt(42, matchcardwins);
        ps.setInt(43, matchcardlosses);
        ps.setInt(44, matchcardties);
        ps.setInt(45, omokwins);
        ps.setInt(46, omoklosses);
        ps.setInt(47, omokties);
        ps.setString(48, dataString);
        ps.setInt(49, quest_fame);
        ps.setLong(50, jailExpiration);
        ps.setInt(51, id);
        int updateRows = ps.executeUpdate();
        if (updateRows < 1) {
            throw new RuntimeException("Character not in database (" + id + ")");
        }
        petLock.lock();
        try {
            for (int i = 0; i < 3; i++) {
                if (pets[i] != null) {
                    pets[i].saveToDb();
                }
            }
        } finally {
            petLock.unlock();
        }
        for (Entry<Integer, Set<Integer>> es : getExcluded().entrySet()) {
            // this set is already protected
            try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM petignores WHERE petid=?")) {
                ps2.setInt(1, es.getKey());
                ps2.executeUpdate();
            }
            try (PreparedStatement ps2 = con.prepareStatement("INSERT INTO petignores (petid, itemid) VALUES (?, ?)")) {
                ps2.setInt(1, es.getKey());
                for (Integer x : es.getValue()) {
                    ps2.setInt(2, x);
                    ps2.addBatch();
                }
                ps2.executeBatch();
            }
        }
        deleteWhereCharacterId(con, "DELETE FROM keymap WHERE characterid = ?");
        ps = con.prepareStatement("INSERT INTO keymap (characterid, `key`, `type`, `action`) VALUES (?, ?, ?, ?)");
        ps.setInt(1, id);
        Set<Entry<Integer, MapleKeyBinding>> keybindingItems = Collections.unmodifiableSet(keymap.entrySet());
        for (Entry<Integer, MapleKeyBinding> keybinding : keybindingItems) {
            ps.setInt(2, keybinding.getKey());
            ps.setInt(3, keybinding.getValue().getType());
            ps.setInt(4, keybinding.getValue().getAction());
            ps.addBatch();
        }
        ps.executeBatch();
        deleteWhereCharacterId(con, "DELETE FROM skillmacros WHERE characterid = ?");
        ps = con.prepareStatement("INSERT INTO skillmacros (characterid, skill1, skill2, skill3, name, shout, position) VALUES (?, ?, ?, ?, ?, ?, ?)");
        ps.setInt(1, getId());
        for (int i = 0; i < 5; i++) {
            SkillMacro macro = skillMacros[i];
            if (macro != null) {
                ps.setInt(2, macro.getSkill1());
                ps.setInt(3, macro.getSkill2());
                ps.setInt(4, macro.getSkill3());
                ps.setString(5, macro.getName());
                ps.setInt(6, macro.getShout());
                ps.setInt(7, i);
                ps.addBatch();
            }
        }
        ps.executeBatch();
        List<Pair<Item, MapleInventoryType>> itemsWithType = new ArrayList<>();
        for (MapleInventory iv : inventory) {
            for (Item item : iv.list()) {
                itemsWithType.add(new Pair<>(item, iv.getType()));
            }
        }
        ItemFactory.INVENTORY.saveItems(itemsWithType, id, con);
        deleteWhereCharacterId(con, "DELETE FROM skills WHERE characterid = ?");
        ps = con.prepareStatement("INSERT INTO skills (characterid, skillid, skilllevel, masterlevel, expiration) VALUES (?, ?, ?, ?, ?)");
        ps.setInt(1, id);
        for (Entry<Skill, SkillEntry> skill : skills.entrySet()) {
            ps.setInt(2, skill.getKey().getId());
            ps.setInt(3, skill.getValue().skillevel);
            ps.setInt(4, skill.getValue().masterlevel);
            ps.setLong(5, skill.getValue().expiration);
            ps.addBatch();
        }
        ps.executeBatch();
        deleteWhereCharacterId(con, "DELETE FROM savedlocations WHERE characterid = ?");
        ps = con.prepareStatement("INSERT INTO savedlocations (characterid, `locationtype`, `map`, `portal`) VALUES (?, ?, ?, ?)");
        ps.setInt(1, id);
        for (SavedLocationType savedLocationType : SavedLocationType.values()) {
            if (savedLocations[savedLocationType.ordinal()] != null) {
                ps.setString(2, savedLocationType.name());
                ps.setInt(3, savedLocations[savedLocationType.ordinal()].getMapId());
                ps.setInt(4, savedLocations[savedLocationType.ordinal()].getPortal());
                ps.addBatch();
            }
        }
        ps.executeBatch();
        deleteWhereCharacterId(con, "DELETE FROM trocklocations WHERE characterid = ?");
        ps = con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 0)");
        for (int i = 0; i < getTrockSize(); i++) {
            if (trockmaps.get(i) != 999999999) {
                ps.setInt(1, getId());
                ps.setInt(2, trockmaps.get(i));
                ps.addBatch();
            }
        }
        ps.executeBatch();
        ps = con.prepareStatement("INSERT INTO trocklocations(characterid, mapid, vip) VALUES (?, ?, 1)");
        for (int i = 0; i < getVipTrockSize(); i++) {
            if (viptrockmaps.get(i) != 999999999) {
                ps.setInt(1, getId());
                ps.setInt(2, viptrockmaps.get(i));
                ps.addBatch();
            }
        }
        ps.executeBatch();
        deleteWhereCharacterId(con, "DELETE FROM buddies WHERE characterid = ? AND pending = 0");
        ps = con.prepareStatement("INSERT INTO buddies (characterid, `buddyid`, `pending`, `group`) VALUES (?, ?, 0, ?)");
        ps.setInt(1, id);
        for (BuddylistEntry entry : buddylist.getBuddies()) {
            if (entry.isVisible()) {
                ps.setInt(2, entry.getCharacterId());
                ps.setString(3, entry.getGroup());
                ps.addBatch();
            }
        }
        ps.executeBatch();
        deleteWhereCharacterId(con, "DELETE FROM area_info WHERE charid = ?");
        ps = con.prepareStatement("INSERT INTO area_info (id, charid, area, info) VALUES (DEFAULT, ?, ?, ?)");
        ps.setInt(1, id);
        for (Entry<Short, String> area : area_info.entrySet()) {
            ps.setInt(2, area.getKey());
            ps.setString(3, area.getValue());
            ps.addBatch();
        }
        ps.executeBatch();
        deleteWhereCharacterId(con, "DELETE FROM eventstats WHERE characterid = ?");
        deleteWhereCharacterId(con, "DELETE FROM queststatus WHERE characterid = ?");
        ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `expires`, `forfeited`) VALUES (DEFAULT, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
        PreparedStatement psf;
        try (PreparedStatement pse = con.prepareStatement("INSERT INTO questprogress VALUES (DEFAULT, ?, ?, ?)")) {
            psf = con.prepareStatement("INSERT INTO medalmaps VALUES (DEFAULT, ?, ?)");
            ps.setInt(1, id);
            synchronized (quests) {
                for (MapleQuestStatus q : quests.values()) {
                    ps.setInt(2, q.getQuest().getId());
                    ps.setInt(3, q.getStatus().getId());
                    ps.setInt(4, (int) (q.getCompletionTime() / 1000));
                    ps.setLong(5, q.getExpirationTime());
                    ps.setInt(6, q.getForfeited());
                    ps.executeUpdate();
                    try (ResultSet rs = ps.getGeneratedKeys()) {
                        rs.next();
                        for (int mob : q.getProgress().keySet()) {
                            pse.setInt(1, rs.getInt(1));
                            pse.setInt(2, mob);
                            pse.setString(3, q.getProgress(mob));
                            pse.addBatch();
                        }
                        for (int i = 0; i < q.getMedalMaps().size(); i++) {
                            psf.setInt(1, rs.getInt(1));
                            psf.setInt(2, q.getMedalMaps().get(i));
                            psf.addBatch();
                        }
                        pse.executeBatch();
                        psf.executeBatch();
                    }
                }
            }
        }
        psf.close();
        ps = con.prepareStatement("UPDATE accounts SET gm = ? WHERE id = ?");
        ps.setInt(1, gmLevel > 1 ? 1 : 0);
        ps.setInt(2, client.getAccID());
        ps.executeUpdate();
        ps.close();
        con.commit();
        con.setAutoCommit(true);
        if (cashshop != null) {
            cashshop.save(con);
        }
        if (storage != null) {
            storage.saveToDB(con);
        }
    } catch (SQLException | RuntimeException t) {
        FilePrinter.printError(FilePrinter.SAVE_CHAR, t, "Error saving " + name + " Level: " + level + " Job: " + job.getId());
        try {
            con.rollback();
        } catch (SQLException se) {
            FilePrinter.printError(FilePrinter.SAVE_CHAR, se, "Error trying to rollback " + name);
        }
    } catch (Exception e) {
        FilePrinter.printError(FilePrinter.SAVE_CHAR, e, "Error saving " + name + " Level: " + level + " Job: " + job.getId());
    } finally {
        try {
            con.setAutoCommit(true);
            con.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) Entry(java.util.Map.Entry) ResultSet(java.sql.ResultSet) Pair(tools.Pair) Calendar(java.util.Calendar) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) SavedLocationType(server.maps.SavedLocationType) MapleInventory(client.inventory.MapleInventory) Point(java.awt.Point) SQLException(java.sql.SQLException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MobSkill(server.life.MobSkill) MaplePortal(server.MaplePortal)

Example 5 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleCharacter method registerEffect.

public void registerEffect(MapleStatEffect effect, long starttime, long expirationtime, boolean isSilent) {
    if (effect.isDragonBlood()) {
        prepareDragonBlood(effect);
    } else if (effect.isBerserk()) {
        checkBerserk(isHidden());
    } else if (effect.isBeholder()) {
        final int beholder = DarkKnight.BEHOLDER;
        if (beholderHealingSchedule != null) {
            beholderHealingSchedule.cancel(false);
        }
        if (beholderBuffSchedule != null) {
            beholderBuffSchedule.cancel(false);
        }
        Skill bHealing = SkillFactory.getSkill(DarkKnight.AURA_OF_BEHOLDER);
        int bHealingLvl = getSkillLevel(bHealing);
        if (bHealingLvl > 0) {
            final MapleStatEffect healEffect = bHealing.getEffect(bHealingLvl);
            int healInterval = healEffect.getX() * 1000;
            beholderHealingSchedule = TimerManager.getInstance().register(new Runnable() {

                @Override
                public void run() {
                    if (awayFromWorld.get())
                        return;
                    addHP(healEffect.getHp());
                    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder, 2));
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.summonSkill(getId(), beholder, 5), true);
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showOwnBuffEffect(beholder, 2), false);
                }
            }, healInterval, healInterval);
        }
        Skill bBuff = SkillFactory.getSkill(DarkKnight.HEX_OF_BEHOLDER);
        if (getSkillLevel(bBuff) > 0) {
            final MapleStatEffect buffEffect = bBuff.getEffect(getSkillLevel(bBuff));
            int buffInterval = buffEffect.getX() * 1000;
            beholderBuffSchedule = TimerManager.getInstance().register(new Runnable() {

                @Override
                public void run() {
                    if (awayFromWorld.get())
                        return;
                    buffEffect.applyTo(MapleCharacter.this);
                    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder, 2));
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.summonSkill(getId(), beholder, (int) (Math.random() * 3) + 6), true);
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(getId(), beholder, 2), false);
                }
            }, buffInterval, buffInterval);
        }
    } else if (effect.isRecovery()) {
        int healInterval = (ServerConstants.USE_ULTRA_RECOVERY) ? 2000 : 5000;
        final byte heal = (byte) effect.getX();
        chrLock.lock();
        try {
            if (recoveryTask != null) {
                recoveryTask.cancel(false);
            }
            recoveryTask = TimerManager.getInstance().register(new Runnable() {

                @Override
                public void run() {
                    if (getBuffSource(MapleBuffStat.RECOVERY) == -1) {
                        chrLock.lock();
                        try {
                            if (recoveryTask != null) {
                                recoveryTask.cancel(false);
                                recoveryTask = null;
                            }
                        } finally {
                            chrLock.unlock();
                        }
                        return;
                    }
                    addHP(heal);
                    client.announce(MaplePacketCreator.showOwnRecovery(heal));
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showRecovery(id, heal), false);
                }
            }, healInterval, healInterval);
        } finally {
            chrLock.unlock();
        }
    } else if (effect.getHpRRate() > 0 || effect.getMpRRate() > 0) {
        if (effect.getHpRRate() > 0) {
            extraHpRec = effect.getHpR();
            extraRecInterval = effect.getHpRRate();
        }
        if (effect.getMpRRate() > 0) {
            extraMpRec = effect.getMpR();
            extraRecInterval = effect.getMpRRate();
        }
        stopExtraTask();
        // HP & MP sharing the same task holder
        startExtraTask(extraHpRec, extraMpRec, extraRecInterval);
    } else if (effect.isMapChair()) {
        startChairTask();
    }
    effLock.lock();
    chrLock.lock();
    try {
        Integer sourceid = effect.getBuffSourceId();
        Map<MapleBuffStat, MapleBuffStatValueHolder> toDeploy;
        Map<MapleBuffStat, MapleBuffStatValueHolder> appliedStatups = new LinkedHashMap<>();
        for (Pair<MapleBuffStat, Integer> ps : effect.getStatups()) {
            appliedStatups.put(ps.getLeft(), new MapleBuffStatValueHolder(effect, starttime, ps.getRight()));
        }
        if (ServerConstants.USE_BUFF_MOST_SIGNIFICANT) {
            toDeploy = new LinkedHashMap<>();
            Map<Integer, Pair<MapleStatEffect, Long>> retrievedEffects = new LinkedHashMap<>();
            for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : appliedStatups.entrySet()) {
                MapleBuffStatValueHolder mbsvh = effects.get(statup.getKey());
                if (mbsvh == null || mbsvh.value <= statup.getValue().value) {
                    toDeploy.put(statup.getKey(), statup.getValue());
                } else {
                    retrievedEffects.put(mbsvh.effect.getBuffSourceId(), new Pair<>(mbsvh.effect, mbsvh.startTime));
                }
                Byte val = buffEffectsCount.get(statup.getKey());
                if (val != null)
                    val = (byte) (val + 1);
                else
                    val = (byte) 1;
                buffEffectsCount.put(statup.getKey(), val);
            }
            if (!isSilent) {
                for (Entry<Integer, Pair<MapleStatEffect, Long>> lmse : retrievedEffects.entrySet()) {
                    lmse.getValue().getLeft().updateBuffEffect(this, getActiveStatupsFromSourceid(lmse.getKey()), lmse.getValue().getRight());
                }
            }
        } else {
            for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : appliedStatups.entrySet()) {
                Byte val = buffEffectsCount.get(statup.getKey());
                if (val != null)
                    val = (byte) (val + 1);
                else
                    val = (byte) 1;
                buffEffectsCount.put(statup.getKey(), val);
            }
            toDeploy = appliedStatups;
        }
        addItemEffectHolder(sourceid, expirationtime, appliedStatups);
        for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : toDeploy.entrySet()) {
            effects.put(statup.getKey(), statup.getValue());
        }
    } finally {
        chrLock.unlock();
        effLock.unlock();
    }
    recalcLocalStats();
}
Also used : Point(java.awt.Point) LinkedHashMap(java.util.LinkedHashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MobSkill(server.life.MobSkill) MapleStatEffect(server.MapleStatEffect) Pair(tools.Pair)

Aggregations

Pair (tools.Pair)51 ArrayList (java.util.ArrayList)34 Point (java.awt.Point)16 Item (client.inventory.Item)15 LinkedList (java.util.LinkedList)12 MapleData (provider.MapleData)11 SQLException (java.sql.SQLException)10 PreparedStatement (java.sql.PreparedStatement)7 List (java.util.List)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 MobSkill (server.life.MobSkill)6 MapleCharacter (client.MapleCharacter)5 Connection (java.sql.Connection)5 ResultSet (java.sql.ResultSet)5 MapleMap (server.maps.MapleMap)5 LinkedHashMap (java.util.LinkedHashMap)4 CharacterIdChannelPair (net.server.channel.CharacterIdChannelPair)4 MaplePartyCharacter (net.server.world.MaplePartyCharacter)4 MapleStatEffect (server.MapleStatEffect)4 DatabaseConnection (tools.DatabaseConnection)4