No delay on card pick-up + refactored item pickup process

Fixed a issue on server delaying whenever a player gets a new card for
the mobbook. Some code refactoring unifying the several item picking-up
methods on the project.
This commit is contained in:
ronancpl
2017-05-21 15:17:18 -03:00
parent 7fcdc07b5b
commit 514656d238
8 changed files with 204 additions and 292 deletions

View File

@@ -32,13 +32,13 @@ import tools.DatabaseConnection;
import tools.MaplePacketCreator;
public final class MonsterBook {
private int specialCard;
private int specialCard = 0;
private int normalCard = 0;
private int bookLevel = 1;
private Map<Integer, Integer> cards = new LinkedHashMap<>();
public void addCard(final MapleClient c, final int cardid) {
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeginCardEffect(c.getPlayer().getId()), false);
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignCardEffect(c.getPlayer().getId()), false);
for (Entry<Integer, Integer> all : cards.entrySet()) {
if (all.getKey() == cardid) {
if (all.getValue() > 4) {
@@ -57,7 +57,13 @@ public final class MonsterBook {
c.announce(MaplePacketCreator.showGainCard());
calculateLevel();
c.getPlayer().saveToDB();
if (cardid / 1000 >= 2388) {
specialCard++;
} else {
normalCard++;
}
//c.getPlayer().saveToDB(); //is it REALLY needed to save to DB every new entry?
}
private void calculateLevel() {