From 943d274e5f0d89427b52e3dca66ef19ecfc691f7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 24 Mar 2024 09:42:27 -0400 Subject: [PATCH] Project reformat. --- src/engine/devcmd/cmds/AddGoldCmd.java | 4 +- src/engine/devcmd/cmds/InfoCmd.java | 6 +- src/engine/devcmd/cmds/PrintEffectsCmd.java | 2 +- src/engine/devcmd/cmds/PrintRunesCmd.java | 2 +- src/engine/devcmd/cmds/RegionCmd.java | 17 +- src/engine/devcmd/cmds/aiInfoCmd.java | 8 +- src/engine/gameManager/BuildingManager.java | 3 +- src/engine/gameManager/GuildManager.java | 9 +- src/engine/gameManager/LootManager.java | 56 +- src/engine/gameManager/NPCManager.java | 62 +- src/engine/gameManager/PowersManager.java | 6 +- src/engine/mobileAI/MobAI.java | 42 +- src/engine/mobileAI/Threads/MobAIThread.java | 8 +- src/engine/mobileAI/Threads/Respawner.java | 1 + src/engine/net/client/ClientMessagePump.java | 4 +- .../client/handlers/AttackCmdMsgHandler.java | 4 +- .../client/handlers/GroupInviteHandler.java | 5 +- .../GuildCreationFinalizeHandler.java | 4 +- .../client/handlers/InviteToGuildHandler.java | 4 +- .../client/handlers/InviteToSubHandler.java | 9 +- .../client/handlers/LeaveGuildHandler.java | 14 +- .../handlers/MinionTrainingMsgHandler.java | 2 +- .../client/handlers/MoveToPointHandler.java | 6 +- .../handlers/ObjectActionMsgHandler.java | 401 +++---- .../handlers/PetitionReceivedMsgHandler.java | 20 +- .../handlers/RepairBuildingMsgHandler.java | 2 +- .../handlers/RequestEnterWorldHandler.java | 1 - .../TransferGoldToFromBuildingMsgHandler.java | 5 +- ...ansferItemFromEquipToInventoryHandler.java | 5 +- ...ansferItemFromInventoryToEquipHandler.java | 5 +- src/engine/net/client/msg/LootMsg.java | 2 - src/engine/net/client/msg/ManageNPCMsg.java | 25 +- src/engine/net/client/msg/MoveToPointMsg.java | 1 - src/engine/net/client/msg/UpdateGoldMsg.java | 5 +- src/engine/objects/AbstractCharacter.java | 32 +- src/engine/objects/AbstractWorldObject.java | 4 +- src/engine/objects/CharacterSkill.java | 34 +- src/engine/objects/City.java | 26 +- src/engine/objects/Item.java | 2 +- src/engine/objects/ItemBase.java | 4 +- src/engine/objects/ItemTemplate.java | 2 +- src/engine/objects/Mob.java | 88 +- src/engine/objects/MobBase.java | 1 - src/engine/objects/MobBaseStats.java | 8 +- src/engine/objects/Petition.java | 1 + src/engine/objects/PlayerCharacter.java | 14 +- src/engine/objects/Portal.java | 3 +- src/engine/objects/Regions.java | 6 +- src/engine/powers/DamageShield.java | 1 + .../DamageShieldEffectModifier.java | 1 + .../effectmodifiers/HealthEffectModifier.java | 1 + .../poweractions/ApplyEffectPowerAction.java | 13 +- src/engine/server/world/WorldServer.java | 982 +++++++++--------- 53 files changed, 1000 insertions(+), 973 deletions(-) diff --git a/src/engine/devcmd/cmds/AddGoldCmd.java b/src/engine/devcmd/cmds/AddGoldCmd.java index 03da03e4..2d25c1bd 100644 --- a/src/engine/devcmd/cmds/AddGoldCmd.java +++ b/src/engine/devcmd/cmds/AddGoldCmd.java @@ -11,7 +11,9 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ChatManager; -import engine.objects.*; +import engine.objects.AbstractGameObject; +import engine.objects.Item; +import engine.objects.PlayerCharacter; /** * @author Eighty diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 55baa024..1f8b059e 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -494,11 +494,11 @@ public class InfoCmd extends AbstractDevCmd { output += newline; output += "No building found." + newline; } - int max = (int)(4.882 * targetMob.level + 121.0); - if(max > 321){ + int max = (int) (4.882 * targetMob.level + 121.0); + if (max > 321) { max = 321; } - int min = (int)(4.469 * targetMob.level - 3.469); + int min = (int) (4.469 * targetMob.level - 3.469); output += "Min Loot Roll = " + min; output += "Max Loot Roll = " + max; break; diff --git a/src/engine/devcmd/cmds/PrintEffectsCmd.java b/src/engine/devcmd/cmds/PrintEffectsCmd.java index 23e19055..3f4785b5 100644 --- a/src/engine/devcmd/cmds/PrintEffectsCmd.java +++ b/src/engine/devcmd/cmds/PrintEffectsCmd.java @@ -47,7 +47,7 @@ public class PrintEffectsCmd extends AbstractDevCmd { String newline = "\r\n "; String output = "Effects For Character: " + tar.getName() + newline; - for(String effect : tar.effects.keySet()){ + for (String effect : tar.effects.keySet()) { output += effect + newline; } throwbackInfo(pc, output); diff --git a/src/engine/devcmd/cmds/PrintRunesCmd.java b/src/engine/devcmd/cmds/PrintRunesCmd.java index ff66417a..01c8cb60 100644 --- a/src/engine/devcmd/cmds/PrintRunesCmd.java +++ b/src/engine/devcmd/cmds/PrintRunesCmd.java @@ -47,7 +47,7 @@ public class PrintRunesCmd extends AbstractDevCmd { String newline = "\r\n "; String output = "Applied Runes For Character: " + ((AbstractCharacter) target).getName() + newline; - for(CharacterRune rune : ((AbstractCharacter)target).runes){ + for (CharacterRune rune : ((AbstractCharacter) target).runes) { output += rune.getRuneBaseID() + " " + rune.getRuneBase().getName() + newline; } throwbackInfo(pc, output); diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 7ba118eb..93a9eb24 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -9,13 +9,10 @@ package engine.devcmd.cmds; -import engine.Enum; import engine.devcmd.AbstractDevCmd; import engine.gameManager.BuildingManager; import engine.objects.*; -import java.lang.reflect.Field; - public class RegionCmd extends AbstractDevCmd { public RegionCmd() { @@ -31,20 +28,20 @@ public class RegionCmd extends AbstractDevCmd { output = "Target Region Information:" + newline; Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc); - if(building == null){ - this.throwbackInfo(pc, "No Building At This Location.") ; + if (building == null) { + this.throwbackInfo(pc, "No Building At This Location."); } - Regions region = ((AbstractCharacter)target).region; + Regions region = ((AbstractCharacter) target).region; if (region == null) { this.throwbackInfo(pc, "No Region Found."); return; } - if(region != null) { + if (region != null) { output += "Player Info: " + ((AbstractCharacter) target).getName() + newline; - output += "Region Building: " + building.getName() + newline; - output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline; - output += "is Stairs: " + region.isStairs() + newline; + output += "Region Building: " + building.getName() + newline; + output += "Region Height: " + region.lerpY((AbstractCharacter) target) + newline; + output += "is Stairs: " + region.isStairs() + newline; output += "is Outside: " + region.isOutside(); this.throwbackInfo(pc, output); } diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index ad515cea..dd4d191c 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -96,9 +96,9 @@ public class aiInfoCmd extends AbstractDevCmd { output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline; } else { output += "BehaviourType: NULL" + newline; - } - output += "Aggro Range: " + mob.getAggroRange() + newline; - output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline; + } + output += "Aggro Range: " + mob.getAggroRange() + newline; + output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline; if (mob.playerAgroMap.size() > 0) { output += "Players Loaded:" + newline; } @@ -112,7 +112,7 @@ public class aiInfoCmd extends AbstractDevCmd { if (mob.guardedCity != null) output += "Patrolling: " + mob.guardedCity.getCityName() + newline; - output += "See Invis Level: " + mob.mobBase.getSeeInvis() + newline; + output += "See Invis Level: " + mob.mobBase.getSeeInvis() + newline; output += "Can Cast: " + MobAI.canCast(mob) + newline; output += "Powers:" + newline; diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index d7d285da..a45242e6 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -42,6 +42,7 @@ public enum BuildingManager { public static HashMap> _buildingFriends = new HashMap<>(); public static HashMap> _buildingCondemned = new HashMap<>(); public static HashMap> _buildingPatrolPoints = new HashMap<>(); + public static int getAvailableSlot(Building building) { ArrayList slotLocations = _slotLocations.get(building.meshUUID); @@ -838,7 +839,7 @@ public enum BuildingManager { // New rank means new mesh newMeshUUID = building.getBlueprint().getMeshForRank(building.rank); - if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)&& (building.rank == 8)) + if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) && (building.rank == 8)) newMeshUUID = Realm.getRealmMesh(building.getCity()); building.meshUUID = newMeshUUID; diff --git a/src/engine/gameManager/GuildManager.java b/src/engine/gameManager/GuildManager.java index d5eef974..72565224 100644 --- a/src/engine/gameManager/GuildManager.java +++ b/src/engine/gameManager/GuildManager.java @@ -200,11 +200,12 @@ public enum GuildManager { } } - public static Boolean meetsLoreRequirements(Guild guild, PlayerCharacter player){ + + public static Boolean meetsLoreRequirements(Guild guild, PlayerCharacter player) { Enum.GuildCharterType charter = guild.getGuildType(); - if(charter.requiredClasses.contains(player.absPromotionClass)) - if(charter.requiredRaces.contains(player.absRace)) - if(charter.sexRequired.contains(player.absGender)) + if (charter.requiredClasses.contains(player.absPromotionClass)) + if (charter.requiredRaces.contains(player.absRace)) + if (charter.sexRequired.contains(player.absGender)) return true; return false; diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 26f10278..156e1efa 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -80,22 +80,22 @@ 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 it : mob.getInventory()) { - ItemBase ib = it.getItemBase(); + ItemBase ib = it.getItemBase(); - if (ib == null) - break; + if (ib == null) + break; - ItemTemplate template = ItemTemplate.templates.get(it.getTemplateID()); + ItemTemplate template = ItemTemplate.templates.get(it.getTemplateID()); - if (ib.isDiscRune() || 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?"); - chatMsg.setMessageType(10); - chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); - DispatchMessage.dispatchMsgToAll(chatMsg); - } + if (ib.isDiscRune() || 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?"); + chatMsg.setMessageType(10); + chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); + DispatchMessage.dispatchMsgToAll(chatMsg); } + } } @@ -146,7 +146,7 @@ public enum LootManager { MobLoot outItem; - int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); + int genRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); @@ -161,9 +161,9 @@ public enum LootManager { //gets the 1-320 roll for this mob int itemTableRoll = 0; int objectType = mob.getObjectType().ordinal(); - if(mob.getObjectType().ordinal() == 52) { //52 = player character - itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); - } else{ + if (mob.getObjectType().ordinal() == 52) { //52 = player character + itemTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); + } else { itemTableRoll = TableRoll(mob.level, inHotzone); } ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); @@ -182,7 +182,7 @@ public enum LootManager { outItem = new MobLoot(mob, ItemTemplate.templates.get(itemUUID), false); - if(selectedRow.pModTable != 0){ + if (selectedRow.pModTable != 0) { try { outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); outItem.flags.remove(Enum.ItemFlags.Identified); @@ -190,7 +190,7 @@ public enum LootManager { Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); } } - if(selectedRow.sModTable != 0){ + if (selectedRow.sModTable != 0) { try { outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); outItem.flags.remove(Enum.ItemFlags.Identified); @@ -215,9 +215,9 @@ public enum LootManager { if (prefixTable == null) return inItem; int prefixTableRoll = 0; - if(mob.getObjectType().ordinal() == 52) { - prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); - } else{ + if (mob.getObjectType().ordinal() == 52) { + prefixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); + } else { prefixTableRoll = TableRoll(mob.level, inHotzone); } ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); @@ -247,9 +247,9 @@ public enum LootManager { if (suffixTable == null) return inItem; int suffixTableRoll = 0; - if(mob.getObjectType().ordinal() == 52) { - suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); - } else{ + if (mob.getObjectType().ordinal() == 52) { + suffixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); + } else { suffixTableRoll = TableRoll(mob.level, inHotzone); } ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); @@ -332,7 +332,7 @@ public enum LootManager { public static void GenerateEquipmentDrop(Mob mob) { - if(mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard)) + if (mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard)) return; // safehold guards don't drop their equipment //do equipment here int dropCount = 0; @@ -404,7 +404,7 @@ public enum LootManager { int genRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll, LootManager.NORMAL_DROP_RATE); - if(selectedRow == null) + if (selectedRow == null) return; //roll 220-320 for the item table selection @@ -431,10 +431,10 @@ public enum LootManager { //determine if the winning item needs a prefix - if(selectedRow.pModTable != 0){ - int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); + if (selectedRow.pModTable != 0) { + int prefixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1); ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll); - if(prefix != null) + if (prefix != null) winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true); } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 306bc7a7..1cb710a8 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -247,30 +247,30 @@ public enum NPCManager { } } - public static void applyGuardStanceModifiers(Mob guard){ + public static void applyGuardStanceModifiers(Mob guard) { float damageModifier = 1; float attackRatingModifier = 1; float defenseModifier = 1; float attackSpeedModifier = 1; float powerDamageModifier = 1; //handle stance modifiers for guard mob - if(guard.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)){ + if (guard.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)) { //apply rogue bonuses attackRatingModifier += 0.5f; defenseModifier += 0.5f; damageModifier += 0.5f; attackSpeedModifier -= 0.36f; - }else { + } else { Integer contractID; if (guard.agentType.equals(Enum.AIAgentType.GUARDMINION)) { contractID = guard.guardCaptain.contract.getContractID(); - } else{ + } else { contractID = guard.contract.getContractID(); } - if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()){ + if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()) { //apply mage offensive Stance powerDamageModifier += 0.5f; - } else{ + } else { //apply fighter offensive stance damageModifier += 0.5f; attackSpeedModifier -= 0.36f; @@ -289,7 +289,7 @@ public enum NPCManager { //TODO figure out how to apply +50% powerdamage to mage guards } - public static void setDamageAndSpeedForGuard(Mob guard){ + public static void setDamageAndSpeedForGuard(Mob guard) { float rankModifier = 1 + (guard.getRank() * 0.1f); int primaryStat = 0; @@ -324,17 +324,17 @@ public enum NPCManager { guard.rangeHandOne = weapon.template.item_weapon_max_range; } else { primaryStat = guard.getStatStrCurrent(); - guard.minDamageHandOne = (int)((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat; - guard.maxDamageHandOne = (int)((guard.mobBase.getDamageMax()) * rankModifier) + primaryStat; + guard.minDamageHandOne = (int) ((guard.mobBase.getDamageMin()) * rankModifier) + primaryStat; + guard.maxDamageHandOne = (int) ((guard.mobBase.getDamageMax()) * rankModifier) + primaryStat; guard.speedHandOne = 30.0f; guard.rangeHandOne = 3; } } } - public static void setDefenseForGuard(Mob guard){ + public static void setDefenseForGuard(Mob guard) { int dexterity = guard.getStatDexCurrent(); - if(dexterity < 1) + if (dexterity < 1) dexterity = 1; int baseDef = guard.mobBase.getDefenseRating(); int armorDefense = 0; @@ -355,29 +355,29 @@ public enum NPCManager { guard.atrHandOne = baseAtr; } - public static void setMaxHealthForGuard(Mob guard){ + public static void setMaxHealthForGuard(Mob guard) { //values derived fom reading memory address for health on client when selecting player guards - switch(guard.getRank()){ + switch (guard.getRank()) { default: guard.healthMax = 750; //rank 1 break; case 2: - guard.healthMax = 2082; + guard.healthMax = 2082; break; case 3: - guard.healthMax = 2740; + guard.healthMax = 2740; break; case 4: - guard.healthMax = 3414; + guard.healthMax = 3414; break; case 5: - guard.healthMax = 4080; + guard.healthMax = 4080; break; case 6: - guard.healthMax = 4746; + guard.healthMax = 4746; break; case 7: - guard.healthMax = 5412; + guard.healthMax = 5412; break; } } @@ -422,7 +422,7 @@ public enum NPCManager { } } - public static void applyEquipmentResists(Mob mob){ + public static void applyEquipmentResists(Mob mob) { if (mob.charItemManager.equipped.isEmpty()) return; @@ -438,18 +438,18 @@ public enum NPCManager { public static void applyMobbaseSkill(Mob mob) { SkillsBase baseSkill = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(mob.mobBase.getMobBaseStats().getBaseSkill()); - if(baseSkill != null) - mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount())); + if (baseSkill != null) + mob.getSkills().put(baseSkill.getName(), new CharacterSkill(baseSkill, mob, mob.mobBase.getMobBaseStats().getBaseSkillAmount())); } - public static void applyRuneSkills(Mob mob, int runeID){ + public static void applyRuneSkills(Mob mob, int runeID) { //load mob skill adjustments from mobbase rune - if(PowersManager._allRuneSkillAdjusts.containsKey(runeID)) - for(RuneSkillAdjustEntry entry : PowersManager._allRuneSkillAdjusts.get(runeID)) { - if(SkillsBase.getFromCache(entry.skill_type) == null) + if (PowersManager._allRuneSkillAdjusts.containsKey(runeID)) + for (RuneSkillAdjustEntry entry : PowersManager._allRuneSkillAdjusts.get(runeID)) { + if (SkillsBase.getFromCache(entry.skill_type) == null) SkillsBase.putInCache(DbManager.SkillsBaseQueries.GET_BASE_BY_NAME(entry.skill_type)); SkillsBase skillBase = SkillsBase.getFromCache(entry.skill_type); - if(skillBase == null) + if (skillBase == null) continue; if (entry.level <= mob.level) if (mob.skills.containsKey(entry.name) == false) @@ -459,15 +459,15 @@ public enum NPCManager { } } - public static void applyRunesForNPC(NPC npc){ + public static void applyRunesForNPC(NPC npc) { npc.runes = new ArrayList<>(); RuneBase shopkeeperBase = RuneBase.getRuneBase(252620); - CharacterRune shopkeeper = new CharacterRune(shopkeeperBase,npc.getObjectUUID()); + CharacterRune shopkeeper = new CharacterRune(shopkeeperBase, npc.getObjectUUID()); npc.runes.add(shopkeeper); - if(NPCManager._runeSetMap.containsKey(npc.runeSetID)) { + if (NPCManager._runeSetMap.containsKey(npc.runeSetID)) { for (int runeID : _runeSetMap.get(npc.runeSetID)) { RuneBase rb = RuneBase.getRuneBase(runeID); - if(rb != null) { + if (rb != null) { CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID()); npc.runes.add(toApply); } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index c7b6324d..e7dce3ad 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -170,11 +170,11 @@ public enum PowersManager { public static void usePower(final PerformActionMsg msg, ClientConnection origin, boolean sendCastToSelf) { - if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (ConfigManager.MB_RULESET.getValue() == "LORE") { PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID()); PlayerCharacter caster = origin.getPlayerCharacter(); PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID()); - if(pb != null && pb.isHarmful == false) { + if (pb != null && pb.isHarmful == false) { if (caster.guild.equals(Guild.getErrantGuild())) return; @@ -1271,7 +1271,7 @@ public enum PowersManager { return; } - if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (ConfigManager.MB_RULESET.getValue() == "LORE") { if (pc.guild.getGuildType().equals(target.guild.getGuildType()) == false) { ChatManager.chatInfoError(pc, "Cannot summon player outside your charter."); diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index e3e04491..c607a3a1 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -323,7 +323,7 @@ public class MobAI { if (mob.isPlayerGuard() == true) { - if(mob.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)) + if (mob.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)) return false; //wall archers don't cast if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) contractID = mob.guardCaptain.contract.getContractID(); @@ -574,10 +574,10 @@ public class MobAI { //no players loaded, no need to proceed unless it's a player guard boolean bypassLoadedPlayerCheck = false; - if(mob.isPlayerGuard() || mob.isSiege()) { + if (mob.isPlayerGuard() || mob.isSiege()) { bypassLoadedPlayerCheck = true; - if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) - if(mob.combatTarget.loc.distanceSquared(mob.loc) > 10000) + if (mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) + if (mob.combatTarget.loc.distanceSquared(mob.loc) > 10000) mob.setCombatTarget(null); } @@ -845,7 +845,7 @@ public class MobAI { try { - if (mob.getCombatTarget() != null && mob.getRange() * mob.getRange() >= MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f) + if (mob.getCombatTarget() != null && mob.getRange() * mob.getRange() >= MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f) return; if (mob.isPlayerGuard() && !mob.despawned) { @@ -888,12 +888,12 @@ public class MobAI { try { - if(mob.getTimestamps().containsKey("lastChase") == false) - mob.getTimestamps().put("lastChase",System.currentTimeMillis()); - else if(System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + (750 + ThreadLocalRandom.current().nextInt(0,500))) - return; + if (mob.getTimestamps().containsKey("lastChase") == false) + mob.getTimestamps().put("lastChase", System.currentTimeMillis()); + else if (System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + (750 + ThreadLocalRandom.current().nextInt(0, 500))) + return; - mob.getTimestamps().put("lastChase",System.currentTimeMillis()); + mob.getTimestamps().put("lastChase", System.currentTimeMillis()); if (mob.getRange() * mob.getRange() <= mob.loc.distanceSquared(mob.combatTarget.loc)) { if (mob.getRange() > 15) { @@ -974,10 +974,10 @@ public class MobAI { } } - if(mob.behaviourType.canRoam) + if (mob.behaviourType.canRoam) CheckMobMovement(mob);//all guards that can move check to move - if(mob.combatTarget != null) + if (mob.combatTarget != null) CheckForAttack(mob); //only check to attack if combat target is not null } catch (Exception e) { @@ -1128,21 +1128,21 @@ public class MobAI { return; } } - if (mob.getCombatTarget() == null) { + if (mob.getCombatTarget() == null) { - //look for siege equipment to aggro if no players found to aggro + //look for siege equipment to aggro if no players found to aggro - HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_SIEGE); + HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, MobAIThread.AI_BASE_AGGRO_RANGE, MBServerStatics.MASK_SIEGE); - for (AbstractWorldObject awoMob : awoList) { + for (AbstractWorldObject awoMob : awoList) { - Mob aggroMob = (Mob) awoMob; - if(GuardCanAggro(mob,aggroMob)) { - mob.setCombatTarget(aggroMob); - return; - } + Mob aggroMob = (Mob) awoMob; + if (GuardCanAggro(mob, aggroMob)) { + mob.setCombatTarget(aggroMob); + return; } + } } } catch (Exception e) { diff --git a/src/engine/mobileAI/Threads/MobAIThread.java b/src/engine/mobileAI/Threads/MobAIThread.java index b3699879..0a7c02d5 100644 --- a/src/engine/mobileAI/Threads/MobAIThread.java +++ b/src/engine/mobileAI/Threads/MobAIThread.java @@ -1,14 +1,13 @@ package engine.mobileAI.Threads; import engine.gameManager.ConfigManager; -import engine.mobileAI.MobAI; import engine.gameManager.ZoneManager; +import engine.mobileAI.MobAI; import engine.objects.Mob; import engine.objects.Zone; -import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -public class MobAIThread implements Runnable{ +public class MobAIThread implements Runnable { public static int AI_BASE_AGGRO_RANGE = 60; public static int AI_DROP_AGGRO_RANGE = 60; public static int AI_PULSE_MOB_THRESHOLD = 200; @@ -25,7 +24,7 @@ public class MobAIThread implements Runnable{ public void run() { //cache config value for mobile casting delay AI_CAST_FREQUENCY = Float.parseFloat(ConfigManager.MB_AI_CAST_FREQUENCY.getValue()); - AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue())); + AI_BASE_AGGRO_RANGE = (int) (60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue())); while (true) { for (Zone zone : ZoneManager.getAllZones()) { @@ -42,6 +41,7 @@ public class MobAIThread implements Runnable{ } } } + public static void startAIThread() { Thread aiThread; aiThread = new Thread(new MobAIThread()); diff --git a/src/engine/mobileAI/Threads/Respawner.java b/src/engine/mobileAI/Threads/Respawner.java index 9aaa477f..b5471c8a 100644 --- a/src/engine/mobileAI/Threads/Respawner.java +++ b/src/engine/mobileAI/Threads/Respawner.java @@ -8,6 +8,7 @@ package engine.mobileAI.Threads; + import engine.objects.Mob; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 56ec074b..d5ad3f35 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1070,10 +1070,10 @@ public class ClientMessagePump implements NetMsgHandler { return; //CombatManager.setAttackTarget(msg, conn); - if(msg.getTargetType() == GameObjectType.Building.ordinal()){ + if (msg.getTargetType() == GameObjectType.Building.ordinal()) { conn.getPlayerCharacter().getPet().setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID())); } - switch(msg.getTargetType()) { + switch (msg.getTargetType()) { case 53: //player character conn.getPlayerCharacter().getPet().setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID())); break; diff --git a/src/engine/net/client/handlers/AttackCmdMsgHandler.java b/src/engine/net/client/handlers/AttackCmdMsgHandler.java index 82f3a5f3..46c96f96 100644 --- a/src/engine/net/client/handlers/AttackCmdMsgHandler.java +++ b/src/engine/net/client/handlers/AttackCmdMsgHandler.java @@ -49,7 +49,7 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { targetType = Enum.GameObjectType.values()[msg.getTargetType()]; - switch(targetType){ + switch (targetType) { case Mob: target = Mob.getMob(msg.getTargetID()); break; @@ -63,7 +63,7 @@ public class AttackCmdMsgHandler extends AbstractClientMsgHandler { target = NPC.getNPC(msg.getTargetID()); break; } - if(target == null) { + if (target == null) { playerCharacter.setCombatTarget(null); return true; // cannot attack a null target } diff --git a/src/engine/net/client/handlers/GroupInviteHandler.java b/src/engine/net/client/handlers/GroupInviteHandler.java index 5bba9132..c2f0f0c4 100644 --- a/src/engine/net/client/handlers/GroupInviteHandler.java +++ b/src/engine/net/client/handlers/GroupInviteHandler.java @@ -14,7 +14,6 @@ import engine.Enum.GameObjectType; import engine.exception.MsgSendException; import engine.gameManager.ConfigManager; import engine.gameManager.GroupManager; -import engine.gameManager.GuildManager; import engine.gameManager.SessionManager; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -106,8 +105,8 @@ public class GroupInviteHandler extends AbstractClientMsgHandler { if (target.isIgnoringPlayer(source)) return false; - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if(source.guild.equals(Guild.getErrantGuild())) + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (source.guild.equals(Guild.getErrantGuild())) return false; if (source.guild.getGuildType() != null) { diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index 4a09b56d..21c30f33 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -26,7 +26,9 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.guild.GuildCreationFinalizeMsg; import engine.net.client.msg.guild.GuildInfoMsg; -import engine.objects.*; +import engine.objects.Guild; +import engine.objects.Item; +import engine.objects.PlayerCharacter; import engine.util.StringUtils; public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { diff --git a/src/engine/net/client/handlers/InviteToGuildHandler.java b/src/engine/net/client/handlers/InviteToGuildHandler.java index 0c533798..8491939e 100644 --- a/src/engine/net/client/handlers/InviteToGuildHandler.java +++ b/src/engine/net/client/handlers/InviteToGuildHandler.java @@ -125,9 +125,9 @@ public class InviteToGuildHandler extends AbstractClientMsgHandler { ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// you do not meet the level required for this SWORN guild return true; } - if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (ConfigManager.MB_RULESET.getValue() == "LORE") { if (GuildManager.meetsLoreRequirements(sourcePlayer.guild, targetPlayer) == false) { - ChatManager.chatGuildError(sourcePlayer,targetPlayer.getFirstName() + " does not meet charter requirements!"); + ChatManager.chatGuildError(sourcePlayer, targetPlayer.getFirstName() + " does not meet charter requirements!"); return true; } } diff --git a/src/engine/net/client/handlers/InviteToSubHandler.java b/src/engine/net/client/handlers/InviteToSubHandler.java index 6492a231..280aae16 100644 --- a/src/engine/net/client/handlers/InviteToSubHandler.java +++ b/src/engine/net/client/handlers/InviteToSubHandler.java @@ -12,7 +12,10 @@ package engine.net.client.handlers; import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; -import engine.gameManager.*; +import engine.gameManager.ChatManager; +import engine.gameManager.ConfigManager; +import engine.gameManager.DbManager; +import engine.gameManager.SessionManager; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -109,8 +112,8 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { sendChat(source, "This Guild can't be subbed."); return true; } - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false){ + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false) { sendChat(source, "You Must Be The Same Charter To Form A Nation."); return true; } diff --git a/src/engine/net/client/handlers/LeaveGuildHandler.java b/src/engine/net/client/handlers/LeaveGuildHandler.java index 1dbc7306..4abf6b68 100644 --- a/src/engine/net/client/handlers/LeaveGuildHandler.java +++ b/src/engine/net/client/handlers/LeaveGuildHandler.java @@ -11,13 +11,19 @@ package engine.net.client.handlers; import engine.Enum.GuildHistoryType; import engine.exception.MsgSendException; -import engine.gameManager.*; +import engine.gameManager.ChatManager; +import engine.gameManager.ConfigManager; +import engine.gameManager.GroupManager; +import engine.gameManager.SessionManager; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.guild.LeaveGuildMsg; -import engine.objects.*; +import engine.objects.Guild; +import engine.objects.GuildStatusController; +import engine.objects.Mine; +import engine.objects.PlayerCharacter; public class LeaveGuildHandler extends AbstractClientMsgHandler { @@ -61,8 +67,8 @@ public class LeaveGuildHandler extends AbstractClientMsgHandler { ChatManager.chatGuildInfo(oldGuild, playerCharacter.getFirstName() + " has left the guild."); oldGuild.removePlayer(playerCharacter, GuildHistoryType.LEAVE); - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if(GroupManager.getGroup(playerCharacter) != null) + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (GroupManager.getGroup(playerCharacter) != null) GroupManager.getGroup(playerCharacter).removeGroupMember(playerCharacter); } // Send message back to client diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index fc84fe56..30f01604 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -70,7 +70,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { DbManager.removeFromCache(toRemove); - if(toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { + if (toRemove.guardCaptain.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain; if (petOwner != null) { diff --git a/src/engine/net/client/handlers/MoveToPointHandler.java b/src/engine/net/client/handlers/MoveToPointHandler.java index c6d99f63..83902e82 100644 --- a/src/engine/net/client/handlers/MoveToPointHandler.java +++ b/src/engine/net/client/handlers/MoveToPointHandler.java @@ -9,14 +9,12 @@ package engine.net.client.handlers; -import engine.Enum; import engine.exception.MsgSendException; -import engine.gameManager.BuildingManager; import engine.gameManager.MovementManager; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.MoveToPointMsg; -import engine.objects.*; +import engine.objects.PlayerCharacter; public class MoveToPointHandler extends AbstractClientMsgHandler { @@ -29,7 +27,7 @@ public class MoveToPointHandler extends AbstractClientMsgHandler { ClientConnection origin) throws MsgSendException { MoveToPointMsg msg = (MoveToPointMsg) baseMsg; PlayerCharacter pc = origin.getPlayerCharacter(); - if(pc == null) + if (pc == null) return true; MovementManager.movement(msg, pc); diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 711f71ca..18376126 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -30,6 +30,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { public ObjectActionMsgHandler() { super(ObjectActionMsg.class); } + @Override protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { @@ -79,235 +80,235 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { int uuid = item.templateID; - switch (item.template.item_type) { - - case DEED: //buildings - //Call add building screen here, ib.getUseID() get's building ID - - //if inside player city, center loc on tol. otherwise center on player. - Vector3fImmutable loc = player.getLoc(); - Zone zone = ZoneManager.findSmallestZone(player.getLoc()); + switch (item.template.item_type) { - if (zone != null) { - if (zone.guild_zone) { - loc = zone.getLoc(); - } - } + case DEED: //buildings + //Call add building screen here, ib.getUseID() get's building ID - PlaceAssetMsg pam = new PlaceAssetMsg(); - pam.setActionType(2); - pam.setContractID(item.getObjectUUID()); - pam.setX(loc.getX() + 64); //offset grid from tol - pam.setY(loc.getY()); - pam.setZ(loc.getZ() + 64); //offset grid from tol - pam.addPlacementInfo(item.template.deed_structure_id); + //if inside player city, center loc on tol. otherwise center on player. + Vector3fImmutable loc = player.getLoc(); + Zone zone = ZoneManager.findSmallestZone(player.getLoc()); - dispatch = Dispatch.borrow(player, pam); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - //itemMan.consume(item); //temporary fix for dupe.. TODO Make Item Unusable after This message is sent. - break; - case FURNITUREDEED: //furniture - //Call add furniture screen here. ib.getUseID() get's furniture ID - break; - case OFFERING: - long shrineCompID = comps.get(1); - Building shrineBuilding = BuildingManager.getBuilding((int) shrineCompID); - if (shrineBuilding == null) { - return true; - } - if (shrineBuilding.getBlueprint() != null && shrineBuilding.getBlueprint().getBuildingGroup() != engine.Enum.BuildingGroup.SHRINE) { - return true; - } - - if (shrineBuilding.getRank() == -1) { - return true; - } - Shrine shrine = Shrine.shrinesByBuildingUUID.get(shrineBuilding.getObjectUUID()); - - if (shrine == null) { - return true; + if (zone != null) { + if (zone.guild_zone) { + loc = zone.getLoc(); } - - if (shrine.addFavor(player, item)) { - shrineBuilding.addEffectBit(1000000 << 2); - shrineBuilding.updateEffects(); - shrineBuilding.removeEffectBit(1000000 << 2); + } + + PlaceAssetMsg pam = new PlaceAssetMsg(); + pam.setActionType(2); + pam.setContractID(item.getObjectUUID()); + pam.setX(loc.getX() + 64); //offset grid from tol + pam.setY(loc.getY()); + pam.setZ(loc.getZ() + 64); //offset grid from tol + pam.addPlacementInfo(item.template.deed_structure_id); + + dispatch = Dispatch.borrow(player, pam); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + + //itemMan.consume(item); //temporary fix for dupe.. TODO Make Item Unusable after This message is sent. + break; + case FURNITUREDEED: //furniture + //Call add furniture screen here. ib.getUseID() get's furniture ID + break; + case OFFERING: + long shrineCompID = comps.get(1); + Building shrineBuilding = BuildingManager.getBuilding((int) shrineCompID); + if (shrineBuilding == null) { + return true; + } + if (shrineBuilding.getBlueprint() != null && shrineBuilding.getBlueprint().getBuildingGroup() != engine.Enum.BuildingGroup.SHRINE) { + return true; + } + + if (shrineBuilding.getRank() == -1) { + return true; + } + Shrine shrine = Shrine.shrinesByBuildingUUID.get(shrineBuilding.getObjectUUID()); + + if (shrine == null) { + return true; + } + + if (shrine.addFavor(player, item)) { + shrineBuilding.addEffectBit(1000000 << 2); + shrineBuilding.updateEffects(); + shrineBuilding.removeEffectBit(1000000 << 2); + } + break; + + case REALMCHARTER: + int charterType = 0; + switch (uuid) { + case 910020: + charterType = 762228431; + break; + case 910021: + charterType = -15978914; + break; + case 910022: + charterType = -600065291; + break; + } + if (Realm.claimRealm(player, charterType) == true) { + itemMan.consume(item); + } + break; + case WAND: //rod of command + long compID = comps.get(1); + + int objectType = AbstractWorldObject.extractTypeID(compID).ordinal(); + Mob toCommand; + if (objectType == engine.Enum.GameObjectType.Mob.ordinal()) { + toCommand = Mob.getFromCache((int) compID); + } //Only Command Mob Types. + else { + return true; + } + + if (toCommand == null) { + return true; + } + + if (!toCommand.isSiege()) + return true; + + if (player.commandSiegeMinion(toCommand)) { + itemMan.consume(item); + } + break; + //ANNIVERSERY GIFT + case TREASURE: + // *** Disabled for now: Needs bootyset created + + //if (ib.getUUID() == 971012) { + // int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); + // int annyID = ItemBase.AnniverseryGifts.get(random); + + // ItemBase annyIB = ItemBase.getItemBase(annyID); + // if (annyIB != null) { + // Item gift = MobLoot.createItemForPlayer(player, annyIB); + // if (gift != null) { + // itemMan.addItemToInventory(gift); + // itemMan.consume(item); + // } + // } + // break; + //} + + LootManager.peddleFate(player, item); + break; + + 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; - - case REALMCHARTER: - int charterType = 0; - switch (uuid) { - case 910020: - charterType = 762228431; - break; - case 910021: - charterType = -15978914; - break; - case 910022: - charterType = -600065291; - break; + } else if (uuid > 249999 && uuid < 250123) { //stat and mastery runes + if (ApplyRuneMsg.applyRune(uuid, origin, player)) { + itemMan.consume(item); } - if (Realm.claimRealm(player, charterType) == true) { + break; + } else if (uuid > 250114 && uuid < 250123) { //mastery runes + if (ApplyRuneMsg.applyRune(uuid, origin, player)) { itemMan.consume(item); } break; - case WAND: //rod of command - long compID = comps.get(1); - - int objectType = AbstractWorldObject.extractTypeID(compID).ordinal(); - Mob toCommand; - if (objectType == engine.Enum.GameObjectType.Mob.ordinal()) { - toCommand = Mob.getFromCache((int) compID); - } //Only Command Mob Types. - else { - return true; + } else if (uuid > 252122 && uuid < 252128) { //mastery runes + if (ApplyRuneMsg.applyRune(uuid, origin, player)) { + itemMan.consume(item); } + break; + } else if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here + { + break; + } else if (uuid > 910010 && uuid < 910019) { - if (toCommand == null) { - return true; - } + int rank = uuid - 910010; - if (!toCommand.isSiege()) + if (rank < 1 || rank > 8) { + ChatManager.chatSystemError(player, "Invalid Rank for bane scroll!"); return true; + } + // Only one banestone at a time + lock.writeLock().lock(); - if (player.commandSiegeMinion(toCommand)) { - itemMan.consume(item); + try { + if (Bane.summonBanestone(player, origin, rank) == true) + itemMan.consume(item); + } finally { + lock.writeLock().unlock(); } break; - //ANNIVERSERY GIFT - case TREASURE: - // *** Disabled for now: Needs bootyset created - - //if (ib.getUUID() == 971012) { - // int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); - // int annyID = ItemBase.AnniverseryGifts.get(random); - - // ItemBase annyIB = ItemBase.getItemBase(annyID); - // if (annyIB != null) { - // Item gift = MobLoot.createItemForPlayer(player, annyIB); - // if (gift != null) { - // itemMan.addItemToInventory(gift); - // itemMan.consume(item); - // } - // } - // break; - //} - - LootManager.peddleFate(player, item); + } else if (uuid == 910010) { //tears of saedron + if (comps.size() > 1) { + AbstractCharacter.removeRune(player, origin, comps.get(1).intValue()); + } break; - - 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); - } - 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 (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) - itemMan.consume(item); - } finally { - lock.writeLock().unlock(); - } - break; - } else 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) { - 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) { - target = (AbstractWorldObject) tarAgo; - } + } else if ((byte) 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) { + target = (AbstractWorldObject) tarAgo; } } + } - // Bypass for waterbuckets + // Bypass for waterbuckets - // test character targeted + // test character targeted - if (item.template.template_id == 910005) { + if (item.template.template_id == 910005) { - // test for valid target type - if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter) - waterbucketBypass = true; - else { - // test distance to structure - Building targetBuilding = (Building) target; - Bounds testBounds = Bounds.borrow(); - testBounds.setBounds(player.getLoc(), 25); + // test for valid target type + if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter) + waterbucketBypass = true; + else { + // test distance to structure + Building targetBuilding = (Building) target; + Bounds testBounds = Bounds.borrow(); + testBounds.setBounds(player.getLoc(), 25); - if (Bounds.collide(targetBuilding.getBounds(), testBounds, .1f) == false) { - ChatManager.chatSystemError(player, "Not in range of structura for to heal!"); - return true; - } + if (Bounds.collide(targetBuilding.getBounds(), testBounds, .1f) == false) { + ChatManager.chatSystemError(player, "Not in range of structura for to heal!"); + return true; } - - // Send piss bucket animation - - VisualUpdateMessage vum = new VisualUpdateMessage(player, 16323); - vum.configure(); - DispatchMessage.sendToAllInRange(player, vum); } - if (waterbucketBypass == false) { - String powerString = item.template.item_power_action.keySet().iterator().next(); - PowersBase powerAction = PowersManager.powersBaseByIDString.get(powerString); - int powerValue = item.template.item_power_action.get(powerString)[0]; - PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, powerAction.getToken(), powerValue, true); - } - itemMan.consume(item); - } else //just remove the item at this point - itemMan.consume(item); + // Send piss bucket animation - dispatch = Dispatch.borrow(player, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - player.cancelOnSpell(); - break; - default: //shouldn't be here, consume item - dispatch = Dispatch.borrow(player, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - // itemMan.consume(item); - } + VisualUpdateMessage vum = new VisualUpdateMessage(player, 16323); + vum.configure(); + DispatchMessage.sendToAllInRange(player, vum); + } + + if (waterbucketBypass == false) { + String powerString = item.template.item_power_action.keySet().iterator().next(); + PowersBase powerAction = PowersManager.powersBaseByIDString.get(powerString); + int powerValue = item.template.item_power_action.get(powerString)[0]; + PowersManager.applyPower(player, target, Vector3fImmutable.ZERO, powerAction.getToken(), powerValue, true); + } + itemMan.consume(item); + } else //just remove the item at this point + itemMan.consume(item); + + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + player.cancelOnSpell(); + break; + default: //shouldn't be here, consume item + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + // itemMan.consume(item); + } } else { // TODO log item does not belong to player // System.out.println("Item does not belong to player"); diff --git a/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java b/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java index e53bcc8d..45d7ebfc 100644 --- a/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java +++ b/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java @@ -39,21 +39,21 @@ public class PetitionReceivedMsgHandler extends AbstractClientMsgHandler { Petition petition = new Petition(petitionReceivedMsg, origin); - // Write petition to database + // Write petition to database - if (petitionReceivedMsg.petition == PETITION_NEW) - DbManager.PetitionQueries.WRITE_PETITION_TO_TABLE(petition); + if (petitionReceivedMsg.petition == PETITION_NEW) + DbManager.PetitionQueries.WRITE_PETITION_TO_TABLE(petition); - // Close the petition window + // Close the petition window - if (petitionReceivedMsg.petition == PETITION_NEW) - petitionReceivedMsg.petition = PETITION_CLOSE; + if (petitionReceivedMsg.petition == PETITION_NEW) + petitionReceivedMsg.petition = PETITION_CLOSE; - petitionReceivedMsg.unknownByte01 = 0; - petitionReceivedMsg.unknown04 = 0; + petitionReceivedMsg.unknownByte01 = 0; + petitionReceivedMsg.unknown04 = 0; - Dispatch dispatch = Dispatch.borrow(playerCharacter, petitionReceivedMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + Dispatch dispatch = Dispatch.borrow(playerCharacter, petitionReceivedMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); return true; } diff --git a/src/engine/net/client/handlers/RepairBuildingMsgHandler.java b/src/engine/net/client/handlers/RepairBuildingMsgHandler.java index 615d0045..59c02bac 100644 --- a/src/engine/net/client/handlers/RepairBuildingMsgHandler.java +++ b/src/engine/net/client/handlers/RepairBuildingMsgHandler.java @@ -59,7 +59,7 @@ public class RepairBuildingMsgHandler extends AbstractClientMsgHandler { //cannot repair mines during 24/7 activity. if (targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE && Mine.getMineFromTower(targetBuilding.getObjectUUID()).isActive == true) { - return; + return; } diff --git a/src/engine/net/client/handlers/RequestEnterWorldHandler.java b/src/engine/net/client/handlers/RequestEnterWorldHandler.java index e1654e6b..46413afa 100644 --- a/src/engine/net/client/handlers/RequestEnterWorldHandler.java +++ b/src/engine/net/client/handlers/RequestEnterWorldHandler.java @@ -14,7 +14,6 @@ import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.*; -import engine.objects.AbstractWorldObject; import engine.objects.Account; import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; diff --git a/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java b/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java index 7f40ce7f..cbb53a05 100644 --- a/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java +++ b/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java @@ -12,7 +12,10 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.PlaceAssetMsg; import engine.net.client.msg.TransferGoldToFromBuildingMsg; import engine.net.client.msg.UpdateGoldMsg; -import engine.objects.*; +import engine.objects.Building; +import engine.objects.CharacterItemManager; +import engine.objects.Item; +import engine.objects.PlayerCharacter; import org.pmw.tinylog.Logger; /* diff --git a/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java b/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java index d3c7db27..dbc852c0 100644 --- a/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java +++ b/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java @@ -16,7 +16,10 @@ import engine.net.client.ClientConnection; import engine.net.client.msg.ApplyEffectMsg; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; -import engine.objects.*; +import engine.objects.CharacterItemManager; +import engine.objects.Effect; +import engine.objects.Item; +import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHandler { diff --git a/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java b/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java index 683112ef..bbe84a15 100644 --- a/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java +++ b/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java @@ -19,7 +19,10 @@ import engine.net.client.msg.ApplyEffectMsg; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; import engine.net.client.msg.TransferItemFromInventoryToEquipMsg; -import engine.objects.*; +import engine.objects.CharacterItemManager; +import engine.objects.Effect; +import engine.objects.Item; +import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHandler { diff --git a/src/engine/net/client/msg/LootMsg.java b/src/engine/net/client/msg/LootMsg.java index 9d13dfae..86c49c03 100644 --- a/src/engine/net/client/msg/LootMsg.java +++ b/src/engine/net/client/msg/LootMsg.java @@ -10,13 +10,11 @@ package engine.net.client.msg; -import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; import engine.net.client.Protocol; import engine.objects.Item; -import engine.objects.Item; public class LootMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index af1566f7..5b68d9ba 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -467,21 +467,21 @@ public class ManageNPCMsg extends ClientNetMsg { ArrayList effectsList = item.getEffectNames(); EffectsBase prefix = null; - EffectsBase suffix = null; + EffectsBase suffix = null; - for (String effectName : effectsList) { + for (String effectName : effectsList) { - if (effectName.contains("PRE")) - prefix = PowersManager.getEffectByIDString(effectName); + if (effectName.contains("PRE")) + prefix = PowersManager.getEffectByIDString(effectName); - if (effectName.contains("SUF")) - suffix = PowersManager.getEffectByIDString(effectName); - } + if (effectName.contains("SUF")) + suffix = PowersManager.getEffectByIDString(effectName); + } - if ((prefix == null && suffix == null)) - writer.putInt(0); - else - writer.putInt(-1497023830); + if ((prefix == null && suffix == null)) + writer.putInt(0); + else + writer.putInt(-1497023830); if ((prefix != null && !item.isRandom()) || (prefix != null && item.isComplete())) writer.putInt(prefix.getToken()); @@ -494,7 +494,7 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(0); writer.putString(item.name); - } + } writer.putInt(0); writer.putInt(0); @@ -771,6 +771,7 @@ public class ManageNPCMsg extends ClientNetMsg { public void setUnknown06(int unknown06) { this.unknown06 = unknown06; } + public int getMessageType() { return messageType; } diff --git a/src/engine/net/client/msg/MoveToPointMsg.java b/src/engine/net/client/msg/MoveToPointMsg.java index 663bacc2..9c2ede1f 100644 --- a/src/engine/net/client/msg/MoveToPointMsg.java +++ b/src/engine/net/client/msg/MoveToPointMsg.java @@ -10,7 +10,6 @@ package engine.net.client.msg; import engine.Enum.GameObjectType; -import engine.gameManager.BuildingManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; diff --git a/src/engine/net/client/msg/UpdateGoldMsg.java b/src/engine/net/client/msg/UpdateGoldMsg.java index ac5df886..90389f2c 100644 --- a/src/engine/net/client/msg/UpdateGoldMsg.java +++ b/src/engine/net/client/msg/UpdateGoldMsg.java @@ -15,7 +15,10 @@ import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; import engine.net.client.Protocol; -import engine.objects.*; +import engine.objects.AbstractWorldObject; +import engine.objects.CharacterItemManager; +import engine.objects.Item; +import engine.objects.PlayerCharacter; /** * Update gold in inventory and/or bank diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index e3c75b54..43637563 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -986,7 +986,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { return 300; } float range = 8; - if (( this).charItemManager.equipped.get(EquipSlotType.RHELD) != null) { + if ((this).charItemManager.equipped.get(EquipSlotType.RHELD) != null) { range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.RHELD).template.item_weapon_max_range; } else if (((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD) != null) { range = ((Mob) this).charItemManager.equipped.get(EquipSlotType.LHELD).template.item_weapon_max_range; @@ -1046,18 +1046,18 @@ public abstract class AbstractCharacter extends AbstractWorldObject { Building building = BuildingManager.getBuildingAtLocation(this.loc); Regions region = null; - if(building != null) { + if (building != null) { //look for region in the building we are in for (Regions regionCycle : building.getBounds().getRegions()) { float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y; - if(regionHeight < 10) + if (regionHeight < 10) regionHeight = 10; if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight) region = regionCycle; } } float regionHeightOffset = 0; - if(region != null){ + if (region != null) { this.region = region; regionHeightOffset = region.lerpY(this); this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc @@ -1071,7 +1071,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } float terrainHeight = Terrain.getWorldHeight(value); - Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z); + Vector3fImmutable finalLocation = new Vector3fImmutable(value.x, terrainHeight + regionHeightOffset, value.z); super.setLoc(finalLocation); // set the location in the world this.resetLastSetLocUpdate(); @@ -1195,7 +1195,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public final void setCombatTarget(final AbstractWorldObject value) { - if(this.getObjectTypeMask() == 2050) {//MOB? + if (this.getObjectTypeMask() == 2050) {//MOB? if (value == null) { if (this.isCombat()) { this.setCombat(false); @@ -1203,7 +1203,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { rwss.setPlayer(this); DispatchMessage.sendToAllInRange(this, rwss); } - }else { + } else { if (!this.isCombat()) { this.setCombat(true); UpdateStateMsg rwss = new UpdateStateMsg(); @@ -1331,22 +1331,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject { CombatManager.handleRetaliate(this, attacker); } - if(this.getObjectType().equals(GameObjectType.Mob)){ + if (this.getObjectType().equals(GameObjectType.Mob)) { //handle hate value addition - Mob target = (Mob)this; + Mob target = (Mob) this; if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) { target.playerAgroMap.put(attacker.getObjectUUID(), target.playerAgroMap.get(attacker.getObjectUUID()) + value); - if (target.isPlayerGuard()){ - if(target.guardedCity != null && target.guardedCity.cityOutlaws.contains(attacker.getObjectUUID()) == false) + if (target.isPlayerGuard()) { + if (target.guardedCity != null && target.guardedCity.cityOutlaws.contains(attacker.getObjectUUID()) == false) target.guardedCity.cityOutlaws.add(attacker.getObjectUUID()); } } - } else if(this.getObjectType().equals(GameObjectType.PlayerCharacter)){ + } else if (this.getObjectType().equals(GameObjectType.PlayerCharacter)) { City playerCity = ZoneManager.getCityAtLocation(this.loc); - if(playerCity != null){ - if(!attacker.getGuild().getNation().equals(playerCity.getGuild().getNation())) - if(!playerCity.getGuild().getNation().getAllyList().contains(attacker.getGuild().getNation())) - if(!playerCity.cityOutlaws.contains(attacker.getObjectUUID())) + if (playerCity != null) { + if (!attacker.getGuild().getNation().equals(playerCity.getGuild().getNation())) + if (!playerCity.getGuild().getNation().getAllyList().contains(attacker.getGuild().getNation())) + if (!playerCity.cityOutlaws.contains(attacker.getObjectUUID())) playerCity.cityOutlaws.add(attacker.getObjectUUID()); } } diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 0bf5939a..8f783507 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -503,9 +503,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject { this.lastLoc = new Vector3fImmutable(this.loc); this.loc = loc; - if(this instanceof AbstractCharacter && this.region != null){ + if (this instanceof AbstractCharacter && this.region != null) { this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude()); - } else{ + } else { this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); } diff --git a/src/engine/objects/CharacterSkill.java b/src/engine/objects/CharacterSkill.java index f1d27a52..f2ba7e28 100644 --- a/src/engine/objects/CharacterSkill.java +++ b/src/engine/objects/CharacterSkill.java @@ -1013,7 +1013,7 @@ public class CharacterSkill extends AbstractGameObject { } public void calculateMobBaseAmount(boolean isGuard) { - if(!isGuard) { + if (!isGuard) { if (CharacterSkill.GetOwner(this) == null) { Logger.error("owner not found for owner uuid : " + this.ownerUID); this.baseAmount = 1; @@ -1037,23 +1037,23 @@ public class CharacterSkill extends AbstractGameObject { //Get bonuses from runes bonus = CharacterSkill.GetOwner(this).getBonuses().getSkillBonus(this.skillsBase.sourceType); - //Get Base skill for unmodified stats + //Get Base skill for unmodified stats - if (this.skillsBase.getStrMod() > 0) - statMod += (float) this.skillsBase.getStrMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseStr() / 100f; - if (this.skillsBase.getDexMod() > 0) - statMod += (float) this.skillsBase.getDexMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseDex() / 100f; - if (this.skillsBase.getConMod() > 0) - statMod += (float) this.skillsBase.getConMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseCon() / 100f; - if (this.skillsBase.getIntMod() > 0) - statMod += (float) this.skillsBase.getIntMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseInt() / 100f; - if (this.skillsBase.getSpiMod() > 0) - statMod += (float) this.skillsBase.getSpiMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseSpi() / 100f; - if (statMod < 1) - statMod = 1f; - else if (statMod > 600) - statMod = 600f; + if (this.skillsBase.getStrMod() > 0) + statMod += (float) this.skillsBase.getStrMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseStr() / 100f; + if (this.skillsBase.getDexMod() > 0) + statMod += (float) this.skillsBase.getDexMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseDex() / 100f; + if (this.skillsBase.getConMod() > 0) + statMod += (float) this.skillsBase.getConMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseCon() / 100f; + if (this.skillsBase.getIntMod() > 0) + statMod += (float) this.skillsBase.getIntMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseInt() / 100f; + if (this.skillsBase.getSpiMod() > 0) + statMod += (float) this.skillsBase.getSpiMod() * (float) ((Mob) CharacterSkill.GetOwner(this)).getMobBase().getMobBaseStats().getBaseSpi() / 100f; + if (statMod < 1) + statMod = 1f; + else if (statMod > 600) + statMod = 600f; } base += CharacterSkill.baseSkillValues[(int) statMod]; @@ -1065,7 +1065,7 @@ public class CharacterSkill extends AbstractGameObject { } public void calculateModifiedAmount(boolean isGuard) { - if(!isGuard) { + if (!isGuard) { if (CharacterSkill.GetOwner(this) == null || this.skillsBase == null) { Logger.error("owner or SkillsBase not found for skill " + this.getObjectUUID()); this.baseAmount = 1; diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 2249ee90..a431ee8e 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -325,11 +325,11 @@ public class City extends AbstractWorldObject { if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) { - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if(city.getGuild().getGuildType().equals(pc.guild.getGuildType())){ + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (city.getGuild().getGuildType().equals(pc.guild.getGuildType())) { cities.add(city); } - }else { + } else { cities.add(city); //verify nation or guild is same } } @@ -351,11 +351,11 @@ public class City extends AbstractWorldObject { cities.add(city); } else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if(city.getGuild().getGuildType().equals(pc.guild.getGuildType())){ + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (city.getGuild().getGuildType().equals(pc.guild.getGuildType())) { cities.add(city); } - }else { + } else { cities.add(city); //verify nation or guild is same } } @@ -410,22 +410,22 @@ public class City extends AbstractWorldObject { if (city.isNpc == 1) if (city.isNoobIsle == 1) { if (playerCharacter.getLevel() < 21) - cities.add(city); //verify nation or guild is same + cities.add(city); //verify nation or guild is same } else if (playerCharacter.getLevel() > 9) - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if(city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())){ + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())) { cities.add(city); } - }else { + } else { cities.add(city); //verify nation or guild is same } } else if (playerCharacter.getLevel() >= guild.getRepledgeMin() && playerCharacter.getLevel() <= guild.getRepledgeMax()) { - if(ConfigManager.MB_RULESET.getValue() == "LORE") { - if(city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())){ + if (ConfigManager.MB_RULESET.getValue() == "LORE") { + if (city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())) { cities.add(city); } - }else { + } else { cities.add(city); //verify nation or guild is same } } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index fa937147..6c5102b9 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -993,7 +993,7 @@ public class Item extends AbstractWorldObject { AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effect.getIDString()); apa.applyBakedInStatsForItem(this, this.template.item_user_power_action.get(effectID)[0]); - } + } } public final void loadEnchantments() { diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 6692525c..92d861f2 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -10,13 +10,11 @@ package engine.objects; import engine.Enum; -import engine.Enum.ItemType; import engine.gameManager.DbManager; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; public class ItemBase { @@ -96,6 +94,7 @@ public class ItemBase { public final int getUUID() { return uuid; } + public String getMastery() { return mastery; } @@ -127,6 +126,7 @@ public class ItemBase { public short getMinDamage() { return minDamage; } + public Enum.SourceType getDamageType() { return damageType; } diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 909d050e..16c38e78 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -534,7 +534,7 @@ public class ItemTemplate { return false; //Item not valid for slot - if(item.template.item_eq_slots_or.contains(slot) == false) + if (item.template.item_eq_slots_or.contains(slot) == false) return false; // Slot is taken diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 7b1e72fc..5116940a 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1037,13 +1037,13 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { } public void recalculateStats() { - if(this.isPlayerGuard()){ + if (this.isPlayerGuard()) { NPCManager.setMaxHealthForGuard(this); NPCManager.setAttackRatingForGuard(this); NPCManager.setDefenseForGuard(this); NPCManager.setDamageAndSpeedForGuard(this); NPCManager.applyGuardStanceModifiers(this); - }else { + } else { try { calculateAtrDefenseDamage(); @@ -1061,64 +1061,64 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { } catch (Exception e) { Logger.error(e.getMessage()); } - if(this.isSiege()) + if (this.isSiege()) this.healthMax = 10000; Resists.calculateResists(this); } public void calculateMaxHealthManaStamina() { - float h; - float m; - float s; + float h; + float m; + float s; - h = this.mobBase.getHealthMax(); - if (this.isPet()) { - h = this.level * 0.5f * 120; - } - m = this.statSpiCurrent; - s = this.statConCurrent; + h = this.mobBase.getHealthMax(); + if (this.isPet()) { + h = this.level * 0.5f * 120; + } + m = this.statSpiCurrent; + s = this.statConCurrent; - // Apply any bonuses from runes and effects + // Apply any bonuses from runes and effects - if (this.bonuses != null) { - h += this.bonuses.getFloat(ModType.HealthFull, SourceType.NONE); - m += this.bonuses.getFloat(ModType.ManaFull, SourceType.NONE); - s += this.bonuses.getFloat(ModType.StaminaFull, SourceType.NONE); + if (this.bonuses != null) { + h += this.bonuses.getFloat(ModType.HealthFull, SourceType.NONE); + m += this.bonuses.getFloat(ModType.ManaFull, SourceType.NONE); + s += this.bonuses.getFloat(ModType.StaminaFull, SourceType.NONE); - //apply effects percent modifiers. DO THIS LAST! + //apply effects percent modifiers. DO THIS LAST! - h *= (1 + this.bonuses.getFloatPercentAll(ModType.HealthFull, SourceType.NONE)); - m *= (1 + this.bonuses.getFloatPercentAll(ModType.ManaFull, SourceType.NONE)); - s *= (1 + this.bonuses.getFloatPercentAll(ModType.StaminaFull, SourceType.NONE)); - } + h *= (1 + this.bonuses.getFloatPercentAll(ModType.HealthFull, SourceType.NONE)); + m *= (1 + this.bonuses.getFloatPercentAll(ModType.ManaFull, SourceType.NONE)); + s *= (1 + this.bonuses.getFloatPercentAll(ModType.StaminaFull, SourceType.NONE)); + } - // Set max health, mana and stamina + // Set max health, mana and stamina - if (h > 0) - this.healthMax = h; - else - this.healthMax = 1; + if (h > 0) + this.healthMax = h; + else + this.healthMax = 1; - if (m > -1) - this.manaMax = m; - else - this.manaMax = 0; + if (m > -1) + this.manaMax = m; + else + this.manaMax = 0; - if (s > -1) - this.staminaMax = s; - else - this.staminaMax = 0; + if (s > -1) + this.staminaMax = s; + else + this.staminaMax = 0; - // Update health, mana and stamina if needed + // Update health, mana and stamina if needed - if (this.getHealth() > this.healthMax) - this.setHealth(this.healthMax); + if (this.getHealth() > this.healthMax) + this.setHealth(this.healthMax); - if (this.mana.get() > this.manaMax) - this.mana.set(this.manaMax); + if (this.mana.get() > this.manaMax) + this.mana.set(this.manaMax); - if (this.stamina.get() > this.staminaMax) - this.stamina.set(staminaMax); + if (this.stamina.get() > this.staminaMax) + this.stamina.set(staminaMax); } @@ -1885,9 +1885,9 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { } } - public Boolean isGuard(){ + public Boolean isGuard() { - switch(this.behaviourType){ + switch (this.behaviourType) { case GuardMinion: case GuardCaptain: case GuardWallArcher: diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index a4b80dda..0901a6fb 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -19,7 +19,6 @@ import engine.server.MBServerStatics; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; public class MobBase extends AbstractGameObject { diff --git a/src/engine/objects/MobBaseStats.java b/src/engine/objects/MobBaseStats.java index 7acd1e3b..91a4c84e 100644 --- a/src/engine/objects/MobBaseStats.java +++ b/src/engine/objects/MobBaseStats.java @@ -79,8 +79,12 @@ public class MobBaseStats { return baseDex; } - public int getBaseSkill(){return mobbaseSkill;} + public int getBaseSkill() { + return mobbaseSkill; + } - public int getBaseSkillAmount(){return mobbaseSkillAmount;} + public int getBaseSkillAmount() { + return mobbaseSkillAmount; + } } diff --git a/src/engine/objects/Petition.java b/src/engine/objects/Petition.java index fb8fe046..d05957a0 100644 --- a/src/engine/objects/Petition.java +++ b/src/engine/objects/Petition.java @@ -7,6 +7,7 @@ // www.magicbane.com package engine.objects; + import engine.math.Vector3fImmutable; import engine.net.client.ClientConnection; import engine.net.client.msg.PetitionReceivedMsg; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 8104928e..381aac2e 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4572,31 +4572,31 @@ public class PlayerCharacter extends AbstractCharacter { this.setBounds(playerBounds); //assign enum values for restrictions - String race = this.getRace().getName().replace("-","").replace(", Male","").replace(", Female",""); + String race = this.getRace().getName().replace("-", "").replace(", Male", "").replace(", Female", ""); this.absRace = Enum.MonsterType.valueOf(race); - if(this.baseClass != null) + if (this.baseClass != null) this.absBaseClass = ClassType.valueOf(this.getBaseClass().getName()); - if(this.promotionClass != null) + if (this.promotionClass != null) this.absPromotionClass = ClassType.valueOf(this.getPromotionClass().getName()); - if(this.isMale()) + if (this.isMale()) this.absGender = SexType.MALE; else this.absGender = SexType.FEMALE; - for(CharacterRune rune : this.runes){ + for (CharacterRune rune : this.runes) { try { DisciplineType disc = DisciplineType.valueOf(RuneBase.getRuneBase(rune.getRuneBaseID()).getName().replace("-", "").replace(" ", "")); if (disc != null) { - if(this.absDisciplines == null) + if (this.absDisciplines == null) this.absDisciplines = EnumSet.of(disc); else this.absDisciplines.add(disc); } - } catch(Exception e){ + } catch (Exception e) { } } diff --git a/src/engine/objects/Portal.java b/src/engine/objects/Portal.java index 2601dc5a..19564ecb 100644 --- a/src/engine/objects/Portal.java +++ b/src/engine/objects/Portal.java @@ -3,7 +3,6 @@ package engine.objects; import engine.Enum; import engine.Enum.PortalType; import engine.InterestManagement.WorldGrid; -import engine.gameManager.BuildingManager; import engine.gameManager.ConfigManager; import engine.job.JobScheduler; import engine.jobs.CloseGateJob; @@ -105,7 +104,7 @@ public class Portal { if (player.getTimeStamp("lastMoveGate") < this.lastActive) return; - player.teleport(targetGate.getLoc().add(0,6,0));//offset height of runegate + player.teleport(targetGate.getLoc().add(0, 6, 0));//offset height of runegate player.setSafeMode(); } diff --git a/src/engine/objects/Regions.java b/src/engine/objects/Regions.java index 1683003c..3f473559 100644 --- a/src/engine/objects/Regions.java +++ b/src/engine/objects/Regions.java @@ -279,7 +279,7 @@ public class Regions { Building building = (Building) awo; if (!Bounds.collide(location, building.getBounds())) continue; - if(building != null) { + if (building != null) { region = BuildingManager.GetRegion(building, location.x, location.y, location.z); } //find regions that intersect x and z, check if object can enter. @@ -289,13 +289,13 @@ public class Regions { // if (region == null) // region = toEnter; // else // we're using a low level to high level tree structure, database not always in order low to high. - //check for highest level index. + //check for highest level index. // if (region != null && toEnter.highLerp.y > region.highLerp.y) // region = toEnter; // } - // } + // } } return region; } diff --git a/src/engine/powers/DamageShield.java b/src/engine/powers/DamageShield.java index 61011563..8ffd1289 100644 --- a/src/engine/powers/DamageShield.java +++ b/src/engine/powers/DamageShield.java @@ -8,6 +8,7 @@ package engine.powers; + import engine.Enum; public class DamageShield { diff --git a/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java b/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java index 6d3f8f38..09b6bd50 100644 --- a/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java +++ b/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java @@ -8,6 +8,7 @@ package engine.powers.effectmodifiers; + import engine.Enum; import engine.jobs.AbstractEffectJob; import engine.objects.*; diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index 89e0c366..ba979109 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -8,6 +8,7 @@ package engine.powers.effectmodifiers; + import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index 2f439ea6..b9aa0e94 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -8,6 +8,7 @@ package engine.powers.poweractions; + import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; @@ -128,21 +129,21 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { } } if (awo != null && awo.getObjectType() == GameObjectType.Mob) { - if(((Mob)awo).isPet()) { + if (((Mob) awo).isPet()) { ((Mob) awo).recalculateStats(); } } this.effect.startEffect(source, awo, trains, eff); } //apply effects to mobs within range for chants - if(pb.isChant){ - for(AbstractGameObject ago : WorldGrid.getObjectsInRangePartial(awo.loc,pb.range, MBServerStatics.MASK_MOB)){ - Mob mob = (Mob)ago; - if(mob.playerAgroMap.containsKey(source.getObjectUUID())) + if (pb.isChant) { + for (AbstractGameObject ago : WorldGrid.getObjectsInRangePartial(awo.loc, pb.range, MBServerStatics.MASK_MOB)) { + Mob mob = (Mob) ago; + if (mob.playerAgroMap.containsKey(source.getObjectUUID())) mob.playerAgroMap.put(source.getObjectUUID(), mob.playerAgroMap.get(source.getObjectUUID()).floatValue() + pb.hateValue); } - }else { + } else { if (awo != null && awo.getObjectType() == GameObjectType.Mob) { Mob mob = (Mob) awo; if (mob.playerAgroMap.containsKey(source.getObjectUUID())) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 4043e974..a827eb88 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -69,705 +69,705 @@ import static java.lang.System.exit; public class WorldServer { - public static int worldMapID = Integer.parseInt(ConfigManager.MB_WORLD_MAPID.getValue()); - public static int worldRealmMap = Integer.parseInt(ConfigManager.MB_WORLD_REALMMAP.getValue()); + public static int worldMapID = Integer.parseInt(ConfigManager.MB_WORLD_MAPID.getValue()); + public static int worldRealmMap = Integer.parseInt(ConfigManager.MB_WORLD_REALMMAP.getValue()); - public static int worldUUID = 1; // Root object in database - public static Enum.AccountStatus worldAccessLevel = Enum.AccountStatus.valueOf(ConfigManager.MB_WORLD_ACCESS_LVL.getValue()); - private static LocalDateTime bootTime = LocalDateTime.now(); - public boolean isRunning = false; + public static int worldUUID = 1; // Root object in database + public static Enum.AccountStatus worldAccessLevel = Enum.AccountStatus.valueOf(ConfigManager.MB_WORLD_ACCESS_LVL.getValue()); + private static LocalDateTime bootTime = LocalDateTime.now(); + public boolean isRunning = false; - // Member variable declaration + // Member variable declaration - public WorldServer() { - super(); - } + public WorldServer() { + super(); + } - public static void main(String[] args) { + public static void main(String[] args) { - WorldServer worldServer; + WorldServer worldServer; - // Configure TinyLogger - Configurator.defaultConfig() - .addWriter(new RollingFileWriter("logs/world/world.txt", 30, new TimestampLabeler(), new StartupPolicy())) - .level(Level.DEBUG) - .formatPattern("{level} {date:yyyy-MM-dd HH:mm:ss.SSS} [{thread}] {class}.{method}({line}) : {message}") - .writingThread("main", 2) - .activate(); + // Configure TinyLogger + Configurator.defaultConfig() + .addWriter(new RollingFileWriter("logs/world/world.txt", 30, new TimestampLabeler(), new StartupPolicy())) + .level(Level.DEBUG) + .formatPattern("{level} {date:yyyy-MM-dd HH:mm:ss.SSS} [{thread}] {class}.{method}({line}) : {message}") + .writingThread("main", 2) + .activate(); - if (ConfigManager.init() == false) { - Logger.error("ABORT! Missing config entry!"); - return; - } + if (ConfigManager.init() == false) { + Logger.error("ABORT! Missing config entry!"); + return; + } - try { + try { - worldServer = new WorldServer(); + worldServer = new WorldServer(); - ConfigManager.serverType = Enum.ServerType.WORLDSERVER; - ConfigManager.worldServer = worldServer; - ConfigManager.handler = new ClientMessagePump(worldServer); + ConfigManager.serverType = Enum.ServerType.WORLDSERVER; + ConfigManager.worldServer = worldServer; + ConfigManager.handler = new ClientMessagePump(worldServer); - worldServer.init(); + worldServer.init(); - int retVal = worldServer.exec(); + int retVal = worldServer.exec(); - if (retVal != 0) - Logger.error( - ".exec() returned value: '" + retVal); - exit(retVal); + if (retVal != 0) + Logger.error( + ".exec() returned value: '" + retVal); + exit(retVal); - } catch (Exception e) { - Logger.error(e.getMessage()); - exit(1); - } - } + } catch (Exception e) { + Logger.error(e.getMessage()); + exit(1); + } + } - public static void trainerInfo(TrainerInfoMsg msg, ClientConnection origin) { + public static void trainerInfo(TrainerInfoMsg msg, ClientConnection origin) { - NPC npc = NPC.getFromCache(msg.getObjectID()); - float sellPercent = 1; + NPC npc = NPC.getFromCache(msg.getObjectID()); + float sellPercent = 1; - if (npc != null) { + if (npc != null) { - if (origin.getPlayerCharacter() != null) - sellPercent = npc.getSellPercent(origin.getPlayerCharacter()); - else - sellPercent = npc.getSellPercent(); + if (origin.getPlayerCharacter() != null) + sellPercent = npc.getSellPercent(origin.getPlayerCharacter()); + else + sellPercent = npc.getSellPercent(); - msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc)); - } + msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc)); + } - Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - } + } - public static void refinerScreen(RefinerScreenMsg msg, ClientConnection origin) - throws MsgSendException { + public static void refinerScreen(RefinerScreenMsg msg, ClientConnection origin) + throws MsgSendException { - NPC npc = NPC.getFromCache(msg.getNpcID()); + NPC npc = NPC.getFromCache(msg.getNpcID()); - if (npc != null) - msg.setUnknown02(0); //cost to refine? + if (npc != null) + msg.setUnknown02(0); //cost to refine? - Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - } + Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + } - public static String getUptimeString() { + public static String getUptimeString() { - String outString = null; - java.time.Duration uptimeDuration; - String newLine = System.getProperty("line.separator"); + String outString = null; + java.time.Duration uptimeDuration; + String newLine = System.getProperty("line.separator"); - try { - outString = "[LUA_UPTIME()]" + newLine; - uptimeDuration = java.time.Duration.between(LocalDateTime.now(), WorldServer.bootTime); - long uptimeSeconds = Math.abs(uptimeDuration.getSeconds()); - String uptime = String.format("%d hours %02d minutes %02d seconds", uptimeSeconds / 3600, (uptimeSeconds % 3600) / 60, (uptimeSeconds % 60)); - outString += "uptime: " + uptime; - outString += " pop: " + SessionManager.getActivePlayerCharacterCount() + " max pop: " + SessionManager._maxPopulation; - } catch (Exception e) { - Logger.error("Failed to build string"); - } - return outString; - } + try { + outString = "[LUA_UPTIME()]" + newLine; + uptimeDuration = java.time.Duration.between(LocalDateTime.now(), WorldServer.bootTime); + long uptimeSeconds = Math.abs(uptimeDuration.getSeconds()); + String uptime = String.format("%d hours %02d minutes %02d seconds", uptimeSeconds / 3600, (uptimeSeconds % 3600) / 60, (uptimeSeconds % 60)); + outString += "uptime: " + uptime; + outString += " pop: " + SessionManager.getActivePlayerCharacterCount() + " max pop: " + SessionManager._maxPopulation; + } catch (Exception e) { + Logger.error("Failed to build string"); + } + return outString; + } - public static void writePopulationFile() { + public static void writePopulationFile() { - int population = SessionManager.getActivePlayerCharacterCount(); - try { + int population = SessionManager.getActivePlayerCharacterCount(); + try { - File populationFile = new File(ConfigManager.DEFAULT_DATA_DIR + ConfigManager.MB_WORLD_NAME.getValue().replaceAll("'", "") + ".pop"); - FileWriter fileWriter; + File populationFile = new File(ConfigManager.DEFAULT_DATA_DIR + ConfigManager.MB_WORLD_NAME.getValue().replaceAll("'", "") + ".pop"); + FileWriter fileWriter; - try { - fileWriter = new FileWriter(populationFile, false); - fileWriter.write(Integer.toString(population)); - fileWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } + try { + fileWriter = new FileWriter(populationFile, false); + fileWriter.write(Integer.toString(population)); + fileWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } - } catch (Exception e) { - Logger.error(e); - } - } + } catch (Exception e) { + Logger.error(e); + } + } - private int exec() { + private int exec() { - LocalDateTime nextHeartbeatTime = LocalDateTime.now(); - LocalDateTime nextPopulationFileTime = LocalDateTime.now(); - LocalDateTime nextFlashTrashCheckTime = LocalDateTime.now(); - LocalDateTime nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); - LocalDateTime nextWareHousePushTime = LocalDateTime.now(); + LocalDateTime nextHeartbeatTime = LocalDateTime.now(); + LocalDateTime nextPopulationFileTime = LocalDateTime.now(); + LocalDateTime nextFlashTrashCheckTime = LocalDateTime.now(); + LocalDateTime nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); + LocalDateTime nextWareHousePushTime = LocalDateTime.now(); - // Begin execution of main game loop + // Begin execution of main game loop - this.isRunning = true; + this.isRunning = true; - while (true) { + while (true) { - if (LocalDateTime.now().isAfter(nextHeartbeatTime)) { - SERVERHEARTBEAT.tick(); - nextHeartbeatTime = LocalDateTime.now().plusNanos(50000000); - } + if (LocalDateTime.now().isAfter(nextHeartbeatTime)) { + SERVERHEARTBEAT.tick(); + nextHeartbeatTime = LocalDateTime.now().plusNanos(50000000); + } - if (LocalDateTime.now().isAfter(nextPopulationFileTime)) { - writePopulationFile(); - nextPopulationFileTime = LocalDateTime.now().plusMinutes(1); - } + if (LocalDateTime.now().isAfter(nextPopulationFileTime)) { + writePopulationFile(); + nextPopulationFileTime = LocalDateTime.now().plusMinutes(1); + } - if (LocalDateTime.now().isAfter(nextFlashTrashCheckTime)) { - processFlashFile(); - processTrashFile(); - nextFlashTrashCheckTime = LocalDateTime.now().plusSeconds(15); - } + if (LocalDateTime.now().isAfter(nextFlashTrashCheckTime)) { + processFlashFile(); + processTrashFile(); + nextFlashTrashCheckTime = LocalDateTime.now().plusSeconds(15); + } - if (LocalDateTime.now().isAfter(nextHourlyJobTime)) { - Thread hourlyJobThread = new Thread(new HourlyJobThread()); - hourlyJobThread.setName("hourlyJob"); - hourlyJobThread.start(); - nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); - } + if (LocalDateTime.now().isAfter(nextHourlyJobTime)) { + Thread hourlyJobThread = new Thread(new HourlyJobThread()); + hourlyJobThread.setName("hourlyJob"); + hourlyJobThread.start(); + nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1); + } - if (LocalDateTime.now().isAfter(nextWareHousePushTime)) { - Thread warehousePushThread = new Thread(new WarehousePushThread()); - warehousePushThread.setName("warehousePush"); - warehousePushThread.start(); - nextWareHousePushTime = LocalDateTime.now().plusMinutes(15); - } + if (LocalDateTime.now().isAfter(nextWareHousePushTime)) { + Thread warehousePushThread = new Thread(new WarehousePushThread()); + warehousePushThread.setName("warehousePush"); + warehousePushThread.start(); + nextWareHousePushTime = LocalDateTime.now().plusMinutes(15); + } - ThreadUtils.sleep(50); - } - } + ThreadUtils.sleep(50); + } + } - private void initClientConnectionManager() { + private void initClientConnectionManager() { - try { + try { - String name = ConfigManager.MB_WORLD_NAME.getValue(); + String name = ConfigManager.MB_WORLD_NAME.getValue(); - if (ConfigManager.MB_EXTERNAL_ADDR.getValue().equals("0.0.0.0")) { + if (ConfigManager.MB_EXTERNAL_ADDR.getValue().equals("0.0.0.0")) { - // Autoconfigure External IP address. Only used in loginserver but useful - // here for bootstrap display + // Autoconfigure External IP address. Only used in loginserver but useful + // here for bootstrap display - Logger.info("AUTOCONFIG EXTERNAL IP ADDRESS"); - URL whatismyip = new URL("http://checkip.amazonaws.com"); + Logger.info("AUTOCONFIG EXTERNAL IP ADDRESS"); + URL whatismyip = new URL("http://checkip.amazonaws.com"); - BufferedReader in = new BufferedReader(new InputStreamReader( - whatismyip.openStream())); - ConfigManager.MB_EXTERNAL_ADDR.setValue(in.readLine()); - } + BufferedReader in = new BufferedReader(new InputStreamReader( + whatismyip.openStream())); + ConfigManager.MB_EXTERNAL_ADDR.setValue(in.readLine()); + } - if (ConfigManager.MB_BIND_ADDR.getValue().equals("0.0.0.0")) { + if (ConfigManager.MB_BIND_ADDR.getValue().equals("0.0.0.0")) { - try (final DatagramSocket socket = new DatagramSocket()) { - socket.connect(InetAddress.getByName("8.8.8.8"), 10002); - ConfigManager.MB_BIND_ADDR.setValue(socket.getLocalAddress().getHostAddress()); - } + try (final DatagramSocket socket = new DatagramSocket()) { + socket.connect(InetAddress.getByName("8.8.8.8"), 10002); + ConfigManager.MB_BIND_ADDR.setValue(socket.getLocalAddress().getHostAddress()); + } - } + } - Logger.info("External address: " + ConfigManager.MB_EXTERNAL_ADDR.getValue() + ":" + ConfigManager.MB_WORLD_PORT.getValue()); - Logger.info("Internal address: " + ConfigManager.MB_BIND_ADDR.getValue() + ":" + ConfigManager.MB_WORLD_PORT.getValue()); + Logger.info("External address: " + ConfigManager.MB_EXTERNAL_ADDR.getValue() + ":" + ConfigManager.MB_WORLD_PORT.getValue()); + Logger.info("Internal address: " + ConfigManager.MB_BIND_ADDR.getValue() + ":" + ConfigManager.MB_WORLD_PORT.getValue()); - InetAddress addy = InetAddress.getByName(ConfigManager.MB_BIND_ADDR.getValue()); - int port = Integer.parseInt(ConfigManager.MB_WORLD_PORT.getValue()); + InetAddress addy = InetAddress.getByName(ConfigManager.MB_BIND_ADDR.getValue()); + int port = Integer.parseInt(ConfigManager.MB_WORLD_PORT.getValue()); - ClientConnectionManager connectionManager = new ClientConnectionManager(name + ".ClientConnMan", addy, - port); - connectionManager.startup(); + ClientConnectionManager connectionManager = new ClientConnectionManager(name + ".ClientConnMan", addy, + port); + connectionManager.startup(); - } catch (IOException e) { - Logger.error("Exception while creating a ClientConnectionManager."); - } - } + } catch (IOException e) { + Logger.error("Exception while creating a ClientConnectionManager."); + } + } - private boolean init() { + private boolean init() { - Logger.info("MAGICBANE SERVER GREETING:"); - Logger.info(ConfigManager.MB_WORLD_GREETING.getValue()); + Logger.info("MAGICBANE SERVER GREETING:"); + Logger.info(ConfigManager.MB_WORLD_GREETING.getValue()); - Logger.info("Initialize network protocol"); - Protocol.initProtocolLookup(); + Logger.info("Initialize network protocol"); + Protocol.initProtocolLookup(); - Logger.info("Initialize database layer"); - initDatabaselayer(); + Logger.info("Initialize database layer"); + initDatabaselayer(); - Logger.info("Starting network Dispatcher"); - DispatchMessage.startMessagePump(); + Logger.info("Starting network Dispatcher"); + DispatchMessage.startMessagePump(); - Logger.info("Setting cross server session behavior"); - SessionManager.setCrossServerBehavior(1); // Sets cross server behavior + 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("Starting Item Production thread"); + ItemProductionManager.ITEMPRODUCTIONMANAGER.startMessagePump(); - Logger.info("Initializing Errant Guild"); - Guild.getErrantGuild(); + Logger.info("Initializing Errant Guild"); + Guild.getErrantGuild(); - Logger.info("Loading zone template data"); - DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES(); + Logger.info("Loading zone template data"); + DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES(); - Logger.info("Initializing PowersManager."); - PowersManager.initPowersManager(true); + Logger.info("Initializing PowersManager."); + PowersManager.initPowersManager(true); - Logger.info("Loading granted Skills for Runes"); - DbManager.SkillsBaseQueries.LOAD_ALL_RUNE_SKILLS(); + Logger.info("Loading granted Skills for Runes"); + DbManager.SkillsBaseQueries.LOAD_ALL_RUNE_SKILLS(); - Logger.info("Loading Player Friends"); - DbManager.PlayerCharacterQueries.LOAD_PLAYER_FRIENDS(); + Logger.info("Loading Player Friends"); + DbManager.PlayerCharacterQueries.LOAD_PLAYER_FRIENDS(); - Logger.info("Loading Building Friends"); - DbManager.BuildingQueries.LOAD_BUILDING_FRIENDS(); + Logger.info("Loading Building Friends"); + DbManager.BuildingQueries.LOAD_BUILDING_FRIENDS(); - Logger.info("Loading Building Condemned"); - DbManager.BuildingQueries.LOAD_BUILDING_CONDEMNED(); + Logger.info("Loading Building Condemned"); + DbManager.BuildingQueries.LOAD_BUILDING_CONDEMNED(); - Logger.info("Loading Barracks Patrol Points"); - DbManager.BuildingQueries.LOAD_BARRACKS_PATROL_POINTS(); + Logger.info("Loading Barracks Patrol Points"); + DbManager.BuildingQueries.LOAD_BARRACKS_PATROL_POINTS(); - Logger.info("Initializing NPC Profits"); - DbManager.NPCQueries.LOAD_NPC_PROFITS(); + Logger.info("Initializing NPC Profits"); + DbManager.NPCQueries.LOAD_NPC_PROFITS(); - Logger.info("Initializing Petition Table"); - DbManager.PetitionQueries.CREATE_PETITION_TABLE(); + Logger.info("Initializing Petition Table"); + DbManager.PetitionQueries.CREATE_PETITION_TABLE(); - Logger.info("Initializing MeshBounds"); - MeshBounds.InitializeBuildingBounds(); + Logger.info("Initializing MeshBounds"); + MeshBounds.InitializeBuildingBounds(); - Logger.info("Loading Item Templates"); - DbManager.ItemQueries.LOAD_ITEM_TEMPLATES(); + Logger.info("Loading Item Templates"); + DbManager.ItemQueries.LOAD_ITEM_TEMPLATES(); - Logger.info("Loading ItemBases"); - ItemBase.loadAllItemBases(); + Logger.info("Loading ItemBases"); + ItemBase.loadAllItemBases(); - Logger.info("Loading PromotionClasses"); - DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); + Logger.info("Loading PromotionClasses"); + DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); - Logger.info("Loading NPC and Mob Rune Sets"); - NPCManager._runeSetMap = dbNPCHandler.LOAD_RUNES_FOR_NPC_AND_MOBS(); + Logger.info("Loading NPC and Mob Rune Sets"); + NPCManager._runeSetMap = dbNPCHandler.LOAD_RUNES_FOR_NPC_AND_MOBS(); - Logger.info("Loading Booty Sets"); - LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); + Logger.info("Loading Booty Sets"); + LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); - // Load new loot system - Logger.info("Initializing Loot Manager"); - LootManager.init(); + // Load new loot system + Logger.info("Initializing Loot Manager"); + LootManager.init(); - RuneBaseAttribute.LoadAllAttributes(); - RuneBase.LoadAllRuneBases(); - BaseClass.LoadAllBaseClasses(); - Race.loadAllRaces(); - RuneBaseEffect.LoadRuneBaseEffects(); - Logger.info("Loading MobBases."); - DbManager.MobBaseQueries.GET_ALL_MOBBASES(); + RuneBaseAttribute.LoadAllAttributes(); + RuneBase.LoadAllRuneBases(); + BaseClass.LoadAllBaseClasses(); + Race.loadAllRaces(); + RuneBaseEffect.LoadRuneBaseEffects(); + Logger.info("Loading MobBases."); + DbManager.MobBaseQueries.GET_ALL_MOBBASES(); - Logger.info("Loading Rune Powers"); - PowersManager._allRunePowers = dbRuneBaseHandler.LOAD_RUNE_POWERS(); + Logger.info("Loading Rune Powers"); + PowersManager._allRunePowers = dbRuneBaseHandler.LOAD_RUNE_POWERS(); - Logger.info("Loading Rune Skill Adjusts"); - PowersManager._allRuneSkillAdjusts = dbRuneBaseHandler.LOAD_RUNE_SKILL_ADJUSTS(); + Logger.info("Loading Rune Skill Adjusts"); + PowersManager._allRuneSkillAdjusts = dbRuneBaseHandler.LOAD_RUNE_SKILL_ADJUSTS(); - Logger.info("Loading item enchants"); - DbManager.LootQueries.LOAD_ENCHANT_VALUES(); + Logger.info("Loading item enchants"); + DbManager.LootQueries.LOAD_ENCHANT_VALUES(); - Logger.info("Loading Realms"); - Realm.loadAllRealms(); + Logger.info("Loading Realms"); + Realm.loadAllRealms(); - Logger.info("Loading RealmMap"); - RealmMap.loadRealmImageMap(); + Logger.info("Loading RealmMap"); + RealmMap.loadRealmImageMap(); - Logger.info("Loading Kits"); - DbManager.KitQueries.GET_ALL_KITS(); + Logger.info("Loading Kits"); + DbManager.KitQueries.GET_ALL_KITS(); - Logger.info("Loading World Grid"); - WorldGrid.InitializeGridObjects(); + Logger.info("Loading World Grid"); + WorldGrid.InitializeGridObjects(); - Logger.info("Starting InterestManager."); - WorldGrid.startLoadJob(); + Logger.info("Starting InterestManager."); + WorldGrid.startLoadJob(); - Logger.info("Loading blueprint data."); - StaticColliders.loadAllStaticColliders(); - BuildingRegions.loadAllStaticColliders(); - Blueprint.loadAllDoorNumbers(); - Blueprint.loadAllBlueprints(); + Logger.info("Loading blueprint data."); + StaticColliders.loadAllStaticColliders(); + BuildingRegions.loadAllStaticColliders(); + Blueprint.loadAllDoorNumbers(); + Blueprint.loadAllBlueprints(); - Logger.info("Loading Heightmap Pixel data"); - MapLoader.loadAlHeightMaps(); + Logger.info("Loading Heightmap Pixel data"); + MapLoader.loadAlHeightMaps(); - Logger.info("Loading Race data"); - Enum.RaceType.initRaceTypeTables(); - Race.loadAllRaces(); + Logger.info("Loading Race data"); + Enum.RaceType.initRaceTypeTables(); + Race.loadAllRaces(); - Logger.info("Loading building slot/stuck location data."); - BuildingLocation.loadBuildingLocations(); + Logger.info("Loading building slot/stuck location data."); + BuildingLocation.loadBuildingLocations(); - // Starting before loading of structures/guilds/characters - // so the database connections are available to write - // historical data. + // Starting before loading of structures/guilds/characters + // so the database connections are available to write + // historical data. - Logger.info("Starting Data Warehouse"); - DataWarehouse.bootStrap(); + Logger.info("Starting Data Warehouse"); + DataWarehouse.bootStrap(); - Logger.info("Loading Minion Bases."); - MinionType.InitializeMinions(); + Logger.info("Loading Minion Bases."); + MinionType.InitializeMinions(); - Logger.info("Loading Pirate Names."); - NPCManager.loadAllPirateNames(); + Logger.info("Loading Pirate Names."); + NPCManager.loadAllPirateNames(); - Logger.info("Loading Support Types"); - SupportMsgType.InitializeSupportMsgType(); + Logger.info("Loading Support Types"); + SupportMsgType.InitializeSupportMsgType(); - //Load Buildings, Mobs and NPCs for server + //Load Buildings, Mobs and NPCs for server - Logger.info("Populating world with objects"); + Logger.info("Populating world with objects"); - long start = System.currentTimeMillis(); + long start = System.currentTimeMillis(); - DbManager.ZoneQueries.GET_ALL_ZONES(); - DbManager.BuildingQueries.GET_ALL_BUILDINGS(); - DbManager.CityQueries.GET_ALL_CITIES(); - DbManager.NPCQueries.GET_ALL_NPCS(); - DbManager.MobQueries.GET_ALL_MOBS(); + DbManager.ZoneQueries.GET_ALL_ZONES(); + DbManager.BuildingQueries.GET_ALL_BUILDINGS(); + DbManager.CityQueries.GET_ALL_CITIES(); + DbManager.NPCQueries.GET_ALL_NPCS(); + DbManager.MobQueries.GET_ALL_MOBS(); - Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); + Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); - // Configure realms for serialization - // Doing this after the world is loaded + // Configure realms for serialization + // Doing this after the world is loaded - Logger.info("Configuring realm serialization data"); - Realm.configureAllRealms(); + Logger.info("Configuring realm serialization data"); + Realm.configureAllRealms(); - Logger.info("Loading Mine data."); - Mine.loadAllMines(); + Logger.info("Loading Mine data."); + Mine.loadAllMines(); - Logger.info("Loading Shrine data."); - DbManager.ShrineQueries.LOAD_ALL_SHRINES(); + Logger.info("Loading Shrine data."); + DbManager.ShrineQueries.LOAD_ALL_SHRINES(); - Logger.info("Initialize Resource type lookup"); - Enum.ResourceType.InitializeResourceTypes(); + Logger.info("Initialize Resource type lookup"); + Enum.ResourceType.InitializeResourceTypes(); - Logger.info("Loading Warehouse data."); - DbManager.WarehouseQueries.LOAD_WAREHOUSES(); + Logger.info("Loading Warehouse data."); + DbManager.WarehouseQueries.LOAD_WAREHOUSES(); - Logger.info("Loading Runegate data."); - Runegate.loadAllRunegates(); + Logger.info("Loading Runegate data."); + Runegate.loadAllRunegates(); - Logger.info("Loading Max Skills for Trainers"); - DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT(); + Logger.info("Loading Max Skills for Trainers"); + DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT(); - //pick a startup Hotzone - ZoneManager.generateAndSetRandomHotzone(); + //pick a startup Hotzone + ZoneManager.generateAndSetRandomHotzone(); - ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); + ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); - Logger.info("Loading Player Heraldries"); - DbManager.PlayerCharacterQueries.LOAD_HERALDY(); + Logger.info("Loading Player Heraldries"); + DbManager.PlayerCharacterQueries.LOAD_HERALDY(); - Logger.info("Running Heraldry Audit for Deleted Players"); - Heraldry.AuditHeraldry(); + Logger.info("Running Heraldry Audit for Deleted Players"); + Heraldry.AuditHeraldry(); - //intiate mob ai thread - Logger.info("Starting Mob AI Thread"); - MobAIThread.startAIThread(); + //intiate mob ai thread + Logger.info("Starting Mob AI Thread"); + MobAIThread.startAIThread(); - Logger.info("World data loaded."); + Logger.info("World data loaded."); - //set default accesslevel for server *** Refactor who two separate variables? - MBServerStatics.accessLevel = worldAccessLevel; - Logger.info("Default access level set to " + MBServerStatics.accessLevel); + //set default accesslevel for server *** Refactor who two separate variables? + MBServerStatics.accessLevel = worldAccessLevel; + Logger.info("Default access level set to " + MBServerStatics.accessLevel); - Logger.info("Initializing Network"); - Network.init(); + Logger.info("Initializing Network"); + Network.init(); - Logger.info("Initializing Client Connection Manager"); - initClientConnectionManager(); + Logger.info("Initializing Client Connection Manager"); + initClientConnectionManager(); - //intiate mob respawn thread - Logger.info("Starting Mob Respawn Thread"); - Respawner.start(); + //intiate mob respawn thread + Logger.info("Starting Mob Respawn Thread"); + Respawner.start(); - // Run maintenance + // Run maintenance - MaintenanceManager.dailyMaintenance(); + MaintenanceManager.dailyMaintenance(); - Logger.info("Starting Orphan Item Purge"); - PurgeOprhans.startPurgeThread(); + Logger.info("Starting Orphan Item Purge"); + PurgeOprhans.startPurgeThread(); - // Open/Close mines for the current window + // Open/Close mines for the current window - Logger.info("Processing mine window."); - HourlyJobThread.processMineWindow(); + Logger.info("Processing mine window."); + HourlyJobThread.processMineWindow(); - // Calculate bootstrap time and rest boot time to current time. + // Calculate bootstrap time and rest boot time to current time. - Duration bootDuration = Duration.between(LocalDateTime.now(), bootTime); - long bootSeconds = Math.abs(bootDuration.getSeconds()); - String boottime = String.format("%d hours %02d minutes %02d seconds", bootSeconds / 3600, (bootSeconds % 3600) / 60, (bootSeconds % 60)); - Logger.info("Bootstrap time was " + boottime); + Duration bootDuration = Duration.between(LocalDateTime.now(), bootTime); + long bootSeconds = Math.abs(bootDuration.getSeconds()); + String boottime = String.format("%d hours %02d minutes %02d seconds", bootSeconds / 3600, (bootSeconds % 3600) / 60, (bootSeconds % 60)); + Logger.info("Bootstrap time was " + boottime); - bootTime = LocalDateTime.now(); + bootTime = LocalDateTime.now(); - Logger.info("Running garbage collection..."); - System.gc(); - return true; - } + Logger.info("Running garbage collection..."); + System.gc(); + return true; + } - protected boolean initDatabaselayer() { + protected boolean initDatabaselayer() { - // Try starting a GOM <-> DB connection. - try { + // Try starting a GOM <-> DB connection. + try { - Logger.info("Configuring GameObjectManager to use Database: '" - + ConfigManager.MB_DATABASE_NAME.getValue() + "' on " - + ConfigManager.MB_DATABASE_ADDRESS.getValue() + ':' - + ConfigManager.MB_DATABASE_PORT.getValue()); + Logger.info("Configuring GameObjectManager to use Database: '" + + ConfigManager.MB_DATABASE_NAME.getValue() + "' on " + + ConfigManager.MB_DATABASE_ADDRESS.getValue() + ':' + + ConfigManager.MB_DATABASE_PORT.getValue()); - DbManager.configureConnectionPool(); + DbManager.configureConnectionPool(); - } catch (Exception e) { - Logger.error(e.getMessage()); - return false; - } + } catch (Exception e) { + Logger.error(e.getMessage()); + return false; + } - return true; - } + return true; + } - /** - * Called to remove a client on "leave world", "quit game", killed client - * process, etc. - */ + /** + * Called to remove a client on "leave world", "quit game", killed client + * process, etc. + */ - public void removeClient(ClientConnection origin) { + public void removeClient(ClientConnection origin) { - if (origin == null) { - Logger.info( - "ClientConnection null in removeClient."); - return; - } + if (origin == null) { + Logger.info( + "ClientConnection null in removeClient."); + return; + } - PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter( - origin); + PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter( + origin); - if (playerCharacter == null) - // TODO log this - return; + if (playerCharacter == null) + // TODO log this + return; - //cancel any trade + //cancel any trade if (playerCharacter.charItemManager != null) playerCharacter.charItemManager.endTrade(true); - // Release any mine claims + // Release any mine claims - Mine.releaseMineClaims(playerCharacter); + Mine.releaseMineClaims(playerCharacter); - // logout - long delta = MBServerStatics.LOGOUT_TIMER_MS; + // logout + long delta = MBServerStatics.LOGOUT_TIMER_MS; - if (System.currentTimeMillis() - playerCharacter.getTimeStamp("LastCombatPlayer") < 60000) { - delta = 60000; + if (System.currentTimeMillis() - playerCharacter.getTimeStamp("LastCombatPlayer") < 60000) { + delta = 60000; - } - playerCharacter.stopMovement(playerCharacter.getLoc()); - UpdateStateMsg updateStateMsg = new UpdateStateMsg(); - updateStateMsg.setPlayer(playerCharacter); + } + playerCharacter.stopMovement(playerCharacter.getLoc()); + UpdateStateMsg updateStateMsg = new UpdateStateMsg(); + updateStateMsg.setPlayer(playerCharacter); - updateStateMsg.setActivity(5); - DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); + updateStateMsg.setActivity(5); + DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); - if (playerCharacter.region != null) - if (PlayerCharacter.CanBindToBuilding(playerCharacter, playerCharacter.region.parentBuildingID)) - playerCharacter.bindBuilding = playerCharacter.region.parentBuildingID; - else - playerCharacter.bindBuilding = 0; + if (playerCharacter.region != null) + if (PlayerCharacter.CanBindToBuilding(playerCharacter, playerCharacter.region.parentBuildingID)) + playerCharacter.bindBuilding = playerCharacter.region.parentBuildingID; + else + playerCharacter.bindBuilding = 0; - playerCharacter.getLoadedObjects().clear(); - playerCharacter.getLoadedStaticObjects().clear(); + playerCharacter.getLoadedObjects().clear(); + playerCharacter.getLoadedStaticObjects().clear(); - LogoutCharacterJob logoutJob = new LogoutCharacterJob(playerCharacter, this); - JobContainer jc = JobScheduler.getInstance().scheduleJob(logoutJob, - System.currentTimeMillis() + delta); - playerCharacter.getTimers().put("Logout", jc); - playerCharacter.getTimestamps().put("logout", System.currentTimeMillis()); + LogoutCharacterJob logoutJob = new LogoutCharacterJob(playerCharacter, this); + JobContainer jc = JobScheduler.getInstance().scheduleJob(logoutJob, + System.currentTimeMillis() + delta); + playerCharacter.getTimers().put("Logout", jc); + playerCharacter.getTimestamps().put("logout", System.currentTimeMillis()); - //send update to friends that you are logged off. + //send update to friends that you are logged off. - PlayerFriends.SendFriendsStatus(playerCharacter, false); + PlayerFriends.SendFriendsStatus(playerCharacter, false); - } + } - public void logoutCharacter(PlayerCharacter player) { + public void logoutCharacter(PlayerCharacter player) { - if (player == null) { - Logger.error("Unable to find PlayerCharacter to logout"); - return; - } - //remove player from loaded mobs agro maps - for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) { - Mob loadedMob = (Mob) awo; - loadedMob.playerAgroMap.remove(player.getObjectUUID()); - } - player.getTimestamps().put("logout", System.currentTimeMillis()); - player.setEnteredWorld(false); + if (player == null) { + Logger.error("Unable to find PlayerCharacter to logout"); + return; + } + //remove player from loaded mobs agro maps + for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) { + Mob loadedMob = (Mob) awo; + loadedMob.playerAgroMap.remove(player.getObjectUUID()); + } + player.getTimestamps().put("logout", System.currentTimeMillis()); + player.setEnteredWorld(false); - // remove from simulation and zero current loc + // remove from simulation and zero current loc - WorldGrid.RemoveWorldObject(player); + WorldGrid.RemoveWorldObject(player); - // clear Logout Timer + // clear Logout Timer - if (player.getTimers() != null) - player.getTimers().remove("Logout"); + if (player.getTimers() != null) + player.getTimers().remove("Logout"); - if (player.getPet() != null) - player.getPet().dismiss(); + if (player.getPet() != null) + player.getPet().dismiss(); - NPCManager.dismissNecroPets(player); + NPCManager.dismissNecroPets(player); - // Set player inactive so they quit loading for other players + // Set player inactive so they quit loading for other players - player.setActive(false); + player.setActive(false); - // Remove from group + // Remove from group - Group group = GroupManager.getGroup(player); + Group group = GroupManager.getGroup(player); - try { - if (group != null) - GroupManager.LeaveGroup(player); - } catch (MsgSendException e) { - Logger.error(e.toString()); - } + try { + if (group != null) + GroupManager.LeaveGroup(player); + } catch (MsgSendException e) { + Logger.error(e.toString()); + } - player.respawnLock.writeLock().lock(); - try { - if (!player.isAlive()) - player.respawn(false, false, true); - } catch (Exception e) { - Logger.error(e); - } finally { - player.respawnLock.writeLock().unlock(); - } - } + player.respawnLock.writeLock().lock(); + try { + if (!player.isAlive()) + player.respawn(false, false, true); + } catch (Exception e) { + Logger.error(e); + } finally { + player.respawnLock.writeLock().unlock(); + } + } - private void processTrashFile() { + private void processTrashFile() { - ArrayList machineList; - ArrayList trashList = new ArrayList<>(); - ArrayList accountList = new ArrayList<>(); + ArrayList machineList; + ArrayList trashList = new ArrayList<>(); + ArrayList accountList = new ArrayList<>(); - File trashFile = new File("trash"); + File trashFile = new File("trash"); - if (trashFile.exists() == false) - return; + if (trashFile.exists() == false) + return; - // Build list of machineID's in the trash file + // Build list of machineID's in the trash file - machineList = DbManager.AccountQueries.GET_TRASH_LIST(); + machineList = DbManager.AccountQueries.GET_TRASH_LIST(); - // Build list of trash characters associated with that machineID + // Build list of trash characters associated with that machineID - for (String machineID : machineList) { - trashList = DbManager.AccountQueries.GET_ALL_CHARS_FOR_MACHINE(machineID); + for (String machineID : machineList) { + trashList = DbManager.AccountQueries.GET_ALL_CHARS_FOR_MACHINE(machineID); - // Deactivate these players and add them to loginCache table + // Deactivate these players and add them to loginCache table - for (PlayerCharacter trashPlayer : trashList) { + for (PlayerCharacter trashPlayer : trashList) { - if (trashPlayer == null) - continue; + if (trashPlayer == null) + continue; - // Need to collate accounts. + // Need to collate accounts. - if (!accountList.contains(trashPlayer.getAccount().getObjectUUID())) - accountList.add(trashPlayer.getAccount().getObjectUUID()); + if (!accountList.contains(trashPlayer.getAccount().getObjectUUID())) + accountList.add(trashPlayer.getAccount().getObjectUUID()); - DbManager.PlayerCharacterQueries.SET_ACTIVE(trashPlayer, false); - DbManager.AccountQueries.INVALIDATE_LOGIN_CACHE(trashPlayer.getObjectUUID(), "character"); - } - } + DbManager.PlayerCharacterQueries.SET_ACTIVE(trashPlayer, false); + DbManager.AccountQueries.INVALIDATE_LOGIN_CACHE(trashPlayer.getObjectUUID(), "character"); + } + } - // delete vault of associated accounts and then invalidate them - // in the login cache. + // delete vault of associated accounts and then invalidate them + // in the login cache. - for (Integer accountID : accountList) { - DbManager.AccountQueries.DELETE_VAULT_FOR_ACCOUNT(accountID); - DbManager.AccountQueries.INVALIDATE_LOGIN_CACHE(accountID, "account"); - } + for (Integer accountID : accountList) { + DbManager.AccountQueries.DELETE_VAULT_FOR_ACCOUNT(accountID); + DbManager.AccountQueries.INVALIDATE_LOGIN_CACHE(accountID, "account"); + } - // Trigger the Login Server to invalidate these accounts in the cache.. + // Trigger the Login Server to invalidate these accounts in the cache.. - try { - Files.write(Paths.get("cacheInvalid"), "".getBytes()); - } catch (IOException e) { - e.printStackTrace(); - } + try { + Files.write(Paths.get("cacheInvalid"), "".getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } - // If any of these players are active disconnect them. - // The account and player should be removed from the login - // server cache file by now. + // If any of these players are active disconnect them. + // The account and player should be removed from the login + // server cache file by now. - Timer timer = new Timer("Disconnect Trash"); - timer.schedule(new DisconnectTrashTask(trashList), 3000L); + Timer timer = new Timer("Disconnect Trash"); + timer.schedule(new DisconnectTrashTask(trashList), 3000L); - // Clean up after ourselves + // Clean up after ourselves - try { - Files.deleteIfExists(Paths.get("trash")); - DbManager.AccountQueries.CLEAR_TRASH_TABLE(); - } catch (IOException e) { - e.printStackTrace(); - } + try { + Files.deleteIfExists(Paths.get("trash")); + DbManager.AccountQueries.CLEAR_TRASH_TABLE(); + } catch (IOException e) { + e.printStackTrace(); + } - } + } - private void processFlashFile() { + private void processFlashFile() { - File flashFile = new File("flash"); - String flashString; - List fileContents; + File flashFile = new File("flash"); + String flashString; + List fileContents; - if (flashFile.exists() == false) - return; + if (flashFile.exists() == false) + return; - try { - fileContents = Files.readAllLines(Paths.get("flash")); - } catch (IOException e) { - return; - } + try { + fileContents = Files.readAllLines(Paths.get("flash")); + } catch (IOException e) { + return; + } - // Flash file detected: read contents - // and send as a flash. + // Flash file detected: read contents + // and send as a flash. - flashString = fileContents.toString(); + flashString = fileContents.toString(); - if (flashString == null) - return; + if (flashString == null) + return; - if (flashString == "") - flashString = "Rebooting for to fix bug."; + if (flashString == "") + flashString = "Rebooting for to fix bug."; - Logger.info("Sending flash from external interface"); - Logger.info("Msg: " + flashString); + Logger.info("Sending flash from external interface"); + Logger.info("Msg: " + flashString); - ChatSystemMsg msg = new ChatSystemMsg(null, flashString); - msg.setChannel(engine.Enum.ChatChannelType.FLASH.getChannelID()); - msg.setMessageType(Enum.ChatMessageType.INFO.ordinal()); - DispatchMessage.dispatchMsgToAll(msg); + ChatSystemMsg msg = new ChatSystemMsg(null, flashString); + msg.setChannel(engine.Enum.ChatChannelType.FLASH.getChannelID()); + msg.setMessageType(Enum.ChatMessageType.INFO.ordinal()); + DispatchMessage.dispatchMsgToAll(msg); - // Delete file + // Delete file - try { - Files.deleteIfExists(Paths.get("flash")); - } catch (IOException e) { - e.printStackTrace(); - } + try { + Files.deleteIfExists(Paths.get("flash")); + } catch (IOException e) { + e.printStackTrace(); + } - } + } } \ No newline at end of file