forked from MagicBane/Server
Merge remote-tracking branch 'origin/magicbox1.5' into new-mob-behaviour
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.objects.BootySetEntry;
|
import engine.objects.BootySetEntry;
|
||||||
import engine.objects.EquipmentSetEntry;
|
|
||||||
import engine.objects.ItemBase;
|
import engine.objects.ItemBase;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -108,49 +107,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, ArrayList<EquipmentSetEntry>> LOAD_EQUIPMENT_FOR_NPC_AND_MOBS() {
|
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<EquipmentSetEntry>> equipmentSets;
|
|
||||||
EquipmentSetEntry equipmentSetEntry;
|
|
||||||
int equipSetID;
|
|
||||||
|
|
||||||
equipmentSets = new HashMap<>();
|
|
||||||
int recordsRead = 0;
|
|
||||||
|
|
||||||
prepareCallable("SELECT * FROM static_npc_equipmentset");
|
|
||||||
|
|
||||||
try {
|
|
||||||
ResultSet rs = executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
|
|
||||||
recordsRead++;
|
|
||||||
|
|
||||||
equipSetID = rs.getInt("equipmentSet");
|
|
||||||
equipmentSetEntry = new EquipmentSetEntry(rs);
|
|
||||||
|
|
||||||
if (equipmentSets.get(equipSetID) == null){
|
|
||||||
ArrayList<EquipmentSetEntry> equipList = new ArrayList<>();
|
|
||||||
equipList.add(equipmentSetEntry);
|
|
||||||
equipmentSets.put(equipSetID, equipList);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ArrayList<EquipmentSetEntry>equipList = equipmentSets.get(equipSetID);
|
|
||||||
equipList.add(equipmentSetEntry);
|
|
||||||
equipmentSets.put(equipSetID, equipList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.info("read: " + recordsRead + " cached: " + equipmentSets.size());
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error( e.toString());
|
|
||||||
} finally {
|
|
||||||
closeCallable();
|
|
||||||
}
|
|
||||||
return equipmentSets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
|
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
|
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
|
||||||
|
|||||||
@@ -17,14 +17,9 @@ import java.util.HashMap;
|
|||||||
public enum NPCManager {
|
public enum NPCManager {
|
||||||
|
|
||||||
NPC_MANAGER;
|
NPC_MANAGER;
|
||||||
public static HashMap<Integer, ArrayList<EquipmentSetEntry>> _equipmentSetMap = new HashMap<>();
|
|
||||||
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
||||||
public static HashMap<Integer, ArrayList<BootySetEntry>> _bootySetMap = new HashMap<>();
|
public static HashMap<Integer, ArrayList<BootySetEntry>> _bootySetMap = new HashMap<>();
|
||||||
|
|
||||||
public static void LoadAllEquipmentSets() {
|
|
||||||
_equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LoadAllRuneSets() {
|
public static void LoadAllRuneSets() {
|
||||||
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
|
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2022
|
|
||||||
// www.magicbane.com
|
|
||||||
|
|
||||||
|
|
||||||
package engine.objects;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class EquipmentSetEntry {
|
|
||||||
|
|
||||||
public int itemID;
|
|
||||||
public float dropChance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ResultSet Constructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
public EquipmentSetEntry(ResultSet rs) throws SQLException {
|
|
||||||
this.itemID = (rs.getInt("itemID"));
|
|
||||||
this.dropChance = (rs.getFloat("dropChance"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -146,20 +146,20 @@ public class MobBase extends AbstractGameObject {
|
|||||||
|
|
||||||
public static HashMap<Integer, MobEquipment> loadEquipmentSet(int equipmentSetID){
|
public static HashMap<Integer, MobEquipment> loadEquipmentSet(int equipmentSetID){
|
||||||
|
|
||||||
ArrayList<EquipmentSetEntry> equipList;
|
ArrayList<BootySetEntry> equipList;
|
||||||
HashMap<Integer, MobEquipment> equip = new HashMap<>();
|
HashMap<Integer, MobEquipment> equip = new HashMap<>();
|
||||||
|
|
||||||
if (equipmentSetID == 0)
|
if (equipmentSetID == 0)
|
||||||
return equip;
|
return equip;
|
||||||
|
|
||||||
equipList = NPCManager._equipmentSetMap.get(equipmentSetID);
|
equipList = NPCManager._bootySetMap.get(equipmentSetID);
|
||||||
|
|
||||||
if (equipList == null)
|
if (equipList == null)
|
||||||
return equip;
|
return equip;
|
||||||
|
|
||||||
for (EquipmentSetEntry equipmentSetEntry : equipList) {
|
for (BootySetEntry equipmentSetEntry : equipList) {
|
||||||
|
|
||||||
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemID, equipmentSetEntry.dropChance);
|
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
|
||||||
ItemBase itemBase = mobEquipment.getItemBase();
|
ItemBase itemBase = mobEquipment.getItemBase();
|
||||||
|
|
||||||
if (itemBase != null) {
|
if (itemBase != null) {
|
||||||
|
|||||||
@@ -1642,7 +1642,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
|
|
||||||
public static boolean UpdateEquipSetID(NPC npc, int equipSetID){
|
public static boolean UpdateEquipSetID(NPC npc, int equipSetID){
|
||||||
|
|
||||||
if (!NPCManager._equipmentSetMap.containsKey(equipSetID))
|
if (!NPCManager._bootySetMap.containsKey(equipSetID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))
|
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))
|
||||||
|
|||||||
@@ -282,9 +282,6 @@ public class WorldServer {
|
|||||||
Logger.info("Loading PromotionClasses");
|
Logger.info("Loading PromotionClasses");
|
||||||
DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
|
DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
|
||||||
|
|
||||||
Logger.info("Loading NPC and Mob Equipment Sets");
|
|
||||||
NPCManager.LoadAllEquipmentSets();
|
|
||||||
|
|
||||||
Logger.info("Loading NPC and Mob Rune Sets");
|
Logger.info("Loading NPC and Mob Rune Sets");
|
||||||
NPCManager.LoadAllRuneSets();
|
NPCManager.LoadAllRuneSets();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user