diff --git a/src/engine/InterestManagement/RealmMap.java b/src/engine/InterestManagement/RealmMap.java index 89d7b4ad..57b3c71c 100644 --- a/src/engine/InterestManagement/RealmMap.java +++ b/src/engine/InterestManagement/RealmMap.java @@ -8,10 +8,6 @@ package engine.InterestManagement; -/* This class is the main interface for Magicbane's - * Interest management facilities. - */ - import engine.math.Vector3fImmutable; import engine.mbEnums; import engine.net.Dispatch; @@ -31,10 +27,17 @@ import static engine.objects.Realm.getRealm; public enum RealmMap { - REALM_MAP; + // MB Dev Notes: + // This class loads and caches realm maps used by each + // map set for its realm overlay. The RealmMap loaded is + // controlled by config entry MB_WORLD_REALMMAP + // + // Unlike a Heightmap this is a just color lookup; identical to + // the old image maps used in 90s web technology. + // + // Realm Map images are stored on disk in /mb.data/realmmaps/ - // Spatial hashmap. Used for determining which Realm - // a player is currently located within. + REALM_MAP; private static final HashMap _rgbToIDMap = new HashMap<>(); public static int[][] _realmImageMap; diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index abd0e638..c52f84a7 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -18,6 +18,14 @@ import java.util.HashMap; import static java.lang.Math.PI; + +// MB Dev Notes: +// The Terrain class handles lookups into the Heightmap data. +// It supports all current maps along with the differences in +// their parenting configuration. +// +// Heightmap images are stored on disk in /mb.data/heightmaps/ + public class Terrain { public static final HashMap _heightmap_pixel_cache = new HashMap<>(); public short[][] terrain_pixel_data; diff --git a/src/engine/db/handlers/dbContractHandler.java b/src/engine/db/handlers/dbContractHandler.java index 5cdb69f5..223417dd 100644 --- a/src/engine/db/handlers/dbContractHandler.java +++ b/src/engine/db/handlers/dbContractHandler.java @@ -10,10 +10,10 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.mbEnums; import engine.objects.Contract; import engine.objects.Item; -import engine.objects.MobLoot; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -66,7 +66,7 @@ public class dbContractHandler extends dbHandlerBase { int templateID = rs.getInt("templateID"); Item item = new Item(templateID); - item.objectUUID = MobLoot.lastNegativeID.decrementAndGet(); + item.objectUUID = ItemManager.lastNegativeID.decrementAndGet(); contract.getSellInventory().add(item); } diff --git a/src/engine/db/handlers/dbEffectsResourceCostHandler.java b/src/engine/db/handlers/dbEffectsResourceCostHandler.java index 8525144c..4ae2013a 100644 --- a/src/engine/db/handlers/dbEffectsResourceCostHandler.java +++ b/src/engine/db/handlers/dbEffectsResourceCostHandler.java @@ -10,8 +10,10 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.gameManager.PowersManager; import engine.mbEnums; import engine.objects.EffectsResourceCosts; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -19,6 +21,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; public class dbEffectsResourceCostHandler extends dbHandlerBase { @@ -27,6 +30,99 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public void GENERATE_COST_DATA() { + ArrayList effectList = GET_EFFECTS_WITH_COST(); + + for (String effectID : effectList) { + JSONObject costMap = GET_EFFECT_COSTMAP(effectID); + WRITE_COSTMAP(effectID, costMap); + } + + } + + public JSONObject GET_EFFECT_COSTMAP(String effectID) { + HashMap costMap = new HashMap<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_power_effectcost` WHERE `IDString` = ?")) { + + preparedStatement.setString(1, effectID); + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.resourceLookup.get(rs.getInt("resource")); + int value = rs.getInt("amount"); + costMap.put(resourceType, value); + } + + } catch (SQLException e) { + Logger.error(e); + } + return new JSONObject(costMap); + } + + public ArrayList GET_EFFECTS_WITH_COST() { + + ArrayList effectList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `IDString` FROM `static_power_effectcost`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + effectList.add(rs.getString("IdString")); + } + + } catch (SQLException e) { + Logger.error(e); + } + return effectList; + } + + public boolean WRITE_COSTMAP(String effectID, JSONObject costmap) { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `static_effect_costmaps` (`effectID`, `costMap`) VALUES (?, ?) " + + "ON DUPLICATE KEY UPDATE `costmap` = VALUES(`costmap`)")) { + + preparedStatement.setString(1, effectID); + preparedStatement.setString(2, costmap.toString()); + + return (preparedStatement.executeUpdate() > 0); + + } catch (SQLException e) { + Logger.error(e); + } + return false; + } + + public void LOAD_ALL_COSTMAPS() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_effect_costmaps`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + String effectID = rs.getString("effectID"); + String costString = rs.getString("costmap"); + JSONObject costJSON = new JSONObject(costString); + HashMap costmap = new HashMap<>(); + + for (String key : costJSON.keySet()) { + int value = costJSON.getInt(key); + costmap.put(mbEnums.ResourceType.valueOf(key), value); + } + + PowersManager._effect_costMaps.put(effectID, costmap); + } + + } catch (SQLException e) { + Logger.error(e); + } + } + public ArrayList GET_ALL_EFFECT_RESOURCES(String idString) { ArrayList effectsResourceCosts = new ArrayList<>(); diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 040441e0..008ca9e9 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -17,8 +17,7 @@ import engine.objects.AbstractCharacter; import engine.objects.CharacterItemManager; import engine.objects.Item; import engine.objects.ItemTemplate; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -26,6 +25,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; @@ -179,7 +179,7 @@ public class dbItemHandler extends dbHandlerBase { public void LOAD_ITEM_TEMPLATES() { - JSONParser jsonParser = new JSONParser(); + HashMap templateTCountMap = new HashMap<>(); try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_templates`;"); @@ -187,12 +187,15 @@ public class dbItemHandler extends dbHandlerBase { while (rs.next()) { int templateID = rs.getInt("id"); - JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("template")); + JSONObject jsonObject = new JSONObject(rs.getString("template")); ItemTemplate itemTemplate = new ItemTemplate(jsonObject); itemTemplate.template_id = templateID; ItemTemplate.templates.put(templateID, itemTemplate); + + templateTCountMap.merge(itemTemplate.item_type, 1, Integer::sum); } + Logger.info(templateTCountMap.toString()); } catch (Exception e) { Logger.error(e); } diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index edf1005f..38ec0fee 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -9,13 +9,12 @@ package engine.db.handlers; -import engine.mbEnums; -import engine.mbEnums.ProfitType; import engine.gameManager.DbManager; import engine.math.Vector3fImmutable; +import engine.mbEnums; +import engine.mbEnums.ProfitType; import engine.objects.NPC; import engine.objects.NPCProfits; -import engine.objects.ProducedItem; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -346,117 +345,6 @@ public class dbNPCHandler extends dbHandlerBase { + NPC._pirateNames.size() + " mobBases"); } - public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long templateID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `templateID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)")) { - - preparedStatement.setLong(1, ID); - preparedStatement.setLong(2, npcUID); - preparedStatement.setLong(3, templateID); - preparedStatement.setTimestamp(4, new java.sql.Timestamp(dateTime.getMillis())); - preparedStatement.setBoolean(5, isRandom); - preparedStatement.setString(6, prefix); - preparedStatement.setString(7, suffix); - preparedStatement.setString(8, name); - preparedStatement.setInt(9, playerID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public boolean REMOVE_FROM_PRODUCTION_LIST(final long ID, final long npcUID) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_npc_production` WHERE `ID`=? AND `npcUID`=?;")) { - - preparedStatement.setLong(1, ID); - preparedStatement.setLong(2, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public boolean UPDATE_ITEM_TO_INVENTORY(final long ID, final long npcUID) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_production` SET `inForge`=? WHERE `ID`=? AND `npcUID`=?;")) { - - preparedStatement.setByte(1, (byte) 0); - preparedStatement.setLong(2, ID); - preparedStatement.setLong(3, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public boolean UPDATE_ITEM_PRICE(final long ID, final long npcUID, int value) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_production` SET `value`=? WHERE `ID`=? AND `npcUID`=?;")) { - - preparedStatement.setInt(1, value); - preparedStatement.setLong(2, ID); - preparedStatement.setLong(3, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public boolean UPDATE_ITEM_ID(final long ID, final long npcUID, final long value) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_production` SET `ID`=? WHERE `ID`=? AND `npcUID`=? LIMIT 1;")) { - - preparedStatement.setLong(1, value); - preparedStatement.setLong(2, ID); - preparedStatement.setLong(3, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public void LOAD_ALL_ITEMS_TO_PRODUCE(NPC npc) { - - if (npc == null) - return; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_npc_production` WHERE `npcUID` = ?")) { - - preparedStatement.setInt(1, npc.getObjectUUID()); - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - ProducedItem producedItem = new ProducedItem(rs); - npc.forgedItems.add(producedItem); - } - - } catch (SQLException e) { - Logger.error(e); - } - } - public boolean UPDATE_PROFITS(NPC npc, ProfitType profitType, float value) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index f70cb5ff..10d391bb 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -9,19 +9,20 @@ package engine.db.handlers; +import engine.gameManager.DbManager; +import engine.gameManager.ForgeManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.mbEnums.TransactionType; -import engine.gameManager.DbManager; import engine.objects.Building; import engine.objects.City; import engine.objects.Transaction; import engine.objects.Warehouse; import engine.server.MBServerStatics; import org.joda.time.DateTime; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; +import org.json.JSONArray; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -106,7 +107,7 @@ public class dbWarehouseHandler extends dbHandlerBase { JSONArray locks = new JSONArray(); for (mbEnums.ResourceType resource : warehouse.locked) - locks.add(resource.name()); + locks.put(resource.name()); warehouseJSON.put("locked", locks); @@ -127,15 +128,13 @@ public class dbWarehouseHandler extends dbHandlerBase { public void LOAD_WAREHOUSES() { - JSONParser jsonParser = new JSONParser(); - try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_warehouse`;"); ResultSet rs = preparedStatement.executeQuery()) { while (rs.next()) { int cityUID = rs.getInt("cityUUID"); - JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("warehouse")); + JSONObject jsonObject = new JSONObject(rs.getString("warehouse")); City city = City.getCity(cityUID); city.warehouse = new Warehouse(jsonObject); city.warehouse.city = city; @@ -154,4 +153,71 @@ public class dbWarehouseHandler extends dbHandlerBase { Logger.error(e); } } + + public boolean WRITE_WORKORDER(WorkOrder workOrder) { + + JSONObject warehouseJSON = WorkOrder.toJson(workOrder); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_workorders` (`workorderID`, `workorder`) VALUES (?, ?) " + + "ON DUPLICATE KEY UPDATE `workorder` = VALUES(`workorder`)")) { + + preparedStatement.setInt(1, workOrder.workOrderID); + preparedStatement.setString(2, warehouseJSON.toString()); + + return (preparedStatement.executeUpdate() > 0); + + } catch (SQLException e) { + Logger.error(e); + } + return false; + } + + public void DELETE_WORKORDER(WorkOrder workOrder) { + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_workorders` WHERE `workorderID` = ?;")) { + preparedStatement.setInt(1, workOrder.workOrderID); + preparedStatement.executeUpdate(); + + } catch (SQLException e) { + Logger.error(e); + } + + } + + public void LOAD_WORKORDERS() { + + ArrayList submitList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;"); + ResultSet rs = preparedStatement.executeQuery()) { + + while (rs.next()) { + JSONObject jsonObject = new JSONObject(rs.getString("workorder")); + WorkOrder workOrder = new WorkOrder(jsonObject); + submitList.add(workOrder); + } + } catch (Exception e) { + Logger.error(e); + } + + // Remove the old workOrder records + + for (WorkOrder workOrder : submitList) + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + + // Submit the new workOrders to the ForgeManager + + for (WorkOrder workOrder : submitList) { + workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet(); + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); + + // If workorder is not yet complete process it + + if (workOrder.runCompleted == false) + ForgeManager.forge.add(workOrder); + + } + } } diff --git a/src/engine/devcmd/cmds/CreateItemCmd.java b/src/engine/devcmd/cmds/CreateItemCmd.java index 5e0bfdf9..07c2f1f5 100644 --- a/src/engine/devcmd/cmds/CreateItemCmd.java +++ b/src/engine/devcmd/cmds/CreateItemCmd.java @@ -10,9 +10,14 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; +import engine.gameManager.ChatManager; +import engine.gameManager.DbManager; +import engine.mbEnums; import engine.objects.AbstractGameObject; -import engine.objects.ItemFactory; +import engine.objects.Item; +import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; +import org.pmw.tinylog.Logger; /** * @author Eighty @@ -24,22 +29,46 @@ public class CreateItemCmd extends AbstractDevCmd { } @Override - protected void _doCmd(PlayerCharacter pc, String[] words, + protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { if (words.length < 2) { - this.sendUsage(pc); + this.sendUsage(playerCharacter); return; } int templateID = Integer.parseInt(words[0]); + ItemTemplate template = ItemTemplate.templates.get(templateID); + if (template == null) { + ChatManager.chatSystemInfo(playerCharacter, "No such template found."); + return; + } int size = 1; if (words.length == 2) size = Integer.parseInt(words[1]); - ItemFactory.fillInventory(pc, templateID, size); + for (int i = 0; i < size; i++) { + + if (!playerCharacter.charItemManager.hasRoomInventory(template.item_wt)) { + ChatManager.chatSystemInfo(playerCharacter, "You are encumbered!."); + break; + } + + Item item = new Item(templateID); + item.ownerID = playerCharacter.getObjectUUID(); + item.ownerType = mbEnums.OwnerType.PlayerCharacter; + item.containerType = mbEnums.ItemContainerType.INVENTORY; + + try { + item = DbManager.ItemQueries.PERSIST(item); + playerCharacter.charItemManager.addItemToInventory(item); + } catch (Exception e) { + Logger.error(e); + } + } + playerCharacter.charItemManager.updateInventory(); } @Override diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index c621180d..e1558930 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -23,6 +23,8 @@ import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -38,9 +40,13 @@ public enum CombatManager { if (attacker == null || target == null || !attacker.isAlive() || !target.isAlive()) return; + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + if (((Mob) attacker).nextAttackTime > System.currentTimeMillis()) + return; + switch (target.getObjectType()) { case Building: - if (((Building) target).isVulnerable() == false) + if (!((Building) target).isVulnerable()) return; break; case PlayerCharacter: @@ -59,33 +65,54 @@ public enum CombatManager { if (mainWeapon == null && offWeapon == null) { //no weapons equipped, punch with both fists processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) + processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); + return; + } + + if (mainWeapon != null && offWeapon == null) { + //swing right hand only + processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); + return; + } + + if (mainWeapon == null && offWeapon != null && !offWeapon.template.item_skill_required.containsKey("Block")) { + //swing left hand only processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - } else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { + return; + } + + if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { //no weapon equipped with a shield, punch with one hand processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - } else if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { + return; + } + + if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { //one weapon equipped with a shield, swing with one hand processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - } else if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { + return; + } + + if (mainWeapon != null && offWeapon != null && !offWeapon.template.item_skill_required.containsKey("Block")) { //two weapons equipped, swing both hands processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - } else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { - //swing left hand only - processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - } else if (mainWeapon != null && offWeapon == null) { - //swing left hand only - processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) + processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); } } public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, mbEnums.EquipSlotType slot) { - // heck if character can even attack yet + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + if (!attacker.isCombat()) + return; - if (attacker.getTimestamps().containsKey("Attack" + slot.name())) - if (System.currentTimeMillis() < attacker.getTimestamps().get("Attack" + slot.name())) + if (attacker.getTimestamps().get("Attack" + slot.name()) != null && attacker.getTimestamps().get("Attack" + slot.name()) < System.currentTimeMillis()) { + setAutoAttackJob(attacker, slot, 1000); return; + } + } // check if character is in range to attack target @@ -109,202 +136,284 @@ public enum CombatManager { float distanceSquared = attacker.loc.distanceSquared(target.loc); - if (distanceSquared > attackRange * attackRange) - return; + boolean inRange = false; + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + attackRange += ((PlayerCharacter) attacker).getCharacterHeight() * 0.5f; + } else { + attackRange += attacker.calcHitBox(); + } + switch (target.getObjectType()) { + case PlayerCharacter: + attackRange += ((PlayerCharacter) target).getCharacterHeight() * 0.5f; + if (distanceSquared < attackRange * attackRange) + inRange = true; + break; + case Mob: + attackRange += ((AbstractCharacter) target).calcHitBox(); + if (distanceSquared < attackRange * attackRange) + inRange = true; + break; + case Building: + float locX = target.loc.x - target.getBounds().getHalfExtents().x; + float locZ = target.loc.z - target.getBounds().getHalfExtents().y; + float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; + float sizeZ = (target.getBounds().getHalfExtents().y + attackRange) * 2; + Rectangle2D.Float rect = new Rectangle2D.Float(locX, locZ, sizeX, sizeZ); + if (rect.contains(new Point2D.Float(attacker.loc.x, attacker.loc.z))) + inRange = true; + break; + } - // take stamina away from attacker + //get delay for the auto attack job + long delay = 5000; if (weapon != null) { - float stam = weapon.template.item_wt / 3f; - stam = (stam < 1) ? 1 : stam; - attacker.modifyStamina(-(stam), attacker, true); - } else - attacker.modifyStamina(-0.5f, attacker, true); - - //cancel things that are cancelled by an attack - attacker.cancelOnAttackSwing(); + int wepSpeed = (int) (weapon.template.item_weapon_wepspeed); - //declare relevant variables + if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus + wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None)); - int min = attacker.minDamageHandOne; - int max = attacker.maxDamageHandOne; - int atr = attacker.atrHandOne; + if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus + wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None)); - //get the proper stats based on which slot is attacking + if (wepSpeed < 10) + wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. - if (slot == mbEnums.EquipSlotType.LHELD) { - min = attacker.minDamageHandTwo; - max = attacker.maxDamageHandTwo; - atr = attacker.atrHandTwo; + delay = wepSpeed * 100L; } - int def = 0; + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + ((Mob) attacker).nextAttackTime = System.currentTimeMillis() + delay; - if (AbstractCharacter.IsAbstractCharacter(target)) - def = ((AbstractCharacter) target).defenseRating; + if (inRange) { - //calculate hit chance based off ATR and DEF + //handle retaliate + if (AbstractCharacter.IsAbstractCharacter(target)) { + if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) { + ((AbstractCharacter) target).combatTarget = attacker; + if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat()) + combatCycle((AbstractCharacter) target, attacker); + } + } - int hitChance; - if (def == 0) - def = 1; - float dif = atr / def; - if (dif <= 0.8f) - hitChance = 4; - else - hitChance = ((int) (450 * (dif - 0.8f)) + 4); - if (target.getObjectType() == mbEnums.GameObjectType.Building) - hitChance = 100; + //check if Out of Stamina + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + if (attacker.getStamina() < (weapon.template.item_wt / 3f)) { + //set auto attack job + setAutoAttackJob(attacker, slot, delay); + return; + } + } + // take stamina away from attacker + if (weapon != null) { + float stam = weapon.template.item_wt / 3f; + stam = (stam < 1) ? 1 : stam; + attacker.modifyStamina(-(stam), attacker, true); + } else + attacker.modifyStamina(-0.5f, attacker, true); - int passiveAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); - if (attacker.charItemManager.getEquipped().get(slot) != null) { - passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true); - } + //cancel things that are cancelled by an attack - if (ThreadLocalRandom.current().nextInt(100) > hitChance) { - TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim); + attacker.cancelOnAttackSwing(); - if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) - DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - else - DispatchMessage.sendToAllInRange(attacker, msg); + //declare relevant variables - return; - } + int min = attacker.minDamageHandOne; + int max = attacker.maxDamageHandOne; + int atr = attacker.atrHandOne; - //calculate passive chances only if target is AbstractCharacter + //get the proper stats based on which slot is attacking - if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) { - mbEnums.PassiveType passiveType = mbEnums.PassiveType.None; - int hitRoll = ThreadLocalRandom.current().nextInt(100); + if (slot == mbEnums.EquipSlotType.LHELD) { + min = attacker.minDamageHandTwo; + max = attacker.maxDamageHandTwo; + atr = attacker.atrHandTwo; + } - float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true); - float blockChance = ((AbstractCharacter) target).getPassiveChance("Block", attacker.getLevel(), true); - float parryChance = ((AbstractCharacter) target).getPassiveChance("Parry", attacker.getLevel(), true); + int def = 0; - // Passive chance clamped at 75 + if (AbstractCharacter.IsAbstractCharacter(target)) + def = ((AbstractCharacter) target).defenseRating; - dodgeChance = Math.max(0, Math.min(75, dodgeChance)); - blockChance = Math.max(0, Math.min(75, blockChance)); - parryChance = Math.max(0, Math.min(75, parryChance)); + //calculate hit chance based off ATR and DEF - if (hitRoll < dodgeChance) - passiveType = mbEnums.PassiveType.Dodge; - else if (hitRoll < blockChance) - passiveType = mbEnums.PassiveType.Block; - else if (hitRoll < parryChance) - passiveType = mbEnums.PassiveType.Parry; + int hitChance; + if (def == 0) + def = 1; + float dif = atr * 1f / def; + if (dif <= 0.8f) + hitChance = 4; + else + hitChance = ((int) (450 * (dif - 0.8f)) + 4); - if (passiveType.equals(mbEnums.PassiveType.None) == false) { - TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value); + if (target.getObjectType() == mbEnums.GameObjectType.Building) + hitChance = 100; + + int passiveAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + if (attacker.charItemManager.getEquipped().get(slot) != null) { + passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true); + } + + if (ThreadLocalRandom.current().nextInt(100) > hitChance) { + TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim); if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); else DispatchMessage.sendToAllInRange(attacker, msg); + //set auto attack job + setAutoAttackJob(attacker, slot, delay); return; } - } - //calculate the base damage - int damage = ThreadLocalRandom.current().nextInt(min, max + 1); - if (damage == 0) - return; + //calculate passive chances only if target is AbstractCharacter - //get the damage type + if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) { + mbEnums.PassiveType passiveType = mbEnums.PassiveType.None; + int hitRoll = ThreadLocalRandom.current().nextInt(100); - mbEnums.DamageType damageType; + float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true); + float blockChance = ((AbstractCharacter) target).getPassiveChance("Block", attacker.getLevel(), true); + float parryChance = ((AbstractCharacter) target).getPassiveChance("Parry", attacker.getLevel(), true); - if (attacker.charItemManager.getEquipped().get(slot) == null) { - damageType = mbEnums.DamageType.CRUSHING; - if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) - if (((Mob) attacker).isSiege()) - damageType = mbEnums.DamageType.SIEGE; - } else { - damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0]; - } + // Passive chance clamped at 75 - //get resists + dodgeChance = Math.max(0, Math.min(75, dodgeChance)); + blockChance = Math.max(0, Math.min(75, blockChance)); + parryChance = Math.max(0, Math.min(75, parryChance)); - Resists resists; + if (hitRoll < dodgeChance) + passiveType = mbEnums.PassiveType.Dodge; + else if (hitRoll < blockChance) + passiveType = mbEnums.PassiveType.Block; + else if (hitRoll < parryChance) + passiveType = mbEnums.PassiveType.Parry; - if (AbstractCharacter.IsAbstractCharacter(target) == false) - resists = ((Building) target).getResists(); //this is a building - else - resists = ((AbstractCharacter) target).getResists(); //this is a character - if (AbstractCharacter.IsAbstractCharacter(target)) { - AbstractCharacter absTarget = (AbstractCharacter) target; + if (!passiveType.equals(mbEnums.PassiveType.None)) { + TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value); - //check damage shields + if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) + DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); + else + DispatchMessage.sendToAllInRange(attacker, msg); - PlayerBonuses bonuses = absTarget.getBonuses(); + //set auto attack job + setAutoAttackJob(attacker, slot, delay); + return; + } + } - if (bonuses != null) { + //calculate the base damage + int damage = ThreadLocalRandom.current().nextInt(min, max + 1); + if (damage == 0) { + //set auto attack job + setAutoAttackJob(attacker, slot, delay); + return; + } + //get the damage type - ConcurrentHashMap damageShields = bonuses.getDamageShields(); - float total = 0; + mbEnums.DamageType damageType; - for (DamageShield ds : damageShields.values()) { + if (attacker.charItemManager.getEquipped().get(slot) == null) { + damageType = mbEnums.DamageType.CRUSHING; + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + if (((Mob) attacker).isSiege()) + damageType = mbEnums.DamageType.SIEGE; + } else { + damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0]; + } - //get amount to damage back + //get resists - float amount; + Resists resists; - if (ds.usePercent()) - amount = damage * ds.getAmount() / 100; - else - amount = ds.getAmount(); + if (!AbstractCharacter.IsAbstractCharacter(target)) + resists = ((Building) target).getResists(); //this is a building + else + resists = ((AbstractCharacter) target).getResists(); //this is a character - //get resisted damage for damagetype + if (AbstractCharacter.IsAbstractCharacter(target)) { + AbstractCharacter absTarget = (AbstractCharacter) target; - if (resists != null) - amount = resists.getResistedDamage(absTarget, attacker, ds.getDamageType(), amount, 0); - total += amount; - } + //check damage shields - if (total > 0) { - //apply Damage back - attacker.modifyHealth(-total, absTarget, true); - TargetedActionMsg cmm = new TargetedActionMsg(attacker, attacker, total, 0); - DispatchMessage.sendToAllInRange(target, cmm); - } - } + PlayerBonuses bonuses = absTarget.getBonuses(); - if (resists != null) { + if (bonuses != null) { - //check for damage type immunities + ConcurrentHashMap damageShields = bonuses.getDamageShields(); + float total = 0; - if (resists.immuneTo(damageType)) - return; + for (DamageShield ds : damageShields.values()) { - //calculate resisted damage including fortitude + //get amount to damage back - damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0); - } - } + float amount; - //remove damage from target health + if (ds.usePercent()) + amount = damage * ds.getAmount() / 100; + else + amount = ds.getAmount(); - if (damage > 0) { + //get resisted damage for damagetype - if (AbstractCharacter.IsAbstractCharacter(target)) - ((AbstractCharacter) target).modifyHealth(-damage, attacker, true); - else - ((Building) target).setCurrentHitPoints(target.getCurrentHitpoints() - damage); + if (resists != null) + amount = resists.getResistedDamage(absTarget, attacker, ds.getDamageType(), amount, 0); + total += amount; + } - int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); - if (attacker.charItemManager.getEquipped().get(slot) != null) { - attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + if (total > 0) { + //apply Damage back + attacker.modifyHealth(-total, absTarget, true); + TargetedActionMsg cmm = new TargetedActionMsg(attacker, attacker, total, 0); + DispatchMessage.sendToAllInRange(target, cmm); + } + } + + if (resists != null) { + + //check for damage type immunities + + if (resists.immuneTo(damageType)) { + //set auto attack job + setAutoAttackJob(attacker, slot, delay); + return; + } + //calculate resisted damage including fortitude + + damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0); + } + } + + //remove damage from target health + + if (damage > 0) { + + if (AbstractCharacter.IsAbstractCharacter(target)) + ((AbstractCharacter) target).modifyHealth(-damage, attacker, true); + else + ((Building) target).setCurrentHitPoints(target.getCurrentHitpoints() - damage); + + int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + if (attacker.charItemManager.getEquipped().get(slot) != null) { + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + DeferredPowerJob weaponPower = ((PlayerCharacter) attacker).getWeaponPower(); + attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, weaponPower, slot.equals(mbEnums.EquipSlotType.RHELD)); + }else { + attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + } + } + TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); + DispatchMessage.sendToAllInRange(target, cmm); } - TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); - DispatchMessage.sendToAllInRange(target, cmm); } + DeferredPowerJob dpj = null; if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { @@ -318,39 +427,9 @@ public enum CombatManager { ((PlayerCharacter) attacker).setWeaponPower(dpj); } } - //calculate next allowed attack and update the timestamp - long delay = 20 * 100; - - if (weapon != null) { - - int wepSpeed = (int) (weapon.template.item_weapon_wepspeed); - - if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus - wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None)); - - if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus - wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None)); - - if (wepSpeed < 10) - wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. - - delay = wepSpeed * 100; - } - - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - - //handle auto attack job creation - - ConcurrentHashMap timers = attacker.getTimers(); - - if (timers != null) { - AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); - JobContainer job; - job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue - timers.put("Attack" + slot, job); - } else - Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + //set auto attack job + setAutoAttackJob(attacker, slot, delay); } @@ -411,116 +490,51 @@ public enum CombatManager { public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, boolean mainHand) { - int token = 0; + int token; - if (dpj != null) - token = (dpj.getPower() != null) ? dpj.getPower().getToken() : 0; + if (dpj != null) { - if (token == 563721004) //kick animation - return 79; - - if (wb == null) - return 75; - - ItemTemplate template = wb; - - if (mainHand) { - if (template.weapon_attack_anim_right.size() > 0) { - - int animation; - - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_right.size()); - - try { - animation = template.weapon_attack_anim_right.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; - } - - } else if (template.weapon_attack_anim_left.size() > 0) { - - int animation; - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size()); + token = (dpj.getPower() != null) ? dpj.getPower().getToken() : 0; - try { - animation = template.weapon_attack_anim_left.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; + if (token == 563721004) //kick animation + return 79; + + if (wb != null) { + if (mainHand) { + int random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); + int anim = wb.weapon_attack_anim_right.get(random)[0]; + return anim; + }else { + int random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); + return wb.weapon_attack_anim_left.get(random)[0]; } } - } else { - if (template.weapon_attack_anim_left.size() > 0) { - - int animation; - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size()); - - try { - animation = template.weapon_attack_anim_left.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; - - } - } else if (template.weapon_attack_anim_left.size() > 0) { + } - int animation; - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size()); + if (wb == null) + return 75; - try { - animation = template.weapon_attack_anim_left.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; + if (mainHand) + return wb.weapon_attack_anim_right.get(0)[0]; + else + return wb.weapon_attack_anim_left.get(0)[0]; - } + } - } - } + public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) { + //calculate next allowed attack and update the timestamp + attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - String required = template.item_skill_used; - String mastery = wb.item_skill_mastery_used; + //handle auto attack job creation + ConcurrentHashMap timers = attacker.getTimers(); - if (required.equals("Unarmed Combat")) - return 75; - else if (required.equals("Sword")) { + if (timers != null) { + AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); + JobContainer job; + job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue + timers.put("Attack" + slot, job); + } else + Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); - if (ItemManager.isTwoHanded(template)) - return 105; - else - return 98; - - } else if (required.equals("Staff") || required.equals("Pole Arm")) { - return 85; - } else if (required.equals("Spear")) { - return 92; - } else if (required.equals("Hammer") || required.equals("Axe")) { - if (ItemManager.isTwoHanded(template)) { - return 105; - } else if (mastery.equals("Throwing")) { - return 115; - } else { - return 100; - } - } else if (required.equals("Dagger")) { - if (mastery.equals("Throwing")) { - return 117; - } else { - return 81; - } - } else if (required.equals("Crossbow")) { - return 110; - } else if (required.equals("Bow")) { - return 109; - } else if (ItemManager.isTwoHanded(template)) { - return 105; - } else { - return 100; - } } } \ No newline at end of file diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index a3a7a258..e49b0f2c 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -8,10 +8,6 @@ package engine.gameManager; -/* This enumeration implements Magicbane's configuration data which - is loaded from environment variables. - */ - import engine.mbEnums; import engine.server.login.LoginServer; import engine.server.world.WorldServer; @@ -27,6 +23,14 @@ import java.util.regex.Pattern; public enum ConfigManager { + // MB Dev notes: + // Magicbane configuration is loaded from environment variables + // + // On boot the game first looks in /mb.conf for the file magicbane.conf. + // + // If not found, a default config is loaded from /mb.data to enable bootstrap. + // This version should never be modified. + MB_BIND_ADDR, MB_EXTERNAL_ADDR, @@ -105,11 +109,11 @@ public enum ConfigManager { // and determine the server type at runtime. public static final String DEFAULT_DATA_DIR = "mb.data/"; - public static Map configMap = new HashMap(System.getenv()); + public static final Map configMap = new HashMap(System.getenv()); public static mbEnums.ServerType serverType = mbEnums.ServerType.NONE; public static WorldServer worldServer; public static LoginServer loginServer; - public static Map regex = new HashMap<>(); + public static final Map regex = new HashMap<>(); public static String currentRepoBranch = ""; @@ -124,7 +128,7 @@ public enum ConfigManager { Logger.info(configSetting.name() + ":" + configSetting.getValue()); else { Logger.error("Missing Config: " + configSetting.name()); - Logger.error("This codebase requires >= MagicBox v1.5.1"); + Logger.error("This codebase requires >= MagicBox v1.5.2"); Logger.error("docker pull magicbane/magicbox:latest"); return false; } diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java new file mode 100644 index 00000000..c5e09219 --- /dev/null +++ b/src/engine/gameManager/ForgeManager.java @@ -0,0 +1,408 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.gameManager; + +import engine.loot.ModTableEntry; +import engine.loot.ModTypeTableEntry; +import engine.loot.WorkOrder; +import engine.mbEnums; +import engine.net.DispatchMessage; +import engine.net.client.msg.ItemProductionMsg; +import engine.objects.City; +import engine.objects.Item; +import engine.objects.ItemTemplate; +import engine.objects.NPC; +import engine.powers.EffectsBase; +import org.pmw.tinylog.Logger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; + +public enum ForgeManager implements Runnable { + + // MB Dev notes: + // Class implements forge rolling mechanics for Magicbane. + // + // .submit(workOrder) may be called from any thread: (ItemProductionMsgHandler). + // Concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock). + // WorkOrders are persisted then reconstituted at bootstrap using table dyn.workorders. + // + // Replaces garbage code that looked as if written by a mental patient with face boils. + + FORGE_MANAGER; + + public static final BlockingQueue forge = new DelayQueue<>(); + public static final AtomicInteger workOrderCounter = new AtomicInteger(0); + public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); + + @Override + + public void run() { + + WorkOrder workOrder; + + while (true) { + + // .forge is a delayQueue (blocking priority queue using an epoc sort) + // workOrders are popped and processed when their completion time has passed. + + try { + workOrder = forge.take(); + + // This workOrder has completed production. + + if (workOrder.total_produced >= workOrder.total_to_produce) { + + // Set items as completed in the window. + // First CONFIRM_PRODUCE adds virtual item to the interface. + // Second CONFIRM_PRODUCE sets virtual item to complete. + + for (Item workOrderItem : workOrder.cooking) { + workOrderItem.flags.add(mbEnums.ItemFlags.Identified); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + } + + workOrder.runCompleted = true; + + // Update workOrder on disk + + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); + } + + if (workOrder.runCompleted) + continue; + + // Move current cooking batch to vendor inventory + + completeWorkOrderBatch(workOrder); + + // Create new set of in-memory only virtual items + + forgeWorkOrderBatch(workOrder); + + // enQueue this workOrder again; back into the oven + // until all items for this workOrder are completed. + + forge.add(workOrder); + + // Debugging: Logger.info(workOrder.toString()); + + } catch (Exception e) { + Logger.error(e); + } + } + } + + public static void start() { + + Thread forgeManager; + forgeManager = new Thread(FORGE_MANAGER); + forgeManager.setName("Forge Manager"); + forgeManager.start(); + } + + public static int submit(WorkOrder workOrder) { + + // Must have a city to roll anything + + City city = workOrder.vendor.building.getCity(); + + if (city == null) + return 58; //58: The formula is beyond the means of this facility + + // Concurrency is rightly managed by same lock as warehouse + + city.transactionLock.writeLock().lock(); + + // Make sure vendor can roll the formulae, warehouse can + // afford this wordOrder and other related checks. + + int validation_result = WorkOrder.validate(workOrder); + + // The return code is used by the caller (ItemProductionMsgHandler) + // for display of a popup error message to the player. + + if (validation_result != 0) + return validation_result; + + try { + // Configure this production run. + + workOrder.workOrderID = workOrderCounter.incrementAndGet(); + workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; + workOrder.slots_used = calcAvailableSlots(workOrder); + + workOrder.total_produced = 0; + + // Single item configuration + + if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) + workOrder.total_to_produce = 1; + + // Set total cost for production run + + workOrder.total_to_produce *= workOrder.slots_used; + + workOrder.production_cost = calcProductionCost(workOrder); + workOrder.production_cost_total.putAll(workOrder.production_cost); + workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); + + // Withdraw gold and resource costs. Availability has previously been validated. + + if (!WorkOrder.withdrawWorkOrderCost(workOrder)) + return 58; //58: The formula is beyond the means of this facility + + // Create new batch of virtual items + + forgeWorkOrderBatch(workOrder); + + // Enqueue workOrder in the .forge and then + // add the workOrder to it's vendor + + vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); + forge.add(workOrder); + + // PERSIST workOrder (dyn_workorders) + + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); + + } catch (Exception e) { + Logger.error(e); + } finally { + city.transactionLock.writeLock().unlock(); + } + Logger.info(workOrder.toString()); + return validation_result; + } + + public static long calcRollingDuration(WorkOrder workOrder) { + + float rollingDuration; + + rollingDuration = workOrder.vendor.getBuilding().getRank() * -5L + 40; + rollingDuration = TimeUnit.MINUTES.toMillis((long) rollingDuration); + rollingDuration *= Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()); + + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + // Bane circles + + if (template.item_bane_rank > 0) + rollingDuration = (long) template.item_bane_rank * 60 * 60 * 3 * 1000 * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()); + + return (long) rollingDuration; + } + + public static int calcAvailableSlots(WorkOrder workOrder) { + + // Slots available in a forge are based on the npc rank + + int availableSlots = workOrder.vendor.getRank(); + + // Subtract the slots currently assigned to other workOrders for this vendor + + for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) + availableSlots = availableSlots - npcWorkOrder.cooking.size(); + + // Single item rolls are always a single slot + + if (availableSlots > 0 && !workOrder.multiple_slot_request) + availableSlots = 1; + + return availableSlots; + } + + public static HashMap calcProductionCost(WorkOrder workOrder) { + + // Calculate production cost for a single run of the workOrder + + HashMap production_cost = new HashMap<>(); + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + // Add gold and resource costs from template + + production_cost.put(mbEnums.ResourceType.GOLD, template.item_value); + production_cost.putAll(template.item_resource_cost); + + // Calculate cost of prefix and suffix + + if (workOrder.prefixToken != 0) { + EffectsBase prefix = PowersManager.getEffectByToken(workOrder.prefixToken); + production_cost.putAll(PowersManager._effect_costMaps.get(prefix.getIDString())); + } + + if (workOrder.suffixToken != 0) { + EffectsBase suffix = PowersManager.getEffectByToken(workOrder.suffixToken); + production_cost.putAll(PowersManager._effect_costMaps.get(suffix.getIDString())); + } + + return production_cost; + } + + public static Item forgeItem(WorkOrder workOrder) { + + // Create new virtual item from specified template + + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + Item forgedItem = new Item(workOrder.templateID); + + // forgedItem gets a negative id; a virtual item which is not persisted + + forgedItem.objectUUID = ItemManager.lastNegativeID.getAndDecrement(); + forgedItem.containerType = mbEnums.ItemContainerType.FORGE; + forgedItem.ownerID = workOrder.vendor.getObjectUUID(); + + // item.upgradeDate is serialized (ItemProductionMsg) + // for vendor forge window completion time. + + forgedItem.setDateToUpgrade(workOrder.completionTime); + + // Assign a prefix and suffix to this item if random rolled + + if (workOrder.prefixToken == 0) + forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); + else + forgedItem.prefixToken = workOrder.prefixToken; + + if (workOrder.suffixToken == 0) + forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable); + else + forgedItem.suffixToken = workOrder.suffixToken; + + // Random rolled items are unidentified until completed + + if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) + forgedItem.flags.remove(mbEnums.ItemFlags.Identified); + else + forgedItem.flags.add(mbEnums.ItemFlags.Identified); + + // Add virtual item to in-memory caches + + workOrder.cooking.add(forgedItem); + DbManager.addToCache(forgedItem); + itemWorkOrderLookup.put(forgedItem, workOrder); + + return forgedItem; + } + + public static void completeWorkOrderBatch(WorkOrder workOrder) { + + ArrayList toRemove = new ArrayList<>(); + + for (Item virutalItem : workOrder.cooking) { + + // Identify completed items + + virutalItem.flags.add(mbEnums.ItemFlags.Identified); + virutalItem.containerType = mbEnums.ItemContainerType.INVENTORY; + + // Persist item + + Item completedItem = DbManager.ItemQueries.PERSIST(virutalItem); + + // Copy Prefix and Suffix tokens from virtual item. + + completedItem.prefixToken = virutalItem.prefixToken; + completedItem.suffixToken = virutalItem.suffixToken; + + // Add effects to these tokens. Writes to disk. + + ItemManager.applyItemEffects(completedItem); + + // Add to the vendor inventory + + workOrder.vendor.charItemManager.addItemToInventory(completedItem); + + ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + toRemove.add(virutalItem); + } + + for (Item virtualItem : toRemove) { + + // Remove virtual items from the forge window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + // Remove virtual item from all collections + + workOrder.cooking.remove(virtualItem); + itemWorkOrderLookup.remove(virtualItem); + DbManager.removeFromCache(virtualItem); + } + } + + public static void forgeWorkOrderBatch(WorkOrder workOrder) { + + // Completion time for this batch is in the future + + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; + + for (int i = 0; i < workOrder.slots_used; ++i) { + + Item forged_item = forgeItem(workOrder); + + // Update NPC window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, forged_item, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.total_produced = workOrder.total_produced + 1; + } + + // Write updated workOrder to disk + + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); + + } + + public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) { + + // Random prefix or suffix token based on item.template.modtable + + int modifier = 0; + ModTypeTableEntry modTypeTableEntry = null; + ModTableEntry modTableEntry; + int rollForModifier; + + switch (itemModType) { + case PREFIX: + int randomPrefix = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(modTable)); + modTypeTableEntry = ModTypeTableEntry.rollTable(randomPrefix, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + break; + case SUFFIX: + int randomSuffix = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(modTable)); + modTypeTableEntry = ModTypeTableEntry.rollTable(randomSuffix, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + break; + } + + if (modTypeTableEntry == null) + return 0; + + rollForModifier = ThreadLocalRandom.current().nextInt(1, 100 + 1); + + if (rollForModifier < 80) { + int randomModifier = LootManager.TableRoll(vendor.getLevel(), false); + modTableEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, randomModifier); + EffectsBase effectsBase = PowersManager.getEffectByIDString(modTableEntry.action); + modifier = effectsBase.getToken(); + } + + return modifier; + } + +} diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 149aa121..76bd7f0f 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -2,10 +2,12 @@ package engine.gameManager; import engine.mbEnums; import engine.objects.*; +import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; // • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ @@ -17,6 +19,8 @@ import java.util.concurrent.ConcurrentHashMap; public enum ItemManager { ITEMMANAGER; + public static final AtomicInteger lastNegativeID = new AtomicInteger(0); + public static Boolean ValidRace(Item item, mbEnums.MonsterType race) { if (item.template.item_race_req.isEmpty() && item.template.item_race_res.isEmpty()) @@ -27,7 +31,7 @@ public enum ItemManager { return true; if (item.template.item_race_res.isEmpty() == false) - if (item.template.item_class_res.contains(race) == false) + if (item.template.item_race_res.contains(race) == false) return true; return false; @@ -185,7 +189,10 @@ public enum ItemManager { if (!validForSkills(item, abstractCharacter.getSkills())) return false; - if (canCharacterEquip(item, abstractCharacter) == false) + if (!ValidRace(item, abstractCharacter.absRace)) + return false; + + if (!ValidClass(item, abstractCharacter.absBaseClass,abstractCharacter.absPromotionClass)) return false; //players can't wear 0 value items. @@ -220,4 +227,18 @@ public enum ItemManager { return true; } + + public static void applyItemEffects(Item forgedItem) { + + if (forgedItem.prefixToken != 0) { + EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); + forgedItem.addPermanentEnchantment(prefix.getIDString(), 0); + } + + if (forgedItem.suffixToken != 0) { + EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); + forgedItem.addPermanentEnchantment(suffix.getIDString(), 0); + } + + } } diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index e70cf827..aa31e0bc 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -80,17 +80,10 @@ public enum LootManager { RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); //lastly, check mobs inventory for godly or disc runes to send a server announcement - for (Item it : mob.getInventory()) { + for (Item item : mob.getInventory()) { - ItemTemplate ib = it.template; - - if (ib == null) - break; - - ItemTemplate template = ItemTemplate.templates.get(it.templateID); - - if ((it.templateID > 2499 && it.templateID <= 3050) || template.item_base_name.toLowerCase().contains("of the gods")) { - ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?"); + if ((item.templateID > 2499 && item.templateID <= 3050) || item.template.item_base_name.toLowerCase().contains("of the gods")) { + ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + item.template.item_base_name + ". Are you tough enough to take it?"); chatMsg.setMessageType(10); chatMsg.setChannel(mbEnums.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); @@ -219,7 +212,7 @@ public enum LootManager { int prefixTableRoll = 0; - if (mob.getObjectType().ordinal() == 52) + if (mob.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) prefixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); else prefixTableRoll = TableRoll(mob.level, inHotzone); @@ -229,7 +222,7 @@ public enum LootManager { if (prefixMod == null) return inItem; - if (prefixMod.action.length() > 0) { + if (prefixMod.action.isEmpty() == false) { inItem.setPrefix(prefixMod.action); inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); } @@ -253,7 +246,7 @@ public enum LootManager { int suffixTableRoll; - if (mob.getObjectType().ordinal() == 52) + if (mob.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) suffixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); else suffixTableRoll = TableRoll(mob.level, inHotzone); @@ -263,7 +256,7 @@ public enum LootManager { if (suffixMod == null) return inItem; - if (suffixMod.action.length() > 0) { + if (suffixMod.action.isEmpty() == false) { inItem.setSuffix(suffixMod.action); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); } @@ -277,14 +270,10 @@ public enum LootManager { mobLevel = 65; int max = (int) (4.882 * mobLevel + 127.0); - - if (max > 319) - max = 319; - int min = (int) (4.469 * mobLevel - 3.469); - if (min < 70) - min = 70; + min = Math.max(min, 70); + max = Math.min(max, 319); if (inHotzone) min += mobLevel; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 54efa093..59e348e0 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -9,6 +9,7 @@ package engine.gameManager; import engine.InterestManagement.WorldGrid; +import engine.loot.WorkOrder; import engine.math.Quaternion; import engine.math.Vector3f; import engine.math.Vector3fImmutable; @@ -26,6 +27,7 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.acos; @@ -516,4 +518,16 @@ public enum NPCManager { return true; } + + public static ArrayList getAllCookingForVendor(NPC npc) { + + ArrayList itemList = new ArrayList<>(); + + ConcurrentHashMap.KeySetView vendorWorkOrders = ForgeManager.vendorWorkOrderLookup.get(npc); + + for (WorkOrder workOrder : vendorWorkOrders) + itemList.addAll(workOrder.cooking); + + return itemList; + } } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 4578f79f..77c19da1 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -57,6 +57,7 @@ public enum PowersManager { public static HashMap AnimationOverrides = new HashMap<>(); public static HashMap> _allRunePowers; public static HashMap> _allRuneSkillAdjusts; + public static HashMap> _effect_costMaps = new HashMap<>(); private static JobScheduler js; public static void initPowersManager(boolean fullPowersLoad) { diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 1ac64199..cbe9f13d 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -24,10 +24,16 @@ import java.time.Duration; import java.time.Instant; import java.util.Collection; -/* - * This class contains all methods necessary to drive periodic - * updates of the game simulation from the main _exec loop. - */ +// MB Dev Notes: +// +// Class models timers that drive Magicbane simulation ticks used +// for movement updates, triggers and more. Eventually we hope to +// refactor to more of a traditional simulation appropriate for a +// mmo with a transform class and other bells and whistles. +// +// Do as little as possible in here. For any tick you do not want +// deltaTime to approach 1.0f. + public enum SimulationManager { SERVERHEARTBEAT; @@ -35,15 +41,14 @@ public enum SimulationManager { private static final long CITY_PULSE = 2000; private static final long RUNEGATE_PULSE = 3000; private static final long UPDATE_PULSE = 1000; - private static final long FlIGHT_PULSE = 100; + private static final long FLIGHT_PULSE = 100; public static Duration executionTime = Duration.ofNanos(1); public static Duration executionMax = Duration.ofNanos(1); - private static SimulationManager instance = null; private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; private long _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE; - private long _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE; + private long _flightPulseTime = System.currentTimeMillis() + FLIGHT_PULSE; private SimulationManager() { @@ -181,7 +186,7 @@ public enum SimulationManager { player.updateFlight(); } - _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE; + _flightPulseTime = System.currentTimeMillis() + FLIGHT_PULSE; } private void pulseCities() { diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java new file mode 100644 index 00000000..ebd2fc83 --- /dev/null +++ b/src/engine/loot/WorkOrder.java @@ -0,0 +1,255 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.loot; + +import engine.gameManager.DbManager; +import engine.gameManager.ForgeManager; +import engine.mbEnums; +import engine.objects.Item; +import engine.objects.ItemTemplate; +import engine.objects.NPC; +import engine.objects.Warehouse; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + +public class WorkOrder implements Delayed { + + // MB Dev notes: + // Class defines a Forge rolling request made through a + // vendor; then passed to the ForgeManager singleton + // for completion. + // + // A workOrder once created will last until all items are + // either completed or junked. They are persisted in the + // table dyn_workorders. + + public int workOrderID; + public NPC vendor; + public int slots_used; + public int total_to_produce; + public int total_produced; + public boolean multiple_slot_request; + public HashMap production_cost = new HashMap<>(); + public HashMap production_cost_total = new HashMap<>(); + public int templateID; + public String item_name_override; + public int prefixToken; + public int suffixToken; + public long rollingDuration; + public long completionTime; + public boolean runCompleted = false; + public boolean runCanceled = false; + + // This collection is serialized to the vendor rolling window in ManageNPCMsg. + + public ConcurrentHashMap.KeySetView cooking = ConcurrentHashMap.newKeySet(); + + public WorkOrder() { + + } + + public WorkOrder(JSONObject jsonWorkOrder) { + + // This constructor is used to load workOrders from disk + // during bootstrap. (dyn_workorders) + + this.workOrderID = jsonWorkOrder.getInt("workOrderID"); + this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); + this.slots_used = jsonWorkOrder.getInt("slots_used"); + this.total_to_produce = jsonWorkOrder.getInt("total_to_produce"); + this.total_produced = jsonWorkOrder.getInt("total_produced"); + this.multiple_slot_request = jsonWorkOrder.getBoolean("multiple_slot_request"); + this.templateID = jsonWorkOrder.getInt("templateID"); + this.item_name_override = jsonWorkOrder.getString("item_name_override"); + this.prefixToken = jsonWorkOrder.getInt("prefixToken"); + this.suffixToken = jsonWorkOrder.getInt("suffixToken"); + this.slots_used = jsonWorkOrder.getInt("slots_used"); + this.rollingDuration = jsonWorkOrder.getLong("rollingDuration"); + this.completionTime = jsonWorkOrder.getLong("completionTime"); + this.runCompleted = jsonWorkOrder.getBoolean("runCompleted"); + + JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost"); + + for (String key : productionCostMap.keySet()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); + int value = productionCostMap.getInt(key); + this.production_cost.put(resourceType, value); + } + + JSONObject productionTotalCostMap = jsonWorkOrder.getJSONObject("production_cost_total"); + + for (String key : productionTotalCostMap.keySet()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); + int value = productionTotalCostMap.getInt(key); + this.production_cost_total.put(resourceType, value); + } + + // Reconstruct cooking items + + JSONArray tokenList = jsonWorkOrder.getJSONArray("cookingTokens"); + + for (Object o : tokenList) { + int prefix = ((JSONArray) o).getInt(0); + int suffix = ((JSONArray) o).getInt(1); + Item cookingItem = ForgeManager.forgeItem(this); + cookingItem.prefixToken = prefix; + cookingItem.suffixToken = suffix; + cookingItem.setDateToUpgrade(this.completionTime); + } + } + + public static int validate(WorkOrder workOrder) { + + // Validate that a workOrder can be completed by both + // the vendor and the forge. + + int validation_result = 0; + + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + if (workOrder.vendor.getBuilding() == null) + return 58; //58: The formula is beyond the means of this facility + + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) + return 30; //30: That person cannot carry that item + + if (!workOrder.vendor.getItemModTable().contains((template.modTable))) + return 59; //59: This hireling does not have this formula + + if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) + return 10; //18: You can't really afford that + + // Forge must be protected in order to access warehouse. + + if (ForgeManager.calcProductionCost(workOrder).size() > 1) + if (!EnumSet.of(mbEnums.ProtectionState.PROTECTED, mbEnums.ProtectionState.CONTRACT).contains(workOrder.vendor.building.protectionState)) + return 193; //193: Production denied: This building must be protected to gain access to warehouse + + return validation_result; + } + + public static boolean withdrawWorkOrderCost(WorkOrder workOrder) { + + if (workOrder.vendor.building.getCity() == null) + return false; + + int strongbox = workOrder.vendor.building.getStrongboxValue(); + + // Strongbox can cover total gold cost; + + if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) <= strongbox) { + + workOrder.vendor.building.setStrongboxValue(strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, 0); + + // Early exit for Strongbox covering gold only rolls + + if (workOrder.production_cost_total.size() == 1) + return true; + } else { + int remainingAmount = workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - strongbox; + workOrder.vendor.building.setStrongboxValue(0); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - remainingAmount); + } + + // There is an overflow at this point and a warehouse is required + + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return false; + + // Deduct total production cost from warehouse + + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); + DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); + + return true; + } + + @Override + public long getDelay(TimeUnit unit) { + long timeRemaining = completionTime - System.currentTimeMillis(); + return unit.convert(timeRemaining, TimeUnit.MILLISECONDS); + } + + @Override + public int compareTo(Delayed o) { + return Long.compare(this.completionTime, ((WorkOrder) o).completionTime); + } + + public static JSONObject toJson(WorkOrder workOrder) { + + // Workorders are persisted in JSON format. + + JSONObject jsonWorkOrder = new JSONObject(); + + jsonWorkOrder.put("workOrderID", workOrder.workOrderID); + jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); + jsonWorkOrder.put("slots_used", workOrder.slots_used); + jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); + jsonWorkOrder.put("total_produced", workOrder.total_produced); + jsonWorkOrder.put("multiple_slot_request", workOrder.multiple_slot_request); + jsonWorkOrder.put("production_cost", workOrder.production_cost); + jsonWorkOrder.put("production_cost_total", workOrder.production_cost_total); + jsonWorkOrder.put("templateID", workOrder.templateID); + jsonWorkOrder.put("item_name_override", workOrder.item_name_override); + jsonWorkOrder.put("prefixToken", workOrder.prefixToken); + jsonWorkOrder.put("suffixToken", workOrder.suffixToken); + jsonWorkOrder.put("rollingDuration", workOrder.rollingDuration); + jsonWorkOrder.put("completionTime", workOrder.completionTime); + jsonWorkOrder.put("runCompleted", workOrder.runCompleted); + + ArrayList cookingTokens = new ArrayList<>(); + + for (Item item : workOrder.cooking) + cookingTokens.add(new Integer[]{item.prefixToken, item.suffixToken}); + + jsonWorkOrder.put("cookingTokens", cookingTokens); + + return jsonWorkOrder; + } + + public String toString() { + + LocalDateTime localDateTime = Instant.ofEpochMilli(this.completionTime) + .atZone(ZoneId.systemDefault()).toLocalDateTime(); + Duration duration = Duration.ofMillis(this.rollingDuration); + + String outSTring = "\r\nwordOrderID: " + this.workOrderID + "\r\n" + + "vendor: " + this.vendor.getObjectUUID() + "\r\n" + + "slots_used: " + this.slots_used + "\r\n" + + "total_to_produce: " + this.total_to_produce + "\r\n" + + "total_produced: " + this.total_produced + "\r\n" + + "templateID: " + this.templateID + "\r\n" + + "item_name_override: " + this.item_name_override + "\r\n" + + "prefixToken: " + this.prefixToken + "\r\n" + + "suffixToken: " + this.suffixToken + "\r\n" + + "rollingDuration: " + duration + "\r\n" + + "completionTime: " + localDateTime + "\r\n" + + "runCompleted: " + this.runCompleted + "\r\n" + + "runCanceled: " + this.runCanceled + "\r\n" + + "productionCost: " + this.production_cost.toString() + "\r\n" + + "totalProductionCost:: " + this.production_cost_total.toString(); + + return outSTring; + } + +} diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index 251aee27..720ede75 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -3024,5 +3024,25 @@ public class mbEnums { } } + + public enum ProductionActionType { + NONE, + PRODUCE, + JUNK, + RECYCLE, + COMPLETE, + SETPRICE, + DEPOSIT, + TAKE, + CONFIRM_PRODUCE, + CONFIRM_SETPRICE, + CONFIRM_DEPOSIT, + CONFIRM_TAKE; + } + + public enum ItemModType { + PREFIX, + SUFFIX; + } } diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index e51b7e34..2f62fdfa 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -38,7 +38,7 @@ import static engine.math.FastMath.sqr; public class MobAI { - private static void AttackTarget(Mob mob, AbstractWorldObject target) { + private static void attackTarget(Mob mob, AbstractWorldObject target) { try { @@ -58,7 +58,7 @@ public class MobAI { if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter && canCast(mob)) { - if (MobCast(mob)) { + if (mobCast(mob)) { mob.updateLocation(); return; } @@ -71,15 +71,15 @@ public class MobAI { switch (target.getObjectType()) { case PlayerCharacter: PlayerCharacter targetPlayer = (PlayerCharacter) target; - AttackPlayer(mob, targetPlayer); + attackPlayer(mob, targetPlayer); break; case Building: Building targetBuilding = (Building) target; - AttackBuilding(mob, targetBuilding); + attackBuilding(mob, targetBuilding); break; case Mob: Mob targetMob = (Mob) target; - AttackMob(mob, targetMob); + attackMob(mob, targetMob); break; } @@ -90,7 +90,7 @@ public class MobAI { } } - public static void AttackPlayer(Mob mob, PlayerCharacter target) { + public static void attackPlayer(Mob mob, PlayerCharacter target) { try { @@ -100,7 +100,7 @@ public class MobAI { } if (mob.behaviourType.callsForHelp) - MobCallForHelp(mob); + mobCallForHelp(mob); if (!MovementUtilities.inRangeDropAggro(mob, target)) { mob.setCombatTarget(null); @@ -128,7 +128,7 @@ public class MobAI { } - public static void AttackBuilding(Mob mob, Building target) { + public static void attackBuilding(Mob mob, Building target) { try { @@ -162,7 +162,7 @@ public class MobAI { } } - public static void AttackMob(Mob mob, Mob target) { + public static void attackMob(Mob mob, Mob target) { try { @@ -179,7 +179,7 @@ public class MobAI { } } - private static void Patrol(Mob mob) { + private static void patrol(Mob mob) { try { @@ -230,7 +230,7 @@ public class MobAI { for (Integer minionUUID : mob.minions) { Mob minion = Mob.getMob(minionUUID); if (minion.isAlive() && minion.combatTarget == null) - MobAI.Patrol(minion); + MobAI.patrol(minion); } MovementUtilities.aiMove(mob, mob.destination, true); @@ -284,7 +284,7 @@ public class MobAI { return false; } - public static boolean MobCast(Mob mob) { + public static boolean mobCast(Mob mob) { try { // Method picks a random spell from a mobile's list of powers @@ -296,7 +296,7 @@ public class MobAI { AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); if (mob.behaviourType.callsForHelp) - MobCallForHelp(mob); + mobCallForHelp(mob); // Generate a list of tokens from the mob powers for this mobile. @@ -410,7 +410,7 @@ public class MobAI { return powerRank; } - public static void MobCallForHelp(Mob mob) { + public static void mobCallForHelp(Mob mob) { try { @@ -445,7 +445,7 @@ public class MobAI { } } - public static void DetermineAction(Mob mob) { + public static void determineAction(Mob mob) { try { @@ -465,7 +465,7 @@ public class MobAI { //trebuchet spawn handler if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { - CheckForRespawn(mob); + checkForRespawn(mob); return; } @@ -486,12 +486,12 @@ public class MobAI { } } - CheckForRespawn(mob); + checkForRespawn(mob); //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting if (!mob.agentType.equals(mbEnums.AIAgentType.PET)) - CheckToSendMobHome(mob); + checkToSendMobHome(mob); return; } @@ -499,7 +499,7 @@ public class MobAI { //no need to continue if mob is dead, check for respawn and move on if (!mob.isAlive()) { - CheckForRespawn(mob); + checkForRespawn(mob); return; } @@ -520,7 +520,7 @@ public class MobAI { if (mob.agentType.equals(mbEnums.AIAgentType.PET) == false) - CheckToSendMobHome(mob); + checkToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -550,17 +550,17 @@ public class MobAI { case GuardCaptain: case GuardMinion: case GuardWallArcher: - GuardLogic(mob); + guardLogic(mob); break; case Pet1: case SiegeEngine: - PetLogic(mob); + petLogic(mob); break; case HamletGuard: - HamletGuardLogic(mob); + hamletGuardLogic(mob); break; default: - DefaultLogic(mob); + defaultLogic(mob); break; } } catch (Exception e) { @@ -568,7 +568,7 @@ public class MobAI { } } - private static void CheckForAggro(Mob aiAgent) { + private static void checkForAggro(Mob aiAgent) { try { @@ -642,7 +642,7 @@ public class MobAI { } } - private static void CheckMobMovement(Mob mob) { + private static void checkMobMovement(Mob mob) { try { @@ -685,9 +685,9 @@ public class MobAI { // Minions only patrol on their own if captain is dead. if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION) == false) - Patrol(mob); + patrol(mob); else if (mob.guardCaptain.isAlive() == false) - Patrol(mob); + patrol(mob); } else mob.stopPatrolTime = System.currentTimeMillis(); } else { @@ -700,7 +700,7 @@ public class MobAI { } } - private static void CheckForRespawn(Mob aiAgent) { + private static void checkForRespawn(Mob aiAgent) { try { @@ -747,7 +747,7 @@ public class MobAI { } } - public static void CheckForAttack(Mob mob) { + public static void checkForAttack(Mob mob) { try { //checks if mob can attack based on attack timer and range @@ -764,25 +764,14 @@ public class MobAI { mob.setCombatTarget(null); return; } - if (System.currentTimeMillis() > mob.getNextAttackTime()) { - int delay = 3000; - if (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.RHELD) != null) { - delay = (int) (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.RHELD).template.item_weapon_wepspeed * 100); - } - if (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD) != null && mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD).template.item_type.equals(mbEnums.ItemType.WEAPON)) { - delay += (int) (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD).template.item_weapon_wepspeed * 100); - } + attackTarget(mob, mob.getCombatTarget()); - - mob.nextAttackTime = System.currentTimeMillis() + delay; - AttackTarget(mob, mob.getCombatTarget()); - } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage()); } } - private static void CheckToSendMobHome(Mob mob) { + private static void checkToSendMobHome(Mob mob) { try { @@ -864,7 +853,7 @@ public class MobAI { } } - private static void SafeGuardAggro(Mob mob) { + private static void safeGuardAggro(Mob mob) { try { HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); @@ -896,19 +885,19 @@ public class MobAI { } } - public static void GuardLogic(Mob mob) { + public static void guardLogic(Mob mob) { try { if (mob.getCombatTarget() == null) { - CheckForPlayerGuardAggro(mob); + checkForPlayerGuardAggro(mob); } else { //do not need to look to change target if target is already null - AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); + AbstractWorldObject newTarget = changeTargetFromHateValue(mob); if (newTarget != null) { if (newTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { - if (GuardCanAggro(mob, (PlayerCharacter) newTarget)) + if (guardCanAggro(mob, (PlayerCharacter) newTarget)) mob.setCombatTarget(newTarget); } else mob.setCombatTarget(newTarget); @@ -916,17 +905,17 @@ public class MobAI { } if (mob.behaviourType.canRoam) - CheckMobMovement(mob);//all guards that can move check to move + checkMobMovement(mob);//all guards that can move check to move if (mob.combatTarget != null) - CheckForAttack(mob); //only check to attack if combat target is not null + checkForAttack(mob); //only check to attack if combat target is not null } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage()); } } - private static void PetLogic(Mob mob) { + private static void petLogic(Mob mob) { try { @@ -935,9 +924,9 @@ public class MobAI { mob.killCharacter("no owner"); if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) - CheckMobMovement(mob); + checkMobMovement(mob); - CheckForAttack(mob); + checkForAttack(mob); //recover health @@ -959,23 +948,23 @@ public class MobAI { } } - private static void HamletGuardLogic(Mob mob) { + private static void hamletGuardLogic(Mob mob) { try { //safehold guard if (mob.getCombatTarget() == null) - SafeGuardAggro(mob); + safeGuardAggro(mob); else if (mob.getCombatTarget().isAlive() == false) - SafeGuardAggro(mob); + safeGuardAggro(mob); - CheckForAttack(mob); + checkForAttack(mob); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage()); } } - private static void DefaultLogic(Mob mob) { + private static void defaultLogic(Mob mob) { try { @@ -986,16 +975,16 @@ public class MobAI { if (mob.behaviourType.isAgressive) { - AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); + AbstractWorldObject newTarget = changeTargetFromHateValue(mob); if (newTarget != null) mob.setCombatTarget(newTarget); else { if (mob.getCombatTarget() == null) { if (mob.behaviourType == mbEnums.MobBehaviourType.HamletGuard) - SafeGuardAggro(mob); //safehold guard + safeGuardAggro(mob); //safehold guard else - CheckForAggro(mob); //normal aggro + checkForAggro(mob); //normal aggro } } } @@ -1003,19 +992,19 @@ public class MobAI { //check if mob can move for patrol or moving to target if (mob.behaviourType.canRoam) - CheckMobMovement(mob); + checkMobMovement(mob); //check if mob can attack if it isn't wimpy if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null) - CheckForAttack(mob); + checkForAttack(mob); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage()); } } - public static void CheckForPlayerGuardAggro(Mob mob) { + public static void checkForPlayerGuardAggro(Mob mob) { try { @@ -1061,7 +1050,7 @@ public class MobAI { // No aggro for this player - if (GuardCanAggro(mob, loadedPlayer) == false) + if (guardCanAggro(mob, loadedPlayer) == false) continue; if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) { @@ -1079,7 +1068,7 @@ public class MobAI { Mob aggroMob = (Mob) awoMob; - if (GuardCanAggro(mob, aggroMob)) { + if (guardCanAggro(mob, aggroMob)) { mob.setCombatTarget(aggroMob); return; } @@ -1091,7 +1080,7 @@ public class MobAI { } } - public static Boolean GuardCanAggro(Mob mob, AbstractCharacter target) { + public static Boolean guardCanAggro(Mob mob, AbstractCharacter target) { try { @@ -1200,7 +1189,7 @@ public class MobAI { } } - public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { + public static AbstractWorldObject changeTargetFromHateValue(Mob mob) { try { diff --git a/src/engine/mobileAI/Threads/MobAIThread.java b/src/engine/mobileAI/Threads/MobAIThread.java index 0a7c02d5..bc05affe 100644 --- a/src/engine/mobileAI/Threads/MobAIThread.java +++ b/src/engine/mobileAI/Threads/MobAIThread.java @@ -32,7 +32,7 @@ public class MobAIThread implements Runnable { try { if (mob != null) - MobAI.DetermineAction(mob); + MobAI.determineAction(mob); } catch (Exception e) { Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e); e.printStackTrace(); diff --git a/src/engine/mobileAI/Threads/Respawner.java b/src/engine/mobileAI/Threads/Respawner.java index b5471c8a..73ca78f8 100644 --- a/src/engine/mobileAI/Threads/Respawner.java +++ b/src/engine/mobileAI/Threads/Respawner.java @@ -16,7 +16,15 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; public enum Respawner implements Runnable { + + // MB Dev Notes: + // + // Thread acts as a throttle for messages to the client. Mobiles are + // respawned over a short time so as not to flood the client when + // an entire camp respawns at once. + RESPAWNER; + public static BlockingQueue respawnQueue = new DelayQueue(); @Override diff --git a/src/engine/net/AbstractConnection.java b/src/engine/net/AbstractConnection.java index 8fb86d11..c5bcf4cd 100644 --- a/src/engine/net/AbstractConnection.java +++ b/src/engine/net/AbstractConnection.java @@ -10,7 +10,6 @@ package engine.net; import engine.job.JobManager; -import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/AbstractNetMsg.java b/src/engine/net/AbstractNetMsg.java index eb7e7095..8a00f4b2 100644 --- a/src/engine/net/AbstractNetMsg.java +++ b/src/engine/net/AbstractNetMsg.java @@ -10,7 +10,6 @@ package engine.net; import engine.exception.SerializationException; -import engine.net.client.Protocol; import engine.server.MBServerStatics; import engine.util.StringUtils; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/CheckNetMsgFactoryJob.java b/src/engine/net/CheckNetMsgFactoryJob.java index 18ec9e7d..29529fce 100644 --- a/src/engine/net/CheckNetMsgFactoryJob.java +++ b/src/engine/net/CheckNetMsgFactoryJob.java @@ -9,7 +9,6 @@ package engine.net; import engine.job.AbstractJob; -import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/ItemProductionManager.java b/src/engine/net/ItemProductionManager.java deleted file mode 100644 index 1e8c8ec1..00000000 --- a/src/engine/net/ItemProductionManager.java +++ /dev/null @@ -1,135 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.net; - -import engine.mbEnums.DispatchChannel; -import engine.objects.ProducedItem; -import org.pmw.tinylog.Logger; - -import java.util.HashSet; -import java.util.concurrent.DelayQueue; -import java.util.concurrent.atomic.LongAdder; - -/** - * Thread blocks until MagicBane dispatch messages are - * enqueued then processes them in FIFO order. The collection - * is thread safe. - *

- * Any large messages not time sensitive such as load object - * sent to more than a single individual should be spawned - * individually on a DispatchMessageThread. - */ - - -public enum ItemProductionManager implements Runnable { - - ITEMPRODUCTIONMANAGER; - - - // Instance variables - - @SuppressWarnings("unchecked") // Cannot have arrays of generics in java. - private static final DelayQueue producedQueue = new DelayQueue<>(); - public static volatile long[] messageCount = new long[DispatchChannel.values().length]; - - // Class variables - public static LongAdder[] dispatchCount = new LongAdder[DispatchChannel.values().length]; - - - // Performance metrics - public static volatile long[] maxRecipients = new long[DispatchChannel.values().length]; - public static LongAdder dispatchPoolSize = new LongAdder(); - public static HashSet FailedItems = new HashSet<>(); - public Thread itemProductionThread = null; - private ItemQueue itemQueue; - private long nextFailedItemAudit; - - // Thread constructor - - public static void send(ItemQueue item) { - - // Don't queue up empty dispatches! - - if (item == null) - return; - - producedQueue.add(item); - - } - - public static String getNetstatString() { - - String outString = null; - String newLine = System.getProperty("line.separator"); - outString = "[LUA_NETSTA()]" + newLine; - outString += "poolSize: " + dispatchPoolSize.longValue() + '\n'; - - for (DispatchChannel dispatchChannel : DispatchChannel.values()) { - - outString += "Channel: " + dispatchChannel.name() + '\n'; - outString += "Dispatches: " + dispatchCount[dispatchChannel.getChannelID()].longValue() + '\n'; - outString += "Messages: " + messageCount[dispatchChannel.getChannelID()] + '\n'; - outString += "maxRecipients: " + maxRecipients[dispatchChannel.getChannelID()] + '\n'; - } - return outString; - } - - public void startMessagePump() { - - itemProductionThread = new Thread(this); - itemProductionThread.setName("ItemProductionManager"); - - } - - public void initialize() { - itemProductionThread.start(); - } - - @Override - public void run() { - - - while (true) { - try { - - this.itemQueue = producedQueue.take(); - - if (this.itemQueue == null) { - return; - } - - if (this.itemQueue != null) { - if (this.itemQueue.item == null) { - this.itemQueue.release(); - return; - } - - - boolean created = this.itemQueue.item.finishProduction(); - - if (!created) - FailedItems.add(this.itemQueue.item); - - this.itemQueue.release(); - - - } - - - } catch (Exception e) { - Logger.error(e); - } - - } - } - - // For Debugging: - //Logger.error("MessageDispatcher", messageDispatch.msg.getOpcodeAsString() + " sent to " + messageDispatch.playerList.size() + " players"); -} diff --git a/src/engine/net/ItemQueue.java b/src/engine/net/ItemQueue.java deleted file mode 100644 index e5373324..00000000 --- a/src/engine/net/ItemQueue.java +++ /dev/null @@ -1,86 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.net; - -import engine.objects.ProducedItem; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Delayed; -import java.util.concurrent.TimeUnit; - -import static engine.net.MessageDispatcher.itemPoolSize; - -/** - * Data class holds a message and a distribution list - */ - -public class ItemQueue implements Delayed { - - private static final ConcurrentLinkedQueue itemPool = new ConcurrentLinkedQueue<>(); - - public ProducedItem item; - public long delayTime; - - - public ItemQueue(ProducedItem item, long delayTime) { - this.item = item; - this.delayTime = System.currentTimeMillis() + delayTime; - - } - - public static ItemQueue borrow(ProducedItem item, long delayTime) { - - ItemQueue itemQueue; - - itemQueue = itemPool.poll(); - - if (itemQueue == null) { - itemQueue = new ItemQueue(item, delayTime); - } else { - itemQueue.item = item; - itemQueue.delayTime = System.currentTimeMillis() + delayTime; - itemPoolSize.decrement(); - } - - return itemQueue; - } - - public void reset() { - this.item = null; - this.delayTime = 0; - } - - public void release() { - this.reset(); - itemPool.add(this); - itemPoolSize.increment(); - } - - @Override - public int compareTo(Delayed another) { - ItemQueue anotherTask = (ItemQueue) another; - - if (this.delayTime < anotherTask.delayTime) { - return -1; - } - - if (this.delayTime > anotherTask.delayTime) { - return 1; - } - - return 0; - } - - @Override - public long getDelay(TimeUnit unit) { - long difference = delayTime - System.currentTimeMillis(); - return unit.convert(difference, TimeUnit.MILLISECONDS); - } -} diff --git a/src/engine/net/MessageDispatcher.java b/src/engine/net/MessageDispatcher.java index 3466b161..90b8fb96 100644 --- a/src/engine/net/MessageDispatcher.java +++ b/src/engine/net/MessageDispatcher.java @@ -17,36 +17,33 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.LongAdder; import java.util.regex.Pattern; -/** - * Thread blocks until MagicBane dispatch messages are - * enqueued then processes them in FIFO order. The collection - * is thread safe. - *

- * Any large messages not time sensitive such as load object - * sent to more than a single individual should be spawned - * individually on a DispatchMessageThread. - */ +// MB Dev Notes: +// All outgoing Protocol messages to the player are managed through the MessageDispatcher.class. +// All incoming Protocol messages from the player are managed by the Protocol.class. +// +// A DispatchMessage is configured (Protocol messsage) and wrapped in a Dispatch (distribution list). +// A Dispatch can be submitted to the MessageDispatcher for delivery from any thread. +// +// Dispatches are interleaved between channels. This is to ensure +// a combat or movement message is not delayed by spam clicking a +// larger message. Choose your channel wisely. public class MessageDispatcher implements Runnable { - // Instance variables + // Class variables - @SuppressWarnings("unchecked") // Cannot have arrays of generics in java. private static final ConcurrentLinkedQueue[] _messageQueue = new ConcurrentLinkedQueue[DispatchChannel.values().length]; private static final LinkedBlockingQueue _blockingQueue = new LinkedBlockingQueue<>(); - - // Class variables public static volatile long[] messageCount = new long[DispatchChannel.values().length]; public static LongAdder[] dispatchCount = new LongAdder[DispatchChannel.values().length]; // Performance metrics + public static volatile long[] maxRecipients = new long[DispatchChannel.values().length]; public static LongAdder itemPoolSize = new LongAdder(); private final Pattern filterPattern; // Unused, but just in case private Dispatch messageDispatch; - // Thread constructor - public MessageDispatcher() { // Create new FIFO queues for this network thread @@ -61,8 +58,41 @@ public class MessageDispatcher implements Runnable { } + @Override + public void run() { + + boolean shouldBlock; + + while (true) { + try { + + shouldBlock = true; + + for (DispatchChannel dispatchChannel : DispatchChannel.values()) { + + this.messageDispatch = _messageQueue[dispatchChannel.getChannelID()].poll(); + + if (this.messageDispatch != null) { + DispatchMessage.serializeDispatch(this.messageDispatch); + shouldBlock = false; + } + } + + if (shouldBlock == true) + shouldBlock = _blockingQueue.take(); + } catch (Exception e) { + Logger.error(e); + } + + } + } + public static void send(Dispatch messageDispatch, DispatchChannel dispatchChannel) { + // Use Dispatch.borrow() for a new dispatch. + // The Dispatch will be released by the system + // once delivered. + // Don't queue up empty dispatches! if (messageDispatch.player == null) @@ -74,12 +104,11 @@ public class MessageDispatcher implements Runnable { // Update performance metrics messageCount[dispatchChannel.getChannelID()]++; - } public static String getNetstatString() { - String outString = null; + String outString; String newLine = System.getProperty("line.separator"); outString = "[LUA_NETSTA()]" + newLine; outString += "poolSize: " + itemPoolSize.longValue() + '\n'; @@ -94,37 +123,6 @@ public class MessageDispatcher implements Runnable { return outString; } - @Override - public void run() { - - boolean shouldBlock; - - while (true) { - try { - - shouldBlock = true; - - for (DispatchChannel dispatchChannel : DispatchChannel.values()) { - - this.messageDispatch = _messageQueue[dispatchChannel.getChannelID()].poll(); - - if (this.messageDispatch != null) { - DispatchMessage.serializeDispatch(this.messageDispatch); - shouldBlock = false; - } - - } - - if (shouldBlock == true) - shouldBlock = _blockingQueue.take(); - - } catch (Exception e) { - Logger.error(e); - } - - } - } - // For Debugging: //Logger.error("MessageDispatcher", messageDispatch.msg.getOpcodeAsString() + " sent to " + messageDispatch.playerList.size() + " players"); } diff --git a/src/engine/net/NetMsgFactory.java b/src/engine/net/NetMsgFactory.java index c1cbba91..79799d8a 100644 --- a/src/engine/net/NetMsgFactory.java +++ b/src/engine/net/NetMsgFactory.java @@ -12,7 +12,6 @@ package engine.net; import engine.exception.FactoryBuildException; import engine.gameManager.ChatManager; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; import org.joda.time.DateTime; diff --git a/src/engine/net/NetMsgStat.java b/src/engine/net/NetMsgStat.java index eef4b0b2..4f57bffe 100644 --- a/src/engine/net/NetMsgStat.java +++ b/src/engine/net/NetMsgStat.java @@ -9,8 +9,6 @@ package engine.net; -import engine.net.client.Protocol; - import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/Protocol.java similarity index 95% rename from src/engine/net/client/Protocol.java rename to src/engine/net/Protocol.java index fef9b5da..a6e94ddd 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/Protocol.java @@ -1,11 +1,13 @@ -package engine.net.client; +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com +package engine.net; -/* This class defines Magicbane's application network protocol. ---> Name / Opcode / Message / Handler - */ -import engine.net.AbstractConnection; -import engine.net.ByteBufferReader; import engine.net.client.handlers.*; import engine.net.client.msg.*; import engine.net.client.msg.chat.*; @@ -18,6 +20,13 @@ import org.pmw.tinylog.Logger; import java.lang.reflect.Constructor; import java.util.HashMap; +// MB Dev Notes: +// This class defines the application network protocol used by SB. +// --> Name / Opcode / Message / Handler +// +// All incoming Protocol messages from the player are managed by the Protocol.class. +// All outgoing Protocol messages to the player are managed through the MessageDispatcher.class. + public enum Protocol { NONE(0x0, null, null), @@ -288,9 +297,7 @@ public enum Protocol { public static boolean handleClientMsg(ClientNetMsg msg) { - // Main message handler for Magicbane. All messages - // incoming from the client are executed here for - // both the login and world servers. + // Process incoming Protocol message from client. if (msg == null) return false; @@ -342,7 +349,6 @@ public enum Protocol { } } - public static int FindNextValidOpcode(ByteBufferReader reader) { int startPos = reader.position(); int bytesLeft = reader.remaining(); diff --git a/src/engine/net/client/ClientConnection.java b/src/engine/net/client/ClientConnection.java index b2ec544a..142f324f 100644 --- a/src/engine/net/client/ClientConnection.java +++ b/src/engine/net/client/ClientConnection.java @@ -17,6 +17,7 @@ import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.AbstractNetMsg; import engine.net.Network; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.login.LoginErrorMsg; import engine.objects.Account; diff --git a/src/engine/net/client/handlers/AbstractChatMsgHandler.java b/src/engine/net/client/handlers/AbstractChatMsgHandler.java index 0b33adf0..d1bba7e3 100644 --- a/src/engine/net/client/handlers/AbstractChatMsgHandler.java +++ b/src/engine/net/client/handlers/AbstractChatMsgHandler.java @@ -10,8 +10,8 @@ package engine.net.client.handlers; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; +import engine.net.Protocol; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.chat.*; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/handlers/DestroyBuildingHandler.java b/src/engine/net/client/handlers/DestroyBuildingHandler.java index ddebbd07..a4a6141c 100644 --- a/src/engine/net/client/handlers/DestroyBuildingHandler.java +++ b/src/engine/net/client/handlers/DestroyBuildingHandler.java @@ -1,10 +1,10 @@ package engine.net.client.handlers; -import engine.mbEnums; -import engine.mbEnums.BuildingGroup; import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; +import engine.mbEnums; +import engine.mbEnums.BuildingGroup; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.DestroyBuildingMsg; @@ -91,8 +91,9 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler { building.disableSpire(true); if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) { + if (city != null) - city.setWarehouseBuildingID(0); + city.warehouse = null; } BuildingManager.setRank(building, -1); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index e54001f0..622f61e7 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -9,12 +9,13 @@ package engine.net.client.handlers; - import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; +import engine.gameManager.ForgeManager; +import engine.gameManager.ItemManager; +import engine.loot.WorkOrder; import engine.mbEnums; -import engine.mbEnums.GameObjectType; import engine.mbEnums.ItemType; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -32,24 +33,158 @@ import java.util.HashMap; * @Summary: Processes application protocol message which modifies * hireling inventory through rolling, junking or depositing. */ -public class ItemProductionMsgHandler extends AbstractClientMsgHandler { - private static final int ACTION_PRODUCE = 1; - private static final int ACTION_JUNK = 2; - private static final int ACTION_RECYCLE = 3; - private static final int ACTION_COMPLETE = 4; - private static final int ACTION_DEPOSIT = 6; - private static final int ACTION_SETPRICE = 5; - private static final int ACTION_TAKE = 7; - private static final int ACTION_CONFIRM_SETPRICE = 9; // Unsure. Sent by client - private static final int ACTION_CONFIRM_DEPOSIT = 10; // Unsure. Sent by client - private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client +public class ItemProductionMsgHandler extends AbstractClientMsgHandler { public ItemProductionMsgHandler() { super(ItemProductionMsg.class); } - private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + // Member variable declaration + + PlayerCharacter player; + NPC vendor; + ItemProductionMsg msg; + Dispatch dispatch; + + // Member variable assignment + + msg = (ItemProductionMsg) baseMsg; + player = origin.getPlayerCharacter(); + + if (player == null) + return true; + + // Grab reference to vendor we are interacting with + + vendor = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); + + // Oops? + + if (vendor == null) + return true; + + // Process Request + + switch (msg.actionType) { + + case PRODUCE: + + // Create new work order + + WorkOrder workOrder = new WorkOrder(); + workOrder.total_to_produce = msg.total_to_produce; + workOrder.vendor = vendor; + workOrder.templateID = msg.itemUUID; + workOrder.prefixToken = msg.pToken; + workOrder.suffixToken = msg.sToken; + workOrder.item_name_override = msg.name; + workOrder.multiple_slot_request = (msg.size != 0); + + // Submit workOder to begin rolling items + + int validation_result = ForgeManager.submit(workOrder); + + // workOrder could not be completed + // Report back to the user the reason why + + if (validation_result != 0) { + ErrorPopupMsg.sendErrorPopup(player, validation_result); + return true; + } + + break; + case JUNK: + junkItem(msg.itemUUID, vendor, origin); + break; + case RECYCLE: + recycleItem(msg.items, vendor, origin); + msg.actionType = mbEnums.ProductionActionType.TAKE; + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + break; + case COMPLETE: + completeItem(msg.itemUUID, vendor); + break; + case DEPOSIT: + depositItem(msg.itemUUID, vendor, origin); + break; + case SETPRICE: + setItemPrice(msg.itemUUID, msg.itemPrice, vendor, origin); + break; + case TAKE: + takeItem(msg.items, vendor, origin); + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + break; + } + return true; + } + + private static void completeItem(int itemUUID, NPC vendor) { + + Item virtualItem = Item.getFromCache(itemUUID); + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + + City city = workOrder.vendor.building.getCity(); + city.transactionLock.writeLock().lock(); + + try { + + // Remove virtual item from the vendor rolling window + // (Add / Completed / Remove) + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + // Remove virtualItem from collections + + workOrder.cooking.remove(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); + DbManager.removeFromCache(virtualItem); + + workOrder.slots_used = workOrder.slots_used - 1; + + // Update workOrder on disk + + if (workOrder.cooking.isEmpty()) { + ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + } else + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); + + // Persist item and add to vendor inventory + + virtualItem.containerType = mbEnums.ItemContainerType.INVENTORY; + Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); + + // Apply Item effects for Prefix and Suffix tokens + + completedItem.prefixToken = virtualItem.prefixToken; + completedItem.suffixToken = virtualItem.suffixToken; + + ItemManager.applyItemEffects(completedItem); + + vendor.charItemManager.addItemToInventory(completedItem); + + // Add persisted items to the vendor inventory window + + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + } catch (Exception e) { + Logger.error(e); + } finally { + city.transactionLock.writeLock().unlock(); + } + } + + private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { Item targetItem; ItemProductionMsg outMsg; @@ -60,48 +195,24 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (player == null) return; - if (itemType == GameObjectType.Item.ordinal()) - targetItem = Item.getFromCache(itemUUID); - else if (itemType == GameObjectType.MobLoot.ordinal()) - targetItem = MobLoot.getFromCache(itemUUID); - else - targetItem = null; - + targetItem = Item.getFromCache(itemUUID); if (targetItem == null) return; - if (targetItem.getObjectType() == GameObjectType.Item) { - if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) { - ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); - return; - } - targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - } else if (targetItem.getObjectType() == GameObjectType.MobLoot) { - MobLoot mobLoot = (MobLoot) targetItem; - if (!DbManager.NPCQueries.UPDATE_ITEM_PRICE(mobLoot.getObjectUUID(), vendor.getObjectUUID(), itemPrice)) { - ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); - return; - } - targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) { + ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); + return; } - // Set item's price + targetItem.setValue(itemPrice); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); + dispatch = Dispatch.borrow(player, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); + dispatch = Dispatch.borrow(player, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } @@ -130,7 +241,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; if (!vendor.charItemManager.hasRoomInventory(targetItem.template.item_wt)) { - ErrorPopupMsg.sendErrorPopup(player, 21); return; } @@ -157,12 +267,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } - - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_CONFIRM_DEPOSIT, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -172,59 +281,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } finally { origin.sellLock.unlock(); } - } - - } - - // Method adds an item from the players inventory to the vendor. - - private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin, ItemProductionMsg msg) { - - Item targetItem; - ManageNPCMsg outMsg; - Dispatch dispatch; - - PlayerCharacter player = origin.getPlayerCharacter(); - - if (player == null) - return; - - if (origin.buyLock.tryLock()) { - try { - targetItem = Item.getFromCache(itemUUID); - - if (targetItem == null) - return; - - - if (!vendor.charItemManager.forgeContains(targetItem, vendor)) - return; - - boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem); - if (!worked) { - Guild guild = vendor.getGuild(); - if (guild == null) - return; - //ChatManager.chatGuildInfo(guild, "Failed to complete Item " + targetItem.getName()); - return; - } - - targetItem.containerType = mbEnums.ItemContainerType.INVENTORY; - targetItem.setOwner(vendor); - vendor.charItemManager.addItemToInventory(targetItem); - - vendor.removeItemFromForge(targetItem); - - outMsg = new ManageNPCMsg(vendor); - outMsg.setMessageType(ACTION_PRODUCE); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - } finally { - origin.buyLock.unlock(); - } - } } // Method completes an item that has been previously rolled @@ -235,7 +293,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { Item targetItem; ItemProductionMsg outMsg; int totalValue = 0; - int currentStrongbox; Dispatch dispatch; if (vendor.getBuilding() == null) @@ -256,12 +313,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { for (int itemUUID : itemList.keySet()) { int itemValue = 0; - int type = itemList.get(itemUUID); - - if (type == GameObjectType.Item.ordinal()) - targetItem = Item.getFromCache(itemUUID); - else - targetItem = MobLoot.getFromCache(itemUUID); + targetItem = Item.getFromCache(itemUUID); if (targetItem == null) continue; @@ -271,7 +323,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) continue; - if (vendor.charItemManager.inventoryContains(targetItem) == false) + + if (!vendor.charItemManager.inventoryContains(targetItem)) continue; itemValue = targetItem.template.item_value; @@ -288,18 +341,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { case REALMCHARTER: case SCROLL: case POTION: - itemValue = 0; continue; } + totalValue += itemValue; - long start = System.currentTimeMillis(); vendor.charItemManager.recycle(targetItem); - long end = System.currentTimeMillis(); - long timetook = end - start; - - // ChatManager.chatSystemInfo(player, "Took " + timetook + " ms to finish"); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_TAKE, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE, true); dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -307,205 +355,129 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Refund a portion of the gold - if (!vendor.getBuilding().transferGold(totalValue, false)) - return; - + vendor.getBuilding().transferGold(totalValue, false); } catch (Exception e) { Logger.error(e); } finally { - origin.sellLock.unlock(); } - } - - // Refresh vendor's inventory to client - } // Method handles recycling of an item private static void junkItem(int itemUUID, NPC vendor, ClientConnection origin) { - MobLoot targetItem; + Item virtualItem; ManageNPCMsg outMsg; Dispatch dispatch; - if (origin.sellLock.tryLock()) { - try { - targetItem = MobLoot.getFromCache(itemUUID); + PlayerCharacter player = origin.getPlayerCharacter(); - PlayerCharacter player = origin.getPlayerCharacter(); + if (player == null) + return; - if (player == null) - return; + // Cannot junk items without a forge! - // Can't junk nothing! + if (vendor.getBuilding() == null) + return; - if (targetItem == null) - return; + // junk nothing? + virtualItem = Item.getFromCache(itemUUID); - if (!vendor.charItemManager.forgeContains(targetItem, vendor)) - return; + if (virtualItem == null) + return; - // Cannot junk items without a forge! + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - if (vendor.getBuilding() == null) - return; + // If this virtual item was already processed then + // it will have been removed from the workOrder. - // Delete the item and cancel any pending rolling timer jobs + if (workOrder == null) + return; - targetItem.recycle(vendor); - vendor.removeItemFromForge(targetItem); + if (workOrder.cooking.contains(virtualItem) == false) + return; + ; - // Refresh vendor's inventory to client + City city = workOrder.vendor.building.getCity(); - outMsg = new ManageNPCMsg(vendor); - outMsg.setMessageType(1); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - ; - } finally { - origin.sellLock.unlock(); + if (city == null) + return; + + city.transactionLock.writeLock().lock(); + + try { + + workOrder.cooking.remove(virtualItem); + DbManager.removeFromCache(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); + + // Update total_to_produce accounting for the slot being + // removed while workOrder is not completed. + + if (workOrder.runCompleted == false) { + int itemsPerSlot = workOrder.total_to_produce / workOrder.slots_used; + workOrder.total_to_produce = workOrder.total_to_produce - itemsPerSlot; } + + // Slot is no longer allocated to this workOrder. + + workOrder.slots_used = workOrder.slots_used - 1; + + // Update workOrder on disk + + if (workOrder.cooking.isEmpty()) { + ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + } else + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); + + // Refresh vendor's inventory to client + + outMsg = new ManageNPCMsg(vendor); + outMsg.setMessageType(1); + dispatch = Dispatch.borrow(player, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + } catch (Exception e) { + Logger.error(e); + } finally { + city.transactionLock.writeLock().unlock(); } } - // Method junks an item that has been rolled but not completed - private static void takeItem(HashMap itemList, NPC vendor, ClientConnection origin) { Item targetItem; - - PlayerCharacter player = origin.getPlayerCharacter(); if (player == null) return; - for (int itemUUID : itemList.keySet()) { - int type = itemList.get(itemUUID); - if (type == GameObjectType.Item.ordinal()) { - targetItem = Item.getFromCache(itemUUID); - - } else { - targetItem = MobLoot.getFromCache(itemUUID); - - } + targetItem = Item.getFromCache(itemUUID); if (targetItem == null) return; - if (targetItem.template.item_type.equals(ItemType.GOLD)) return; - if (vendor.charItemManager.inventoryContains(targetItem) == false) + + if (!vendor.charItemManager.inventoryContains(targetItem)) return; - if (player.charItemManager.hasRoomInventory(targetItem.template.item_wt) == false) + if (!player.charItemManager.hasRoomInventory(targetItem.template.item_wt)) return; player.charItemManager.buyFromNPC(targetItem, vendor); - } player.charItemManager.updateInventory(); - // Update NPC inventory to client - - - } - - // Method removes item from an NPC's inventory and transferes it to a player - - @Override - protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { - - // Member variable declaration - - PlayerCharacter player; - NPC vendorNPC; - ItemProductionMsg msg; - Dispatch dispatch; - - // Member variable assignment - - msg = (ItemProductionMsg) baseMsg; - player = origin.getPlayerCharacter(); - - if (player == null) - return true; - - // Grab reference to vendor we are interacting with - - vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.getNpcUUID()); - - // Oops? - - if (vendorNPC == null) - return true; - - // Process Request - - switch (msg.getActionType()) { - - case ACTION_PRODUCE: - boolean isRandom = false; - if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0) - isRandom = true; - //Create Multiple Item Function.. Fill all empty slots - if (msg.isMultiple()) { - int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); - if (emptySlots > 0) { - for (int i = 0; i < emptySlots; i++) { - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getItemUUID()); - } - } - } else - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getItemUUID()); - break; - case ACTION_JUNK: - junkItem(msg.getItemUUID(), vendorNPC, origin); - break; - case ACTION_RECYCLE: - recycleItem(msg.getItemIDtoTypeMap(), vendorNPC, origin); - msg.setActionType(7); - dispatch = Dispatch.borrow(player, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - break; - case ACTION_COMPLETE: - - vendorNPC.completeItem(msg.getItemUUID()); - - // ManageNPCMsg outMsg = new ManageNPCMsg(vendorNPC); - // outMsg.setMessageType(1); - // - // dispatch = Dispatch.borrow(player, outMsg); - // DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - - break; - case ACTION_DEPOSIT: - depositItem(msg.getItemUUID(), vendorNPC, origin); - break; - case ACTION_SETPRICE: - setItemPrice(msg.getItemType(), msg.getItemUUID(), msg.getItemPrice(), vendorNPC, origin); - break; - case ACTION_TAKE: - takeItem(msg.getItemIDtoTypeMap(), vendorNPC, origin); - dispatch = Dispatch.borrow(player, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - break; - - } - return true; } - // Method handles rolling item requests from the client - } diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 17033af2..0e23dd32 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -185,62 +185,41 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { case BUCKET: //water bucket case POTION: //potions, tears of saedron - case SCROLL: //runes, petition, warrant, scrolls - if (uuid > 3000 && uuid < 3050) { //Discipline Runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 249999 && uuid < 250123) { //stat and mastery runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 250114 && uuid < 250123) { //mastery runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 252122 && uuid < 252128) { //mastery runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } + if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here break; - } else if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here - { - break; - } else if (uuid > 910010 && uuid < 910019) { - int rank = uuid - 910010; + if (item.template.item_bane_rank > 0) { - if (rank < 1 || rank > 8) { - ChatManager.chatSystemError(player, "Invalid Rank for bane scroll!"); - return true; - } // Only one banestone at a time + lock.writeLock().lock(); try { - if (Bane.summonBanestone(player, origin, rank) == true) + if (Bane.summonBanestone(player, origin, item.template.item_bane_rank) == true) itemMan.consume(item); } finally { lock.writeLock().unlock(); } break; - } else if (uuid == 910010) { //tears of saedron - if (comps.size() > 1) { + } + + if (uuid == 910010) { //tears of saedron + if (comps.size() > 1) AbstractCharacter.removeRune(player, origin, comps.get(1).intValue()); - } break; - } else if ((byte) item.chargesRemaining > 0) { + } + + if (item.chargesRemaining > 0) { ArrayList tarList = msg.getTargetCompID(); AbstractWorldObject target = player; + if (tarList.size() > 1) { long tarID = tarList.get(1); + if (tarID != 0) { AbstractGameObject tarAgo = AbstractGameObject.getFromTypeAndID(tarID); - if (tarAgo != null && tarAgo instanceof AbstractWorldObject) { + if (tarAgo instanceof AbstractWorldObject) { target = (AbstractWorldObject) tarAgo; } } @@ -248,8 +227,6 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { // Bypass for waterbuckets - // test character targeted - if (item.template.item_type.equals(mbEnums.ItemType.BUCKET)) { // test for valid target type @@ -288,6 +265,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); player.cancelOnSpell(); break; + case RUNE: + ApplyRuneMsg.applyRune(uuid,origin,player); + itemMan.consume(item); + break; default: //shouldn't be here, consume item dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index d6b0ad59..582a8e74 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -1358,8 +1358,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (city == null) return true; - city.setWarehouseBuildingID(newMesh.getObjectUUID()); - return true; } } \ No newline at end of file diff --git a/src/engine/net/client/handlers/ViewResourcesMsgHandler.java b/src/engine/net/client/handlers/ViewResourcesMsgHandler.java index 731e47e2..61bbe598 100644 --- a/src/engine/net/client/handlers/ViewResourcesMsgHandler.java +++ b/src/engine/net/client/handlers/ViewResourcesMsgHandler.java @@ -8,9 +8,8 @@ package engine.net.client.handlers; -import engine.mbEnums.DispatchChannel; import engine.exception.MsgSendException; -import engine.gameManager.BuildingManager; +import engine.mbEnums.DispatchChannel; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -46,13 +45,16 @@ public class ViewResourcesMsgHandler extends AbstractClientMsgHandler { if (city == null) return true; - Building warehouse = BuildingManager.getBuilding(city.getWarehouseBuildingID()); + if (city.warehouse == null) + return true; + + Building warehouseBuilding = city.warehouse.building; - if (warehouse == null) + if (warehouseBuilding == null) return true; ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); - vrm.setWarehouseBuilding(warehouse); + vrm.setWarehouseBuilding(warehouseBuilding); vrm.setGuild(playerCharacter.getGuild()); vrm.configure(); diff --git a/src/engine/net/client/msg/AbandonAssetMsg.java b/src/engine/net/client/msg/AbandonAssetMsg.java index 51e1b19a..c33ca990 100644 --- a/src/engine/net/client/msg/AbandonAssetMsg.java +++ b/src/engine/net/client/msg/AbandonAssetMsg.java @@ -13,7 +13,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class AbandonAssetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/AcceptFriendMsg.java b/src/engine/net/client/msg/AcceptFriendMsg.java index b309e78e..b9ed8024 100644 --- a/src/engine/net/client/msg/AcceptFriendMsg.java +++ b/src/engine/net/client/msg/AcceptFriendMsg.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AcceptTradeRequestMsg.java b/src/engine/net/client/msg/AcceptTradeRequestMsg.java index e0f63f5e..3b0da8d4 100644 --- a/src/engine/net/client/msg/AcceptTradeRequestMsg.java +++ b/src/engine/net/client/msg/AcceptTradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/ActivateNPCMessage.java b/src/engine/net/client/msg/ActivateNPCMessage.java index 985acbf9..45dd7ecd 100644 --- a/src/engine/net/client/msg/ActivateNPCMessage.java +++ b/src/engine/net/client/msg/ActivateNPCMessage.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Item; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/AddFriendMessage.java b/src/engine/net/client/msg/AddFriendMessage.java index 0ed159fb..051eb4a2 100644 --- a/src/engine/net/client/msg/AddFriendMessage.java +++ b/src/engine/net/client/msg/AddFriendMessage.java @@ -10,7 +10,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java b/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java index ee1ab4ff..818abbce 100644 --- a/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java +++ b/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class AddGoldToTradeWindowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/AddItemToTradeWindowMsg.java b/src/engine/net/client/msg/AddItemToTradeWindowMsg.java index c66c4b9b..d2f6c91b 100644 --- a/src/engine/net/client/msg/AddItemToTradeWindowMsg.java +++ b/src/engine/net/client/msg/AddItemToTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; public class AddItemToTradeWindowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/AllianceChangeMsg.java b/src/engine/net/client/msg/AllianceChangeMsg.java index 97ff500b..a132a028 100644 --- a/src/engine/net/client/msg/AllianceChangeMsg.java +++ b/src/engine/net/client/msg/AllianceChangeMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AllyEnemyListMsg.java b/src/engine/net/client/msg/AllyEnemyListMsg.java index 95f5b756..242427cc 100644 --- a/src/engine/net/client/msg/AllyEnemyListMsg.java +++ b/src/engine/net/client/msg/AllyEnemyListMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Guild; import engine.objects.GuildAlliances; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/ApplyBuildingEffectMsg.java b/src/engine/net/client/msg/ApplyBuildingEffectMsg.java index f1b221fa..8a8df691 100644 --- a/src/engine/net/client/msg/ApplyBuildingEffectMsg.java +++ b/src/engine/net/client/msg/ApplyBuildingEffectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ApplyBuildingEffectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ApplyEffectMsg.java b/src/engine/net/client/msg/ApplyEffectMsg.java index b0179ce6..c4e1cb3e 100644 --- a/src/engine/net/client/msg/ApplyEffectMsg.java +++ b/src/engine/net/client/msg/ApplyEffectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ApplyEffectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ApplyRuneMsg.java b/src/engine/net/client/msg/ApplyRuneMsg.java index 22b88fab..aea94c6b 100644 --- a/src/engine/net/client/msg/ApplyRuneMsg.java +++ b/src/engine/net/client/msg/ApplyRuneMsg.java @@ -13,7 +13,6 @@ import engine.gameManager.DbManager; import engine.mbEnums; import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.CharacterRune; import engine.objects.PlayerCharacter; import engine.objects.RuneBase; diff --git a/src/engine/net/client/msg/ArcLoginNotifyMsg.java b/src/engine/net/client/msg/ArcLoginNotifyMsg.java index fd4f48df..37bdeab2 100644 --- a/src/engine/net/client/msg/ArcLoginNotifyMsg.java +++ b/src/engine/net/client/msg/ArcLoginNotifyMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcLoginNotifyMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcMineChangeProductionMsg.java b/src/engine/net/client/msg/ArcMineChangeProductionMsg.java index 0799a9ce..ad8207be 100644 --- a/src/engine/net/client/msg/ArcMineChangeProductionMsg.java +++ b/src/engine/net/client/msg/ArcMineChangeProductionMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcMineChangeProductionMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java b/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java index 249600cd..118fa551 100644 --- a/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java +++ b/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.Guild; import engine.server.MBServerStatics; diff --git a/src/engine/net/client/msg/ArcMineWindowChangeMsg.java b/src/engine/net/client/msg/ArcMineWindowChangeMsg.java index f8b6d309..9c6011af 100644 --- a/src/engine/net/client/msg/ArcMineWindowChangeMsg.java +++ b/src/engine/net/client/msg/ArcMineWindowChangeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcMineWindowChangeMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcOwnedMinesListMsg.java b/src/engine/net/client/msg/ArcOwnedMinesListMsg.java index 202dc621..24d0b70f 100644 --- a/src/engine/net/client/msg/ArcOwnedMinesListMsg.java +++ b/src/engine/net/client/msg/ArcOwnedMinesListMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Mine; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/ArcSiegeSpireMsg.java b/src/engine/net/client/msg/ArcSiegeSpireMsg.java index 2942fce6..71155876 100644 --- a/src/engine/net/client/msg/ArcSiegeSpireMsg.java +++ b/src/engine/net/client/msg/ArcSiegeSpireMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcSiegeSpireMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java b/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java index f9ab6df8..924f0e5c 100644 --- a/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java +++ b/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java @@ -16,7 +16,7 @@ import engine.mbEnums.TransactionType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/AssetSupportMsg.java b/src/engine/net/client/msg/AssetSupportMsg.java index 7c92a009..3a35a18e 100644 --- a/src/engine/net/client/msg/AssetSupportMsg.java +++ b/src/engine/net/client/msg/AssetSupportMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/AttackCmdMsg.java b/src/engine/net/client/msg/AttackCmdMsg.java index f2c41b4e..66dd1379 100644 --- a/src/engine/net/client/msg/AttackCmdMsg.java +++ b/src/engine/net/client/msg/AttackCmdMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class AttackCmdMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ChangeAltitudeMsg.java b/src/engine/net/client/msg/ChangeAltitudeMsg.java index 924a7031..f5cc95dc 100644 --- a/src/engine/net/client/msg/ChangeAltitudeMsg.java +++ b/src/engine/net/client/msg/ChangeAltitudeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; public class ChangeAltitudeMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ChangeGuildLeaderMsg.java b/src/engine/net/client/msg/ChangeGuildLeaderMsg.java index 6443ad86..071e385d 100644 --- a/src/engine/net/client/msg/ChangeGuildLeaderMsg.java +++ b/src/engine/net/client/msg/ChangeGuildLeaderMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ChangeGuildLeaderMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ChatFilterMsg.java b/src/engine/net/client/msg/ChatFilterMsg.java index cd3e8bcd..84570168 100644 --- a/src/engine/net/client/msg/ChatFilterMsg.java +++ b/src/engine/net/client/msg/ChatFilterMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ChatFilterMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/CityAssetMsg.java b/src/engine/net/client/msg/CityAssetMsg.java index 5000ba92..7af6d02f 100644 --- a/src/engine/net/client/msg/CityAssetMsg.java +++ b/src/engine/net/client/msg/CityAssetMsg.java @@ -17,7 +17,7 @@ import engine.mbEnums.ProtectionState; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.City; import engine.objects.Zone; diff --git a/src/engine/net/client/msg/CityChoiceMsg.java b/src/engine/net/client/msg/CityChoiceMsg.java index 1e89ec07..d43f26fa 100644 --- a/src/engine/net/client/msg/CityChoiceMsg.java +++ b/src/engine/net/client/msg/CityChoiceMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/CityDataMsg.java b/src/engine/net/client/msg/CityDataMsg.java index 673a2dfc..62f27363 100644 --- a/src/engine/net/client/msg/CityDataMsg.java +++ b/src/engine/net/client/msg/CityDataMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg; import engine.gameManager.DbManager; import engine.mbEnums; -import engine.net.AbstractConnection; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.Network; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.AbstractGameObject; import engine.objects.City; import engine.objects.Mine; diff --git a/src/engine/net/client/msg/CityZoneMsg.java b/src/engine/net/client/msg/CityZoneMsg.java index b5e19696..7b80ea4c 100644 --- a/src/engine/net/client/msg/CityZoneMsg.java +++ b/src/engine/net/client/msg/CityZoneMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Zone; public class CityZoneMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ClaimAssetMsg.java b/src/engine/net/client/msg/ClaimAssetMsg.java index 5e41afae..590a4d8a 100644 --- a/src/engine/net/client/msg/ClaimAssetMsg.java +++ b/src/engine/net/client/msg/ClaimAssetMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ClaimAssetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ClaimGuildTreeMsg.java b/src/engine/net/client/msg/ClaimGuildTreeMsg.java index de4d2767..221d808d 100644 --- a/src/engine/net/client/msg/ClaimGuildTreeMsg.java +++ b/src/engine/net/client/msg/ClaimGuildTreeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/ClientNetMsg.java b/src/engine/net/client/msg/ClientNetMsg.java index 250d810c..a521f5e4 100644 --- a/src/engine/net/client/msg/ClientNetMsg.java +++ b/src/engine/net/client/msg/ClientNetMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; public abstract class ClientNetMsg extends AbstractNetMsg { diff --git a/src/engine/net/client/msg/CloseTradeWindowMsg.java b/src/engine/net/client/msg/CloseTradeWindowMsg.java index 322d9c4b..b34629a6 100644 --- a/src/engine/net/client/msg/CloseTradeWindowMsg.java +++ b/src/engine/net/client/msg/CloseTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/CommitToTradeMsg.java b/src/engine/net/client/msg/CommitToTradeMsg.java index f0bd2e71..cc871155 100644 --- a/src/engine/net/client/msg/CommitToTradeMsg.java +++ b/src/engine/net/client/msg/CommitToTradeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/ConfirmPromoteMsg.java b/src/engine/net/client/msg/ConfirmPromoteMsg.java index 0031d0e3..ff3a9a6f 100644 --- a/src/engine/net/client/msg/ConfirmPromoteMsg.java +++ b/src/engine/net/client/msg/ConfirmPromoteMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ConfirmPromoteMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/CostOpenBankMsg.java b/src/engine/net/client/msg/CostOpenBankMsg.java index e854f7dc..5831816d 100644 --- a/src/engine/net/client/msg/CostOpenBankMsg.java +++ b/src/engine/net/client/msg/CostOpenBankMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; /** diff --git a/src/engine/net/client/msg/DeclineFriendMsg.java b/src/engine/net/client/msg/DeclineFriendMsg.java index d1d52f2c..0e1a7258 100644 --- a/src/engine/net/client/msg/DeclineFriendMsg.java +++ b/src/engine/net/client/msg/DeclineFriendMsg.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/DeleteItemMsg.java b/src/engine/net/client/msg/DeleteItemMsg.java index fd6ea26d..289cedd1 100644 --- a/src/engine/net/client/msg/DeleteItemMsg.java +++ b/src/engine/net/client/msg/DeleteItemMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DeleteItemMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/DestroyBuildingMsg.java b/src/engine/net/client/msg/DestroyBuildingMsg.java index d5df7216..7bdfa851 100644 --- a/src/engine/net/client/msg/DestroyBuildingMsg.java +++ b/src/engine/net/client/msg/DestroyBuildingMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DestroyBuildingMsg extends ClientNetMsg { private int pad = 0; diff --git a/src/engine/net/client/msg/DoorTryOpenMsg.java b/src/engine/net/client/msg/DoorTryOpenMsg.java index d9766b7f..daf32760 100644 --- a/src/engine/net/client/msg/DoorTryOpenMsg.java +++ b/src/engine/net/client/msg/DoorTryOpenMsg.java @@ -22,7 +22,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DoorTryOpenMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/DropGoldMsg.java b/src/engine/net/client/msg/DropGoldMsg.java index 667916a5..fbde49dc 100644 --- a/src/engine/net/client/msg/DropGoldMsg.java +++ b/src/engine/net/client/msg/DropGoldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DropGoldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/EnterWorldReceivedMsg.java b/src/engine/net/client/msg/EnterWorldReceivedMsg.java index b300a16a..d93b170f 100644 --- a/src/engine/net/client/msg/EnterWorldReceivedMsg.java +++ b/src/engine/net/client/msg/EnterWorldReceivedMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class EnterWorldReceivedMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ErrorPopupMsg.java b/src/engine/net/client/msg/ErrorPopupMsg.java index d01204f3..6c995f1b 100644 --- a/src/engine/net/client/msg/ErrorPopupMsg.java +++ b/src/engine/net/client/msg/ErrorPopupMsg.java @@ -11,7 +11,6 @@ package engine.net.client.msg; import engine.mbEnums; import engine.net.*; -import engine.net.client.Protocol; import engine.objects.PlayerCharacter; public class ErrorPopupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/FriendRequestMsg.java b/src/engine/net/client/msg/FriendRequestMsg.java index ad735157..7f6c0aa3 100644 --- a/src/engine/net/client/msg/FriendRequestMsg.java +++ b/src/engine/net/client/msg/FriendRequestMsg.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/FurnitureMsg.java b/src/engine/net/client/msg/FurnitureMsg.java index 202db069..c682a8ff 100644 --- a/src/engine/net/client/msg/FurnitureMsg.java +++ b/src/engine/net/client/msg/FurnitureMsg.java @@ -9,13 +9,13 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; import engine.math.Vector3fImmutable; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class FurnitureMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/GoldFromVaultMsg.java b/src/engine/net/client/msg/GoldFromVaultMsg.java index cc55ecde..0357a44d 100644 --- a/src/engine/net/client/msg/GoldFromVaultMsg.java +++ b/src/engine/net/client/msg/GoldFromVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer gold from vault to inventory diff --git a/src/engine/net/client/msg/GoldToVaultMsg.java b/src/engine/net/client/msg/GoldToVaultMsg.java index b927ba63..8acef2a6 100644 --- a/src/engine/net/client/msg/GoldToVaultMsg.java +++ b/src/engine/net/client/msg/GoldToVaultMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer gold from inventory to vault diff --git a/src/engine/net/client/msg/GrantExperienceMsg.java b/src/engine/net/client/msg/GrantExperienceMsg.java index cdff6397..c8e43551 100644 --- a/src/engine/net/client/msg/GrantExperienceMsg.java +++ b/src/engine/net/client/msg/GrantExperienceMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; public class GrantExperienceMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/GuildTreeStatusMsg.java b/src/engine/net/client/msg/GuildTreeStatusMsg.java index 8b108589..ca304f53 100644 --- a/src/engine/net/client/msg/GuildTreeStatusMsg.java +++ b/src/engine/net/client/msg/GuildTreeStatusMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import java.time.LocalDateTime; diff --git a/src/engine/net/client/msg/HirelingServiceMsg.java b/src/engine/net/client/msg/HirelingServiceMsg.java index 8a428dab..1b63a48d 100644 --- a/src/engine/net/client/msg/HirelingServiceMsg.java +++ b/src/engine/net/client/msg/HirelingServiceMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class HirelingServiceMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/HotzoneChangeMsg.java b/src/engine/net/client/msg/HotzoneChangeMsg.java index b779e3ac..9239ce18 100644 --- a/src/engine/net/client/msg/HotzoneChangeMsg.java +++ b/src/engine/net/client/msg/HotzoneChangeMsg.java @@ -15,7 +15,7 @@ import engine.gameManager.ZoneManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.time.Duration; import java.time.Instant; diff --git a/src/engine/net/client/msg/IgnoreListMsg.java b/src/engine/net/client/msg/IgnoreListMsg.java index cbfb0991..7f4c268d 100644 --- a/src/engine/net/client/msg/IgnoreListMsg.java +++ b/src/engine/net/client/msg/IgnoreListMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/IgnoreMsg.java b/src/engine/net/client/msg/IgnoreMsg.java index 6c86cf1b..f7bca0f4 100644 --- a/src/engine/net/client/msg/IgnoreMsg.java +++ b/src/engine/net/client/msg/IgnoreMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class IgnoreMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/InvalidTradeRequestMsg.java b/src/engine/net/client/msg/InvalidTradeRequestMsg.java index 4e97395b..0c9d917c 100644 --- a/src/engine/net/client/msg/InvalidTradeRequestMsg.java +++ b/src/engine/net/client/msg/InvalidTradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/ItemEffectMsg.java b/src/engine/net/client/msg/ItemEffectMsg.java index 5408118c..4600fb2a 100644 --- a/src/engine/net/client/msg/ItemEffectMsg.java +++ b/src/engine/net/client/msg/ItemEffectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ItemEffectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ItemFromVaultMsg.java b/src/engine/net/client/msg/ItemFromVaultMsg.java index c1aee4c9..75cec72f 100644 --- a/src/engine/net/client/msg/ItemFromVaultMsg.java +++ b/src/engine/net/client/msg/ItemFromVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from Vault to inventory diff --git a/src/engine/net/client/msg/ItemHealthUpdateMsg.java b/src/engine/net/client/msg/ItemHealthUpdateMsg.java index ba818e3d..fdd93c82 100644 --- a/src/engine/net/client/msg/ItemHealthUpdateMsg.java +++ b/src/engine/net/client/msg/ItemHealthUpdateMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ItemHealthUpdateMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 08d3abda..eaf49f60 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -10,53 +10,34 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; -import engine.gameManager.PowersManager; +import engine.gameManager.ForgeManager; +import engine.loot.WorkOrder; +import engine.mbEnums; import engine.mbEnums.GameObjectType; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Building; import engine.objects.Item; -import engine.objects.MobLoot; import engine.objects.NPC; -import engine.powers.EffectsBase; -import java.util.ArrayList; import java.util.HashMap; public class ItemProductionMsg extends ClientNetMsg { - private static final int ACTION_PRODUCE = 1; - private static final int ACTION_JUNK = 2; - private static final int ACTION_RECYCLE = 3; - private static final int ACTION_COMPLETE = 4; - private static final int ACTION_DEPOSIT = 6; - private static final int ACTION_SETPRICE = 5; - private static final int ACTION_TAKE = 7; - private static final int ACTION_CONFIRM_SETPRICE = 9; - private static final int ACTION_CONFIRM_DEPOSIT = 10; - private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client - private static final int ACTION_CONFIRM_PRODUCE = 8; - - private ArrayList ItemList; - private int size; - private int buildingUUID; - private int unknown01; - private int itemUUID; - private int itemType; - private int totalProduction; - private int unknown03; - private int pToken; - private int sToken; - private String name; - private int actionType; - private int npcUUID; - private boolean add; - private int itemPrice; - private boolean isMultiple; - private HashMap itemIDtoTypeMap; + public int size; + public int buildingUUID; + public int unknown01; + public int itemUUID; + public int itemType; + public int total_to_produce; + public int unknown03; + public int pToken; + public int sToken; + public String name; + public mbEnums.ProductionActionType actionType; + public int npcUUID; + public boolean add; + public int itemPrice; + public HashMap items; /** * This is the general purpose constructor. @@ -64,12 +45,12 @@ public class ItemProductionMsg extends ClientNetMsg { public ItemProductionMsg() { super(Protocol.ITEMPRODUCTION); - this.actionType = 0; + this.actionType = mbEnums.ProductionActionType.NONE; this.size = 0; this.buildingUUID = 0; this.unknown01 = 0; this.itemUUID = 0; - this.totalProduction = 0; + this.total_to_produce = 0; this.unknown03 = 0; this.pToken = 0; this.sToken = 0; @@ -79,9 +60,7 @@ public class ItemProductionMsg extends ClientNetMsg { } - ; - - public ItemProductionMsg(Building building, NPC vendor, Item item, int actionType, boolean add) { + public ItemProductionMsg(Building building, NPC vendor, Item item, mbEnums.ProductionActionType actionType, boolean add) { super(Protocol.ITEMPRODUCTION); this.actionType = actionType; this.size = 0; @@ -90,7 +69,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.itemType = item.getObjectType().ordinal(); this.itemUUID = item.getObjectUUID(); this.unknown01 = 0; - this.totalProduction = 0; + this.total_to_produce = 0; this.unknown03 = 0; this.pToken = 0; this.sToken = 0; @@ -130,7 +109,7 @@ public class ItemProductionMsg extends ClientNetMsg { return; // Common Header - writer.putInt(this.actionType); + writer.putInt(this.actionType.ordinal()); writer.putInt(GameObjectType.Building.ordinal()); writer.putInt(this.buildingUUID); writer.putInt(GameObjectType.NPC.ordinal()); @@ -138,7 +117,7 @@ public class ItemProductionMsg extends ClientNetMsg { switch (this.actionType) { - case ACTION_CONFIRM_DEPOSIT: + case CONFIRM_DEPOSIT: writer.putInt(0); // Not item ordinal? writer.putInt(0); // Not item uuid? writer.putInt(1); @@ -146,9 +125,13 @@ public class ItemProductionMsg extends ClientNetMsg { if (!add) { writer.put((byte) 1); - Item item = Item.getFromCache(this.itemUUID); + + Item item; + item = Item.getFromCache(this.itemUUID); // Negative ID items not sent here. Deposit virtual item? + if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); + writer.putInt(building.getStrongboxValue()); writer.putInt(0); writer.putInt(0); @@ -159,19 +142,18 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.put((byte) 1); - Item item; - if (this.itemType == GameObjectType.Item.ordinal()) - item = Item.getFromCache(this.itemUUID); - else - item = MobLoot.getFromCache(this.itemUUID); + + Item item = Item.getFromCache(this.itemUUID); + if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); + writer.putInt(building.getStrongboxValue()); writer.putInt(0); writer.putInt(0); writer.put((byte) 0); break; - case ACTION_CONFIRM_TAKE: + case CONFIRM_TAKE: writer.putInt(this.itemType); writer.putInt(this.itemUUID); writer.putInt(1); @@ -183,7 +165,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_SETPRICE: + case SETPRICE: writer.putInt(this.itemType); writer.putInt(this.itemUUID); writer.putInt(1); @@ -196,7 +178,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_CONFIRM_SETPRICE: + case CONFIRM_SETPRICE: writer.putInt(this.itemType); writer.putInt(this.itemUUID); writer.putInt(1); @@ -210,7 +192,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); //writer.put((byte) 0); break; - case ACTION_DEPOSIT: + case DEPOSIT: writer.putInt(this.itemType); writer.putInt(this.itemUUID); writer.putInt(1); @@ -222,9 +204,8 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_TAKE: - case ACTION_RECYCLE: - + case TAKE: + case RECYCLE: writer.putInt(0); writer.putInt(0); writer.putInt(1); @@ -235,11 +216,11 @@ public class ItemProductionMsg extends ClientNetMsg { writer.put((byte) 1); writer.putInt(building.getStrongboxValue()); - if (this.itemIDtoTypeMap != null) { - writer.putInt(this.itemIDtoTypeMap.size()); + if (this.items != null) { + writer.putInt(this.items.size()); - for (int itemID : this.itemIDtoTypeMap.keySet()) { - writer.putInt(this.itemIDtoTypeMap.get(itemID)); + for (int itemID : this.items.keySet()) { + writer.putInt(this.items.get(itemID)); writer.putInt(itemID); } @@ -249,28 +230,19 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); break; - case ACTION_CONFIRM_PRODUCE: + case CONFIRM_PRODUCE: writer.putInt(0); writer.putInt(0); writer.putInt(1); - MobLoot toRoll = MobLoot.getFromCache(this.itemUUID); + Item toRoll = Item.getFromCache(this.itemUUID); writer.putInt(-1497023830); - if (toRoll != null && toRoll.getPrefix() != null && !toRoll.getPrefix().isEmpty()) { - EffectsBase eb = PowersManager.getEffectByIDString(toRoll.getPrefix()); - if (eb == null) - this.pToken = 0; - else - this.pToken = eb.getToken(); - } - if (toRoll != null && toRoll.getSuffix() != null && !toRoll.getSuffix().isEmpty()) { - EffectsBase eb = PowersManager.getEffectByIDString(toRoll.getSuffix()); - if (eb == null) - this.sToken = 0; - else - this.sToken = eb.getToken(); - } - if (toRoll.isRandom() == false || (toRoll != null && toRoll.isComplete())) { + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(toRoll); + + this.pToken = toRoll.prefixToken; + this.sToken = toRoll.suffixToken; + + if (toRoll.isComplete() || (workOrder.prefixToken != 0 && workOrder.suffixToken != 0)) { writer.putInt(this.pToken); writer.putInt(this.sToken); } else { @@ -279,17 +251,12 @@ public class ItemProductionMsg extends ClientNetMsg { } writer.putString(toRoll.name); - writer.putInt(GameObjectType.MobLoot.ordinal()); + writer.putInt(toRoll.getObjectType().ordinal()); writer.putInt(this.itemUUID); writer.putInt(0); //items left to produce? - if (toRoll != null) { - writer.putInt(toRoll.templateID); - writer.putInt(toRoll.getValue()); - } else { - writer.putInt(0); - writer.putInt(0); - } + writer.putInt(toRoll.templateID); + writer.putInt(toRoll.getValue()); NPC vendor = NPC.getFromCache(this.npcUUID); if (vendor != null) { @@ -327,10 +294,10 @@ public class ItemProductionMsg extends ClientNetMsg { //writer.putInt(0); //error popup break; - case ACTION_COMPLETE: + case COMPLETE: writer.putInt(this.itemType); writer.putInt(this.itemUUID); - writer.putInt(this.totalProduction); + writer.putInt(this.total_to_produce); writer.putInt(this.unknown03); writer.putInt(this.pToken); writer.putInt(this.sToken); @@ -339,10 +306,10 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_JUNK: + case JUNK: writer.putInt(this.itemType); writer.putInt(this.itemUUID); - writer.putInt(this.totalProduction); + writer.putInt(this.total_to_produce); writer.putInt(this.unknown03); writer.putInt(this.pToken); writer.putInt(this.sToken); @@ -359,7 +326,6 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); break; } - } /** @@ -370,14 +336,14 @@ public class ItemProductionMsg extends ClientNetMsg { // Common header - this.actionType = reader.getInt(); + this.actionType = mbEnums.ProductionActionType.values()[reader.getInt()]; reader.getInt(); // Building type padding this.buildingUUID = reader.getInt(); reader.getInt(); // NPC type padding this.npcUUID = reader.getInt(); switch (this.actionType) { - case ACTION_SETPRICE: + case SETPRICE: this.itemType = reader.getInt(); this.itemUUID = reader.getInt(); reader.getInt(); @@ -390,8 +356,8 @@ public class ItemProductionMsg extends ClientNetMsg { reader.getInt(); reader.get(); break; - case ACTION_RECYCLE: - case ACTION_TAKE: + case RECYCLE: + case TAKE: reader.getInt(); reader.getInt(); reader.getInt(); @@ -408,9 +374,9 @@ public class ItemProductionMsg extends ClientNetMsg { tempIDs.put(this.itemUUID, type); } reader.getInt(); - this.itemIDtoTypeMap = tempIDs; + this.items = tempIDs; break; - case ACTION_DEPOSIT: + case DEPOSIT: this.itemType = reader.getInt(); this.itemUUID = reader.getInt(); reader.getInt(); @@ -422,10 +388,10 @@ public class ItemProductionMsg extends ClientNetMsg { reader.getInt(); reader.get(); break; - case ACTION_JUNK: + case JUNK: this.itemType = reader.getInt(); this.itemUUID = reader.getInt(); - this.totalProduction = reader.getInt(); + this.total_to_produce = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); this.sToken = reader.getInt(); @@ -437,132 +403,20 @@ public class ItemProductionMsg extends ClientNetMsg { default: this.itemType = reader.getInt(); this.itemUUID = reader.getInt(); - this.totalProduction = reader.getInt(); + this.total_to_produce = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); this.sToken = reader.getInt(); this.name = reader.getString(); - this.isMultiple = reader.getInt() != 0 ? true : false; + this.size = reader.getInt(); reader.getInt(); - if (this.actionType == ACTION_COMPLETE || this.actionType == ACTION_JUNK) + if (this.actionType == mbEnums.ProductionActionType.COMPLETE || this.actionType == mbEnums.ProductionActionType.JUNK) reader.get(); else reader.getShort(); break; - } } - public int getItemType() { - return itemType; - } - - // TODO fix ArrayList Accessability. - public ArrayList getItemList() { - return this.ItemList; - } - - public void setItemList(ArrayList value) { - this.ItemList = value; - } - - public void addItem(Long item) { - this.ItemList.add(item); - } - - public int getUnknown01() { - return unknown01; - } - - public void setUnknown01(int unknown01) { - this.unknown01 = unknown01; - } - - public int getTotalProduction() { - return totalProduction; - } - - public void setTotalProduction(int unknown02) { - this.totalProduction = unknown02; - } - - public int getUnknown03() { - return unknown03; - } - - public void setUnknown03(int unknown03) { - this.unknown03 = unknown03; - } - - public int getItemUUID() { - return itemUUID; - } - - public void setItemUUID(int itemUUID) { - this.itemUUID = itemUUID; - } - - public int getpToken() { - return pToken; - } - - public void setpToken(int pToken) { - this.pToken = pToken; - } - - public int getsToken() { - return sToken; - } - - public void setsToken(int sToken) { - this.sToken = sToken; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - public int getActionType() { - return actionType; - } - - public final void setActionType(int actionType) { - this.actionType = actionType; - } - - public int getNpcUUID() { - return npcUUID; - } - - public HashMap getItemIDtoTypeMap() { - return itemIDtoTypeMap; - } - - /** - * @return the itemPrice - */ - public int getItemPrice() { - return itemPrice; - } - - public boolean isMultiple() { - return isMultiple; - } - - public void setMultiple(boolean isMultiple) { - this.isMultiple = isMultiple; - } } diff --git a/src/engine/net/client/msg/ItemToVaultMsg.java b/src/engine/net/client/msg/ItemToVaultMsg.java index b4e3eb11..2c0ef59e 100644 --- a/src/engine/net/client/msg/ItemToVaultMsg.java +++ b/src/engine/net/client/msg/ItemToVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from inventory to vault diff --git a/src/engine/net/client/msg/KeepAliveServerClientMsg.java b/src/engine/net/client/msg/KeepAliveServerClientMsg.java index e674d1b5..96d35334 100644 --- a/src/engine/net/client/msg/KeepAliveServerClientMsg.java +++ b/src/engine/net/client/msg/KeepAliveServerClientMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class KeepAliveServerClientMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LeaderboardMessage.java b/src/engine/net/client/msg/LeaderboardMessage.java index b5179f64..0026c456 100644 --- a/src/engine/net/client/msg/LeaderboardMessage.java +++ b/src/engine/net/client/msg/LeaderboardMessage.java @@ -15,7 +15,7 @@ import engine.mbEnums.ShrineType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.Guild; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/LeaveWorldMsg.java b/src/engine/net/client/msg/LeaveWorldMsg.java index 0711c881..45b622bd 100644 --- a/src/engine/net/client/msg/LeaveWorldMsg.java +++ b/src/engine/net/client/msg/LeaveWorldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LeaveWorldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LoadCharacterMsg.java b/src/engine/net/client/msg/LoadCharacterMsg.java index 50399a6f..e4efc1b3 100644 --- a/src/engine/net/client/msg/LoadCharacterMsg.java +++ b/src/engine/net/client/msg/LoadCharacterMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.AbstractCharacter; import engine.objects.Corpse; diff --git a/src/engine/net/client/msg/LoadStructureMsg.java b/src/engine/net/client/msg/LoadStructureMsg.java index fe8014d2..a59a8064 100644 --- a/src/engine/net/client/msg/LoadStructureMsg.java +++ b/src/engine/net/client/msg/LoadStructureMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Building; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/LockUnlockDoorMsg.java b/src/engine/net/client/msg/LockUnlockDoorMsg.java index b644be14..99fe3750 100644 --- a/src/engine/net/client/msg/LockUnlockDoorMsg.java +++ b/src/engine/net/client/msg/LockUnlockDoorMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LockUnlockDoorMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LoginToGameServerMsg.java b/src/engine/net/client/msg/LoginToGameServerMsg.java index e77639aa..f1f17db8 100644 --- a/src/engine/net/client/msg/LoginToGameServerMsg.java +++ b/src/engine/net/client/msg/LoginToGameServerMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LoginToGameServerMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LootMsg.java b/src/engine/net/client/msg/LootMsg.java index 86c49c03..84b0024a 100644 --- a/src/engine/net/client/msg/LootMsg.java +++ b/src/engine/net/client/msg/LootMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; public class LootMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LootWindowRequestMsg.java b/src/engine/net/client/msg/LootWindowRequestMsg.java index 94832bec..cd938df8 100644 --- a/src/engine/net/client/msg/LootWindowRequestMsg.java +++ b/src/engine/net/client/msg/LootWindowRequestMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LootWindowRequestMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LootWindowResponseMsg.java b/src/engine/net/client/msg/LootWindowResponseMsg.java index c6d42530..e18fe1f2 100644 --- a/src/engine/net/client/msg/LootWindowResponseMsg.java +++ b/src/engine/net/client/msg/LootWindowResponseMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/ManageCityAssetsMsg.java b/src/engine/net/client/msg/ManageCityAssetsMsg.java index 5f640f05..85620300 100644 --- a/src/engine/net/client/msg/ManageCityAssetsMsg.java +++ b/src/engine/net/client/msg/ManageCityAssetsMsg.java @@ -16,7 +16,7 @@ import engine.mbEnums.*; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import org.joda.time.DateTime; import org.joda.time.Period; diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index a13620b9..7c4d6647 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -10,15 +10,13 @@ package engine.net.client.msg; import engine.gameManager.NPCManager; -import engine.gameManager.PowersManager; import engine.mbEnums.GameObjectType; import engine.mbEnums.MinionType; import engine.mbEnums.ProtectionState; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; -import engine.powers.EffectsBase; import org.joda.time.DateTime; import org.joda.time.Period; import org.joda.time.Seconds; @@ -26,8 +24,6 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashSet; -import java.util.List; -import java.util.stream.Collectors; /** * Order NPC @@ -435,12 +431,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - List itemList = npc.getRolling(); - itemList = itemList.stream().limit(npc.getRank()).collect(Collectors.toList()); + ArrayList cooking = NPCManager.getAllCookingForVendor(npc); + writer.putInt(cooking.size()); - writer.putInt(itemList.size()); - - for (Item item : itemList) { + for (Item item : cooking) { writer.put((byte) 0); // ? Unknown45 writer.putInt(item.getObjectType().ordinal()); @@ -462,33 +456,13 @@ public class ManageNPCMsg extends ClientNetMsg { else writer.put((byte) 0); - ArrayList effectsList = item.getEffectNames(); - EffectsBase prefix = null; - EffectsBase suffix = null; - - for (String effectName : effectsList) { - - if (effectName.contains("PRE")) - prefix = PowersManager.getEffectByIDString(effectName); - - if (effectName.contains("SUF")) - suffix = PowersManager.getEffectByIDString(effectName); - } - - if ((prefix == null && suffix == null)) + if ((item.prefixToken == 0 && item.suffixToken == 0)) writer.putInt(0); else writer.putInt(-1497023830); - if ((prefix != null && !item.isRandom()) || (prefix != null && item.isComplete())) - writer.putInt(prefix.getToken()); - else - writer.putInt(0); - - if ((suffix != null && !item.isRandom()) || (suffix != null && item.isComplete())) - writer.putInt(suffix.getToken()); - else - writer.putInt(0); + writer.putInt(item.prefixToken); + writer.putInt(item.suffixToken); writer.putString(item.name); } @@ -523,10 +497,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(2); writer.putInt(0); writer.putInt(1); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt));//writer.putInt(-916801465); effectItemType + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue());//writer.putInt(-916801465); effectItemType writer.putInt(mtp); //prefix int mts = modPrefixList.indexOf(mtp); writer.putInt(npc.getModSuffixTable().get(mts)); //suffix diff --git a/src/engine/net/client/msg/MerchantMsg.java b/src/engine/net/client/msg/MerchantMsg.java index d14d0692..fd14a2f7 100644 --- a/src/engine/net/client/msg/MerchantMsg.java +++ b/src/engine/net/client/msg/MerchantMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class MerchantMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/MinionTrainingMessage.java b/src/engine/net/client/msg/MinionTrainingMessage.java index 507db953..d9e3cf84 100644 --- a/src/engine/net/client/msg/MinionTrainingMessage.java +++ b/src/engine/net/client/msg/MinionTrainingMessage.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class MinionTrainingMessage extends ClientNetMsg { private int npcID; diff --git a/src/engine/net/client/msg/ModifyCommitToTradeMsg.java b/src/engine/net/client/msg/ModifyCommitToTradeMsg.java index dad76a06..18b83439 100644 --- a/src/engine/net/client/msg/ModifyCommitToTradeMsg.java +++ b/src/engine/net/client/msg/ModifyCommitToTradeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/ModifyHealthKillMsg.java b/src/engine/net/client/msg/ModifyHealthKillMsg.java index e0de0498..30e705f3 100644 --- a/src/engine/net/client/msg/ModifyHealthKillMsg.java +++ b/src/engine/net/client/msg/ModifyHealthKillMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class ModifyHealthKillMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ModifyHealthMsg.java b/src/engine/net/client/msg/ModifyHealthMsg.java index 39a9a94b..7e79efc6 100644 --- a/src/engine/net/client/msg/ModifyHealthMsg.java +++ b/src/engine/net/client/msg/ModifyHealthMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.Building; diff --git a/src/engine/net/client/msg/ModifyStatMsg.java b/src/engine/net/client/msg/ModifyStatMsg.java index f01ff56c..318c2242 100644 --- a/src/engine/net/client/msg/ModifyStatMsg.java +++ b/src/engine/net/client/msg/ModifyStatMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ModifyStatMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/MoveCorrectionMsg.java b/src/engine/net/client/msg/MoveCorrectionMsg.java index 67618bd8..b23b6b42 100644 --- a/src/engine/net/client/msg/MoveCorrectionMsg.java +++ b/src/engine/net/client/msg/MoveCorrectionMsg.java @@ -14,7 +14,7 @@ import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class MoveCorrectionMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/MoveToPointMsg.java b/src/engine/net/client/msg/MoveToPointMsg.java index e9f83de7..6f9253fc 100644 --- a/src/engine/net/client/msg/MoveToPointMsg.java +++ b/src/engine/net/client/msg/MoveToPointMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.Building; diff --git a/src/engine/net/client/msg/ObjectActionMsg.java b/src/engine/net/client/msg/ObjectActionMsg.java index c3922440..2e64dafc 100644 --- a/src/engine/net/client/msg/ObjectActionMsg.java +++ b/src/engine/net/client/msg/ObjectActionMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java index 4082d469..6b130bd9 100644 --- a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java +++ b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java @@ -15,8 +15,8 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; +import engine.net.Protocol; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/OpenTradeWindowMsg.java b/src/engine/net/client/msg/OpenTradeWindowMsg.java index 05af29b5..35931622 100644 --- a/src/engine/net/client/msg/OpenTradeWindowMsg.java +++ b/src/engine/net/client/msg/OpenTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/OpenVaultMsg.java b/src/engine/net/client/msg/OpenVaultMsg.java index 61aca7e9..3238008d 100644 --- a/src/engine/net/client/msg/OpenVaultMsg.java +++ b/src/engine/net/client/msg/OpenVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/OrderNPCMsg.java b/src/engine/net/client/msg/OrderNPCMsg.java index dac9ea5b..f2e7f103 100644 --- a/src/engine/net/client/msg/OrderNPCMsg.java +++ b/src/engine/net/client/msg/OrderNPCMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/PassiveMessageTriggerMsg.java b/src/engine/net/client/msg/PassiveMessageTriggerMsg.java index 87070bdf..e6374948 100644 --- a/src/engine/net/client/msg/PassiveMessageTriggerMsg.java +++ b/src/engine/net/client/msg/PassiveMessageTriggerMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PassiveMessageTriggerMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PerformActionMsg.java b/src/engine/net/client/msg/PerformActionMsg.java index 0c838b09..e7301a05 100644 --- a/src/engine/net/client/msg/PerformActionMsg.java +++ b/src/engine/net/client/msg/PerformActionMsg.java @@ -15,7 +15,7 @@ import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PerformActionMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetAttackMsg.java b/src/engine/net/client/msg/PetAttackMsg.java index 40ae985b..86295028 100644 --- a/src/engine/net/client/msg/PetAttackMsg.java +++ b/src/engine/net/client/msg/PetAttackMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PetAttackMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetCmdMsg.java b/src/engine/net/client/msg/PetCmdMsg.java index 64095719..1c13adf5 100644 --- a/src/engine/net/client/msg/PetCmdMsg.java +++ b/src/engine/net/client/msg/PetCmdMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PetCmdMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetMsg.java b/src/engine/net/client/msg/PetMsg.java index ca378aae..886ba0bd 100644 --- a/src/engine/net/client/msg/PetMsg.java +++ b/src/engine/net/client/msg/PetMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Mob; public class PetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetitionReceivedMsg.java b/src/engine/net/client/msg/PetitionReceivedMsg.java index fa66f1a9..5019632c 100644 --- a/src/engine/net/client/msg/PetitionReceivedMsg.java +++ b/src/engine/net/client/msg/PetitionReceivedMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.stream.IntStream; diff --git a/src/engine/net/client/msg/PlaceAssetMsg.java b/src/engine/net/client/msg/PlaceAssetMsg.java index 9991590f..15d0f14c 100644 --- a/src/engine/net/client/msg/PlaceAssetMsg.java +++ b/src/engine/net/client/msg/PlaceAssetMsg.java @@ -13,7 +13,6 @@ import engine.math.Vector3fImmutable; import engine.mbEnums; import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.Zone; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/PowerProjectileMsg.java b/src/engine/net/client/msg/PowerProjectileMsg.java index 0a7f46c2..1f31dd06 100644 --- a/src/engine/net/client/msg/PowerProjectileMsg.java +++ b/src/engine/net/client/msg/PowerProjectileMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/PromptRecallMsg.java b/src/engine/net/client/msg/PromptRecallMsg.java index d550bed4..fb4e716b 100644 --- a/src/engine/net/client/msg/PromptRecallMsg.java +++ b/src/engine/net/client/msg/PromptRecallMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PromptRecallMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RandomMsg.java b/src/engine/net/client/msg/RandomMsg.java index e2b12421..1c12f9a1 100644 --- a/src/engine/net/client/msg/RandomMsg.java +++ b/src/engine/net/client/msg/RandomMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RandomMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RecommendNationMsg.java b/src/engine/net/client/msg/RecommendNationMsg.java index d5b86184..5efc2de8 100644 --- a/src/engine/net/client/msg/RecommendNationMsg.java +++ b/src/engine/net/client/msg/RecommendNationMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/RecvSummonsMsg.java b/src/engine/net/client/msg/RecvSummonsMsg.java index bf37bf96..e84caa10 100644 --- a/src/engine/net/client/msg/RecvSummonsMsg.java +++ b/src/engine/net/client/msg/RecvSummonsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RecvSummonsMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RecyclePowerMsg.java b/src/engine/net/client/msg/RecyclePowerMsg.java index 015e5164..e91b626e 100644 --- a/src/engine/net/client/msg/RecyclePowerMsg.java +++ b/src/engine/net/client/msg/RecyclePowerMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RecyclePowerMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RefineMsg.java b/src/engine/net/client/msg/RefineMsg.java index 1e6e6eba..aa12f22c 100644 --- a/src/engine/net/client/msg/RefineMsg.java +++ b/src/engine/net/client/msg/RefineMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RefineMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RefinerScreenMsg.java b/src/engine/net/client/msg/RefinerScreenMsg.java index 54f5e8e3..674e63a3 100644 --- a/src/engine/net/client/msg/RefinerScreenMsg.java +++ b/src/engine/net/client/msg/RefinerScreenMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RefinerScreenMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RejectTradeRequestMsg.java b/src/engine/net/client/msg/RejectTradeRequestMsg.java index 1305a3a6..9fdb282e 100644 --- a/src/engine/net/client/msg/RejectTradeRequestMsg.java +++ b/src/engine/net/client/msg/RejectTradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/RemoveFriendMessage.java b/src/engine/net/client/msg/RemoveFriendMessage.java index be34be10..42c88a98 100644 --- a/src/engine/net/client/msg/RemoveFriendMessage.java +++ b/src/engine/net/client/msg/RemoveFriendMessage.java @@ -10,7 +10,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RemoveFriendMessage extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RepairBuildingMsg.java b/src/engine/net/client/msg/RepairBuildingMsg.java index fdf86960..1cb03004 100644 --- a/src/engine/net/client/msg/RepairBuildingMsg.java +++ b/src/engine/net/client/msg/RepairBuildingMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RepairBuildingMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RepairMsg.java b/src/engine/net/client/msg/RepairMsg.java index cd3712b5..08a51023 100644 --- a/src/engine/net/client/msg/RepairMsg.java +++ b/src/engine/net/client/msg/RepairMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Contract; import engine.objects.NPC; diff --git a/src/engine/net/client/msg/ReqBankInventoryMsg.java b/src/engine/net/client/msg/ReqBankInventoryMsg.java index a2941cef..fd5f14bd 100644 --- a/src/engine/net/client/msg/ReqBankInventoryMsg.java +++ b/src/engine/net/client/msg/ReqBankInventoryMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/RequestBallListMessage.java b/src/engine/net/client/msg/RequestBallListMessage.java index 3e4a689e..1c29dc71 100644 --- a/src/engine/net/client/msg/RequestBallListMessage.java +++ b/src/engine/net/client/msg/RequestBallListMessage.java @@ -10,7 +10,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/RequestEnterWorldMsg.java b/src/engine/net/client/msg/RequestEnterWorldMsg.java index 217eb375..28c1eb9e 100644 --- a/src/engine/net/client/msg/RequestEnterWorldMsg.java +++ b/src/engine/net/client/msg/RequestEnterWorldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RequestEnterWorldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RespawnMsg.java b/src/engine/net/client/msg/RespawnMsg.java index ebf5eaa5..368f18e5 100644 --- a/src/engine/net/client/msg/RespawnMsg.java +++ b/src/engine/net/client/msg/RespawnMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RespawnMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RespondLeaveWorldMsg.java b/src/engine/net/client/msg/RespondLeaveWorldMsg.java index a2c646dc..a75a1cb2 100644 --- a/src/engine/net/client/msg/RespondLeaveWorldMsg.java +++ b/src/engine/net/client/msg/RespondLeaveWorldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RespondLeaveWorldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RotateObjectMsg.java b/src/engine/net/client/msg/RotateObjectMsg.java index 090a9b8c..ed19cfa8 100644 --- a/src/engine/net/client/msg/RotateObjectMsg.java +++ b/src/engine/net/client/msg/RotateObjectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Mob; public class RotateObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/SafeModeMsg.java b/src/engine/net/client/msg/SafeModeMsg.java index 8dfb9de5..9aecaeab 100644 --- a/src/engine/net/client/msg/SafeModeMsg.java +++ b/src/engine/net/client/msg/SafeModeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class SafeModeMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ScaleObjectMsg.java b/src/engine/net/client/msg/ScaleObjectMsg.java index 877fbcef..cd78d77b 100644 --- a/src/engine/net/client/msg/ScaleObjectMsg.java +++ b/src/engine/net/client/msg/ScaleObjectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ScaleObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/SelectCityMsg.java b/src/engine/net/client/msg/SelectCityMsg.java index 4e13af87..07c199eb 100644 --- a/src/engine/net/client/msg/SelectCityMsg.java +++ b/src/engine/net/client/msg/SelectCityMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/SendBallEntryMessage.java b/src/engine/net/client/msg/SendBallEntryMessage.java index 9b431841..447bbc11 100644 --- a/src/engine/net/client/msg/SendBallEntryMessage.java +++ b/src/engine/net/client/msg/SendBallEntryMessage.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/SendOwnPlayerMsg.java b/src/engine/net/client/msg/SendOwnPlayerMsg.java index f83f0dc1..bd43ba20 100644 --- a/src/engine/net/client/msg/SendOwnPlayerMsg.java +++ b/src/engine/net/client/msg/SendOwnPlayerMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Building; import engine.objects.PlayerCharacter; import engine.objects.Regions; diff --git a/src/engine/net/client/msg/SendSummonsMsg.java b/src/engine/net/client/msg/SendSummonsMsg.java index 6b5723b5..64942b23 100644 --- a/src/engine/net/client/msg/SendSummonsMsg.java +++ b/src/engine/net/client/msg/SendSummonsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class SendSummonsMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ServerInfoMsg.java b/src/engine/net/client/msg/ServerInfoMsg.java index 33320c0f..4d2f57f1 100644 --- a/src/engine/net/client/msg/ServerInfoMsg.java +++ b/src/engine/net/client/msg/ServerInfoMsg.java @@ -14,7 +14,7 @@ import engine.gameManager.ConfigManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.server.MBServerStatics; import engine.server.login.LoginServer; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/SetCombatModeMsg.java b/src/engine/net/client/msg/SetCombatModeMsg.java index 7ae0f3f5..2dab8536 100644 --- a/src/engine/net/client/msg/SetCombatModeMsg.java +++ b/src/engine/net/client/msg/SetCombatModeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/SetObjectValueMsg.java b/src/engine/net/client/msg/SetObjectValueMsg.java index a7ea9e68..74cd0a16 100644 --- a/src/engine/net/client/msg/SetObjectValueMsg.java +++ b/src/engine/net/client/msg/SetObjectValueMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; public class SetObjectValueMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ShowBankInventoryMsg.java b/src/engine/net/client/msg/ShowBankInventoryMsg.java index c85801d6..f739f47a 100644 --- a/src/engine/net/client/msg/ShowBankInventoryMsg.java +++ b/src/engine/net/client/msg/ShowBankInventoryMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.Item; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/ShowMsg.java b/src/engine/net/client/msg/ShowMsg.java index 93686ce8..730bd234 100644 --- a/src/engine/net/client/msg/ShowMsg.java +++ b/src/engine/net/client/msg/ShowMsg.java @@ -14,7 +14,7 @@ import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ShowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ShowVaultInventoryMsg.java b/src/engine/net/client/msg/ShowVaultInventoryMsg.java index 5df29795..04692531 100644 --- a/src/engine/net/client/msg/ShowVaultInventoryMsg.java +++ b/src/engine/net/client/msg/ShowVaultInventoryMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/SocialMsg.java b/src/engine/net/client/msg/SocialMsg.java index be748357..cc9c7f21 100644 --- a/src/engine/net/client/msg/SocialMsg.java +++ b/src/engine/net/client/msg/SocialMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class SocialMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/StuckMsg.java b/src/engine/net/client/msg/StuckMsg.java index b598cb15..2ae240ca 100644 --- a/src/engine/net/client/msg/StuckMsg.java +++ b/src/engine/net/client/msg/StuckMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class StuckMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TargetObjectMsg.java b/src/engine/net/client/msg/TargetObjectMsg.java index 55d6f28f..d124a8de 100644 --- a/src/engine/net/client/msg/TargetObjectMsg.java +++ b/src/engine/net/client/msg/TargetObjectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TargetObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TargetedActionMsg.java b/src/engine/net/client/msg/TargetedActionMsg.java index c60d7056..25736d37 100644 --- a/src/engine/net/client/msg/TargetedActionMsg.java +++ b/src/engine/net/client/msg/TargetedActionMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.objects.PlayerCharacter; @@ -81,7 +81,7 @@ public class TargetedActionMsg extends ClientNetMsg { private float locX; private float locZ; private int unknown01 = 14; - private int unknown02 = 100; //source animation + private int animationID = 100; //source animation private float unknown03 = 1f; private float sourceStamina = 1f; // attackers stamina after attack private int unknown05 = 6; //signify passive defense @@ -164,7 +164,7 @@ public class TargetedActionMsg extends ClientNetMsg { this.newHealth = 1f; this.damage = damage; } - this.unknown02 = swingAnimation; + this.animationID = swingAnimation; //this.unknown02 = TargetedActionMsg.un2cnt; } @@ -196,7 +196,7 @@ public class TargetedActionMsg extends ClientNetMsg { this.newHealth = 1f; this.damage = damage; } - this.unknown02 = swingAnimation; + this.animationID = swingAnimation; //this.unknown02 = TargetedActionMsg.un2cnt; } @@ -247,7 +247,7 @@ public class TargetedActionMsg extends ClientNetMsg { writer.putFloat(this.locX); writer.putFloat(this.locZ); writer.putInt(this.unknown01); - writer.putInt(this.unknown02); + writer.putInt(this.animationID); writer.putFloat(this.unknown03); writer.putFloat(this.sourceStamina); writer.putInt(this.unknown05); @@ -275,7 +275,7 @@ public class TargetedActionMsg extends ClientNetMsg { this.locX = reader.getFloat(); this.locZ = reader.getFloat(); this.unknown01 = reader.getInt(); - this.unknown02 = reader.getInt(); + this.animationID = reader.getInt(); this.unknown03 = reader.getFloat(); this.sourceStamina = reader.getFloat(); this.unknown05 = reader.getInt(); diff --git a/src/engine/net/client/msg/TaxCityMsg.java b/src/engine/net/client/msg/TaxCityMsg.java index e2e80e22..d0030bf7 100644 --- a/src/engine/net/client/msg/TaxCityMsg.java +++ b/src/engine/net/client/msg/TaxCityMsg.java @@ -9,13 +9,13 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; import engine.gameManager.BuildingManager; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/TaxResourcesMsg.java b/src/engine/net/client/msg/TaxResourcesMsg.java index a14639f8..f6ca4e28 100644 --- a/src/engine/net/client/msg/TaxResourcesMsg.java +++ b/src/engine/net/client/msg/TaxResourcesMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import java.util.HashMap; diff --git a/src/engine/net/client/msg/TeleportRepledgeListMsg.java b/src/engine/net/client/msg/TeleportRepledgeListMsg.java index a76f2abf..d48fc751 100644 --- a/src/engine/net/client/msg/TeleportRepledgeListMsg.java +++ b/src/engine/net/client/msg/TeleportRepledgeListMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.City; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/TeleportToPointMsg.java b/src/engine/net/client/msg/TeleportToPointMsg.java index 61fcd6a6..78d888df 100644 --- a/src/engine/net/client/msg/TeleportToPointMsg.java +++ b/src/engine/net/client/msg/TeleportToPointMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class TeleportToPointMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TerritoryChangeMessage.java b/src/engine/net/client/msg/TerritoryChangeMessage.java index 87e811b0..ff42b87a 100644 --- a/src/engine/net/client/msg/TerritoryChangeMessage.java +++ b/src/engine/net/client/msg/TerritoryChangeMessage.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; import engine.objects.Realm; diff --git a/src/engine/net/client/msg/ToggleCombatMsg.java b/src/engine/net/client/msg/ToggleCombatMsg.java index 613ee1f0..170016df 100644 --- a/src/engine/net/client/msg/ToggleCombatMsg.java +++ b/src/engine/net/client/msg/ToggleCombatMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ToggleCombatMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java b/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java index 8b443240..1ce26b80 100644 --- a/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java +++ b/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ToggleLfgRecruitingMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ToggleSitStandMsg.java b/src/engine/net/client/msg/ToggleSitStandMsg.java index e7e94898..db55f3c8 100644 --- a/src/engine/net/client/msg/ToggleSitStandMsg.java +++ b/src/engine/net/client/msg/ToggleSitStandMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ToggleSitStandMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TrackArrowMsg.java b/src/engine/net/client/msg/TrackArrowMsg.java index b66056de..872f5995 100644 --- a/src/engine/net/client/msg/TrackArrowMsg.java +++ b/src/engine/net/client/msg/TrackArrowMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TrackArrowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TrackWindowMsg.java b/src/engine/net/client/msg/TrackWindowMsg.java index 61256bfb..07751e55 100644 --- a/src/engine/net/client/msg/TrackWindowMsg.java +++ b/src/engine/net/client/msg/TrackWindowMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; import engine.mbEnums.GameObjectType; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.*; import java.util.HashSet; diff --git a/src/engine/net/client/msg/TradeRequestMsg.java b/src/engine/net/client/msg/TradeRequestMsg.java index bf9ace62..bfcbd30a 100644 --- a/src/engine/net/client/msg/TradeRequestMsg.java +++ b/src/engine/net/client/msg/TradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/TrainMsg.java b/src/engine/net/client/msg/TrainMsg.java index 7cd3213f..9fd4ce7d 100644 --- a/src/engine/net/client/msg/TrainMsg.java +++ b/src/engine/net/client/msg/TrainMsg.java @@ -12,7 +12,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.NPC; diff --git a/src/engine/net/client/msg/TrainerInfoMsg.java b/src/engine/net/client/msg/TrainerInfoMsg.java index ea8c5630..4f751aea 100644 --- a/src/engine/net/client/msg/TrainerInfoMsg.java +++ b/src/engine/net/client/msg/TrainerInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TrainerInfoMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferAssetMsg.java b/src/engine/net/client/msg/TransferAssetMsg.java index 1ea61d0a..bfa55504 100644 --- a/src/engine/net/client/msg/TransferAssetMsg.java +++ b/src/engine/net/client/msg/TransferAssetMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TransferAssetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferBuildingMsg.java b/src/engine/net/client/msg/TransferBuildingMsg.java index 7a04c25c..83886f5da 100644 --- a/src/engine/net/client/msg/TransferBuildingMsg.java +++ b/src/engine/net/client/msg/TransferBuildingMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TransferBuildingMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java b/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java index 60011884..0681c9f4 100644 --- a/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java +++ b/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/TransferItemFromBankMsg.java b/src/engine/net/client/msg/TransferItemFromBankMsg.java index e330984f..3ee1da26 100644 --- a/src/engine/net/client/msg/TransferItemFromBankMsg.java +++ b/src/engine/net/client/msg/TransferItemFromBankMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from bank to inventory diff --git a/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java b/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java index 48ba28c2..dce19863 100644 --- a/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java +++ b/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java @@ -10,12 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.exception.SerializationException; +import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; public class TransferItemFromEquipToInventoryMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java b/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java index 9aeb8ff3..8b734f3c 100644 --- a/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java +++ b/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java @@ -10,12 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.exception.SerializationException; +import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferItemToBankMsg.java b/src/engine/net/client/msg/TransferItemToBankMsg.java index 617befdb..deda39f6 100644 --- a/src/engine/net/client/msg/TransferItemToBankMsg.java +++ b/src/engine/net/client/msg/TransferItemToBankMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from inventory to bank diff --git a/src/engine/net/client/msg/UncommitToTradeMsg.java b/src/engine/net/client/msg/UncommitToTradeMsg.java index 7a175350..abc38e61 100644 --- a/src/engine/net/client/msg/UncommitToTradeMsg.java +++ b/src/engine/net/client/msg/UncommitToTradeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/Unknown1Msg.java b/src/engine/net/client/msg/Unknown1Msg.java index 4c92abf1..25a48584 100644 --- a/src/engine/net/client/msg/Unknown1Msg.java +++ b/src/engine/net/client/msg/Unknown1Msg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class Unknown1Msg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UnknownMsg.java b/src/engine/net/client/msg/UnknownMsg.java index 7d57ea49..c0501f8e 100644 --- a/src/engine/net/client/msg/UnknownMsg.java +++ b/src/engine/net/client/msg/UnknownMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class UnknownMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UnloadObjectsMsg.java b/src/engine/net/client/msg/UnloadObjectsMsg.java index e300e646..a1caed51 100644 --- a/src/engine/net/client/msg/UnloadObjectsMsg.java +++ b/src/engine/net/client/msg/UnloadObjectsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/UpdateCharOrMobMessage.java b/src/engine/net/client/msg/UpdateCharOrMobMessage.java index 5eae48ed..de5ab270 100644 --- a/src/engine/net/client/msg/UpdateCharOrMobMessage.java +++ b/src/engine/net/client/msg/UpdateCharOrMobMessage.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class UpdateCharOrMobMessage extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UpdateClientAlliancesMsg.java b/src/engine/net/client/msg/UpdateClientAlliancesMsg.java index a872c431..c2b23970 100644 --- a/src/engine/net/client/msg/UpdateClientAlliancesMsg.java +++ b/src/engine/net/client/msg/UpdateClientAlliancesMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Guild; diff --git a/src/engine/net/client/msg/UpdateEffectsMsg.java b/src/engine/net/client/msg/UpdateEffectsMsg.java index aa7a1f8b..0537b019 100644 --- a/src/engine/net/client/msg/UpdateEffectsMsg.java +++ b/src/engine/net/client/msg/UpdateEffectsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; import engine.objects.Effect; diff --git a/src/engine/net/client/msg/UpdateFriendStatusMessage.java b/src/engine/net/client/msg/UpdateFriendStatusMessage.java index ecb34248..32444398 100644 --- a/src/engine/net/client/msg/UpdateFriendStatusMessage.java +++ b/src/engine/net/client/msg/UpdateFriendStatusMessage.java @@ -6,12 +6,12 @@ HashSet playerFriendSet = PlayerFriendsMap.get(playerUID); package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.gameManager.SessionManager; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/UpdateGoldMsg.java b/src/engine/net/client/msg/UpdateGoldMsg.java index 604014fa..4c706581 100644 --- a/src/engine/net/client/msg/UpdateGoldMsg.java +++ b/src/engine/net/client/msg/UpdateGoldMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; import engine.objects.CharacterItemManager; import engine.objects.Item; diff --git a/src/engine/net/client/msg/UpdateInventoryMsg.java b/src/engine/net/client/msg/UpdateInventoryMsg.java index 2e458f9e..3eb03447 100644 --- a/src/engine/net/client/msg/UpdateInventoryMsg.java +++ b/src/engine/net/client/msg/UpdateInventoryMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.ItemType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/UpdateObjectMsg.java b/src/engine/net/client/msg/UpdateObjectMsg.java index aae3ea64..9b16e475 100644 --- a/src/engine/net/client/msg/UpdateObjectMsg.java +++ b/src/engine/net/client/msg/UpdateObjectMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; public class UpdateObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UpdateStateMsg.java b/src/engine/net/client/msg/UpdateStateMsg.java index 775fcafc..1496d432 100644 --- a/src/engine/net/client/msg/UpdateStateMsg.java +++ b/src/engine/net/client/msg/UpdateStateMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/UpdateTradeWindowMsg.java b/src/engine/net/client/msg/UpdateTradeWindowMsg.java index 9bf0d9d9..80937e16 100644 --- a/src/engine/net/client/msg/UpdateTradeWindowMsg.java +++ b/src/engine/net/client/msg/UpdateTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/UpdateVaultMsg.java b/src/engine/net/client/msg/UpdateVaultMsg.java index 0ef84124..9a8a278c 100644 --- a/src/engine/net/client/msg/UpdateVaultMsg.java +++ b/src/engine/net/client/msg/UpdateVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Account; /** diff --git a/src/engine/net/client/msg/UpgradeAssetMessage.java b/src/engine/net/client/msg/UpgradeAssetMessage.java index d0366928..2f69180d 100644 --- a/src/engine/net/client/msg/UpgradeAssetMessage.java +++ b/src/engine/net/client/msg/UpgradeAssetMessage.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; public class UpgradeAssetMessage extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UseCharterMsg.java b/src/engine/net/client/msg/UseCharterMsg.java index 8b80ca23..1fe5f91f 100644 --- a/src/engine/net/client/msg/UseCharterMsg.java +++ b/src/engine/net/client/msg/UseCharterMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.ItemType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/VendorBuyMsg.java b/src/engine/net/client/msg/VendorBuyMsg.java index 58183e53..643865b6 100644 --- a/src/engine/net/client/msg/VendorBuyMsg.java +++ b/src/engine/net/client/msg/VendorBuyMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; public class VendorBuyMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/VendorBuyWindowMsg.java b/src/engine/net/client/msg/VendorBuyWindowMsg.java index acbb835d..9c5517a3 100644 --- a/src/engine/net/client/msg/VendorBuyWindowMsg.java +++ b/src/engine/net/client/msg/VendorBuyWindowMsg.java @@ -9,14 +9,10 @@ package engine.net.client.msg; -import engine.mbEnums.ItemType; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; +import engine.mbEnums.ItemType; +import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/VendorDialogMsg.java b/src/engine/net/client/msg/VendorDialogMsg.java index f694a5a4..e91c7c34 100644 --- a/src/engine/net/client/msg/VendorDialogMsg.java +++ b/src/engine/net/client/msg/VendorDialogMsg.java @@ -12,7 +12,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.MenuOption; import engine.objects.VendorDialog; diff --git a/src/engine/net/client/msg/VendorSellMsg.java b/src/engine/net/client/msg/VendorSellMsg.java index 830400e4..630f8a60 100644 --- a/src/engine/net/client/msg/VendorSellMsg.java +++ b/src/engine/net/client/msg/VendorSellMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Buy from NPC msg diff --git a/src/engine/net/client/msg/VendorSellWindowMsg.java b/src/engine/net/client/msg/VendorSellWindowMsg.java index 5a81f731..152a3c74 100644 --- a/src/engine/net/client/msg/VendorSellWindowMsg.java +++ b/src/engine/net/client/msg/VendorSellWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/ViewResourcesMsg.java b/src/engine/net/client/msg/ViewResourcesMsg.java index cbaaaa94..b3e5acff 100644 --- a/src/engine/net/client/msg/ViewResourcesMsg.java +++ b/src/engine/net/client/msg/ViewResourcesMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.gameManager.DbManager; +import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; diff --git a/src/engine/net/client/msg/VisualUpdateMessage.java b/src/engine/net/client/msg/VisualUpdateMessage.java index 94e79894..fa88e585 100644 --- a/src/engine/net/client/msg/VisualUpdateMessage.java +++ b/src/engine/net/client/msg/VisualUpdateMessage.java @@ -10,12 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; import engine.objects.Building; diff --git a/src/engine/net/client/msg/WhoRequestMsg.java b/src/engine/net/client/msg/WhoRequestMsg.java index 93433461..13849af0 100644 --- a/src/engine/net/client/msg/WhoRequestMsg.java +++ b/src/engine/net/client/msg/WhoRequestMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class WhoRequestMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/WhoResponseMsg.java b/src/engine/net/client/msg/WhoResponseMsg.java index 02cb59db..c89fe630 100644 --- a/src/engine/net/client/msg/WhoResponseMsg.java +++ b/src/engine/net/client/msg/WhoResponseMsg.java @@ -9,11 +9,10 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.gameManager.SessionManager; +import engine.mbEnums; import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.Guild; import engine.objects.GuildStatusController; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index 025a30fe..bd526df0 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -10,16 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.exception.SerializationException; import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.mbEnums; +import engine.net.*; import engine.objects.Zone; import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/WorldRealmMsg.java b/src/engine/net/client/msg/WorldRealmMsg.java index fde56eb5..3959504b 100644 --- a/src/engine/net/client/msg/WorldRealmMsg.java +++ b/src/engine/net/client/msg/WorldRealmMsg.java @@ -12,7 +12,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Realm; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/AbstractChatMsg.java b/src/engine/net/client/msg/chat/AbstractChatMsg.java index 5b69e03a..bdb17057 100644 --- a/src/engine/net/client/msg/chat/AbstractChatMsg.java +++ b/src/engine/net/client/msg/chat/AbstractChatMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/chat/ChatCSRMsg.java b/src/engine/net/client/msg/chat/ChatCSRMsg.java index 1aff5bbd..b9e7a537 100644 --- a/src/engine/net/client/msg/chat/ChatCSRMsg.java +++ b/src/engine/net/client/msg/chat/ChatCSRMsg.java @@ -14,8 +14,8 @@ import engine.gameManager.SessionManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; +import engine.net.Protocol; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; import engine.session.Session; diff --git a/src/engine/net/client/msg/chat/ChatCityMsg.java b/src/engine/net/client/msg/chat/ChatCityMsg.java index 20956c9a..68cff1ea 100644 --- a/src/engine/net/client/msg/chat/ChatCityMsg.java +++ b/src/engine/net/client/msg/chat/ChatCityMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractGameObject; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/chat/ChatGlobalMsg.java b/src/engine/net/client/msg/chat/ChatGlobalMsg.java index f7658ddd..b11f26fe 100644 --- a/src/engine/net/client/msg/chat/ChatGlobalMsg.java +++ b/src/engine/net/client/msg/chat/ChatGlobalMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/ChatGroupMsg.java b/src/engine/net/client/msg/chat/ChatGroupMsg.java index 15bbe6a1..90fea319 100644 --- a/src/engine/net/client/msg/chat/ChatGroupMsg.java +++ b/src/engine/net/client/msg/chat/ChatGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatGroupMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatGuildMsg.java b/src/engine/net/client/msg/chat/ChatGuildMsg.java index 8974654e..5bf73048 100644 --- a/src/engine/net/client/msg/chat/ChatGuildMsg.java +++ b/src/engine/net/client/msg/chat/ChatGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatGuildMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatICMsg.java b/src/engine/net/client/msg/chat/ChatICMsg.java index b2d3dfe4..8b73f1cc 100644 --- a/src/engine/net/client/msg/chat/ChatICMsg.java +++ b/src/engine/net/client/msg/chat/ChatICMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatICMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatInfoMsg.java b/src/engine/net/client/msg/chat/ChatInfoMsg.java index 5645e8d0..f5cd1df9 100644 --- a/src/engine/net/client/msg/chat/ChatInfoMsg.java +++ b/src/engine/net/client/msg/chat/ChatInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatInfoMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatLeaderMsg.java b/src/engine/net/client/msg/chat/ChatLeaderMsg.java index 7f83f1ed..0c59c615 100644 --- a/src/engine/net/client/msg/chat/ChatLeaderMsg.java +++ b/src/engine/net/client/msg/chat/ChatLeaderMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatLeaderMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatPvPMsg.java b/src/engine/net/client/msg/chat/ChatPvPMsg.java index a84610af..5f7eaf59 100644 --- a/src/engine/net/client/msg/chat/ChatPvPMsg.java +++ b/src/engine/net/client/msg/chat/ChatPvPMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatPvPMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatSayMsg.java b/src/engine/net/client/msg/chat/ChatSayMsg.java index 03826d7c..08f915f9 100644 --- a/src/engine/net/client/msg/chat/ChatSayMsg.java +++ b/src/engine/net/client/msg/chat/ChatSayMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractGameObject; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/chat/ChatShoutMsg.java b/src/engine/net/client/msg/chat/ChatShoutMsg.java index 761f13dd..c5169445 100644 --- a/src/engine/net/client/msg/chat/ChatShoutMsg.java +++ b/src/engine/net/client/msg/chat/ChatShoutMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java b/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java index 30e1f1a9..a3581b39 100644 --- a/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java +++ b/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatSystemChannelMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatSystemMsg.java b/src/engine/net/client/msg/chat/ChatSystemMsg.java index 29b412fa..785c38e1 100644 --- a/src/engine/net/client/msg/chat/ChatSystemMsg.java +++ b/src/engine/net/client/msg/chat/ChatSystemMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; import engine.server.MBServerStatics; diff --git a/src/engine/net/client/msg/chat/ChatTellMsg.java b/src/engine/net/client/msg/chat/ChatTellMsg.java index fe60e679..3170b47a 100644 --- a/src/engine/net/client/msg/chat/ChatTellMsg.java +++ b/src/engine/net/client/msg/chat/ChatTellMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java b/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java index 6b6b5918..52867810 100644 --- a/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java +++ b/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; public class GuildEnterWorldMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java b/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java index a24be476..f6635c93 100644 --- a/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java +++ b/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.AbstractGameObject; diff --git a/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java b/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java index d3d4013b..f04d2180 100644 --- a/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java +++ b/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class AppointGroupLeaderMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/DisbandGroupMsg.java b/src/engine/net/client/msg/group/DisbandGroupMsg.java index b23ae529..0f0ac390 100644 --- a/src/engine/net/client/msg/group/DisbandGroupMsg.java +++ b/src/engine/net/client/msg/group/DisbandGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DisbandGroupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/FormationFollowMsg.java b/src/engine/net/client/msg/group/FormationFollowMsg.java index afd2acc4..f98abb7c 100644 --- a/src/engine/net/client/msg/group/FormationFollowMsg.java +++ b/src/engine/net/client/msg/group/FormationFollowMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class FormationFollowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/GroupInviteMsg.java b/src/engine/net/client/msg/group/GroupInviteMsg.java index f6afdf00..5748a440 100644 --- a/src/engine/net/client/msg/group/GroupInviteMsg.java +++ b/src/engine/net/client/msg/group/GroupInviteMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GroupInviteMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/GroupInviteResponseMsg.java b/src/engine/net/client/msg/group/GroupInviteResponseMsg.java index c9e26bf9..bb5b92d8 100644 --- a/src/engine/net/client/msg/group/GroupInviteResponseMsg.java +++ b/src/engine/net/client/msg/group/GroupInviteResponseMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GroupInviteResponseMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/GroupUpdateMsg.java b/src/engine/net/client/msg/group/GroupUpdateMsg.java index f09f063c..bd57f065 100644 --- a/src/engine/net/client/msg/group/GroupUpdateMsg.java +++ b/src/engine/net/client/msg/group/GroupUpdateMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg.group; -import engine.mbEnums.GameObjectType; import engine.gameManager.GroupManager; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.Group; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/group/LeaveGroupMsg.java b/src/engine/net/client/msg/group/LeaveGroupMsg.java index f477de3b..8cbcb3b7 100644 --- a/src/engine/net/client/msg/group/LeaveGroupMsg.java +++ b/src/engine/net/client/msg/group/LeaveGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class LeaveGroupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/RemoveFromGroupMsg.java b/src/engine/net/client/msg/group/RemoveFromGroupMsg.java index 7ff6586a..da78c30a 100644 --- a/src/engine/net/client/msg/group/RemoveFromGroupMsg.java +++ b/src/engine/net/client/msg/group/RemoveFromGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class RemoveFromGroupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java b/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java index 1becdabb..2a27444c 100644 --- a/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java +++ b/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ToggleGroupSplitMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java b/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java index d8ef71d0..7fb2969d 100644 --- a/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java +++ b/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class AcceptInviteToGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java b/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java index 42f99620..d83a4158 100644 --- a/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java +++ b/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java @@ -22,7 +22,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class AcceptSubInviteMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/BanishUnbanishMsg.java b/src/engine/net/client/msg/guild/BanishUnbanishMsg.java index d06af36c..f0413e5d 100644 --- a/src/engine/net/client/msg/guild/BanishUnbanishMsg.java +++ b/src/engine/net/client/msg/guild/BanishUnbanishMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class BanishUnbanishMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/BreakFealtyMsg.java b/src/engine/net/client/msg/guild/BreakFealtyMsg.java index 7a003f63..77da9596 100644 --- a/src/engine/net/client/msg/guild/BreakFealtyMsg.java +++ b/src/engine/net/client/msg/guild/BreakFealtyMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class BreakFealtyMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/ChangeRankMsg.java b/src/engine/net/client/msg/guild/ChangeRankMsg.java index f3a9c46d..0803a00c 100644 --- a/src/engine/net/client/msg/guild/ChangeRankMsg.java +++ b/src/engine/net/client/msg/guild/ChangeRankMsg.java @@ -22,7 +22,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ChangeRankMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/DisbandGuildMsg.java b/src/engine/net/client/msg/guild/DisbandGuildMsg.java index f9f7cfd3..2b7f34f5 100644 --- a/src/engine/net/client/msg/guild/DisbandGuildMsg.java +++ b/src/engine/net/client/msg/guild/DisbandGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DisbandGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/DismissGuildMsg.java b/src/engine/net/client/msg/guild/DismissGuildMsg.java index 5d67a966..30dec40b 100644 --- a/src/engine/net/client/msg/guild/DismissGuildMsg.java +++ b/src/engine/net/client/msg/guild/DismissGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DismissGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/GuildControlMsg.java b/src/engine/net/client/msg/guild/GuildControlMsg.java index 8d938a1d..d744134c 100644 --- a/src/engine/net/client/msg/guild/GuildControlMsg.java +++ b/src/engine/net/client/msg/guild/GuildControlMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GuildControlMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java b/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java index 3a259238..28b43e6d 100644 --- a/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java +++ b/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java b/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java index acfe60a9..9ba812e9 100644 --- a/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java +++ b/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; import engine.objects.Item; diff --git a/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java b/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java index c22979b0..0a4fb9b4 100644 --- a/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java +++ b/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/GuildInfoMsg.java b/src/engine/net/client/msg/guild/GuildInfoMsg.java index 938c2732..fc692299 100644 --- a/src/engine/net/client/msg/guild/GuildInfoMsg.java +++ b/src/engine/net/client/msg/guild/GuildInfoMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.*; import org.joda.time.DateTime; diff --git a/src/engine/net/client/msg/guild/GuildListMsg.java b/src/engine/net/client/msg/guild/GuildListMsg.java index 1a225cb5..821745a7 100644 --- a/src/engine/net/client/msg/guild/GuildListMsg.java +++ b/src/engine/net/client/msg/guild/GuildListMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.Guild; import engine.objects.GuildHistory; diff --git a/src/engine/net/client/msg/guild/GuildUnknownMsg.java b/src/engine/net/client/msg/guild/GuildUnknownMsg.java index 87ff4020..940b53b9 100644 --- a/src/engine/net/client/msg/guild/GuildUnknownMsg.java +++ b/src/engine/net/client/msg/guild/GuildUnknownMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GuildUnknownMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/InviteToGuildMsg.java b/src/engine/net/client/msg/guild/InviteToGuildMsg.java index 48d9369f..192288ee 100644 --- a/src/engine/net/client/msg/guild/InviteToGuildMsg.java +++ b/src/engine/net/client/msg/guild/InviteToGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/InviteToSubMsg.java b/src/engine/net/client/msg/guild/InviteToSubMsg.java index d9c325e7..abe743cd 100644 --- a/src/engine/net/client/msg/guild/InviteToSubMsg.java +++ b/src/engine/net/client/msg/guild/InviteToSubMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/LeaveGuildMsg.java b/src/engine/net/client/msg/guild/LeaveGuildMsg.java index f8a56216..cfd69d3d 100644 --- a/src/engine/net/client/msg/guild/LeaveGuildMsg.java +++ b/src/engine/net/client/msg/guild/LeaveGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class LeaveGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/MOTDCommitMsg.java b/src/engine/net/client/msg/guild/MOTDCommitMsg.java index 6f821824..39736fc1 100644 --- a/src/engine/net/client/msg/guild/MOTDCommitMsg.java +++ b/src/engine/net/client/msg/guild/MOTDCommitMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class MOTDCommitMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/MOTDMsg.java b/src/engine/net/client/msg/guild/MOTDMsg.java index 16060ae5..441b4a33 100644 --- a/src/engine/net/client/msg/guild/MOTDMsg.java +++ b/src/engine/net/client/msg/guild/MOTDMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class MOTDMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/ReqGuildListMsg.java b/src/engine/net/client/msg/guild/ReqGuildListMsg.java index 8dbe382a..00b652a1 100644 --- a/src/engine/net/client/msg/guild/ReqGuildListMsg.java +++ b/src/engine/net/client/msg/guild/ReqGuildListMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ReqGuildListMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/SendGuildEntryMsg.java b/src/engine/net/client/msg/guild/SendGuildEntryMsg.java index 6398c14c..3cca297b 100644 --- a/src/engine/net/client/msg/guild/SendGuildEntryMsg.java +++ b/src/engine/net/client/msg/guild/SendGuildEntryMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.Guild; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/SwearInGuildMsg.java b/src/engine/net/client/msg/guild/SwearInGuildMsg.java index a9051f59..d32c0e4e 100644 --- a/src/engine/net/client/msg/guild/SwearInGuildMsg.java +++ b/src/engine/net/client/msg/guild/SwearInGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class SwearInGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/SwearInMsg.java b/src/engine/net/client/msg/guild/SwearInMsg.java index aa9c239e..8ae6e113 100644 --- a/src/engine/net/client/msg/guild/SwearInMsg.java +++ b/src/engine/net/client/msg/guild/SwearInMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class SwearInMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/CharSelectScreenMsg.java b/src/engine/net/client/msg/login/CharSelectScreenMsg.java index 34fd3f32..fec17ef2 100644 --- a/src/engine/net/client/msg/login/CharSelectScreenMsg.java +++ b/src/engine/net/client/msg/login/CharSelectScreenMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg.login; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.net.client.msg.ClientNetMsg; import engine.objects.Account; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/login/ClientLoginInfoMsg.java b/src/engine/net/client/msg/login/ClientLoginInfoMsg.java index 419360f5..0b2e0c3a 100644 --- a/src/engine/net/client/msg/login/ClientLoginInfoMsg.java +++ b/src/engine/net/client/msg/login/ClientLoginInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ClientLoginInfoMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/CommitNewCharacterMsg.java b/src/engine/net/client/msg/login/CommitNewCharacterMsg.java index 673656cf..2e17797a 100644 --- a/src/engine/net/client/msg/login/CommitNewCharacterMsg.java +++ b/src/engine/net/client/msg/login/CommitNewCharacterMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class CommitNewCharacterMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/DeleteCharacterMsg.java b/src/engine/net/client/msg/login/DeleteCharacterMsg.java index 0763c989..71a6be29 100644 --- a/src/engine/net/client/msg/login/DeleteCharacterMsg.java +++ b/src/engine/net/client/msg/login/DeleteCharacterMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DeleteCharacterMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/GameServerIPRequestMsg.java b/src/engine/net/client/msg/login/GameServerIPRequestMsg.java index 19798412..678d9ee7 100644 --- a/src/engine/net/client/msg/login/GameServerIPRequestMsg.java +++ b/src/engine/net/client/msg/login/GameServerIPRequestMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GameServerIPRequestMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/GameServerIPResponseMsg.java b/src/engine/net/client/msg/login/GameServerIPResponseMsg.java index fe258fc9..7f07359c 100644 --- a/src/engine/net/client/msg/login/GameServerIPResponseMsg.java +++ b/src/engine/net/client/msg/login/GameServerIPResponseMsg.java @@ -14,7 +14,7 @@ import engine.gameManager.ConfigManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GameServerIPResponseMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/InvalidNameMsg.java b/src/engine/net/client/msg/login/InvalidNameMsg.java index 0547abea..d3acc843 100644 --- a/src/engine/net/client/msg/login/InvalidNameMsg.java +++ b/src/engine/net/client/msg/login/InvalidNameMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/login/LoginErrorMsg.java b/src/engine/net/client/msg/login/LoginErrorMsg.java index d5247d96..c1cf76fa 100644 --- a/src/engine/net/client/msg/login/LoginErrorMsg.java +++ b/src/engine/net/client/msg/login/LoginErrorMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class LoginErrorMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/ServerStatusMsg.java b/src/engine/net/client/msg/login/ServerStatusMsg.java index 32d96198..6ff31558 100644 --- a/src/engine/net/client/msg/login/ServerStatusMsg.java +++ b/src/engine/net/client/msg/login/ServerStatusMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ServerStatusMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/VersionInfoMsg.java b/src/engine/net/client/msg/login/VersionInfoMsg.java index 81852009..5718cec9 100644 --- a/src/engine/net/client/msg/login/VersionInfoMsg.java +++ b/src/engine/net/client/msg/login/VersionInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class VersionInfoMsg extends ClientNetMsg { diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index 3f5a76e1..e6b803a7 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -18,11 +18,12 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -/* @Summary - Blueprint class is used for determining - characteristics of instanced player owned - structures such as available slots, upgrade - cost/time and the target window symbol icon. - */ +// MB Dev Notes: +// This class is the building equivalent of an itemTemplate; +// with helper methods to place, slot and rank buildings. +// +// DB table static_building_blueprint contains the data. + public class Blueprint { public final static Vector2f IrikieForgeExtents = new Vector2f(32, 32); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 4003ff5d..ffd8f672 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -9,7 +9,10 @@ package engine.objects; -import engine.gameManager.*; +import engine.gameManager.BuildingManager; +import engine.gameManager.ConfigManager; +import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.math.Vector3fImmutable; import engine.mbEnums; import engine.mbEnums.GameObjectType; @@ -152,9 +155,7 @@ public class CharacterItemManager { i.junk(); break; } - } - this.goldVault = this.account.vaultGold; //check all gold is created @@ -305,11 +306,9 @@ public class CharacterItemManager { ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.absCharacter, 203); return false; } - } break; - } return true; } @@ -370,44 +369,6 @@ public class CharacterItemManager { return success; } - public synchronized boolean tradeRequest(TradeRequestMsg msg) { - - PlayerCharacter source = (PlayerCharacter) this.getOwner(); - PlayerCharacter target = PlayerCharacter.getFromCache(msg.getPlayerID()); - Dispatch dispatch; - - if (!canTrade(source, target)) { - ChatManager.chatSystemError(source, "Can't currently trade with target player"); - return false; - } - - // TODO uncomment this block after we determine when we - // setBankOpen(false) and setVaultOpen(false) - CharacterItemManager cim1 = source.charItemManager; - CharacterItemManager cim2 = target.charItemManager; - - if (cim1 == null) - return false; - - if (cim2 == null) - return false; - - dispatch = Dispatch.borrow(target, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - return true; - - } - - public synchronized boolean invalidTradeRequest(InvalidTradeRequestMsg msg) { - PlayerCharacter requester = PlayerCharacter.getFromCache(msg.getRequesterID()); - Dispatch dispatch; - - dispatch = Dispatch.borrow(requester, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - return true; - - } - public static synchronized boolean canTrade(PlayerCharacter playerA, PlayerCharacter playerB) { if (playerA == null || playerB == null) @@ -449,6 +410,7 @@ public class CharacterItemManager { if (this.getTradingWith().getPlayerCharacter() == null) return false; + CharacterItemManager man2 = this.getTradingWith().getPlayerCharacter().charItemManager; Dispatch dispatch; @@ -469,11 +431,10 @@ public class CharacterItemManager { } public synchronized boolean closeTradeWindow(CloseTradeWindowMsg msg, boolean sourceTrade) { - - Dispatch dispatch; PlayerCharacter source = (PlayerCharacter) this.getOwner(); + if (source == null) return false; @@ -501,11 +462,8 @@ public class CharacterItemManager { } sourceItemMan.endTrade(); - - cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false); - return true; } @@ -697,17 +655,19 @@ public class CharacterItemManager { // add to Bank this.bank.add(i); i.addToCache(); - calculateWeights(); return true; } public synchronized boolean moveGoldToBank(Item from, int amt) { + if (from == null) return false; + if (from.getNumOfItems() - amt < 0) return false; + if (this.goldBank.getNumOfItems() + amt > MBServerStatics.BANK_GOLD_LIMIT) { if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pc = (PlayerCharacter) this.absCharacter; @@ -719,26 +679,33 @@ public class CharacterItemManager { if (!DbManager.ItemQueries.MOVE_GOLD(from, this.getGoldBank(), amt)) return false; + from.setNumOfItems(from.getNumOfItems() - amt); this.goldBank.setNumOfItems(this.goldBank.getNumOfItems() + amt); return true; } public synchronized boolean moveGoldToVault(Item from, int amt) { + if (from == null) return false; + if (from.getNumOfItems() - amt < 0) return false; + if (!DbManager.ItemQueries.MOVE_GOLD(from, this.account.vaultGold, amt)) return false; + from.setNumOfItems(from.getNumOfItems() - amt); this.account.vaultGold.setNumOfItems(this.goldVault.getNumOfItems() + amt); return true; } public synchronized boolean moveGoldToInventory(Item from, int amt) { + if (from == null) return false; + if (from.getNumOfItems() - amt < 0 || amt < 1) return false; @@ -841,7 +808,6 @@ public class CharacterItemManager { // add to Vault i.addToCache(); - calculateWeights(); return true; @@ -893,20 +859,12 @@ public class CharacterItemManager { this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - if (i.template != null) this.inventoryWeight += i.template.item_wt; return true; } - //called for adding gold of a specified amount - public synchronized boolean addItemToInventory(Item i, int amount) { - if (i.template.item_type.equals(ItemType.GOLD)) - return DbManager.ItemQueries.UPDATE_GOLD(this.getGoldInventory(), this.goldInventory.getNumOfItems() + amount); - return false; - } - public boolean equipItem(Item i, mbEnums.EquipSlotType slot) { synchronized (this) { @@ -955,6 +913,7 @@ public class CharacterItemManager { } //Apply Bonuses and update player + if (this.absCharacter != null) { this.absCharacter.applyBonuses(); if (this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)) @@ -971,7 +930,6 @@ public class CharacterItemManager { if (cost <= 0 || (gold.getNumOfItems() - cost) < 0) return false; - if (this.getOwner() != null && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { if (this.goldTradingAmount > 0) { ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195); @@ -982,25 +940,20 @@ public class CharacterItemManager { // Create gold from screatch instead of building strongbox // if the NPC is not slotted. - if (vendorBuilding == null) { - + if (vendorBuilding == null) return this.modifyInventoryGold(-cost); - } - if (vendorBuilding.getStrongboxValue() + cost > vendorBuilding.getMaxGold()) { - if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pc = (PlayerCharacter) this.absCharacter; if (pc.getClientConnection() != null) ErrorPopupMsg.sendErrorPopup(pc, 206); } - return false; } - // Update strongbox and inventory gold + if (!this.modifyInventoryGold(-cost)) return false; @@ -1026,7 +979,7 @@ public class CharacterItemManager { //Used for selling items to NPC public synchronized boolean sellToNPC(Building building, int cost, Item item) { - // Create gold from screatch instead of building strongbox + // Create gold from scratch instead of building strongbox // if the NPC is not slotted. if (this.getGoldInventory().getNumOfItems() + cost < 0) @@ -1063,11 +1016,6 @@ public class CharacterItemManager { return this.modifyInventoryGold(cost); } - /** - * This sells an item to an npc - * - * @return True on success - */ public synchronized boolean sellToNPC(Item itemToSell, NPC npc) { CharacterItemManager itemMan; @@ -1127,12 +1075,6 @@ public class CharacterItemManager { return true; } - /** - * This buys an item from an npc - * Handles transfer of item. - * - * @return True on success - */ public synchronized boolean buyFromNPC(Item purchasedItem, NPC npc) { CharacterItemManager itemMan; @@ -1162,45 +1104,27 @@ public class CharacterItemManager { // attempt to transfer item in db - if (purchasedItem.getObjectType() == GameObjectType.MobLoot) { - - Item newItem = ((MobLoot) purchasedItem).promoteToItem((PlayerCharacter) this.absCharacter); - if (newItem == null) - return false; - - if (!itemMan.removeItemFromInventory(purchasedItem)) - return false; - - if (!addItemToInventory(newItem)) - return false; - //Item was created and still a mobloot item, remove from npc production list in db. - - DbManager.NPCQueries.REMOVE_FROM_PRODUCTION_LIST(purchasedItem.getObjectUUID(), npc.getObjectUUID()); - - - } else { - if (!purchasedItem.moveItemToInventory((PlayerCharacter) this.absCharacter)) - return false; - - // Reset value + if (!purchasedItem.moveItemToInventory((PlayerCharacter) this.absCharacter)) + return false; - purchasedItem.value = (int) (purchasedItem.template.item_value * (purchasedItem.combat_health_current / purchasedItem.template.combat_health_full)); + // Reset value - // db transfer successfully, remove from this character - // skip this check if this is a mobLoot item (which is not in any inventory) - if (!itemMan.removeItemFromInventory(purchasedItem)) - return false; + purchasedItem.value = (int) (purchasedItem.template.item_value * (purchasedItem.combat_health_current / purchasedItem.template.combat_health_full)); - // add item to looter. + // db transfer successfully, remove from this character + // skip this check if this is a mobLoot item (which is not in any inventory) + if (!itemMan.removeItemFromInventory(purchasedItem)) + return false; - if (!addItemToInventory(purchasedItem)) - return false; - } + // add item to looter. + if (!addItemToInventory(purchasedItem)) + return false; } } // calculate new weights + calculateInventoryWeight(); itemMan.calculateInventoryWeight(); return true; @@ -1341,28 +1265,22 @@ public class CharacterItemManager { /* * Delegates */ - public synchronized boolean bankContains(Item i) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == i.getObjectUUID()); - return bank.contains(i); - } - - public synchronized boolean inventoryContains(Item i) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); - return inventory.contains(i); + public synchronized boolean bankContains(Item item) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == item.getObjectUUID()); + return bank.contains(item); } - public synchronized boolean forgeContains(Item i, NPC vendor) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); - return vendor.getRolling().contains(i); + public synchronized boolean inventoryContains(Item item) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == item.getObjectUUID()); + return inventory.contains(item); } - public synchronized boolean vaultContains(Item i) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == i.getObjectUUID()); - return this.account.getVault().contains(i); + public synchronized boolean vaultContains(Item item) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == item.getObjectUUID()); + return this.account.getVault().contains(item); } public synchronized boolean equippedContains(Item i) { diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 92feb734..74cb81dd 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -78,7 +78,6 @@ public class City extends AbstractWorldObject { private Vector3fImmutable location = Vector3fImmutable.ZERO; // Players who have entered the city (used for adding and removing affects) private Vector3fImmutable bindLoc; - private int warehouseBuildingID = 0; private boolean open = false; private String hash; public Warehouse warehouse; @@ -1060,14 +1059,6 @@ public class City extends AbstractWorldObject { } } - public int getWarehouseBuildingID() { - return warehouseBuildingID; - } - - public void setWarehouseBuildingID(int warehouseBuildingID) { - this.warehouseBuildingID = warehouseBuildingID; - } - public final void destroy() { Thread destroyCityThread = new Thread(new DestroyCityThread(this)); diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index 5defef35..c094f9c6 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -34,7 +34,7 @@ public class Contract extends AbstractGameObject { private ArrayList npcMenuOptions = new ArrayList<>(); private ArrayList npcModTypeTable = new ArrayList<>(); private ArrayList npcModSuffixTable = new ArrayList<>(); - private ArrayList itemModTable = new ArrayList<>(); + private ArrayList itemModTable = new ArrayList<>(); private ArrayList sellInventory = new ArrayList<>(); public EnumSet allowedBuildings; private ArrayList buyItemType = new ArrayList<>(); @@ -122,7 +122,7 @@ public class Contract extends AbstractGameObject { if (!itemMod.isEmpty()) { String[] data2 = itemMod.split(" "); for (byte i = 0; i < data2.length; i++) { - this.itemModTable.add(Byte.parseByte(data2[i])); + this.itemModTable.add(Integer.parseInt(data2[i])); } } @@ -193,7 +193,7 @@ public class Contract extends AbstractGameObject { return npcModSuffixTable; } - public ArrayList getItemModTable() { + public ArrayList getItemModTable() { return itemModTable; } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 134d9e7d..bc437ea7 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -51,7 +51,6 @@ public class Item extends AbstractWorldObject { public int chargesRemaining; public mbEnums.EquipSlotType equipSlot; private boolean canDestroy; - private boolean isRandom = false; public int value; public OwnerType ownerType; public int templateID; @@ -59,6 +58,8 @@ public class Item extends AbstractWorldObject { public int magicValue; public ItemTemplate template; public String name = ""; + public int prefixToken; // Forge support + public int suffixToken; // Forge support /** * In Memory constructor @@ -1127,14 +1128,6 @@ public class Item extends AbstractWorldObject { this.value = value; } - public boolean isRandom() { - return isRandom; - } - - public void setRandom(boolean isRandom) { - this.isRandom = isRandom; - } - public boolean isCustomValue() { if (this.value == 0) return false; diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java deleted file mode 100644 index 4ae1b050..00000000 --- a/src/engine/objects/ItemFactory.java +++ /dev/null @@ -1,1029 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.gameManager.*; -import engine.loot.ModTableEntry; -import engine.loot.ModTypeTableEntry; -import engine.mbEnums; -import engine.mbEnums.ItemContainerType; -import engine.mbEnums.ItemType; -import engine.mbEnums.OwnerType; -import engine.net.ItemProductionManager; -import engine.net.ItemQueue; -import engine.net.client.ClientConnection; -import engine.net.client.msg.ErrorPopupMsg; -import engine.powers.EffectsBase; -import engine.server.MBServerStatics; -import org.joda.time.DateTime; -import org.pmw.tinylog.Logger; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; - -public class ItemFactory { - - public static void fillInventory(PlayerCharacter pc, int templateID, int count) { - - if (pc == null) - return; - - int max = 20; - CharacterItemManager itemManager = pc.charItemManager; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - if (count > max) - count = max; - - ClientConnection cc = pc.getClientConnection(); - - if (itemManager == null || template == null || cc == null) - return; - - boolean worked; - - for (int i = 0; i < count; i++) { - worked = false; - - if (!itemManager.hasRoomInventory(template.item_wt)) { - if (pc != null) - ChatManager.chatSystemInfo(pc, "You can not carry any more of that item."); - break; - } - - Item item = new Item(templateID); - item.ownerID = pc.getObjectUUID(); - item.ownerType = OwnerType.PlayerCharacter; - item.containerType = ItemContainerType.INVENTORY; - - try { - item = DbManager.ItemQueries.PERSIST(item); - worked = true; - } catch (Exception e) { - Logger.error(e); - } - if (worked) { - itemManager.addItemToInventory(item); - } - } - itemManager.updateInventory(); - } - - public static Item fillForge(NPC npc, PlayerCharacter pc, int itemsToRoll, int templateID, int pToken, int sToken, String customName) { - - String prefixString = ""; - String suffixString = ""; - if (npc == null) - return null; - - boolean useWarehouse = false; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - if (template == null) - return null; - - Building forge = npc.getBuilding(); - - if (forge == null) - return null; - - if (!npc.charItemManager.hasRoomInventory(template.item_wt)) { - if (pc != null) - ErrorPopupMsg.sendErrorPopup(pc, 21); - return null; - } - - Zone zone = npc.getBuilding().getParentZone(); - - if (zone == null) - return null; - - City city = City.getCity(zone.playerCityUUID); - - if (city == null) - return null; - - MobLoot ml = null; - city.transactionLock.writeLock().lock(); - - try { - Warehouse cityWarehouse = city.warehouse; - - if (cityWarehouse != null && forge.assetIsProtected()) - useWarehouse = true; - // ROLL BANE SCROLL. - - if (templateID > 910010 && templateID < 910019) { - ConcurrentHashMap resources = cityWarehouse.resources; - - - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value); - int overdraft = BuildingManager.GetOverdraft(forge, template.item_value); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + template.item_base_name); - return null; - } - - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + " " + template.item_base_name); - return null; - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0) - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - - ml = new MobLoot(npc, template, false); - - ml.containerType = mbEnums.ItemContainerType.FORGE; - ml.setValue(0); - ml.loadEnchantments(); - - float time; - float rank = npc.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); - time = (20 - rate); - time *= MBServerStatics.ONE_MINUTE; - - if (ml.templateID > 910010 && ml.templateID < 910019) { - rank = ml.templateID - 910010; - time = rank * 60 * 60 * 3 * 1000; - - } - - // No job is submitted, as object's upgradetime field - // is used to determin whether or not an object has - // compelted rolling. The game object exists previously - // to this, not when 'compelte' is pressed. - long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - - DateTime dateTime = new DateTime(); - dateTime = dateTime.withMillis(upgradeTime); - ml.setDateToUpgrade(upgradeTime); - - npc.addItemToForge(ml); - - int playerID = 0; - - if (pc != null) - playerID = pc.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, "", "", "", false, playerID); - ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, false, "", "", "", playerID); - pi.setProducedItemID(ml.getObjectUUID()); - pi.setAmount(itemsToRoll); - pi.setRandom(false); - - ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); - ItemProductionManager.send(produced); - - return ml; - } - - int galvorAmount = 0; - int wormwoodAmount = 0; - int prefixCost = 0; - int suffixCost = 0; - - if (template.item_type.equals(ItemType.WEAPON) && template.item_skill_required.isEmpty() == false && - template.item_skill_required.values().iterator().next() == 110) { - switch (template.item_skill_used) { - case "Bow": - case "Crossbow": - case "Spear": - case "Pole Arm": - case "Staff": - wormwoodAmount = 20; - break; - case "Axe": - case "Dagger": - case "Sword": - case "Hammer": - case "Unarmed Combat": - - if (ItemManager.isTwoHanded(template)) - galvorAmount = 20; - else - galvorAmount = 10; - break; - } - } - - if (galvorAmount > 0 || wormwoodAmount > 0) - if (!useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "This item requires resources to roll! Please make sure the forge is protected to access the warehouse." + template.item_base_name); - return null; - - } - - if (galvorAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GALVOR)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.GALVOR) < galvorAmount) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name); - return null; - } - } - - if (wormwoodAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.WORMWOOD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.WORMWOOD) < wormwoodAmount) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + template.item_base_name); - return null; - } - } - ConcurrentHashMap suffixResourceCosts = null; - ConcurrentHashMap prefixResourceCosts = null; - - EffectsBase prefix = null; - - if (pToken != 0) { - - if (!useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + template.item_base_name); - return null; - } - prefix = PowersManager.getEffectByToken(pToken); - if (prefix == null) - return null; - EffectsBase prefixValue = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); - if (prefixValue == null) - return null; - - int baseCost = template.item_value; - int effectCost = (int) prefixValue.getValue(); - int total = baseCost * 10 + effectCost; - - prefixCost = effectCost; - int overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - prefixResourceCosts = prefix.getResourcesForEffect(); - - for (mbEnums.ResourceType ibResources : prefixResourceCosts.keySet()) { - int warehouseAmount = cityWarehouse.resources.get(ibResources); - int creationAmount = prefixResourceCosts.get(ibResources); - - if (warehouseAmount < creationAmount) - return null; - } - } - EffectsBase suffix = null; - - if (sToken != 0) { - - if (!useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + template.item_base_name); - return null; - } - suffix = PowersManager.getEffectByToken(sToken); - if (suffix == null) - return null; - EffectsBase suffixValue = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); - if (suffixValue == null) - return null; - suffixResourceCosts = suffix.getResourcesForEffect(); - int baseCost = template.item_value; - int effectCost = (int) suffixValue.getValue(); - suffixCost = effectCost; - int total = baseCost * 10 + effectCost; - - - // int buildingWithdraw = Building.GetWithdrawAmountForRolling(forge, total); - int overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - - for (mbEnums.ResourceType ibResources : suffixResourceCosts.keySet()) { - int warehouseAmount = cityWarehouse.resources.get(ibResources); - int creationAmount = suffixResourceCosts.get(ibResources); - - if (warehouseAmount < creationAmount) - return null; - } - } - - //Check if Total suffix and prefix costs + itemCost can be withdrawn. - - int costToCreate = suffixCost + prefixCost + template.item_value; - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate); - - int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - // if (pc != null){ - // ChatManager.chatGuildInfo(pc.getGuild(), "Building withdraw = " + buildingWithdraw); - // ChatManager.chatGuildInfo(pc.getGuild(), "Warehouse overdraft withdraw = " + overdraft); - // - // ChatManager.chatGuildInfo(pc.getGuild(), "total withdraw = " + (overdraft + buildingWithdraw)); - // } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0 && useWarehouse) - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - - - if (prefix != null) { - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Cannot Resource Roll without access to the warehouse! Make sure the forge is currently protected." + template.item_base_name); - return null; - } - - - for (mbEnums.ResourceType ibResources : prefixResourceCosts.keySet()) { - - int creationAmount = prefixResourceCosts.get(ibResources); - - if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) - return null; - - int oldAmount = cityWarehouse.resources.get(ibResources); - int amount = creationAmount; - - if (oldAmount < amount) - amount = oldAmount; - - if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) { - //ChatManager.chatGuildError(pc, "Failed to create Item"); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - } - } - - if (suffix != null) { - - for (mbEnums.ResourceType ibResources : suffixResourceCosts.keySet()) { - int creationAmount = suffixResourceCosts.get(ibResources); - - if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) { - ChatManager.chatSystemError(pc, "Resource is locked!" + template.item_base_name); - return null; - } - - int oldAmount = cityWarehouse.resources.get(ibResources); - int amount = creationAmount; - - if (oldAmount < amount) - amount = oldAmount; - - if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) { - //ChatManager.chatGuildError(pc, "Failed to create Item"); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - } - } - - if (prefix == null && suffix == null) { - - int baseCost = template.item_value; - int total = (int) (baseCost + baseCost * (float) .10); - - buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total); - - overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0) - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - //ChatManager.chatGuildError(pc, "Failed to create Item"); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - - // ChatManager.chatGuildInfo(pc, "Gold Cost = " + total); - - if (galvorAmount > 0) { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GALVOR, galvorAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - - if (wormwoodAmount > 0) { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.WORMWOOD, wormwoodAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - - ml = new MobLoot(npc, template, false); - - ml.containerType = mbEnums.ItemContainerType.FORGE; - - if (customName.isEmpty() == false) - ml.name = customName; - - if (prefix != null) { - ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true); - ml.setPrefix(prefix.getIDString()); - prefixString = prefix.getIDString(); - } - - if (suffix != null) { - ml.addPermanentEnchantment(suffix.getIDString(), 0, 0, false); - ml.setSuffix(suffix.getIDString()); - suffixString = suffix.getIDString(); - } - - ml.loadEnchantments(); - //set value to 0 so magicvalue can be recalculated in getValue. - ml.setValue(0); - - float time; - float rank = npc.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); - time = (20 - rate); - time *= MBServerStatics.ONE_MINUTE; - - if (ml.templateID > 910010 && ml.templateID < 910019) { - rank = ml.templateID - 910010; - time = rank * 60 * 60 * 3 * 1000; - } - - - // No job is submitted, as object's upgradetime field - // is used to determin whether or not an object has - // compelted rolling. The game object exists previously - // to this, not when 'compelte' is pressed. - long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - - DateTime dateTime = new DateTime(); - dateTime = dateTime.withMillis(upgradeTime); - ml.setDateToUpgrade(upgradeTime); - - npc.addItemToForge(ml); - int playerID = 0; - - if (pc != null) - playerID = pc.getObjectUUID(); - - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, prefixString, suffixString, ml.name, false, playerID); - ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.templateID, dateTime, false, prefixString, suffixString, ml.name, playerID); - pi.setProducedItemID(ml.getObjectUUID()); - pi.setAmount(itemsToRoll); - - ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); - ItemProductionManager.send(produced); - } catch (Exception e) { - Logger.error(e); - } finally { - city.transactionLock.writeLock().unlock(); - } - - - // npc.addItemToForge(item); - return ml; - - } - - - public static Item randomRoll(NPC vendor, PlayerCharacter playerCharacter, int itemsToRoll, int templateID) { - byte itemModTable; - int prefixMod = 0; - int suffixMod = 0; - String prefix = ""; - String suffix = ""; - - ModTableEntry prefixEntry = null; - ModTableEntry suffixEntry = null; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - if (template == null) - return null; - - if (!vendor.charItemManager.hasRoomInventory(template.item_wt)) { - - if (playerCharacter != null) - ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full."); - - return null; - } - - itemModTable = (byte) template.modTable; - - if (!vendor.getItemModTable().contains(itemModTable)) { - - if (playerCharacter != null) - ErrorPopupMsg.sendErrorPopup(playerCharacter, 59); - - return null; - } - - for (byte temp : vendor.getItemModTable()) { - - if (itemModTable != temp) - continue; - - prefixMod = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(temp)); - suffixMod = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(temp)); - } - - if (prefixMod == 0 && suffixMod == 0) { - Logger.info("Failed to find modTables for item " + template.item_base_name); - return null; - } - - // Roll on the tables for this vendor - - ModTypeTableEntry prefixTypeTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - ModTypeTableEntry suffixTypeTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - - // Sanity check. - - if (prefixTypeTable == null || suffixTypeTable == null) - return null; - - int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - - if (rollPrefix < 80) { - - int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); - prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); - - if (prefixEntry != null) - prefix = prefixEntry.action; - - } - - int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - - // Always have at least one mod on a magic rolled item. - // Suffix will be our backup plan. - - if (rollSuffix < 80 || prefixEntry == null) { - - int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); - suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); - - if (suffixEntry != null) - suffix = suffixEntry.action; - } - - MobLoot toRoll = ItemFactory.produceRandomRoll(vendor, playerCharacter, prefix, suffix, templateID); - - if (toRoll == null) - return null; - - toRoll.setValue(0); - - float time; - float rank = vendor.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); - time = (20 - rate); - time *= MBServerStatics.ONE_MINUTE; - - // Bane circles - - if (toRoll.templateID > 910010 && toRoll.templateID < 910019) { - rank = toRoll.templateID - 910010; - time = rank * 60 * 60 * 3 * 1000; - } - - // No job is submitted, as object's upgradetime field - // is used to determine whether an object has - // completed rolling. The game object exists previously - // to this, not when 'complete' is pressed. - - long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - - DateTime dateTime = new DateTime(); - dateTime = dateTime.withMillis(upgradeTime); - toRoll.setDateToUpgrade(upgradeTime); - - int playerID = 0; - - if (playerCharacter != null) - playerID = playerCharacter.getObjectUUID(); - - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.templateID, dateTime, prefix, suffix, toRoll.name, true, playerID); - - ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.templateID, dateTime, true, prefix, suffix, toRoll.name, playerID); - pi.setProducedItemID(toRoll.getObjectUUID()); - pi.setAmount(itemsToRoll); - ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); - ItemProductionManager.send(produced); - - return toRoll; - } - - public static MobLoot produceRandomRoll(NPC npc, PlayerCharacter pc, String prefixString, String suffixString, int templateID) { - - boolean useWarehouse = false; - - if (npc == null) - return null; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - Building forge = npc.getBuilding(); - - if (forge == null) - return null; - - Zone zone = npc.getBuilding().getParentZone(); - - if (zone == null) - return null; - - City city = City.getCity(zone.playerCityUUID); - - if (city == null) - return null; - - MobLoot ml = null; - city.transactionLock.writeLock().lock(); - - try { - - - Warehouse cityWarehouse = city.warehouse; - - if (cityWarehouse != null && forge.assetIsProtected()) - useWarehouse = true; - - ConcurrentHashMap resources = null; - - if (useWarehouse) - resources = cityWarehouse.resources; - - int galvorAmount = 0; - int wormwoodAmount = 0; - - if (template.item_type.equals(ItemType.WEAPON) && template.item_skill_required.isEmpty() == false && - template.item_skill_required.values().iterator().next() == 110) { - switch (template.item_skill_used) { - case "Bow": - case "Crossbow": - case "Spear": - case "Pole Arm": - case "Staff": - wormwoodAmount = 22; - break; - case "Axe": - case "Dagger": - case "Sword": - case "Hammer": - case "Unarmed Combat": - - if (ItemManager.isTwoHanded(template)) - galvorAmount = 22; - else - galvorAmount = 11; - break; - } - } - - //Cant roll 110% weapons that require resources if not allowed to use warehouse. - if (galvorAmount > 0 || wormwoodAmount > 0) - if (!useWarehouse) - return null; - - if (galvorAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GALVOR)) { - ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.GALVOR) < galvorAmount) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name); - return null; - } - } - - if (wormwoodAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.WORMWOOD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.WORMWOOD) < wormwoodAmount) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name); - return null; - } - } - - EffectsBase prefix = null; - - if (!prefixString.isEmpty()) { - prefix = PowersManager.getEffectByIDString(prefixString); - if (prefix == null) - return null; - } - - int baseCost = template.item_value; - int total = (int) (baseCost + baseCost * .10); - - EffectsBase suffix = null; - - if (!suffixString.isEmpty()) { - suffix = PowersManager.getEffectByIDString(suffixString); - - if (suffix == null) - return null; - } - - //calculate gold costs and remove from the warehouse - if (prefix != null || suffix != null) { - int costToCreate = (int) (template.item_value + template.item_value * .10f); - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate); - int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); - - if (overdraft > 0 && !useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - // there was an overdraft, withdraw the rest from warehouse. - if (overdraft > 0) { - if (pc != null) { - if (!Warehouse.withdraw(cityWarehouse, pc, mbEnums.ResourceType.GOLD, overdraft, false, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } else { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - } - } - - if (prefix == null && suffix == null) { - - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total); - int overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0 && useWarehouse) { - - if (pc != null) { - if (!Warehouse.withdraw(cityWarehouse, pc, mbEnums.ResourceType.GOLD, overdraft, false, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } else { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - } - } - - if (galvorAmount > 0 && useWarehouse) { - //ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse"); - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GALVOR, galvorAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - - if (wormwoodAmount > 0 && useWarehouse) { - //ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse"); - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.WORMWOOD, wormwoodAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - - return null; - } - } - - ml = new MobLoot(npc, template, false); - - ml.containerType = mbEnums.ItemContainerType.FORGE; - - if (prefix != null) { - ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true); - ml.setPrefix(prefix.getIDString()); - } - - if (suffix != null) { - ml.addPermanentEnchantment(suffix.getIDString(), 0, 0, false); - ml.setSuffix(suffix.getIDString()); - } - - ml.loadEnchantments(); - - - ml.setValue(0); - ml.setRandom(true); - npc.addItemToForge(ml); - } catch (Exception e) { - Logger.error(e); - } finally { - city.transactionLock.writeLock().unlock(); - } - return ml; - - } -} diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index b186450e..2ce24d81 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -10,8 +10,8 @@ package engine.objects; import engine.math.Vector3fImmutable; import engine.mbEnums; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -20,11 +20,24 @@ import java.util.HashMap; public class ItemTemplate { + // MB Dev Notes: + // This class parses JSON data generated by mbEditor Pro 2.1. + // Cache definitions are loaded for ItemType.ITEM, ItemType,DEED + // and ItemType.RUNE. + // + // Exported JSON data is stored in db table static_item_templates + // and can be easily mass updated using tooling available on the Wiki. + // + // Always read never write! + // Use copies of fields to avoid side effects. + // Global template lookup + public static HashMap templates = new HashMap<>(); public int template_id; // Template Properties + public String obj_name; public boolean obj_pickable; public Vector3fImmutable obj_scale; @@ -121,10 +134,8 @@ public class ItemTemplate { public boolean rune_group_is_guild = false; public String rune_dsc; public String rune_fx_txt; - public EnumSet rune_group_tactics = EnumSet.noneOf(mbEnums.MobBehaviourType.class); - ; - public EnumSet rune_group_role_set = EnumSet.noneOf(mbEnums.MobBehaviourType.class); - ; + public final EnumSet rune_group_tactics = EnumSet.noneOf(mbEnums.MobBehaviourType.class); + public final EnumSet rune_group_role_set = EnumSet.noneOf(mbEnums.MobBehaviourType.class); public boolean rune_renderable = false; public int rune_natural_power_attack; public final HashMap rune_sparse_data = new HashMap<>(); @@ -133,93 +144,99 @@ public class ItemTemplate { public final EnumSet rune_not_enemy_monster_types = EnumSet.noneOf(mbEnums.MonsterType.class); public final ArrayList rune_groupee_monster_types = new ArrayList<>(); public final ArrayList rune_helper_monster_types = new ArrayList<>(); + public int item_bane_rank; public ItemTemplate(JSONObject jsonObject) { try { // Reading a String - obj_name = (String) jsonObject.get("obj_name"); + obj_name = jsonObject.getString("obj_name"); // Reading a boolean - obj_pickable = (boolean) jsonObject.get("obj_pickable"); + obj_pickable = jsonObject.getBoolean("obj_pickable"); // Reading floats from an array (note always check for empty arrays) - JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale"); + JSONArray scaleData = jsonObject.getJSONArray("obj_scale"); if (scaleData.isEmpty() == false) - obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(), - ((Double) scaleData.get(2)).floatValue()); + obj_scale = new Vector3fImmutable(scaleData.getFloat(0), scaleData.getFloat(1), + scaleData.getFloat(2)); - JSONArray forwardVector = (JSONArray) jsonObject.get("obj_forward_vector"); + JSONArray forwardVector = jsonObject.getJSONArray("obj_forward_vector"); if (forwardVector.isEmpty() == false) - obj_forward_vector = new Vector3fImmutable(((Double) forwardVector.get(0)).floatValue(), ((Double) forwardVector.get(1)).floatValue(), - ((Double) forwardVector.get(2)).floatValue()); + obj_forward_vector = new Vector3fImmutable(forwardVector.getFloat(0), forwardVector.getFloat(1), + forwardVector.getFloat(2)); - JSONArray defaultAlighment = (JSONArray) jsonObject.get("obj_default_alignment"); + JSONArray defaultAlignment = jsonObject.getJSONArray("obj_default_alignment"); - if (defaultAlighment.isEmpty() == false) - obj_default_alignment = new Vector3fImmutable(((Double) defaultAlighment.get(0)).floatValue(), ((Double) defaultAlighment.get(1)).floatValue(), - ((Double) defaultAlighment.get(2)).floatValue()); + if (defaultAlignment.isEmpty() == false) + obj_default_alignment = new Vector3fImmutable(defaultAlignment.getFloat(0), defaultAlignment.getFloat(1), + defaultAlignment.getFloat(2)); // Reading an integer value - obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue(); - obj_icon = ((Long) jsonObject.get("obj_icon")).intValue(); + obj_render_object = jsonObject.getInt("obj_render_object"); + obj_icon = jsonObject.getInt("obj_icon"); - JSONObject obj_sparse_json = (JSONObject) jsonObject.get("obj_sparse_data"); + JSONObject obj_sparse_json = jsonObject.getJSONObject("obj_sparse_data"); - for (Object key : obj_sparse_json.keySet()) { - String sparseType = (String) key; + for (String sparseType : obj_sparse_json.keySet()) { Object sparseValue = obj_sparse_json.get(sparseType); obj_sparse_data.put(sparseType, sparseValue.toString()); } + // Banes are defined by their sparse data field + + if (obj_sparse_data.get("ACTIONRESPONSE") != null) + if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122")) + item_bane_rank = jsonObject.getInt("item_bane_rank"); + // Reading float values - combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue(); - combat_health_full = ((Double) jsonObject.get("combat_health_full")).floatValue(); + combat_health_current = jsonObject.getFloat("combat_health_current"); + combat_health_full = jsonObject.getFloat("combat_health_full"); // Reading a hashmap of floats - JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist"); + JSONObject resist_json = jsonObject.getJSONObject("combat_attack_resist"); - for (Object key : resist_json.keySet()) { - float resist = ((Double) resist_json.get(key)).floatValue(); - combat_attack_resist.put((String) key, resist); + for (String resistType : resist_json.keySet()) { + float resistValue = resist_json.getFloat(resistType); + combat_attack_resist.put(resistType, resistValue); } // Parsing an enum - item_type = mbEnums.ItemType.valueOf((String) jsonObject.get("item_type")); - item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue(); - item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type"); + item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type")); + item_eq_slots_value = jsonObject.getInt("item_eq_slots_value"); + item_eq_slots_type = jsonObject.getBoolean("item_eq_slots_type"); // Parsing an enumset - JSONArray eq_slots_or = (JSONArray) jsonObject.get("item_eq_slots_or"); + JSONArray eq_slots_or = jsonObject.getJSONArray("item_eq_slots_or"); if (eq_slots_or.isEmpty() == false) for (Object o : eq_slots_or) item_eq_slots_or.add(mbEnums.EquipSlotType.valueOf((String) o)); - JSONArray eq_slots_and = (JSONArray) jsonObject.get("item_eq_slots_and"); + JSONArray eq_slots_and = jsonObject.getJSONArray("item_eq_slots_and"); if (eq_slots_and.isEmpty() == false) for (Object o : eq_slots_and) item_eq_slots_and.add(mbEnums.EquipSlotType.valueOf((String) o)); - item_takeable = (boolean) jsonObject.get("item_takeable"); - item_value = ((Long) jsonObject.get("item_value")).intValue(); - item_wt = ((Long) jsonObject.get("item_wt")).intValue(); - item_passive_defense_mod = ((Double) jsonObject.get("item_passive_defense_mod")).floatValue(); - item_base_name = (String) jsonObject.get("item_base_name"); - item_dsc = (String) jsonObject.get("item_dsc"); - item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue(); - item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue(); + item_takeable = jsonObject.getBoolean("item_takeable"); + item_value = (jsonObject.getInt("item_value")); + item_wt = jsonObject.getInt("item_wt"); + item_passive_defense_mod = jsonObject.getFloat("item_passive_defense_mod"); + item_base_name = jsonObject.getString("item_base_name"); + item_dsc = jsonObject.getString("item_dsc"); + item_render_object_female = jsonObject.getInt("item_render_object_female"); + item_health_full = jsonObject.getFloat("item_health_full"); Object skill_used = jsonObject.get("item_skill_used"); @@ -233,74 +250,74 @@ public class ItemTemplate { if (mastery_used instanceof String) item_skill_mastery_used = (String) mastery_used; - item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue(); + item_parry_anim_id = jsonObject.getInt("item_parry_anim_id"); // Reading offering data - JSONArray offering_data = (JSONArray) jsonObject.get("item_offering_info"); + JSONArray offering_data = jsonObject.getJSONArray("item_offering_info"); for (Object entry : offering_data) { JSONObject offering_entry = (JSONObject) entry; - String offering_type = ((String) offering_entry.get("offering_type")).replaceAll("-", ""); - int offering_value = ((Long) offering_entry.get("offering_value")).intValue(); + String offering_type = offering_entry.getString("offering_type").replaceAll("-", ""); + int offering_value = offering_entry.getInt("offering_value"); item_offering_info.put(mbEnums.ShrineType.valueOf(offering_type), offering_value); } // Fields only present for ARMOR if (item_type.equals(mbEnums.ItemType.ARMOR)) { - item_bulk_factor = ((Double) jsonObject.get("item_bulk_factor")).floatValue(); - item_defense_rating = ((Long) jsonObject.get("item_defense_rating")).intValue(); + item_bulk_factor = jsonObject.getFloat("item_bulk_factor"); + item_defense_rating = jsonObject.getInt("item_defense_rating"); } // Fields only present for WEAPON if (item_type.equals(mbEnums.ItemType.WEAPON)) { - JSONObject item_weapon = (JSONObject) jsonObject.get("item_weapon"); - item_weapon_wepspeed = ((Double) item_weapon.get("weapon_wepspeed")).floatValue(); - item_weapon_max_range = ((Double) item_weapon.get("weapon_max_range")).floatValue(); - item_weapon_projectile_id = ((Long) item_weapon.get("weapon_projectile_id")).intValue(); - item_weapon_projectile_speed = ((Double) item_weapon.get("weapon_projectile_speed")).floatValue(); - item_weapon_combat_idle_anim = ((Long) item_weapon.get("weapon_combat_idle_anim")).intValue(); + JSONObject item_weapon = jsonObject.getJSONObject("item_weapon"); + item_weapon_wepspeed = item_weapon.getFloat("weapon_wepspeed"); + item_weapon_max_range = item_weapon.getFloat("weapon_max_range"); + item_weapon_projectile_id = item_weapon.getInt("weapon_projectile_id"); + item_weapon_projectile_speed = item_weapon.getFloat("weapon_projectile_speed"); + item_weapon_combat_idle_anim = item_weapon.getInt("weapon_combat_idle_anim"); - JSONArray weapon_damage = (JSONArray) item_weapon.get("weapon_damage"); + JSONArray weapon_damage = item_weapon.getJSONArray("weapon_damage"); if (weapon_damage.isEmpty() == false) for (Object o : weapon_damage) { JSONObject damage_entry = (JSONObject) o; - mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(((String) damage_entry.get("damage_type"))); - int min = ((Long) damage_entry.get("damage_min")).intValue(); - int max = ((Long) damage_entry.get("damage_max")).intValue(); + mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(damage_entry.getString("damage_type")); + int min = damage_entry.getInt("damage_min"); + int max = damage_entry.getInt("damage_max"); int[] minMax = {min, max}; item_weapon_damage.put(damageType, minMax); } - JSONArray attack_anim_right = (JSONArray) item_weapon.get("weapon_attack_anim_right"); + JSONArray attack_anim_right = item_weapon.getJSONArray("weapon_attack_anim_right"); if (attack_anim_right.isEmpty() == false) for (Object o : attack_anim_right) { JSONArray animationEntry = (JSONArray) o; - int animation = ((Long) animationEntry.get(0)).intValue(); - int duration = ((Long) animationEntry.get(1)).intValue(); + int animation = animationEntry.getInt(0); + int duration = animationEntry.getInt(1); weapon_attack_anim_right.add(new int[]{animation, duration}); } - JSONArray attack_anim_left = (JSONArray) item_weapon.get("weapon_attack_anim_left"); + JSONArray attack_anim_left = item_weapon.getJSONArray("weapon_attack_anim_left"); if (attack_anim_left.isEmpty() == false) for (Object o : attack_anim_left) { JSONArray animationEntry = (JSONArray) o; - int animation = ((Long) animationEntry.get(0)).intValue(); - int duration = ((Long) animationEntry.get(1)).intValue(); + int animation = animationEntry.getInt(0); + int duration = animationEntry.getInt(1); weapon_attack_anim_left.add(new int[]{animation, duration}); } - item_primary_attr = mbEnums.AttributeType.valueOf((String) jsonObject.get("item_primary_attr")); - item_secondary_attr = mbEnums.AttributeType.valueOf((String) jsonObject.get("item_secondary_attr")); + item_primary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_primary_attr")); + item_secondary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_secondary_attr")); } - JSONArray itemflags = (JSONArray) jsonObject.get("item_flags"); + JSONArray itemflags = jsonObject.getJSONArray("item_flags"); if (itemflags.isEmpty() == false) for (Object o : itemflags) { @@ -309,29 +326,29 @@ public class ItemTemplate { item_flags.add(mbEnums.ItemFlags.valueOf((String) o)); } - JSONArray itemUseflags = (JSONArray) jsonObject.get("item_use_flags"); + JSONArray itemUseflags = jsonObject.getJSONArray("item_use_flags"); if (itemUseflags.isEmpty() == false) for (Object o : itemUseflags) item_use_flags.add(mbEnums.ItemUseFlags.valueOf((String) o)); - item_initial_charges = ((Long) jsonObject.get("item_initial_charges")).intValue(); + item_initial_charges = jsonObject.getInt("item_initial_charges"); - JSONArray skill_required = (JSONArray) jsonObject.get("item_skill_req"); + JSONArray skill_required = jsonObject.getJSONArray("item_skill_req"); if (skill_required.isEmpty() == false) for (Object o : skill_required) { JSONObject skill_req = (JSONObject) o; - String skill_type = (String) skill_req.get("skill_type"); - int skill_level = ((Long) skill_req.get("skill_level")).intValue(); + String skill_type = skill_req.getString("skill_type"); + int skill_level = skill_req.getInt("skill_level"); if (skill_type.equals("Cloth") == false) item_skill_required.put(skill_type, skill_level); } - JSONObject race_required = (JSONObject) jsonObject.get("item_race_req"); - boolean restrict = ((Boolean) race_required.get("restrict")); - JSONArray races = (JSONArray) race_required.get("races"); + JSONObject race_required = jsonObject.getJSONObject("item_race_req"); + boolean restrict = race_required.getBoolean("restrict"); + JSONArray races = race_required.getJSONArray("races"); if (races.isEmpty() == false) for (Object o : races) { @@ -346,9 +363,9 @@ public class ItemTemplate { item_race_req.add(mbEnums.MonsterType.valueOf(race)); } - JSONObject class_required = (JSONObject) jsonObject.get("item_class_req"); - restrict = ((Boolean) class_required.get("restrict")); - JSONArray classes = (JSONArray) class_required.get("classes"); + JSONObject class_required = jsonObject.getJSONObject("item_class_req"); + restrict = class_required.getBoolean("restrict"); + JSONArray classes = class_required.getJSONArray("classes"); if (classes.isEmpty() == false) for (Object o : classes) { @@ -362,9 +379,9 @@ public class ItemTemplate { item_class_req.add(mbEnums.ClassType.valueOf(classEntry)); } - JSONObject disc_required = (JSONObject) jsonObject.get("item_disc_req"); - restrict = ((Boolean) disc_required.get("restrict")); - JSONArray discs = (JSONArray) disc_required.get("discs"); + JSONObject disc_required = jsonObject.getJSONObject("item_disc_req"); + restrict = disc_required.getBoolean("restrict"); + JSONArray discs = disc_required.getJSONArray("discs"); if (discs.isEmpty() == false) for (Object o : discs) { @@ -378,62 +395,61 @@ public class ItemTemplate { item_disc_req.add(mbEnums.DisciplineType.valueOf(disc)); } - item_level_req = ((Long) jsonObject.get("item_level_req")).intValue(); - item_sex_req = mbEnums.SexType.valueOf((String) jsonObject.get("item_sex_req")); + item_level_req = jsonObject.getInt("item_level_req"); + item_sex_req = mbEnums.SexType.valueOf(jsonObject.getString("item_sex_req")); - JSONArray userPowerActions = (JSONArray) jsonObject.get("item_user_power_action"); + JSONArray userPowerActions = jsonObject.getJSONArray("item_user_power_action"); if (userPowerActions.isEmpty() == false) for (Object o : userPowerActions) { JSONObject powerActionEntry = (JSONObject) o; - String power = (String) powerActionEntry.get("power"); - JSONArray args = (JSONArray) powerActionEntry.get("arguments"); - int[] arguments = {((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()}; + String power = powerActionEntry.getString("power"); + JSONArray args = powerActionEntry.getJSONArray("arguments"); + int[] arguments = {args.getInt(0), args.getInt(1)}; item_user_power_action.put(power, arguments); } - JSONArray powerGrantsArray = (JSONArray) jsonObject.get("item_power_grant"); + JSONArray powerGrantsArray = jsonObject.getJSONArray("item_power_grant"); if (powerGrantsArray.isEmpty() == false) { for (Object grantArrayEntry : powerGrantsArray) { JSONObject powerGrantEntry = (JSONObject) grantArrayEntry; - String power_type = (String) powerGrantEntry.get("power_type"); - int power_value = ((Long) powerGrantEntry.get("power_value")).intValue(); + String power_type = powerGrantEntry.getString("power_type"); + int power_value = powerGrantEntry.getInt("power_value"); item_power_grant.put(power_type, power_value); - JSONArray skill_granted_array = (JSONArray) powerGrantEntry.get("power_granted_skills"); + JSONArray skill_granted_array = powerGrantEntry.getJSONArray("power_granted_skills"); for (Object skillGrantEntry : skill_granted_array) { JSONArray skill_entry = (JSONArray) skillGrantEntry; - String skill_type = (String) skill_entry.get(0); - int skill_level = ((Long) skill_entry.get(1)).intValue(); + String skill_type = skill_entry.getString(0); + int skill_level = skill_entry.getInt(1); power_granted_skills.put(skill_type, skill_level); } } - } - JSONArray item_power_actions = (JSONArray) jsonObject.get("item_power_action"); + JSONArray item_power_actions = jsonObject.getJSONArray("item_power_action"); if (item_power_actions.isEmpty() == false) for (Object o : item_power_actions) { JSONObject powerActionEntry = (JSONObject) o; - String power = (String) powerActionEntry.get("power_type"); - JSONArray power_actions = (JSONArray) powerActionEntry.get("power_actions"); - JSONObject argument_entry = (JSONObject) power_actions.get(0); - JSONArray power_args = (JSONArray) argument_entry.get("power_arguments"); - int[] power_arguments = {((Long) power_args.get(0)).intValue(), ((Long) power_args.get(1)).intValue()}; + String power = powerActionEntry.getString("power_type"); + JSONArray power_actions = powerActionEntry.getJSONArray("power_actions"); + JSONObject argument_entry = power_actions.getJSONObject(0); + JSONArray power_args = argument_entry.getJSONArray("power_arguments"); + int[] power_arguments = {power_args.getInt(0), power_args.getInt(1)}; item_power_action.put(power, power_arguments); } - JSONArray resource_costs = (JSONArray) jsonObject.get("item_resource_costs"); + JSONArray resource_costs = jsonObject.getJSONArray("item_resource_costs"); if (resource_costs.isEmpty() == false) for (Object o : resource_costs) { JSONObject resource_entry = (JSONObject) o; - mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(((String) resource_entry.get("resource_type")).toUpperCase()); - int resource_value = ((Long) resource_entry.get("resource_value")).intValue(); + mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(resource_entry.getString("resource_type").toUpperCase()); + int resource_value = resource_entry.getInt("resource_value"); item_resource_cost.put(resource_type, resource_value); } @@ -441,69 +457,69 @@ public class ItemTemplate { if (item_type.equals(mbEnums.ItemType.DEED)) { - deed_type = ((Long) jsonObject.get("deed_type")).intValue(); - deed_furniture_id = ((Long) jsonObject.get("deed_furniture_id")).intValue(); - deed_target_id = ((Long) jsonObject.get("deed_target_id")).intValue(); - deed_employment = ((Long) jsonObject.get("deed_employment")).intValue(); - deed_start_rank = ((Long) jsonObject.get("deed_start_rank")).intValue(); - deed_name_lookup = ((Long) jsonObject.get("deed_name_lookup")).intValue(); - deed_indoors = ((Boolean) jsonObject.get("deed_indoors")); - deed_is_fortress = ((Boolean) jsonObject.get("deed_is_fortress")); - deed_namelookup_val = ((Double) jsonObject.get("deed_namelookup_val")).floatValue(); - deed_custom_city = ((Boolean) jsonObject.get("deed_custom_city")); - deed_structure_id = ((Long) jsonObject.get("deed_structure_id")).intValue(); + deed_type = jsonObject.getInt("deed_type"); + deed_furniture_id = jsonObject.getInt("deed_furniture_id"); + deed_target_id = jsonObject.getInt("deed_target_id"); + deed_employment = jsonObject.getInt("deed_employment"); + deed_start_rank = jsonObject.getInt("deed_start_rank"); + deed_name_lookup = jsonObject.getInt("deed_name_lookup"); + deed_indoors = jsonObject.getBoolean("deed_indoors"); + deed_is_fortress = jsonObject.getBoolean("deed_is_fortress"); + deed_namelookup_val = jsonObject.getFloat("deed_namelookup_val"); + deed_custom_city = jsonObject.getBoolean("deed_custom_city"); + deed_structure_id = jsonObject.getInt("deed_structure_id"); } if (item_type.equals(mbEnums.ItemType.RUNE)) { - rune_type = (String) jsonObject.get("rune_type"); + rune_type = jsonObject.getString("rune_type"); Object subType = jsonObject.get("rune_sub_type"); if (subType instanceof String) rune_sub_type = (String) subType; - rune_is_standard_character_creation = ((Boolean) jsonObject.get("rune_is_standard_character_creation")); - rune_creation_cost = ((Long) jsonObject.get("rune_creation_cost")).intValue(); - rune_rank = ((Long) jsonObject.get("rune_rank")).intValue(); - rune_pracs_per_level = ((Long) jsonObject.get("rune_pracs_per_level")).intValue(); - rune_exp_req_to_level = ((Double) jsonObject.get("rune_exp_req_to_level")).floatValue(); - rune_sex = mbEnums.SexType.valueOf((String) jsonObject.get("rune_sex")); - rune_class_icon = ((Long) jsonObject.get("rune_class_icon")).intValue(); - rune_health = ((Long) jsonObject.get("rune_health")).intValue(); - rune_mana = ((Long) jsonObject.get("rune_mana")).intValue(); - rune_stamina = ((Long) jsonObject.get("rune_stamina")).intValue(); - rune_min_damage = ((Double) jsonObject.get("rune_min_damage")).floatValue(); - rune_max_damage = ((Double) jsonObject.get("rune_max_damage")).floatValue(); - rune_attack = ((Long) jsonObject.get("rune_attack")).intValue(); - rune_defense = ((Long) jsonObject.get("rune_defense")).intValue(); - rune_level = ((Long) jsonObject.get("rune_level")).intValue(); - - JSONObject rune_speed_json = (JSONObject) jsonObject.get("rune_speed"); - - for (Object key : rune_speed_json.keySet()) { - mbEnums.MovementType movementType = mbEnums.MovementType.valueOf((String) key); - float speed = ((Double) rune_speed_json.get(key)).floatValue(); + rune_is_standard_character_creation = jsonObject.getBoolean("rune_is_standard_character_creation"); + rune_creation_cost = jsonObject.getInt("rune_creation_cost"); + rune_rank = jsonObject.getInt("rune_rank"); + rune_pracs_per_level = jsonObject.getInt("rune_pracs_per_level"); + rune_exp_req_to_level = jsonObject.getFloat("rune_exp_req_to_level"); + rune_sex = mbEnums.SexType.valueOf(jsonObject.getString("rune_sex")); + rune_class_icon = jsonObject.getInt("rune_class_icon"); + rune_health = jsonObject.getInt("rune_health"); + rune_mana = jsonObject.getInt("rune_mana"); + rune_stamina = jsonObject.getInt("rune_stamina"); + rune_min_damage = jsonObject.getFloat("rune_min_damage"); + rune_max_damage = jsonObject.getFloat("rune_max_damage"); + rune_attack = jsonObject.getInt("rune_attack"); + rune_defense = jsonObject.getInt("rune_defense"); + rune_level = jsonObject.getInt("rune_level"); + + JSONObject rune_speed_json = jsonObject.getJSONObject("rune_speed"); + + for (String key : rune_speed_json.keySet()) { + mbEnums.MovementType movementType = mbEnums.MovementType.valueOf(key); + float speed = rune_speed_json.getFloat(key); rune_speed.put(movementType, speed); } - JSONObject rune_group = (JSONObject) jsonObject.get("rune_group"); + JSONObject rune_group = jsonObject.getJSONObject("rune_group"); - rune_group_type = ((Long) rune_group.get("group_type")).intValue(); - rune_group_is_faction = ((Boolean) rune_group.get("group_is_faction")); - rune_group_is_guild = ((Boolean) rune_group.get("group_is_guild")); - rune_dsc = (String) jsonObject.get("rune_dsc"); - rune_fx_txt = (String) jsonObject.get("rune_fx_txt"); + rune_group_type = rune_group.getInt("group_type"); + rune_group_is_faction = rune_group.getBoolean("group_is_faction"); + rune_group_is_guild = rune_group.getBoolean("group_is_guild"); + rune_dsc = jsonObject.getString("rune_dsc"); + rune_fx_txt = jsonObject.getString("rune_fx_txt"); - int group_tactics_bitvector = ((Long) jsonObject.get("rune_group_tactics")).intValue(); + long group_tactics_bitvector = jsonObject.getLong("rune_group_tactics"); rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); - int group_role_bitvector = ((Long) jsonObject.get("rune_group_role_set")).intValue(); + long group_role_bitvector = jsonObject.getLong("rune_group_role_set"); rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class)); - JSONArray enemy_types_json = (JSONArray) jsonObject.get("rune_enemy_monster_types"); + JSONArray enemy_types_json = jsonObject.getJSONArray("rune_enemy_monster_types"); for (Object o : enemy_types_json) { String enemy = (String) o; @@ -512,7 +528,7 @@ public class ItemTemplate { rune_enemy_monster_types.add(monsterType); } - JSONArray not_enemy_types_json = (JSONArray) jsonObject.get("rune_not_enemy_monster_types"); + JSONArray not_enemy_types_json = jsonObject.getJSONArray("rune_not_enemy_monster_types"); for (Object o : not_enemy_types_json) { String notenemy = (String) o; @@ -521,27 +537,26 @@ public class ItemTemplate { rune_not_enemy_monster_types.add(monsterType); } - JSONArray groupee_types_json = (JSONArray) jsonObject.get("rune_groupee_monster_types"); + JSONArray groupee_types_json = jsonObject.getJSONArray("rune_groupee_monster_types"); for (Object o : groupee_types_json) { - int groupeeId = ((Long) o).intValue(); + int groupeeId = (int) o; rune_groupee_monster_types.add(groupeeId); } - JSONArray helper_types_json = (JSONArray) jsonObject.get("rune_helper_monster_types"); + JSONArray helper_types_json = jsonObject.getJSONArray("rune_helper_monster_types"); for (Object o : helper_types_json) { - int helperId = ((Long) o).intValue(); + int helperId = (int) o; rune_helper_monster_types.add(helperId); } - rune_renderable = ((Boolean) jsonObject.get("rune_renderable")); - rune_natural_power_attack = ((Long) jsonObject.get("rune_natural_power_attack")).intValue(); + rune_renderable = jsonObject.getBoolean("rune_renderable"); + rune_natural_power_attack = jsonObject.getInt("rune_natural_power_attack"); - JSONObject rune_sparse_json = (JSONObject) jsonObject.get("rune_sparse_data"); + JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data"); - for (Object key : rune_sparse_json.keySet()) { - String sparseType = (String) key; + for (String sparseType : rune_sparse_json.keySet()) { Object sparseValue = rune_sparse_json.get(sparseType); rune_sparse_data.put(sparseType, sparseValue.toString()); } @@ -550,51 +565,51 @@ public class ItemTemplate { for (Object skillEntry : skill_adj_json) { JSONObject skill = (JSONObject) skillEntry; - String typeString = (String) skill.get("skill_type"); - JSONArray adjArray = (JSONArray) skill.get("skill_adjusts"); + String typeString = skill.getString("skill_type"); + JSONArray adjArray = skill.getJSONArray("skill_adjusts"); for (Object adjustList : adjArray) { JSONArray adjustEntry = (JSONArray) adjustList; - int[] adjust = {((Long) adjustEntry.get(0)).intValue(), ((Long) adjustEntry.get(1)).intValue()}; + int[] adjust = {adjustEntry.getInt(0), adjustEntry.getInt(1)}; rune_skill_adj.put(typeString, adjust); } } - JSONArray attr_adj_json = (JSONArray) jsonObject.get("rune_attr_adj"); + JSONArray attr_adj_json = jsonObject.getJSONArray("rune_attr_adj"); for (Object attributeEntry : attr_adj_json) { JSONObject attribute = (JSONObject) attributeEntry; - String typeString = (String) attribute.get("attr_type"); + String typeString = attribute.getString("attr_type"); mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString); - int attributeValue = ((Long) attribute.get("attr_value")).intValue(); + int attributeValue = attribute.getInt("attr_value"); rune_attr_adj.put(attributeType, attributeValue); } - JSONArray max_attr_adj_json = (JSONArray) jsonObject.get("rune_max_attr_adj"); + JSONArray max_attr_adj_json = jsonObject.getJSONArray("rune_max_attr_adj"); for (Object attributeEntry : max_attr_adj_json) { JSONObject attribute = (JSONObject) attributeEntry; - String typeString = (String) attribute.get("attr_type"); + String typeString = attribute.getString("attr_type"); mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString); - int attributeValue = ((Long) attribute.get("attr_value")).intValue(); + int attributeValue = attribute.getInt("attr_value"); rune_max_attr_adj.put(attributeType, attributeValue); } - JSONArray skill_grant_json = (JSONArray) jsonObject.get("rune_skill_grant"); + JSONArray skill_grant_json = jsonObject.getJSONArray("rune_skill_grant"); if (skill_grant_json.isEmpty() == false) for (Object runeSkillEntry : skill_grant_json) { JSONObject skill_granted = (JSONObject) runeSkillEntry; - String typeString = (String) skill_granted.get("skill_type"); - int skill_level = ((Long) skill_granted.get("skill_value")).intValue(); + String typeString = skill_granted.getString("skill_type"); + int skill_level = skill_granted.getInt("skill_value"); rune_skill_grant.put(typeString, skill_level); - JSONArray skill_granted_array = (JSONArray) skill_granted.get("skill_granted_skills"); + JSONArray skill_granted_array = skill_granted.getJSONArray("skill_granted_skills"); for (Object skillGrantEntry : skill_granted_array) { JSONArray skill_entry = (JSONArray) skillGrantEntry; - typeString = (String) skill_entry.get(0); - skill_level = ((Long) skill_entry.get(1)).intValue(); + typeString = skill_entry.getString(0); + skill_level = skill_entry.getInt(1); skill_granted_skills.put(typeString, skill_level); } } diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index fe573a4a..ee54309b 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -10,6 +10,7 @@ package engine.objects; import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.gameManager.LootManager; import engine.loot.BootySetEntry; import engine.mbEnums; @@ -126,7 +127,7 @@ public class MobBase extends AbstractGameObject { for (BootySetEntry equipmentSetEntry : equipList) { Item item = new Item(equipmentSetEntry.templateID); - item.objectUUID = MobLoot.lastNegativeID.decrementAndGet(); + item.objectUUID = ItemManager.lastNegativeID.decrementAndGet(); item.drop_chance = equipmentSetEntry.dropChance; item.equipSlot = item.template.item_eq_slots_or.iterator().next(); equip.put(item.equipSlot, item); diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index b24a8798..643e53eb 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -10,6 +10,7 @@ package engine.objects; import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.gameManager.PowersManager; import engine.mbEnums; import engine.mbEnums.ItemType; @@ -17,8 +18,6 @@ import engine.mbEnums.OwnerType; import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; -import java.util.concurrent.atomic.AtomicInteger; - /** * An immutable, non-persistant implementation of Item * @@ -26,8 +25,6 @@ import java.util.concurrent.atomic.AtomicInteger; */ public final class MobLoot extends Item { - public static final AtomicInteger lastNegativeID = new AtomicInteger(0); - private boolean isDeleted = false; private boolean noSteal; private String prefix = ""; @@ -77,7 +74,7 @@ public final class MobLoot extends Item { * @return Id number */ private static int generateId() { - int id = lastNegativeID.decrementAndGet(); + int id = ItemManager.lastNegativeID.decrementAndGet(); //TODO Add a way to reclaim disposed IDs if this becomes a problem if (id == (-10000)) @@ -142,7 +139,6 @@ public final class MobLoot extends Item { //remove from production list for npc in db - DbManager.NPCQueries.REMOVE_FROM_PRODUCTION_LIST(this.getObjectUUID(), vendor.getObjectUUID()); this.removeFromCache(); isDeleted = true; } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 38dee29c..ddb12851 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -23,8 +23,6 @@ import engine.mbEnums.*; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; -import engine.net.client.msg.ErrorPopupMsg; -import engine.net.client.msg.ItemProductionMsg; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; import engine.server.MBServerStatics; @@ -49,9 +47,7 @@ public class NPC extends AbstractCharacter { public static HashMap> _pirateNames = new HashMap<>(); // Used for thread safety public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - private final ArrayList rolling = new ArrayList<>(); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); - public ArrayList forgedItems = new ArrayList<>(); public int runeSetID = 0; public int extraRune2 = 0; protected int loadID; @@ -69,7 +65,7 @@ public class NPC extends AbstractCharacter { protected int vendorID; protected ArrayList modTypeTable; protected ArrayList modSuffixTable; - protected ArrayList itemModTable; + protected ArrayList itemModTable; protected int symbol; // Variables NOT to be stored in db protected boolean isStatic = false; @@ -803,7 +799,7 @@ public class NPC extends AbstractCharacter { return modSuffixTable; } - public ArrayList getItemModTable() { + public ArrayList getItemModTable() { return itemModTable; } @@ -873,6 +869,11 @@ public class NPC extends AbstractCharacter { if (this.building != null) NPCManager.slotCharacterInBuilding(this); + // If NPC is a vendor then configure ForgeManager support + + if (this.contract.isTrainer() == false) + ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> ConcurrentHashMap.newKeySet()); + this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); this.modSuffixTable = this.contract.getNpcModSuffixTable(); @@ -913,58 +914,6 @@ public class NPC extends AbstractCharacter { this.charItemManager.equipped = loadEquipmentSet(this.equipmentSetID); - try { - - DbManager.NPCQueries.LOAD_ALL_ITEMS_TO_PRODUCE(this); - - for (ProducedItem producedItem : this.forgedItems) { - MobLoot ml = new MobLoot(this, ItemTemplate.templates.get(producedItem.getTemplateID()), false); - - DbManager.NPCQueries.UPDATE_ITEM_ID(producedItem.getID(), currentID, ml.getObjectUUID()); - - if (producedItem.isInForge()) { - - if (producedItem.getPrefix() != null && !producedItem.getPrefix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getPrefix(), 0, 0, true); - ml.setPrefix(producedItem.getPrefix()); - } - - if (producedItem.getSuffix() != null && !producedItem.getSuffix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getSuffix(), 0, 0, false); - ml.setSuffix(producedItem.getSuffix()); - } - - if (!producedItem.isRandom()) - ml.flags.add(ItemFlags.Identified); - - ml.loadEnchantments(); - - ml.setValue(producedItem.getValue()); - ml.setDateToUpgrade(producedItem.getDateToUpgrade().getMillis()); - ml.containerType = mbEnums.ItemContainerType.FORGE; - this.addItemToForge(ml); - - } else { - - if (producedItem.getPrefix() != null && !producedItem.getPrefix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getPrefix(), 0, 0, true); - ml.setPrefix(producedItem.getPrefix()); - } - - if (producedItem.getSuffix() != null && !producedItem.getSuffix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getSuffix(), 0, 0, false); - ml.setSuffix(producedItem.getSuffix()); - } - - ml.setDateToUpgrade(producedItem.getDateToUpgrade().getMillis()); - ml.containerType = mbEnums.ItemContainerType.INVENTORY; - ml.flags.add(ItemFlags.Identified); - - this.charItemManager.addItemToInventory(ml); - } - ml.setValue(producedItem.getValue()); - } - // Create NPC bounds object Bounds npcBounds = Bounds.borrow(); npcBounds.setBounds(this.getLoc()); @@ -973,9 +922,6 @@ public class NPC extends AbstractCharacter { NPCManager.applyRunesForNPC(this); this.resists.setImmuneToAll(true); - } catch (Exception e) { - Logger.error(e.getMessage()); - } } public void removeFromZone() { @@ -1006,30 +952,6 @@ public class NPC extends AbstractCharacter { this.upgradeDateTime = upgradeDateTime; } - public ArrayList getRolling() { - synchronized (rolling) { - return rolling; - } - } - - public int getRollingCount() { - synchronized (this.rolling) { - return rolling.size(); - } - } - - public void addItemToForge(MobLoot item) { - synchronized (this.rolling) { - this.rolling.add(item); - } - } - - public void removeItemFromForge(Item item) { - synchronized (this.rolling) { - this.rolling.remove(item); - } - } - @Override public Guild getGuild() { if (this.building != null) @@ -1164,109 +1086,6 @@ public class NPC extends AbstractCharacter { return 0; } - public synchronized Item produceItem(int playerID, int amount, boolean isRandom, int pToken, int sToken, String customName, int itemID) { - - Zone serverZone; - City city; - Item item = null; - - PlayerCharacter player = null; - - if (playerID != 0) - player = SessionManager.getPlayerCharacterByID(playerID); - - try { - - if (this.getRollingCount() >= this.getRank()) { - - if (player != null) - ChatManager.chatSystemInfo(player, this.getName() + " " + this.getContract().getName() + " slots are full"); - - return null; - } - - // Cannot roll items without a warehouse. - // Due to the fact fillForge references the - // warehouse and early exits. *** Refactor??? - - serverZone = this.building.getParentZone(); - - if (serverZone == null) - return null; - - city = City.GetCityFromCache(serverZone.playerCityUUID); - - if (city == null) { - - if (player != null) - ErrorPopupMsg.sendErrorMsg(player, "Could not find city."); // Production denied: This building must be protected to gain access to warehouse resources. - - return null; - } - - if (this.building == null) { - - if (player != null) - ErrorPopupMsg.sendErrorMsg(player, "Could not find building."); // Production denied: This building must be protected to gain ac - - return null; - } - - //TODO create Normal Items. - - if (amount == 0) - amount = 1; - - if (isRandom) - item = ItemFactory.randomRoll(this, player, amount, itemID); - else - item = ItemFactory.fillForge(this, player, amount, itemID, pToken, sToken, customName); - - if (item == null) - return null; - - ItemProductionMsg outMsg = new ItemProductionMsg(this.building, this, item, 8, true); - DispatchMessage.dispatchMsgToInterestArea(this, outMsg, DispatchChannel.SECONDARY, 700, false, false); - - } catch (Exception e) { - Logger.error(e); - } - return item; - } - - public synchronized boolean completeItem(int itemUUID) { - - MobLoot targetItem; - - try { - targetItem = MobLoot.getFromCache(itemUUID); - - if (targetItem == null) - return false; - - if (!this.charItemManager.forgeContains(targetItem, this)) - return false; - - if (!DbManager.NPCQueries.UPDATE_ITEM_TO_INVENTORY(targetItem.getObjectUUID(), currentID)) - return false; - - targetItem.flags.add(ItemFlags.Identified); - - this.rolling.remove(targetItem); - this.charItemManager.addItemToInventory(targetItem); - - //remove from client forge window - - ItemProductionMsg outMsg1 = new ItemProductionMsg(this.building, this, targetItem, 9, true); - DispatchMessage.dispatchMsgToInterestArea(this, outMsg1, DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); - ItemProductionMsg outMsg = new ItemProductionMsg(this.building, this, targetItem, 10, true); - DispatchMessage.dispatchMsgToInterestArea(this, outMsg, DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); - - } catch (Exception e) { - Logger.error(e.getMessage()); - } - return true; - } public int getEquipmentSetID() { return equipmentSetID; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 6b4c35db..0d4704b5 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2193,7 +2193,7 @@ public class PlayerCharacter extends AbstractCharacter { public boolean setPromotionClass(int value) { PromotionClass promotionClass = PromotionClass.GetPromtionClassFromCache(value); - + this.absPromotionClass = mbEnums.ClassType.valueOf(promotionClass.getName()); if (promotionClass == null) return false; diff --git a/src/engine/objects/ProducedItem.java b/src/engine/objects/ProducedItem.java deleted file mode 100644 index e999fb44..00000000 --- a/src/engine/objects/ProducedItem.java +++ /dev/null @@ -1,225 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.gameManager.PowersManager; -import engine.mbEnums.DispatchChannel; -import engine.net.DispatchMessage; -import engine.net.client.msg.ItemProductionMsg; -import engine.powers.EffectsBase; -import org.joda.time.DateTime; -import org.pmw.tinylog.Logger; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Date; - -public class ProducedItem { - - private int ID; - private int npcUID; - private int templateID; - private DateTime dateToUpgrade; - private boolean isRandom; - - private String prefix; - private String suffix; - private String name; - private int amount; - private int producedItemID = 0; - private boolean inForge; - private int value; - - private int playerID; - - - /** - * ResultSet Constructor - */ - - public ProducedItem(ResultSet rs) throws SQLException { - this.ID = rs.getInt("ID"); - this.npcUID = rs.getInt("npcUID"); - this.templateID = rs.getInt("templateID"); - - Date sqlDateTime = rs.getTimestamp("dateToUpgrade"); - - if (sqlDateTime != null) - this.dateToUpgrade = new DateTime(sqlDateTime); - else - dateToUpgrade = null; - this.isRandom = rs.getBoolean("isRandom"); - this.prefix = rs.getString("prefix"); - this.suffix = rs.getString("suffix"); - this.name = rs.getString("name"); - this.inForge = rs.getBoolean("inForge"); - this.value = rs.getInt("value"); - this.playerID = rs.getInt("playerID"); - } - - public ProducedItem(int ID, int npcUID, int templateID, DateTime dateToUpgrade, boolean isRandom, String prefix, String suffix, String name, int playerID) { - super(); - this.ID = ID; - this.npcUID = npcUID; - this.templateID = templateID; - this.dateToUpgrade = dateToUpgrade; - this.isRandom = isRandom; - this.prefix = prefix; - this.suffix = suffix; - this.name = name; - this.value = 0; - this.playerID = playerID; - - - } - - public int getNpcUID() { - return npcUID; - } - - public DateTime getDateToUpgrade() { - return dateToUpgrade; - } - - public int getTemplateID() { - return templateID; - } - - public void setTemplateID(int templateID) { - this.templateID = templateID; - } - - public boolean isRandom() { - return isRandom; - } - - public void setRandom(boolean isRandom) { - this.isRandom = isRandom; - } - - public String getPrefix() { - return prefix; - } - - public String getSuffix() { - return suffix; - } - - public void setSuffix(String suffix) { - this.suffix = suffix; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getID() { - return ID; - } - - public void setID(int iD) { - ID = iD; - } - - public int getAmount() { - return amount; - } - - public void setAmount(int amount) { - this.amount = amount; - } - - - public int getProducedItemID() { - return producedItemID; - } - - public void setProducedItemID(int producedItemID) { - this.producedItemID = producedItemID; - } - - public boolean isInForge() { - return inForge; - } - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - - public boolean finishProduction() { - NPC npc = NPC.getFromCache(this.getNpcUID()); - - if (npc == null) - return false; - - - //update the client to ID the item in the window when item finishes rolling. - //If there is more than 1 item left to roll, complete the item and throw it in inventory - //and reproduce next item. - - try { - - if (this.getAmount() > 1) { - this.setAmount(this.getAmount() - 1); - npc.completeItem(this.getProducedItemID()); - - int pToken = 0; - int sToken = 0; - - if (!this.isRandom()) { - EffectsBase eb = PowersManager.getEffectByIDString(this.getPrefix()); - if (eb != null) - pToken = eb.getToken(); - eb = PowersManager.getEffectByIDString(this.getSuffix()); - if (eb != null) - sToken = eb.getToken(); - - } - - Item item = npc.produceItem(0, this.getAmount(), this.isRandom(), pToken, sToken, this.getName(), this.getTemplateID()); - - if (item == null) - return false; - - } else { - - //update item to complete - MobLoot targetItem = MobLoot.getFromCache(this.getProducedItemID()); - - if (targetItem == null) - return false; - - ItemProductionMsg outMsg = new ItemProductionMsg(npc.getBuilding(), npc, targetItem, 8, true); - - - DispatchMessage.dispatchMsgToInterestArea(npc, outMsg, DispatchChannel.SECONDARY, 700, false, false); - } - - } catch (Exception e) { - Logger.error(e); - return false; - } - return true; - } - - public int getPlayerID() { - return playerID; - } - - -} diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 0f30940d..58c3a06f 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -11,6 +11,7 @@ package engine.objects; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -18,8 +19,8 @@ import engine.net.client.ClientConnection; import engine.net.client.msg.*; import engine.server.MBServerStatics; import org.joda.time.DateTime; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.SQLException; @@ -55,9 +56,9 @@ public class Warehouse { JSONObject resources = (JSONObject) warehouse.get("resources"); - for (Object key : resources.keySet()) { - mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf((String) key); - int value = ((Long) resources.get(key)).intValue(); + for (String key : resources.keySet()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); + int value = resources.getInt(key); this.resources.put(resourceType, value); } @@ -69,22 +70,6 @@ public class Warehouse { } - public static HashMap - calculateWarehouseOverdraft(Warehouse warehouse, HashMap costMap) { - - HashMap overdraft = new HashMap<>(); - - for (mbEnums.ResourceType resourceType : costMap.keySet()) { - - int cost = costMap.get(resourceType); - - if (cost > warehouse.resources.get(resourceType)) - overdraft.put(resourceType, cost - warehouse.resources.get(resourceType)); - } - - return overdraft; - } - public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { Building warehouseBuilding; @@ -616,13 +601,8 @@ public class Warehouse { return true; } - public static void loadAllTransactions(Warehouse warehouse) { - warehouse.transactions = DbManager.WarehouseQueries.GET_TRANSACTIONS_FOR_WAREHOUSE(warehouse.building.getObjectUUID()); - } - public static void AddTransactionToWarehouse(Warehouse warehouse, mbEnums.GameObjectType targetType, int targetUUID, mbEnums.TransactionType transactionType, mbEnums.ResourceType resource, int amount) { - if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now())) return; @@ -640,4 +620,39 @@ public class Warehouse { return warehouse.locked.contains(resourceType); } + public static HashMap calcCostOverrun(WorkOrder workOrder) { + + HashMap costMap = new HashMap<>(); + Warehouse warehouse; + + // See if we can meet gold only requirements and early exit + + if (workOrder.production_cost_total.size() == 1) { + if (workOrder.vendor.building.getStrongboxValue() > workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)) + return costMap; + } + + // Gold deficit exists so a warehouse is required + + warehouse = workOrder.vendor.building.getCity() == null ? null : workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return workOrder.production_cost_total; + + // Method returns a map of resourceType that a transaction overdrafts. + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : workOrder.production_cost_total.keySet()) { + + int debit = warehouse.resources.get(resourceType) - workOrder.production_cost_total.get(resourceType); + + // Locked resources are always unavailable + + if (debit < 0 || warehouse.locked.contains(resourceType)) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } } \ No newline at end of file diff --git a/src/engine/powers/EffectsBase.java b/src/engine/powers/EffectsBase.java index dc72873a..24043173 100644 --- a/src/engine/powers/EffectsBase.java +++ b/src/engine/powers/EffectsBase.java @@ -9,10 +9,6 @@ package engine.powers; -import engine.mbEnums; -import engine.mbEnums.EffectSourceType; -import engine.mbEnums.GameObjectType; -import engine.mbEnums.PowerFailCondition; import engine.gameManager.DbManager; import engine.gameManager.PowersManager; import engine.job.JobContainer; @@ -20,11 +16,18 @@ import engine.jobs.AbstractEffectJob; import engine.jobs.DamageOverTimeJob; import engine.jobs.FinishSpireEffectJob; import engine.jobs.NoTimeJob; +import engine.mbEnums; +import engine.mbEnums.EffectSourceType; +import engine.mbEnums.GameObjectType; +import engine.mbEnums.PowerFailCondition; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ApplyEffectMsg; -import engine.objects.*; +import engine.objects.AbstractCharacter; +import engine.objects.AbstractWorldObject; +import engine.objects.Effect; +import engine.objects.PlayerCharacter; import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -718,15 +721,4 @@ public class EffectsBase { this.value = Value; } - public ConcurrentHashMap getResourcesForEffect() { - if (this.resourceCosts.isEmpty()) { - ArrayList effectsCostList = DbManager.EffectsResourceCostsQueries.GET_ALL_EFFECT_RESOURCES(this.IDString); - for (EffectsResourceCosts erc : effectsCostList) { - this.resourceCosts.put(mbEnums.ResourceType.resourceLookup.get(erc.getResourceID()), erc.getAmount()); - } - } - return this.resourceCosts; - } - - } diff --git a/src/engine/server/login/LoginServer.java b/src/engine/server/login/LoginServer.java index 1c951e81..341221b7 100644 --- a/src/engine/server/login/LoginServer.java +++ b/src/engine/server/login/LoginServer.java @@ -17,9 +17,9 @@ import engine.mbEnums; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.Network; +import engine.net.Protocol; import engine.net.client.ClientConnection; import engine.net.client.ClientConnectionManager; -import engine.net.client.Protocol; import engine.net.client.msg.login.*; import engine.objects.*; import engine.server.MBServerStatics; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 25a63082..48de8981 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -26,11 +26,10 @@ import engine.mbEnums.SupportMsgType; import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.Respawner; import engine.net.DispatchMessage; -import engine.net.ItemProductionManager; import engine.net.Network; +import engine.net.Protocol; import engine.net.client.ClientConnection; import engine.net.client.ClientConnectionManager; -import engine.net.client.Protocol; import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; @@ -267,9 +266,6 @@ public class WorldServer { Logger.info("Setting cross server session behavior"); SessionManager.setCrossServerBehavior(1); // Sets cross server behavior - Logger.info("Starting Item Production thread"); - ItemProductionManager.ITEMPRODUCTIONMANAGER.startMessagePump(); - Logger.info("Initializing Errant Guild"); Guild.getErrantGuild(); @@ -427,8 +423,6 @@ public class WorldServer { //pick a startup Hotzone ZoneManager.generateAndSetRandomHotzone(); - ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); - Logger.info("Loading Player Heraldries"); DbManager.PlayerCharacterQueries.LOAD_HERALDY(); @@ -455,6 +449,15 @@ public class WorldServer { Logger.info("Starting Mob Respawn Thread"); Respawner.start(); + Logger.info("Loading effect cost maps"); + DbManager.EffectsResourceCostsQueries.LOAD_ALL_COSTMAPS(); + + Logger.info("Starting ForgeManager thread"); + ForgeManager.start(); + + Logger.info("Restoring NPC workOrders"); + DbManager.WarehouseQueries.LOAD_WORKORDERS(); + // Run maintenance MaintenanceManager.dailyMaintenance();