Monster drops are retrieved from DropProvider (postgres db)
This commit emphasizes the need for events to be reworked. This is the chain of constructors the DropProvider has to pass through to reach MapleMap: Channel -> EventScriptManager -> EventManager -> EventInstanceManager -> MapManager -> MapleMap
This commit is contained in:
@@ -28,6 +28,7 @@ import client.status.MonsterStatusEffect;
|
||||
import config.YamlConfig;
|
||||
import constants.id.MobId;
|
||||
import constants.skills.*;
|
||||
import database.drop.DropProvider;
|
||||
import net.packet.Packet;
|
||||
import net.server.channel.Channel;
|
||||
import net.server.coordinator.world.MonsterAggroCoordinator;
|
||||
@@ -738,9 +739,9 @@ public class Monster extends AbstractLoadedLife {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MonsterDropEntry> retrieveRelevantDrops() {
|
||||
public List<MonsterDropEntry> retrieveRelevantDrops(DropProvider dropProvider) {
|
||||
if (this.getStats().isFriendly()) { // thanks Conrad for noticing friendly mobs not spawning loots after a recent update
|
||||
return MonsterInformationProvider.getInstance().retrieveEffectiveDrop(this.getId());
|
||||
return dropProvider.getMonsterDropEntries(this.getId());
|
||||
}
|
||||
|
||||
Map<Integer, Character> pchars = map.getMapAllPlayers();
|
||||
@@ -753,7 +754,7 @@ public class Monster extends AbstractLoadedLife {
|
||||
}
|
||||
}
|
||||
|
||||
return LootManager.retrieveRelevantDrops(this.getId(), lootChars);
|
||||
return LootManager.retrieveRelevantDrops(this.getId(), lootChars, dropProvider);
|
||||
}
|
||||
|
||||
public Character killBy(final Character killer) {
|
||||
|
||||
@@ -99,34 +99,6 @@ public class MonsterInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MonsterDropEntry> retrieveEffectiveDrop(final int monsterId) {
|
||||
return retrieveDrop(monsterId);
|
||||
}
|
||||
|
||||
private List<MonsterDropEntry> retrieveDrop(final int monsterId) {
|
||||
if (drops.containsKey(monsterId)) {
|
||||
return drops.get(monsterId);
|
||||
}
|
||||
final List<MonsterDropEntry> ret = new LinkedList<>();
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT itemid, chance, minimum_quantity, maximum_quantity, questid FROM drop_data WHERE dropperid = ?")) {
|
||||
ps.setInt(1, monsterId);
|
||||
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
ret.add(new MonsterDropEntry(rs.getInt("itemid"), rs.getInt("chance"), rs.getInt("minimum_quantity"), rs.getInt("maximum_quantity"), rs.getShort("questid")));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return ret;
|
||||
}
|
||||
|
||||
drops.put(monsterId, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final void setMobAttackAnimationTime(int monsterId, int attackPos, int animationTime) {
|
||||
mobAttackAnimationTime.put(new Pair<>(monsterId, attackPos), animationTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user