From 9704fc65aef9f6ea43954eaee8df79ab05ff1a37 Mon Sep 17 00:00:00 2001 From: Obique Date: Tue, 22 May 2018 11:40:40 -0500 Subject: [PATCH] Partially completed refactor --- .gitmodules | 6 +- PSWGCommon | 1 - build.gradle | 15 +- pswgcommon | 1 + settings.gradle | 4 +- .../scripts/radial/RadialHandler.groovy | 2 +- .../com/projectswg/holocore/ProjectSWG.java | 20 +- .../holocore/intents/BuffIntent.java | 3 +- .../holocore/intents/CivilWarPointIntent.java | 10 +- .../holocore/intents/DanceIntent.java | 3 +- .../holocore/intents/FactionIntent.java | 3 +- .../holocore/intents/FlourishIntent.java | 3 +- .../holocore/intents/GalacticIntent.java | 3 +- .../holocore/intents/GrantBadgeIntent.java | 3 +- .../intents/GrantClickyCollectionIntent.java | 3 +- .../holocore/intents/GroupEventIntent.java | 3 +- .../holocore/intents/LoginEventIntent.java | 2 +- .../intents/NotifyPlayersPacketIntent.java | 7 +- .../holocore/intents/PlayerEventIntent.java | 3 +- .../holocore/intents/RequestZoneInIntent.java | 4 +- .../holocore/intents/SetTitleIntent.java | 13 +- .../holocore/intents/SkillModIntent.java | 3 +- .../holocore/intents/WatchIntent.java | 3 +- .../intents/chat/ChatAvatarRequestIntent.java | 3 +- .../intents/chat/ChatCommandIntent.java | 3 +- .../intents/chat/ChatRoomUpdateIntent.java | 3 +- .../intents/chat/PersistentMessageIntent.java | 3 +- .../intents/chat/SpatialChatIntent.java | 3 +- .../intents/chat/SystemMessageIntent.java | 3 +- .../intents/combat/CorpseLootedIntent.java | 3 +- .../combat/CreatureIncapacitatedIntent.java | 3 +- .../intents/combat/CreatureKilledIntent.java | 3 +- .../intents/combat/DeathblowIntent.java | 3 +- .../intents/combat/DuelPlayerIntent.java | 3 +- .../combat/IncapacitateCreatureIntent.java | 3 +- .../intents/combat/KillCreatureIntent.java | 3 +- .../intents/combat/LootItemIntent.java | 3 +- .../combat/loot/LootRequestIntent.java | 2 +- .../intents/connection/ForceLogoutIntent.java | 3 +- .../crafting/survey/SampleResourceIntent.java | 3 +- .../survey/StartSurveyToolIntent.java | 3 +- .../crafting/survey/StartSurveyingIntent.java | 3 +- .../intents/experience/ExperienceIntent.java | 3 +- .../intents/experience/GrantSkillIntent.java | 3 +- .../experience/LevelChangedIntent.java | 3 +- .../network/CloseConnectionIntent.java | 3 +- .../network/ConnectionClosedIntent.java | 2 +- .../network/ConnectionOpenedIntent.java | 2 +- .../intents/network/GalacticPacketIntent.java | 9 +- .../intents/network/InboundPacketIntent.java | 2 +- .../network/InboundPacketPendingIntent.java | 3 +- .../intents/network/OutboundPacketIntent.java | 2 +- .../object/ContainerTransferIntent.java | 14 +- .../object/CreateStaticItemIntent.java | 3 +- .../intents/object/DestroyObjectIntent.java | 3 +- .../object/ForceAwarenessUpdateIntent.java | 11 +- .../intents/object/MoveObjectIntent.java | 3 +- .../intents/object/ObjectCreatedIntent.java | 3 +- .../intents/object/ObjectTeleportIntent.java | 3 +- .../player/CreatedCharacterIntent.java | 3 +- .../intents/player/DeleteCharacterIntent.java | 3 +- .../player/PlayerTransformedIntent.java | 3 +- .../player/uniform/OpenUniformBoxIntent.java | 2 +- .../intents/server/ConfigChangedIntent.java | 3 +- .../server/ServerManagementIntent.java | 7 +- .../intents/server/ServerStatusIntent.java | 7 +- .../holocore/intents/sui/SuiWindowIntent.java | 3 +- .../intents/travel/TicketPurchaseIntent.java | 3 +- .../intents/travel/TicketUseIntent.java | 3 +- .../travel/TravelPointSelectionIntent.java | 3 +- .../resources/buildout/BuildoutAreaGrid.java | 4 +- .../holocore/resources/chat/ChatRange.java | 9 + .../holocore/resources/chat/ChatType.java | 9 + .../resources/client_info/ServerFactory.java | 14 +- .../resources/collections/SWGBitSet.java | 5 +- .../resources/collections/SWGFlag.java | 11 +- .../resources/collections/SWGList.java | 4 +- .../resources/collections/SWGMap.java | 4 +- .../resources/collections/SWGSet.java | 6 +- .../resources/commands/CombatCommand.java | 7 +- .../callbacks/AdminTeleportCallback.java | 1 - .../callbacks/AttributesCmdCallback.java | 1 - .../callbacks/FindFriendCallback.java | 7 +- .../commands/callbacks/GotoCmdCallback.java | 9 +- .../commands/callbacks/JumpCmdCallback.java | 1 - .../commands/callbacks/KneelCmdCallback.java | 1 - .../commands/callbacks/LogoutCmdCallback.java | 10 +- .../commands/callbacks/ProneCmdCallback.java | 1 - .../commands/callbacks/QaToolCmdCallback.java | 7 +- .../RequestBiographyCmdCallback.java | 3 +- .../callbacks/RequestDraftSlotsCallback.java | 1 - .../callbacks/RequestWaypointCmdCallback.java | 1 - .../commands/callbacks/ServerCmdCallback.java | 9 +- .../callbacks/SitOnObjectCmdCallback.java | 1 - .../callbacks/SocialInternalCmdCallback.java | 1 - .../commands/callbacks/StandCmdCallback.java | 1 - .../callbacks/StartDanceCallback.java | 6 +- .../callbacks/TransferItemCallback.java | 2 - .../callbacks/WaypointCmdCallback.java | 1 - .../resources/location/InstanceLocation.java | 11 +- .../resources/network/BaselineBuilder.java | 15 +- .../resources/network/BaselineObject.java | 20 +- .../resources/network/DeltaBuilder.java | 1 - .../holocore/resources/network/UDPServer.java | 11 +- .../holocore/resources/objects/Equipment.java | 3 +- .../resources/objects/GameObjectType.java | 4 +- .../holocore/resources/objects/SWGObject.java | 41 +- .../objects/awareness/AwarenessUtilities.java | 4 +- .../awareness/DataTransformHandler.java | 1 - .../objects/awareness/ObjectAware.java | 21 +- .../objects/awareness/ObjectAwareness.java | 13 +- .../objects/awareness/TerrainMap.java | 9 +- .../objects/awareness/TerrainMapChunk.java | 10 +- .../objects/building/BuildingObject.java | 26 +- .../objects/buildouts/BuildoutLoader.java | 12 +- .../objects/buildouts/SnapshotLoader.java | 10 +- .../objects/buildouts/SwgBuildoutRow.java | 4 +- .../buildouts/TerrainBuildoutLoader.java | 13 +- .../buildouts/TerrainSnapshotLoader.java | 13 +- .../objects/creature/CreatureObject.java | 3 - .../creature/CreatureObjectAwareness.java | 10 +- .../creature/CreatureObjectSharedNP.java | 12 +- .../resources/objects/custom/AIObject.java | 11 +- .../objects/custom/LoiterAIObject.java | 7 +- .../objects/custom/PatrolAIObject.java | 9 +- .../resources/objects/custom/PatrolGroup.java | 4 +- .../objects/custom/RandomAIObject.java | 4 +- .../objects/custom/TurningAIObject.java | 7 +- .../objects/factory/FactoryObject.java | 1 - .../resources/objects/group/GroupObject.java | 18 +- .../resources/objects/guild/GuildObject.java | 1 - .../installation/InstallationObject.java | 1 - .../objects/intangible/IntangibleObject.java | 1 - .../ManufactureSchematicObject.java | 5 +- .../objects/mission/MissionObject.java | 1 - .../objects/player/PlayerObject.java | 2 - .../objects/player/PlayerObjectPrivate.java | 1 - .../objects/player/PlayerObjectPrivateNP.java | 9 +- .../objects/player/PlayerObjectShared.java | 5 +- .../objects/player/PlayerObjectSharedNP.java | 1 - .../resource/ResourceContainerObject.java | 1 - .../resources/objects/ship/ShipObject.java | 1 - .../resources/objects/sound/SoundObject.java | 1 - .../objects/staticobject/StaticObject.java | 1 - .../objects/tangible/CreditObject.java | 9 +- .../objects/tangible/TangibleObject.java | 6 +- .../objects/weapon/WeaponObject.java | 1 - .../persistable/SWGObjectFactory.java | 1 - .../holocore/resources/player/Player.java | 15 +- .../resources/server_info/BasicLogStream.java | 10 +- .../server_info/CachedObjectDatabase.java | 14 +- .../resources/server_info/ConfigWatcher.java | 25 +- .../resources/server_info/DataManager.java | 14 +- .../resources/server_info/ObjectDatabase.java | 12 +- .../resources/server_info/SdbLoader.java | 70 +-- .../resources/server_info/StandardLog.java | 2 +- .../server_info/loader/BuildingLoader.java | 13 +- .../server_info/loader/npc/NpcLoader.java | 19 +- .../loader/npc/NpcPatrolRouteLoader.java | 17 +- .../server_info/loader/npc/NpcStatLoader.java | 9 +- .../loader/spawn/StaticSpawnLoader.java | 19 +- .../holocore/resources/spawn/Spawner.java | 9 +- .../holocore/resources/sui/SuiWindow.java | 1 - .../holocore/resources/zone/NameFilter.java | 9 +- .../holocore/services/CoreManager.java | 17 +- .../holocore/services/EngineManager.java | 11 +- .../holocore/services/ShutdownService.java | 13 +- .../services/chat/ChatFriendService.java | 160 ++++++ .../chat/ChatInstantMessageService.java | 56 ++ .../services/chat/ChatMailService.java | 38 +- .../holocore/services/chat/ChatManager.java | 358 +----------- .../holocore/services/chat/ChatMember.java | 1 - .../services/chat/ChatRoomContainer.java | 40 +- .../services/chat/ChatRoomHandler.java | 47 +- .../services/chat/ChatRoomService.java | 17 +- .../services/chat/ChatSpatialService.java | 33 ++ .../services/chat/ChatSystemService.java | 64 +++ .../collections/CollectionBadgeManager.java | 8 +- .../collections/CollectionService.java | 4 +- .../collections/ExplorationBadgeService.java | 19 +- ...Service.java => CombatCloningService.java} | 221 +++----- .../services/combat/CombatCommandService.java | 334 ++++++++++++ .../combat/CombatDeathblowService.java | 137 +++++ ...yerService.java => CombatDuelService.java} | 59 +- ...vice.java => CombatExperienceService.java} | 37 +- .../services/combat/CombatManager.java | 516 +----------------- .../services/combat/CombatNpcService.java | 74 +++ .../combat/CombatRegenerationService.java | 72 +++ .../services/combat/CombatStatusService.java | 11 + .../services/combat/loot/LootManager.java | 16 + .../loot/LootService.java} | 26 +- .../{ => combat}/loot/RareLootService.java | 6 +- .../services/commands/BuffService.java | 42 +- .../services/commands/CommandContainer.java | 22 +- .../commands/CommandCooldownHandler.java | 13 +- .../services/commands/CommandLauncher.java | 8 +- .../services/commands/CommandService.java | 38 +- .../commands/EntertainmentService.java | 23 +- .../services/commands/buff/BuffData.java | 14 +- .../services/commands/buff/BuffMap.java | 10 +- .../services/crafting/CraftingManager.java | 11 +- .../crafting/resource/ResourceService.java | 13 +- .../resource/galactic/GalacticResource.java | 1 - .../galactic/GalacticResourceLoader.java | 7 +- .../galactic/GalacticResourceSpawn.java | 7 +- .../galactic/GalacticResourceSpawner.java | 17 +- .../galactic/GalacticResourceStats.java | 4 +- .../resource/galactic/RawResourceType.java | 7 +- .../storage/GalacticResourceContainer.java | 62 +-- .../crafting/resource/raw/RawResource.java | 7 +- .../resource/raw/RawResourceContainer.java | 13 +- .../survey/InProgressSampleManager.java | 6 +- .../survey/InProgressSurveyManager.java | 6 +- .../crafting/survey/SampleSession.java | 7 +- .../crafting/survey/SurveyService.java | 15 +- .../crafting/survey/SurveySession.java | 7 +- .../services/dev/DeveloperService.java | 3 +- ...e.java => ExperienceExpertiseService.java} | 33 +- .../experience/ExperienceLevelService.java | 105 ++++ .../experience/ExperienceManager.java | 109 +--- .../experience/ExperienceRoleService.java | 69 +++ .../experience/skills/SkillManager.java | 42 ++ .../SkillService.java} | 112 +--- .../{ => skills}/SkillTemplateService.java | 28 +- .../services/faction/CivilWarService.java | 32 +- .../services/faction/FactionFlagService.java | 219 ++++++++ .../services/faction/FactionManager.java | 220 +------- .../services/galaxy/ConnectionService.java | 40 +- .../services/galaxy/EnvironmentService.java | 22 +- .../services/galaxy/GalacticManager.java | 13 +- .../holocore/services/galaxy/GameManager.java | 3 +- .../services/galaxy/SkillModService.java | 25 +- .../services/galaxy/travel/TravelGroup.java | 11 +- .../services/galaxy/travel/TravelHelper.java | 23 +- .../services/galaxy/travel/TravelPoint.java | 1 - .../galaxy/travel/TravelPointManager.java | 6 +- .../services/galaxy/travel/TravelService.java | 15 +- .../services/group/GroupInviterData.java | 1 - .../holocore/services/group/GroupService.java | 66 +-- .../holocore/services/map/CityService.java | 19 +- .../holocore/services/map/MapManager.java | 17 +- .../network/HolocoreSessionManager.java | 3 +- .../services/network/NetworkClient.java | 7 +- .../network/NetworkClientManager.java | 20 +- .../services/network/NetworkManager.java | 2 +- .../services/objects/AwarenessService.java | 35 +- .../objects/ClientBuildoutService.java | 11 +- .../services/objects/ObjectCreator.java | 17 +- .../services/objects/ObjectManager.java | 17 +- .../services/objects/RadialService.java | 4 +- .../services/objects/StaticItemService.java | 15 +- .../services/objects/UniformBoxService.java | 19 +- .../player/CharacterCreationRestriction.java | 13 +- .../player/CharacterCreationService.java | 32 +- .../services/player/LoginService.java | 5 +- .../services/player/PlayerManager.java | 18 +- .../services/player/TerrainZoneInsertion.java | 8 +- .../holocore/services/player/ZoneManager.java | 11 +- .../player/creation/CharacterCreation.java | 8 +- .../services/player/zone/ZoneRequester.java | 7 +- .../holocore/services/spawn/NPCCreator.java | 11 +- .../services/spawn/SpawnerService.java | 38 +- .../services/spawn/StaticService.java | 20 +- .../holocore/services/sui/SuiService.java | 4 +- .../holocore/services/trade/TradeService.java | 19 +- .../holocore/services/trade/TradeSession.java | 29 +- .../utilities/AwarenessUtilities.java | 4 +- .../holocore/utilities/BuildoutGenerator.java | 15 +- .../holocore/utilities/IntentFactory.java | 3 +- .../utilities/ScheduledUtilities.java | 4 +- .../holocore/utilities/SdbGenerator.java | 8 +- .../buildouts/BuildingListGenerator.java | 15 +- .../ClientdataPrinterCommands.java | 10 +- .../ClientdataPrinterDatatable.java | 6 +- .../utilities/namegen/SWGNameGenerator.java | 2 +- .../java/com/projectswg/holocore/TestAll.java | 2 +- .../resources/objects/TestSWGObject.java | 2 +- .../resources/services/TestConfig.java | 2 +- .../holocore/runners/TestRunnerNoIntents.java | 2 +- .../holocore/services/TestServices.java | 2 +- .../loot/TestRareLootService.java | 2 +- .../services/faction/TestCivilWarService.java | 2 +- 282 files changed, 2624 insertions(+), 2876 deletions(-) delete mode 160000 PSWGCommon create mode 160000 pswgcommon create mode 100644 src/main/java/com/projectswg/holocore/resources/chat/ChatRange.java create mode 100644 src/main/java/com/projectswg/holocore/resources/chat/ChatType.java create mode 100644 src/main/java/com/projectswg/holocore/services/chat/ChatFriendService.java create mode 100644 src/main/java/com/projectswg/holocore/services/chat/ChatInstantMessageService.java create mode 100644 src/main/java/com/projectswg/holocore/services/chat/ChatSpatialService.java create mode 100644 src/main/java/com/projectswg/holocore/services/chat/ChatSystemService.java rename src/main/java/com/projectswg/holocore/services/combat/{CorpseService.java => CombatCloningService.java} (72%) create mode 100644 src/main/java/com/projectswg/holocore/services/combat/CombatCommandService.java create mode 100644 src/main/java/com/projectswg/holocore/services/combat/CombatDeathblowService.java rename src/main/java/com/projectswg/holocore/services/combat/{DuelPlayerService.java => CombatDuelService.java} (96%) rename src/main/java/com/projectswg/holocore/services/combat/{CombatXpService.java => CombatExperienceService.java} (92%) create mode 100644 src/main/java/com/projectswg/holocore/services/combat/CombatNpcService.java create mode 100644 src/main/java/com/projectswg/holocore/services/combat/CombatRegenerationService.java create mode 100644 src/main/java/com/projectswg/holocore/services/combat/CombatStatusService.java create mode 100644 src/main/java/com/projectswg/holocore/services/combat/loot/LootManager.java rename src/main/java/com/projectswg/holocore/services/{loot/LootManager.java => combat/loot/LootService.java} (97%) rename src/main/java/com/projectswg/holocore/services/{ => combat}/loot/RareLootService.java (97%) rename src/main/java/com/projectswg/holocore/services/experience/{ExpertiseService.java => ExperienceExpertiseService.java} (96%) create mode 100644 src/main/java/com/projectswg/holocore/services/experience/ExperienceLevelService.java create mode 100644 src/main/java/com/projectswg/holocore/services/experience/ExperienceRoleService.java create mode 100644 src/main/java/com/projectswg/holocore/services/experience/skills/SkillManager.java rename src/main/java/com/projectswg/holocore/services/experience/{SkillManager.java => skills/SkillService.java} (54%) rename src/main/java/com/projectswg/holocore/services/experience/{ => skills}/SkillTemplateService.java (97%) create mode 100644 src/main/java/com/projectswg/holocore/services/faction/FactionFlagService.java rename src/test/java/com/projectswg/holocore/services/{ => combat}/loot/TestRareLootService.java (98%) diff --git a/.gitmodules b/.gitmodules index b809dc150..856c61c94 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "PSWGCommon"] - path = PSWGCommon - url = https://Obique@bitbucket.org/projectswg/pswgcommon.git +[submodule "pswgcommon"] + path = pswgcommon + url = git@bitbucket.org:projectswg/pswgcommon.git diff --git a/PSWGCommon b/PSWGCommon deleted file mode 160000 index de5dfb2ac..000000000 --- a/PSWGCommon +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de5dfb2ace8e625a9c4d3232a6a25b6a4d5339ee diff --git a/build.gradle b/build.gradle index 0d183ea17..298111c75 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,12 @@ buildscript { jcenter() } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3' } } plugins { - id 'com.github.johnrengelman.shadow' version '2.0.2' + id 'com.github.johnrengelman.shadow' version '2.0.3' id 'application' id 'java' id 'groovy' @@ -18,8 +18,8 @@ plugins { } mainClassName = 'com.projectswg.holocore.ProjectSWG' -sourceCompatibility = 9 -targetCompatibility = 9 +sourceCompatibility = 1.8 +targetCompatibility = 1.8 sourceSets { // https://stackoverflow.com/questions/22159699/gradle-groovy-and-java-class-dependency-compile @@ -62,20 +62,19 @@ repositories { } dependencies { - compile project(':PSWGCommon') + compile project(':pswgcommon') compile group: 'org.codehaus.groovy', name: 'groovy', version: '3.0.0-alpha-1' compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.21.0.1' - compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2' testCompile 'junit:junit:4.12' - displayCompile project(':PSWGCommon') + displayCompile project(':pswgcommon') displayCompile sourceSets.main.output } task wrapper(type: Wrapper) { - gradleVersion = "4.4.1" + gradleVersion = "4.7" } tasks.withType(FindBugs) { diff --git a/pswgcommon b/pswgcommon new file mode 160000 index 000000000..047d8d2cd --- /dev/null +++ b/pswgcommon @@ -0,0 +1 @@ +Subproject commit 047d8d2cdd278ac7e625cb49c9d8e54b01b755d3 diff --git a/settings.gradle b/settings.gradle index 0d002c766..98436d501 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -rootProject.name = 'Holocore' -include 'PSWGCommon' +rootProject.name = 'holocore' +include 'pswgcommon' diff --git a/src/main/groovy/com/projectswg/holocore/scripts/radial/RadialHandler.groovy b/src/main/groovy/com/projectswg/holocore/scripts/radial/RadialHandler.groovy index f919032bf..a809374a1 100644 --- a/src/main/groovy/com/projectswg/holocore/scripts/radial/RadialHandler.groovy +++ b/src/main/groovy/com/projectswg/holocore/scripts/radial/RadialHandler.groovy @@ -89,7 +89,7 @@ class RadialHandler { getHandler(target).handleSelection(player, target, selection) } - @Nonnull + @NotNull private static def getHandler(SWGObject target) { def type = target.getTemplate() RadialHandlerInterface handler = handlers.get(type) diff --git a/src/main/java/com/projectswg/holocore/ProjectSWG.java b/src/main/java/com/projectswg/holocore/ProjectSWG.java index 687f41528..35f95bbda 100644 --- a/src/main/java/com/projectswg/holocore/ProjectSWG.java +++ b/src/main/java/com/projectswg/holocore/ProjectSWG.java @@ -26,19 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore; -import com.projectswg.common.concurrency.Delay; -import com.projectswg.common.control.IntentManager; -import com.projectswg.common.control.IntentManager.IntentSpeedRecord; import com.projectswg.common.data.encodables.galaxy.Galaxy.GalaxyStatus; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Log; -import com.projectswg.common.debug.Log.LogLevel; -import com.projectswg.common.debug.log_wrapper.ConsoleLogWrapper; -import com.projectswg.common.debug.log_wrapper.FileLogWrapper; import com.projectswg.holocore.intents.server.ServerStatusIntent; import com.projectswg.holocore.resources.control.ServerStatus; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.CoreManager; +import me.joshlarson.jlcommon.concurrency.Delay; +import me.joshlarson.jlcommon.control.IntentManager; +import me.joshlarson.jlcommon.control.IntentManager.IntentSpeedRecord; +import me.joshlarson.jlcommon.log.Log; +import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper; +import me.joshlarson.jlcommon.log.log_wrapper.FileLogWrapper; import java.io.File; import java.lang.Thread.State; @@ -93,7 +92,7 @@ public class ProjectSWG { File logDirectory = new File("log"); if (!logDirectory.isDirectory() && !logDirectory.mkdir()) Log.w("Failed to make log directory!"); - Log.addWrapper(new ConsoleLogWrapper(LogLevel.VERBOSE)); + Log.addWrapper(new ConsoleLogWrapper()); Log.addWrapper(new FileLogWrapper(new File("log/log.txt"))); Log.i("Holocore version: %s", VERSION); @@ -156,7 +155,7 @@ public class ProjectSWG { List intentTimes = IntentManager.getInstance().getSpeedRecorder().getAllTimes(); Collections.sort(intentTimes); Log.i(" Intent Times: [%d]", intentTimes.size()); - Log.i(" %-30s%-40s%-10s%-20s%-10s", "Intent", "Receiver", "Count", "Time", "Priority"); + Log.i(" %-30s%-40s%-10s%-20s", "Intent", "Receiver", "Count", "Time"); for (IntentSpeedRecord record : intentTimes) { String receiverName = record.getConsumer().getClass().getName(); if (receiverName.indexOf('$') != -1) @@ -165,8 +164,7 @@ public class ProjectSWG { String intentName = record.getIntent().getSimpleName(); String recordCount = Long.toString(record.getCount()); String recordTime = String.format("%.6fms", record.getTime() / 1E6); - String priority = Integer.toString(record.getPriority()); - Log.i(" %-30s%-40s%-10s%-20s%-10s", intentName, receiverName, recordCount, recordTime, priority); + Log.i(" %-30s%-40s%-10s%-20s", intentName, receiverName, recordCount, recordTime); } } diff --git a/src/main/java/com/projectswg/holocore/intents/BuffIntent.java b/src/main/java/com/projectswg/holocore/intents/BuffIntent.java index 0b8634976..a81fab52b 100644 --- a/src/main/java/com/projectswg/holocore/intents/BuffIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/BuffIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class BuffIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/CivilWarPointIntent.java b/src/main/java/com/projectswg/holocore/intents/CivilWarPointIntent.java index 4e50853bb..f856ebbbe 100644 --- a/src/main/java/com/projectswg/holocore/intents/CivilWarPointIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/CivilWarPointIntent.java @@ -26,22 +26,20 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; import com.projectswg.holocore.resources.objects.player.PlayerObject; - -import javax.annotation.Nonnull; +import me.joshlarson.jlcommon.control.Intent; public class CivilWarPointIntent extends Intent { private final PlayerObject receiver; private final int points; - private CivilWarPointIntent(@Nonnull PlayerObject receiver, int points) { + private CivilWarPointIntent(@NotNull PlayerObject receiver, int points) { this.receiver = receiver; this.points = points; } - @Nonnull + @NotNull public PlayerObject getReceiver() { return receiver; } @@ -50,7 +48,7 @@ public class CivilWarPointIntent extends Intent { return points; } - public static void broadcast(@Nonnull PlayerObject receiver, int points) { + public static void broadcast(@NotNull PlayerObject receiver, int points) { new CivilWarPointIntent(receiver, points).broadcast(); } diff --git a/src/main/java/com/projectswg/holocore/intents/DanceIntent.java b/src/main/java/com/projectswg/holocore/intents/DanceIntent.java index ecb929c3b..be7d815a2 100644 --- a/src/main/java/com/projectswg/holocore/intents/DanceIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/DanceIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class DanceIntent extends Intent { private final String danceName; diff --git a/src/main/java/com/projectswg/holocore/intents/FactionIntent.java b/src/main/java/com/projectswg/holocore/intents/FactionIntent.java index 530787c26..d72350c36 100644 --- a/src/main/java/com/projectswg/holocore/intents/FactionIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/FactionIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.encodables.tangible.PvpFaction; import com.projectswg.common.data.encodables.tangible.PvpStatus; - import com.projectswg.holocore.resources.objects.tangible.TangibleObject; +import me.joshlarson.jlcommon.control.Intent; public class FactionIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/FlourishIntent.java b/src/main/java/com/projectswg/holocore/intents/FlourishIntent.java index ce297a85c..c99db11aa 100644 --- a/src/main/java/com/projectswg/holocore/intents/FlourishIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/FlourishIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class FlourishIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/GalacticIntent.java b/src/main/java/com/projectswg/holocore/intents/GalacticIntent.java index 3c1bcb1d1..7c378f3bf 100644 --- a/src/main/java/com/projectswg/holocore/intents/GalacticIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/GalacticIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.services.galaxy.GalacticManager; import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.player.PlayerManager; +import me.joshlarson.jlcommon.control.Intent; public abstract class GalacticIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/GrantBadgeIntent.java b/src/main/java/com/projectswg/holocore/intents/GrantBadgeIntent.java index d3d4efc93..2cd2afdae 100644 --- a/src/main/java/com/projectswg/holocore/intents/GrantBadgeIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/GrantBadgeIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class GrantBadgeIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/GrantClickyCollectionIntent.java b/src/main/java/com/projectswg/holocore/intents/GrantClickyCollectionIntent.java index 82fcce355..f522ed7ca 100644 --- a/src/main/java/com/projectswg/holocore/intents/GrantClickyCollectionIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/GrantClickyCollectionIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.collections.CollectionItem; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class GrantClickyCollectionIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/GroupEventIntent.java b/src/main/java/com/projectswg/holocore/intents/GroupEventIntent.java index 85382d94b..ee2be566f 100644 --- a/src/main/java/com/projectswg/holocore/intents/GroupEventIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/GroupEventIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class GroupEventIntent extends Intent { private GroupEventType eventType; diff --git a/src/main/java/com/projectswg/holocore/intents/LoginEventIntent.java b/src/main/java/com/projectswg/holocore/intents/LoginEventIntent.java index 7ed02e3c8..8988861cc 100644 --- a/src/main/java/com/projectswg/holocore/intents/LoginEventIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/LoginEventIntent.java @@ -26,7 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; +import me.joshlarson.jlcommon.control.Intent; public class LoginEventIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/NotifyPlayersPacketIntent.java b/src/main/java/com/projectswg/holocore/intents/NotifyPlayersPacketIntent.java index 8213f683c..190bafa85 100644 --- a/src/main/java/com/projectswg/holocore/intents/NotifyPlayersPacketIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/NotifyPlayersPacketIntent.java @@ -26,13 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import java.util.List; - -import com.projectswg.common.control.Intent; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.network.packets.SWGPacket; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; + +import java.util.List; public class NotifyPlayersPacketIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/PlayerEventIntent.java b/src/main/java/com/projectswg/holocore/intents/PlayerEventIntent.java index fd93356f9..b9e1355b6 100644 --- a/src/main/java/com/projectswg/holocore/intents/PlayerEventIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/PlayerEventIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.player.PlayerEvent; +import me.joshlarson.jlcommon.control.Intent; public class PlayerEventIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/RequestZoneInIntent.java b/src/main/java/com/projectswg/holocore/intents/RequestZoneInIntent.java index 305bd8033..e32166f68 100644 --- a/src/main/java/com/projectswg/holocore/intents/RequestZoneInIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/RequestZoneInIntent.java @@ -26,10 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class RequestZoneInIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/SetTitleIntent.java b/src/main/java/com/projectswg/holocore/intents/SetTitleIntent.java index cca87e297..063fa9fed 100644 --- a/src/main/java/com/projectswg/holocore/intents/SetTitleIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/SetTitleIntent.java @@ -26,33 +26,30 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.player.PlayerObject; - -import javax.annotation.Nonnull; +import me.joshlarson.jlcommon.control.Intent; public class SetTitleIntent extends Intent { private final String title; private final PlayerObject requester; - private SetTitleIntent(@Nonnull String title, @Nonnull PlayerObject requester) { + private SetTitleIntent(@NotNull String title, @NotNull PlayerObject requester) { this.title = title; this.requester = requester; } - @Nonnull + @NotNull public String getTitle() { return title; } - @Nonnull + @NotNull public PlayerObject getRequester() { return requester; } - public static void broadcast(@Nonnull String title, @Nonnull PlayerObject requester) { + public static void broadcast(@NotNull String title, @NotNull PlayerObject requester) { new SetTitleIntent(title, requester).broadcast(); } diff --git a/src/main/java/com/projectswg/holocore/intents/SkillModIntent.java b/src/main/java/com/projectswg/holocore/intents/SkillModIntent.java index 54bd9c429..47830d8ca 100644 --- a/src/main/java/com/projectswg/holocore/intents/SkillModIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/SkillModIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class SkillModIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/WatchIntent.java b/src/main/java/com/projectswg/holocore/intents/WatchIntent.java index 04ec4721f..0a7613f49 100644 --- a/src/main/java/com/projectswg/holocore/intents/WatchIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/WatchIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class WatchIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/chat/ChatAvatarRequestIntent.java b/src/main/java/com/projectswg/holocore/intents/chat/ChatAvatarRequestIntent.java index 094f3c1b7..d882282af 100644 --- a/src/main/java/com/projectswg/holocore/intents/chat/ChatAvatarRequestIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/chat/ChatAvatarRequestIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.chat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class ChatAvatarRequestIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/chat/ChatCommandIntent.java b/src/main/java/com/projectswg/holocore/intents/chat/ChatCommandIntent.java index 5763baae0..ab72f71c9 100644 --- a/src/main/java/com/projectswg/holocore/intents/chat/ChatCommandIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/chat/ChatCommandIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.chat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.commands.Command; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class ChatCommandIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/chat/ChatRoomUpdateIntent.java b/src/main/java/com/projectswg/holocore/intents/chat/ChatRoomUpdateIntent.java index f66baf7c3..487ce643d 100644 --- a/src/main/java/com/projectswg/holocore/intents/chat/ChatRoomUpdateIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/chat/ChatRoomUpdateIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.chat; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.encodables.chat.ChatAvatar; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class ChatRoomUpdateIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/chat/PersistentMessageIntent.java b/src/main/java/com/projectswg/holocore/intents/chat/PersistentMessageIntent.java index 0bf9bba29..7ab3a5df9 100644 --- a/src/main/java/com/projectswg/holocore/intents/chat/PersistentMessageIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/chat/PersistentMessageIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.chat; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.encodables.player.Mail; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.control.Intent; public class PersistentMessageIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/chat/SpatialChatIntent.java b/src/main/java/com/projectswg/holocore/intents/chat/SpatialChatIntent.java index e60ec54cf..65f2fd9e8 100644 --- a/src/main/java/com/projectswg/holocore/intents/chat/SpatialChatIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/chat/SpatialChatIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.chat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class SpatialChatIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/chat/SystemMessageIntent.java b/src/main/java/com/projectswg/holocore/intents/chat/SystemMessageIntent.java index e6f3fa273..49d1313dd 100644 --- a/src/main/java/com/projectswg/holocore/intents/chat/SystemMessageIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/chat/SystemMessageIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.chat; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class SystemMessageIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/CorpseLootedIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/CorpseLootedIntent.java index df416112d..95cb5d373 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/CorpseLootedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/CorpseLootedIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class CorpseLootedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/CreatureIncapacitatedIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/CreatureIncapacitatedIntent.java index e5f3e91d3..569c1b891 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/CreatureIncapacitatedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/CreatureIncapacitatedIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class CreatureIncapacitatedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/CreatureKilledIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/CreatureKilledIntent.java index 45146c0d2..b02fbb5d1 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/CreatureKilledIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/CreatureKilledIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class CreatureKilledIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/DeathblowIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/DeathblowIntent.java index 3a779ab86..ae3c18f87 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/DeathblowIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/DeathblowIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class DeathblowIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/DuelPlayerIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/DuelPlayerIntent.java index 9facd8057..37d9468f1 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/DuelPlayerIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/DuelPlayerIntent.java @@ -27,9 +27,8 @@ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class DuelPlayerIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/IncapacitateCreatureIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/IncapacitateCreatureIntent.java index c84e0e559..b4d641e23 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/IncapacitateCreatureIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/IncapacitateCreatureIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class IncapacitateCreatureIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/KillCreatureIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/KillCreatureIntent.java index 7fbb02a22..2b65ae134 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/KillCreatureIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/KillCreatureIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class KillCreatureIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/LootItemIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/LootItemIntent.java index 541bd95a5..94ea491c2 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/LootItemIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/LootItemIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.combat; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class LootItemIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/combat/loot/LootRequestIntent.java b/src/main/java/com/projectswg/holocore/intents/combat/loot/LootRequestIntent.java index 07c52f3e5..f12ed5a92 100644 --- a/src/main/java/com/projectswg/holocore/intents/combat/loot/LootRequestIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/combat/loot/LootRequestIntent.java @@ -27,9 +27,9 @@ package com.projectswg.holocore.intents.combat.loot; -import com.projectswg.common.control.Intent; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class LootRequestIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/connection/ForceLogoutIntent.java b/src/main/java/com/projectswg/holocore/intents/connection/ForceLogoutIntent.java index 7875ef088..024a84e5f 100644 --- a/src/main/java/com/projectswg/holocore/intents/connection/ForceLogoutIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/connection/ForceLogoutIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.connection; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class ForceLogoutIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/crafting/survey/SampleResourceIntent.java b/src/main/java/com/projectswg/holocore/intents/crafting/survey/SampleResourceIntent.java index 3d0a81ea6..a4e64f17e 100644 --- a/src/main/java/com/projectswg/holocore/intents/crafting/survey/SampleResourceIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/crafting/survey/SampleResourceIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.crafting.survey; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; +import me.joshlarson.jlcommon.control.Intent; public class SampleResourceIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyToolIntent.java b/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyToolIntent.java index 7b5cf215f..224c64c86 100644 --- a/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyToolIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyToolIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.crafting.survey; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class StartSurveyToolIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyingIntent.java b/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyingIntent.java index dea85cb05..a15749e57 100644 --- a/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyingIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/crafting/survey/StartSurveyingIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.crafting.survey; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; +import me.joshlarson.jlcommon.control.Intent; public class StartSurveyingIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/experience/ExperienceIntent.java b/src/main/java/com/projectswg/holocore/intents/experience/ExperienceIntent.java index 635b439f5..0a07c5fb2 100644 --- a/src/main/java/com/projectswg/holocore/intents/experience/ExperienceIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/experience/ExperienceIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.experience; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public final class ExperienceIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/experience/GrantSkillIntent.java b/src/main/java/com/projectswg/holocore/intents/experience/GrantSkillIntent.java index cc8c36d7c..b3633f88d 100644 --- a/src/main/java/com/projectswg/holocore/intents/experience/GrantSkillIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/experience/GrantSkillIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.experience; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public final class GrantSkillIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/experience/LevelChangedIntent.java b/src/main/java/com/projectswg/holocore/intents/experience/LevelChangedIntent.java index bf209741a..00c8622fd 100644 --- a/src/main/java/com/projectswg/holocore/intents/experience/LevelChangedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/experience/LevelChangedIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.experience; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public final class LevelChangedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/network/CloseConnectionIntent.java b/src/main/java/com/projectswg/holocore/intents/network/CloseConnectionIntent.java index b1ec208a3..b3a854257 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/CloseConnectionIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/CloseConnectionIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.network; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.network.DisconnectReason; +import me.joshlarson.jlcommon.control.Intent; public class CloseConnectionIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/network/ConnectionClosedIntent.java b/src/main/java/com/projectswg/holocore/intents/network/ConnectionClosedIntent.java index 392bbc9f7..4befebf96 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/ConnectionClosedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/ConnectionClosedIntent.java @@ -26,8 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.network; -import com.projectswg.common.control.Intent; import com.projectswg.common.network.packets.swg.holo.HoloConnectionStopped.ConnectionStoppedReason; +import me.joshlarson.jlcommon.control.Intent; public class ConnectionClosedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/network/ConnectionOpenedIntent.java b/src/main/java/com/projectswg/holocore/intents/network/ConnectionOpenedIntent.java index 27e4f6f26..b0b2da0c8 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/ConnectionOpenedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/ConnectionOpenedIntent.java @@ -26,7 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.network; -import com.projectswg.common.control.Intent; +import me.joshlarson.jlcommon.control.Intent; public class ConnectionOpenedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/network/GalacticPacketIntent.java b/src/main/java/com/projectswg/holocore/intents/network/GalacticPacketIntent.java index 1f1816152..6b9c8a546 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/GalacticPacketIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/GalacticPacketIntent.java @@ -27,28 +27,25 @@ package com.projectswg.holocore.intents.network; import com.projectswg.common.network.packets.SWGPacket; - import com.projectswg.holocore.intents.GalacticIntent; import com.projectswg.holocore.resources.player.Player; -import javax.annotation.Nonnull; - public class GalacticPacketIntent extends GalacticIntent { private final SWGPacket packet; private final Player player; - public GalacticPacketIntent(@Nonnull SWGPacket packet, @Nonnull Player player) { + public GalacticPacketIntent(@NotNull SWGPacket packet, @NotNull Player player) { this.packet = packet; this.player = player; } - @Nonnull + @NotNull public SWGPacket getPacket() { return packet; } - @Nonnull + @NotNull public Player getPlayer() { return player; } diff --git a/src/main/java/com/projectswg/holocore/intents/network/InboundPacketIntent.java b/src/main/java/com/projectswg/holocore/intents/network/InboundPacketIntent.java index 2a230ed6a..072a7db07 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/InboundPacketIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/InboundPacketIntent.java @@ -26,8 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.network; -import com.projectswg.common.control.Intent; import com.projectswg.common.network.packets.SWGPacket; +import me.joshlarson.jlcommon.control.Intent; public class InboundPacketIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/network/InboundPacketPendingIntent.java b/src/main/java/com/projectswg/holocore/intents/network/InboundPacketPendingIntent.java index 891e48136..9420ac335 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/InboundPacketPendingIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/InboundPacketPendingIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.network; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.services.network.NetworkClient; +import me.joshlarson.jlcommon.control.Intent; public class InboundPacketPendingIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/network/OutboundPacketIntent.java b/src/main/java/com/projectswg/holocore/intents/network/OutboundPacketIntent.java index ae2e2f587..d12892473 100644 --- a/src/main/java/com/projectswg/holocore/intents/network/OutboundPacketIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/network/OutboundPacketIntent.java @@ -26,8 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.network; -import com.projectswg.common.control.Intent; import com.projectswg.common.network.packets.SWGPacket; +import me.joshlarson.jlcommon.control.Intent; public class OutboundPacketIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/object/ContainerTransferIntent.java b/src/main/java/com/projectswg/holocore/intents/object/ContainerTransferIntent.java index 58ac5e3ac..546c24910 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/ContainerTransferIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/ContainerTransferIntent.java @@ -26,12 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.control.Intent; import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; public class ContainerTransferIntent extends Intent { @@ -39,28 +37,28 @@ public class ContainerTransferIntent extends Intent { private SWGObject container; private SWGObject oldContainer; - public ContainerTransferIntent(@Nonnull SWGObject obj, @CheckForNull SWGObject oldContainer, @CheckForNull SWGObject container) { + public ContainerTransferIntent(@NotNull SWGObject obj, @Nullable SWGObject oldContainer, @Nullable SWGObject container) { this.obj = obj; this.oldContainer = oldContainer; this.container = container; } - @Nonnull + @NotNull public SWGObject getObject() { return obj; } - @CheckForNull + @Nullable public SWGObject getContainer() { return container; } - @CheckForNull + @Nullable public SWGObject getOldContainer() { return oldContainer; } - public static void broadcast(@Nonnull SWGObject obj, @CheckForNull SWGObject oldContainer, @CheckForNull SWGObject newContainer) { + public static void broadcast(@NotNull SWGObject obj, @Nullable SWGObject oldContainer, @Nullable SWGObject newContainer) { new ContainerTransferIntent(obj, oldContainer, newContainer).broadcast(); } diff --git a/src/main/java/com/projectswg/holocore/intents/object/CreateStaticItemIntent.java b/src/main/java/com/projectswg/holocore/intents/object/CreateStaticItemIntent.java index 2224d037e..0c3c12e83 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/CreateStaticItemIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/CreateStaticItemIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.containers.ContainerPermissionsType; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.services.objects.StaticItemService.ObjectCreationHandler; +import me.joshlarson.jlcommon.control.Intent; public final class CreateStaticItemIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/object/DestroyObjectIntent.java b/src/main/java/com/projectswg/holocore/intents/object/DestroyObjectIntent.java index 3ab60dc6c..1d775d7e4 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/DestroyObjectIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/DestroyObjectIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.control.Intent; public class DestroyObjectIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/object/ForceAwarenessUpdateIntent.java b/src/main/java/com/projectswg/holocore/intents/object/ForceAwarenessUpdateIntent.java index 5d292ae59..f1633b02c 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/ForceAwarenessUpdateIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/ForceAwarenessUpdateIntent.java @@ -26,26 +26,23 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; - -import javax.annotation.Nonnull; +import me.joshlarson.jlcommon.control.Intent; public class ForceAwarenessUpdateIntent extends Intent { private final SWGObject obj; - public ForceAwarenessUpdateIntent(@Nonnull SWGObject obj) { + public ForceAwarenessUpdateIntent(@NotNull SWGObject obj) { this.obj = obj; } - @Nonnull + @NotNull public SWGObject getObject() { return obj; } - public static void broadcast(@Nonnull SWGObject obj) { + public static void broadcast(@NotNull SWGObject obj) { new ForceAwarenessUpdateIntent(obj).broadcast(); } diff --git a/src/main/java/com/projectswg/holocore/intents/object/MoveObjectIntent.java b/src/main/java/com/projectswg/holocore/intents/object/MoveObjectIntent.java index 8ce50d973..1d7ce05eb 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/MoveObjectIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/MoveObjectIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.location.Location; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.control.Intent; public class MoveObjectIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/object/ObjectCreatedIntent.java b/src/main/java/com/projectswg/holocore/intents/object/ObjectCreatedIntent.java index 1291a0a04..0c1e2bb88 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/ObjectCreatedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/ObjectCreatedIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.control.Intent; public class ObjectCreatedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/object/ObjectTeleportIntent.java b/src/main/java/com/projectswg/holocore/intents/object/ObjectTeleportIntent.java index ffebc1aa4..9c529e662 100644 --- a/src/main/java/com/projectswg/holocore/intents/object/ObjectTeleportIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/object/ObjectTeleportIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.object; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.location.Location; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.control.Intent; public class ObjectTeleportIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/player/CreatedCharacterIntent.java b/src/main/java/com/projectswg/holocore/intents/player/CreatedCharacterIntent.java index a7e53c9a5..0f921ccfa 100644 --- a/src/main/java/com/projectswg/holocore/intents/player/CreatedCharacterIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/player/CreatedCharacterIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.player; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class CreatedCharacterIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/player/DeleteCharacterIntent.java b/src/main/java/com/projectswg/holocore/intents/player/DeleteCharacterIntent.java index b8a1b639b..0efa7e34c 100644 --- a/src/main/java/com/projectswg/holocore/intents/player/DeleteCharacterIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/player/DeleteCharacterIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.player; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class DeleteCharacterIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/player/PlayerTransformedIntent.java b/src/main/java/com/projectswg/holocore/intents/player/PlayerTransformedIntent.java index d8af32f05..51e7e3e29 100644 --- a/src/main/java/com/projectswg/holocore/intents/player/PlayerTransformedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/player/PlayerTransformedIntent.java @@ -26,12 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.player; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class PlayerTransformedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/player/uniform/OpenUniformBoxIntent.java b/src/main/java/com/projectswg/holocore/intents/player/uniform/OpenUniformBoxIntent.java index 6684dd4b6..5b2074b36 100644 --- a/src/main/java/com/projectswg/holocore/intents/player/uniform/OpenUniformBoxIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/player/uniform/OpenUniformBoxIntent.java @@ -27,8 +27,8 @@ package com.projectswg.holocore.intents.player.uniform; -import com.projectswg.common.control.Intent; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class OpenUniformBoxIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/server/ConfigChangedIntent.java b/src/main/java/com/projectswg/holocore/intents/server/ConfigChangedIntent.java index aadcd51f1..d8c177e87 100644 --- a/src/main/java/com/projectswg/holocore/intents/server/ConfigChangedIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/server/ConfigChangedIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.server; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.config.ConfigFile; +import me.joshlarson.jlcommon.control.Intent; public final class ConfigChangedIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/server/ServerManagementIntent.java b/src/main/java/com/projectswg/holocore/intents/server/ServerManagementIntent.java index 1484e565f..7bb9784a5 100644 --- a/src/main/java/com/projectswg/holocore/intents/server/ServerManagementIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/server/ServerManagementIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.server; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; + +import java.util.concurrent.TimeUnit; public class ServerManagementIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/server/ServerStatusIntent.java b/src/main/java/com/projectswg/holocore/intents/server/ServerStatusIntent.java index 1dcfe657f..c1df332a0 100644 --- a/src/main/java/com/projectswg/holocore/intents/server/ServerStatusIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/server/ServerStatusIntent.java @@ -26,11 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.server; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.control.ServerStatus; +import me.joshlarson.jlcommon.control.Intent; + +import java.util.concurrent.TimeUnit; public class ServerStatusIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/sui/SuiWindowIntent.java b/src/main/java/com/projectswg/holocore/intents/sui/SuiWindowIntent.java index ab92eb7ae..f482d592c 100644 --- a/src/main/java/com/projectswg/holocore/intents/sui/SuiWindowIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/sui/SuiWindowIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.sui; -import com.projectswg.common.control.Intent; import com.projectswg.common.data.sui.SuiBaseWindow; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class SuiWindowIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/travel/TicketPurchaseIntent.java b/src/main/java/com/projectswg/holocore/intents/travel/TicketPurchaseIntent.java index 0b5a37dcc..c7b0e5f54 100644 --- a/src/main/java/com/projectswg/holocore/intents/travel/TicketPurchaseIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/travel/TicketPurchaseIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.travel; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public final class TicketPurchaseIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/travel/TicketUseIntent.java b/src/main/java/com/projectswg/holocore/intents/travel/TicketUseIntent.java index e5a1312e8..11bf4cb6f 100644 --- a/src/main/java/com/projectswg/holocore/intents/travel/TicketUseIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/travel/TicketUseIntent.java @@ -26,10 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.travel; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Intent; public class TicketUseIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/intents/travel/TravelPointSelectionIntent.java b/src/main/java/com/projectswg/holocore/intents/travel/TravelPointSelectionIntent.java index 2205b9c7b..bc34b45fb 100644 --- a/src/main/java/com/projectswg/holocore/intents/travel/TravelPointSelectionIntent.java +++ b/src/main/java/com/projectswg/holocore/intents/travel/TravelPointSelectionIntent.java @@ -26,9 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.intents.travel; -import com.projectswg.common.control.Intent; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Intent; public class TravelPointSelectionIntent extends Intent { diff --git a/src/main/java/com/projectswg/holocore/resources/buildout/BuildoutAreaGrid.java b/src/main/java/com/projectswg/holocore/resources/buildout/BuildoutAreaGrid.java index 76777c88b..ed4518768 100644 --- a/src/main/java/com/projectswg/holocore/resources/buildout/BuildoutAreaGrid.java +++ b/src/main/java/com/projectswg/holocore/resources/buildout/BuildoutAreaGrid.java @@ -26,12 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.buildout; +import com.projectswg.common.data.location.Terrain; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import com.projectswg.common.data.location.Terrain; - public class BuildoutAreaGrid { diff --git a/src/main/java/com/projectswg/holocore/resources/chat/ChatRange.java b/src/main/java/com/projectswg/holocore/resources/chat/ChatRange.java new file mode 100644 index 000000000..cafa6c002 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/chat/ChatRange.java @@ -0,0 +1,9 @@ +package com.projectswg.holocore.resources.chat; + +public enum ChatRange { + PERSONAL, + ROOM, + LOCAL, + TERRAIN, + GALAXY +} diff --git a/src/main/java/com/projectswg/holocore/resources/chat/ChatType.java b/src/main/java/com/projectswg/holocore/resources/chat/ChatType.java new file mode 100644 index 000000000..d9b9a0e3d --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/chat/ChatType.java @@ -0,0 +1,9 @@ +package com.projectswg.holocore.resources.chat; + +public enum ChatType { + MAIL, + TELL, + SYSTEM, + SPATIAL, + CHAT +} diff --git a/src/main/java/com/projectswg/holocore/resources/client_info/ServerFactory.java b/src/main/java/com/projectswg/holocore/resources/client_info/ServerFactory.java index a7292c394..8bb38953e 100644 --- a/src/main/java/com/projectswg/holocore/resources/client_info/ServerFactory.java +++ b/src/main/java/com/projectswg/holocore/resources/client_info/ServerFactory.java @@ -27,6 +27,13 @@ package com.projectswg.holocore.resources.client_info; +import com.projectswg.common.data.swgfile.ClientData; +import com.projectswg.common.data.swgfile.DataFactory; +import com.projectswg.common.data.swgfile.SWGFile; +import com.projectswg.common.data.swgfile.visitors.DatatableData; +import com.projectswg.common.data.swgfile.visitors.DatatableData.ColumnType; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -39,13 +46,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import com.projectswg.common.data.swgfile.ClientData; -import com.projectswg.common.data.swgfile.DataFactory; -import com.projectswg.common.data.swgfile.SWGFile; -import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.data.swgfile.visitors.DatatableData.ColumnType; -import com.projectswg.common.debug.Log; - /** * Created by Waverunner on 6/9/2015 diff --git a/src/main/java/com/projectswg/holocore/resources/collections/SWGBitSet.java b/src/main/java/com/projectswg/holocore/resources/collections/SWGBitSet.java index 7425de363..1a31395e9 100644 --- a/src/main/java/com/projectswg/holocore/resources/collections/SWGBitSet.java +++ b/src/main/java/com/projectswg/holocore/resources/collections/SWGBitSet.java @@ -26,15 +26,14 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.collections; -import java.util.BitSet; - import com.projectswg.common.encoding.Encodable; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.objects.SWGObject; +import java.util.BitSet; + public class SWGBitSet extends BitSet implements Encodable, Persistable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/projectswg/holocore/resources/collections/SWGFlag.java b/src/main/java/com/projectswg/holocore/resources/collections/SWGFlag.java index 0dc4cf0a8..49d5315f6 100644 --- a/src/main/java/com/projectswg/holocore/resources/collections/SWGFlag.java +++ b/src/main/java/com/projectswg/holocore/resources/collections/SWGFlag.java @@ -26,19 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.collections; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.BitSet; - import com.projectswg.common.encoding.Encodable; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.objects.SWGObject; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.BitSet; + public class SWGFlag extends BitSet implements Encodable, Persistable { private static final long serialVersionUID = 2L; diff --git a/src/main/java/com/projectswg/holocore/resources/collections/SWGList.java b/src/main/java/com/projectswg/holocore/resources/collections/SWGList.java index 1e9dc3419..0552d2768 100644 --- a/src/main/java/com/projectswg/holocore/resources/collections/SWGList.java +++ b/src/main/java/com/projectswg/holocore/resources/collections/SWGList.java @@ -26,13 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.collections; -import com.projectswg.common.concurrency.SynchronizedList; -import com.projectswg.common.debug.Log; import com.projectswg.common.encoding.Encodable; import com.projectswg.common.encoding.Encoder; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBuffer; import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.concurrency.SynchronizedList; +import me.joshlarson.jlcommon.log.Log; import java.lang.reflect.InvocationTargetException; import java.nio.ByteBuffer; diff --git a/src/main/java/com/projectswg/holocore/resources/collections/SWGMap.java b/src/main/java/com/projectswg/holocore/resources/collections/SWGMap.java index f699121da..e96e677d4 100644 --- a/src/main/java/com/projectswg/holocore/resources/collections/SWGMap.java +++ b/src/main/java/com/projectswg/holocore/resources/collections/SWGMap.java @@ -26,13 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.collections; -import com.projectswg.common.concurrency.SynchronizedMap; -import com.projectswg.common.debug.Log; import com.projectswg.common.encoding.Encodable; import com.projectswg.common.encoding.Encoder; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBuffer; import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.concurrency.SynchronizedMap; +import me.joshlarson.jlcommon.log.Log; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/src/main/java/com/projectswg/holocore/resources/collections/SWGSet.java b/src/main/java/com/projectswg/holocore/resources/collections/SWGSet.java index 646d2f897..1fbf560d3 100644 --- a/src/main/java/com/projectswg/holocore/resources/collections/SWGSet.java +++ b/src/main/java/com/projectswg/holocore/resources/collections/SWGSet.java @@ -26,14 +26,14 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.collections; -import com.projectswg.common.concurrency.SynchronizedList; -import com.projectswg.common.concurrency.SynchronizedSet; -import com.projectswg.common.debug.Log; import com.projectswg.common.encoding.Encodable; import com.projectswg.common.encoding.Encoder; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBuffer; import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.concurrency.SynchronizedList; +import me.joshlarson.jlcommon.concurrency.SynchronizedSet; +import me.joshlarson.jlcommon.log.Log; import java.lang.reflect.InvocationTargetException; import java.nio.ByteBuffer; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/CombatCommand.java b/src/main/java/com/projectswg/holocore/resources/commands/CombatCommand.java index 4a8f5b7d4..0d42a2c12 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/CombatCommand.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/CombatCommand.java @@ -26,13 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands; +import com.projectswg.common.data.combat.*; +import com.projectswg.holocore.resources.objects.weapon.WeaponType; + import java.util.HashMap; import java.util.Map; -import com.projectswg.common.data.combat.*; - -import com.projectswg.holocore.resources.objects.weapon.WeaponType; - public class CombatCommand extends Command { private ValidTarget validTarget; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AdminTeleportCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AdminTeleportCallback.java index 4c5c7ad0d..ac90254cf 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AdminTeleportCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AdminTeleportCallback.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.ObjectTeleportIntent; import com.projectswg.holocore.resources.commands.ICmdCallback; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AttributesCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AttributesCmdCallback.java index 06af83d14..0ae07344c 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AttributesCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/AttributesCmdCallback.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.network.packets.swg.zone.spatial.AttributeListMessage; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/FindFriendCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/FindFriendCallback.java index 5f6f523db..b260aeb39 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/FindFriendCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/FindFriendCallback.java @@ -27,14 +27,10 @@ package com.projectswg.holocore.resources.commands.callbacks; -import java.util.Locale; -import java.util.Map; - import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.oob.waypoint.WaypointColor; import com.projectswg.common.data.location.Location; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.commands.ICmdCallback; @@ -47,6 +43,9 @@ import com.projectswg.holocore.services.galaxy.GalacticManager; import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import java.util.Locale; +import java.util.Map; + /** * @author Waverunner */ diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/GotoCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/GotoCmdCallback.java index 044c1763d..5128dd7e1 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/GotoCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/GotoCmdCallback.java @@ -26,15 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands.callbacks; -import java.sql.ResultSet; -import java.sql.SQLException; - import com.projectswg.common.data.info.RelationalServerData; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.ObjectTeleportIntent; import com.projectswg.holocore.resources.commands.ICmdCallback; @@ -44,6 +39,10 @@ import com.projectswg.holocore.resources.objects.cell.CellObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.services.galaxy.GalacticManager; import com.projectswg.holocore.services.objects.ObjectManager; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.ResultSet; +import java.sql.SQLException; public class GotoCmdCallback implements ICmdCallback { diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/JumpCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/JumpCmdCallback.java index 55a6d2a1e..7790c26e6 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/JumpCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/JumpCmdCallback.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.network.packets.swg.zone.object_controller.JumpUpdate; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/KneelCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/KneelCmdCallback.java index 4268a046a..10aea2883 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/KneelCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/KneelCmdCallback.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.network.packets.swg.zone.object_controller.PostureUpdate; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/LogoutCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/LogoutCmdCallback.java index 4dbf0cecb..aeffdd0a6 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/LogoutCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/LogoutCmdCallback.java @@ -26,15 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands.callbacks; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.control.IntentChain; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.Posture; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.connection.ForceLogoutIntent; import com.projectswg.holocore.resources.commands.ICmdCallback; @@ -44,6 +38,10 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.player.PlayerState; import com.projectswg.holocore.services.galaxy.GalacticManager; import com.projectswg.holocore.utilities.ScheduledUtilities; +import me.joshlarson.jlcommon.control.IntentChain; +import me.joshlarson.jlcommon.log.Log; + +import java.util.concurrent.TimeUnit; public class LogoutCmdCallback implements ICmdCallback { diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ProneCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ProneCmdCallback.java index cb30ce3d5..8f86662f5 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ProneCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ProneCmdCallback.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.network.packets.swg.zone.object_controller.PostureUpdate; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/QaToolCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/QaToolCmdCallback.java index 32ae4203d..71785269e 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/QaToolCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/QaToolCmdCallback.java @@ -29,11 +29,7 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.CivilWarPointIntent; -import com.projectswg.holocore.resources.objects.player.PlayerObject; -import com.projectswg.holocore.scripts.commands.admin.qatool.QaToolDetails; import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.experience.ExperienceIntent; import com.projectswg.holocore.intents.network.CloseConnectionIntent; @@ -46,12 +42,15 @@ import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.network.DisconnectReason; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import com.projectswg.holocore.resources.objects.player.PlayerObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiMessageBox; +import com.projectswg.holocore.scripts.commands.admin.qatool.QaToolDetails; import com.projectswg.holocore.services.galaxy.GalacticManager; import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import me.joshlarson.jlcommon.log.Log; /** * Created by Waverunner on 8/19/2015 diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestBiographyCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestBiographyCmdCallback.java index 2663a73bc..db4a9b362 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestBiographyCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestBiographyCmdCallback.java @@ -26,14 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands.callbacks; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.object_controller.BiographyUpdate; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.services.galaxy.GalacticManager; +import me.joshlarson.jlcommon.log.Log; /** * diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestDraftSlotsCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestDraftSlotsCallback.java index 6b429ef99..5c4c7c952 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestDraftSlotsCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestDraftSlotsCallback.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.schematic.DraftSchematic; import com.projectswg.common.network.packets.swg.zone.object_controller.DraftSlotsQueryResponse; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestWaypointCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestWaypointCmdCallback.java index 5ea1f4aae..a48bc0aa0 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestWaypointCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/RequestWaypointCmdCallback.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.encodables.oob.waypoint.WaypointColor; import com.projectswg.common.data.location.Point3D; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.commands.ICmdCallback; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ServerCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ServerCmdCallback.java index 9f250e155..a78790113 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ServerCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/ServerCmdCallback.java @@ -26,11 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands.callbacks; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.server.ServerManagementIntent; import com.projectswg.holocore.intents.server.ServerManagementIntent.ServerManagementEvent; import com.projectswg.holocore.resources.commands.ICmdCallback; @@ -41,6 +36,10 @@ import com.projectswg.holocore.resources.sui.SuiInputBox; import com.projectswg.holocore.resources.sui.SuiListBox; import com.projectswg.holocore.resources.sui.SuiMessageBox; import com.projectswg.holocore.services.galaxy.GalacticManager; +import me.joshlarson.jlcommon.log.Log; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; public class ServerCmdCallback implements ICmdCallback { diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SitOnObjectCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SitOnObjectCmdCallback.java index e7affb365..2c1003601 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SitOnObjectCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SitOnObjectCmdCallback.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.data.location.Location; import com.projectswg.common.network.packets.swg.zone.object_controller.SitOnObject; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SocialInternalCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SocialInternalCmdCallback.java index 52d5f813e..87326fec6 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SocialInternalCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/SocialInternalCmdCallback.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.network.packets.swg.zone.object_controller.PlayerEmote; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StandCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StandCmdCallback.java index a4090605b..a21aa04e7 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StandCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StandCmdCallback.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.commands.callbacks; import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.network.packets.swg.zone.object_controller.PostureUpdate; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StartDanceCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StartDanceCallback.java index 025d0be6e..870b10bed 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StartDanceCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/StartDanceCallback.java @@ -26,9 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands.callbacks; -import java.util.Locale; -import java.util.Set; - import com.projectswg.holocore.resources.commands.ICmdCallback; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; @@ -37,6 +34,9 @@ import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiListBox; import com.projectswg.holocore.services.galaxy.GalacticManager; +import java.util.Locale; +import java.util.Set; + public class StartDanceCallback implements ICmdCallback { private static final String ABILITY_NAME_PREFIX = "startDance+"; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/TransferItemCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/TransferItemCallback.java index 0b2b118f5..a48a3d4ce 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/TransferItemCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/TransferItemCallback.java @@ -26,9 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.commands.callbacks; -import com.projectswg.common.debug.Assert; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; - import com.projectswg.holocore.intents.BuffIntent; import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.combat.LootItemIntent; diff --git a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/WaypointCmdCallback.java b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/WaypointCmdCallback.java index efdacdddb..f66318fce 100644 --- a/src/main/java/com/projectswg/holocore/resources/commands/callbacks/WaypointCmdCallback.java +++ b/src/main/java/com/projectswg/holocore/resources/commands/callbacks/WaypointCmdCallback.java @@ -30,7 +30,6 @@ import com.projectswg.common.data.encodables.oob.waypoint.WaypointColor; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Location.LocationBuilder; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.commands.ICmdCallback; diff --git a/src/main/java/com/projectswg/holocore/resources/location/InstanceLocation.java b/src/main/java/com/projectswg/holocore/resources/location/InstanceLocation.java index 93724e42b..60540a5e5 100644 --- a/src/main/java/com/projectswg/holocore/resources/location/InstanceLocation.java +++ b/src/main/java/com/projectswg/holocore/resources/location/InstanceLocation.java @@ -26,8 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.location; -import java.util.concurrent.atomic.AtomicReference; - import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Location.LocationBuilder; import com.projectswg.common.data.location.Point3D; @@ -35,10 +33,9 @@ import com.projectswg.common.data.location.Quaternion; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.objects.SWGObject; -import javax.annotation.Nonnull; +import java.util.concurrent.atomic.AtomicReference; public class InstanceLocation implements Persistable { @@ -106,17 +103,17 @@ public class InstanceLocation implements Persistable { setInstance(InstanceType.NONE, 0); } - @Nonnull + @NotNull public Location getLocation() { return location.get(); } - @Nonnull + @NotNull public Point3D getPosition() { return getLocation().getPosition(); } - @Nonnull + @NotNull public Terrain getTerrain() { return getLocation().getTerrain(); } diff --git a/src/main/java/com/projectswg/holocore/resources/network/BaselineBuilder.java b/src/main/java/com/projectswg/holocore/resources/network/BaselineBuilder.java index e9387ef0b..1f7867e6c 100644 --- a/src/main/java/com/projectswg/holocore/resources/network/BaselineBuilder.java +++ b/src/main/java/com/projectswg/holocore/resources/network/BaselineBuilder.java @@ -26,19 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.network; +import com.projectswg.common.encoding.Encodable; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.log.Log; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import com.projectswg.common.debug.Log; -import com.projectswg.common.encoding.Encodable; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.player.Player; - public class BaselineBuilder { public static final Charset ASCII = StandardCharsets.UTF_8; diff --git a/src/main/java/com/projectswg/holocore/resources/network/BaselineObject.java b/src/main/java/com/projectswg/holocore/resources/network/BaselineObject.java index 2c5c34bf0..18ab232e1 100644 --- a/src/main/java/com/projectswg/holocore/resources/network/BaselineObject.java +++ b/src/main/java/com/projectswg/holocore/resources/network/BaselineObject.java @@ -26,24 +26,20 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.network; +import com.projectswg.common.encoding.StringType; +import com.projectswg.common.network.NetBuffer; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.log.Log; + import java.lang.ref.SoftReference; import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; import java.util.ArrayList; import java.util.List; -import com.projectswg.common.debug.Log; -import com.projectswg.common.encoding.StringType; -import com.projectswg.common.network.NetBuffer; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; -import com.projectswg.common.utilities.ByteUtilities; - -import com.projectswg.holocore.resources.config.ConfigFile; -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.player.Player; -import com.projectswg.holocore.resources.server_info.DataManager; - public class BaselineObject { private transient final List> baselineData; diff --git a/src/main/java/com/projectswg/holocore/resources/network/DeltaBuilder.java b/src/main/java/com/projectswg/holocore/resources/network/DeltaBuilder.java index 662fd8f45..5d94f5733 100644 --- a/src/main/java/com/projectswg/holocore/resources/network/DeltaBuilder.java +++ b/src/main/java/com/projectswg/holocore/resources/network/DeltaBuilder.java @@ -30,7 +30,6 @@ import com.projectswg.common.encoding.Encoder; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; import com.projectswg.common.network.packets.swg.zone.deltas.DeltasMessage; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/network/UDPServer.java b/src/main/java/com/projectswg/holocore/resources/network/UDPServer.java index e35cd17c2..af5452436 100644 --- a/src/main/java/com/projectswg/holocore/resources/network/UDPServer.java +++ b/src/main/java/com/projectswg/holocore/resources/network/UDPServer.java @@ -26,18 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.network; +import me.joshlarson.jlcommon.log.Log; + import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.SocketException; -import java.net.UnknownHostException; +import java.net.*; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; -import com.projectswg.common.debug.Log; - /** * This class represents a UDP server that listens for SWGPackets and diff --git a/src/main/java/com/projectswg/holocore/resources/objects/Equipment.java b/src/main/java/com/projectswg/holocore/resources/objects/Equipment.java index 767d8f0dc..e73378151 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/Equipment.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/Equipment.java @@ -27,17 +27,16 @@ package com.projectswg.holocore.resources.objects; import com.projectswg.common.data.CRC; -import com.projectswg.common.debug.Log; import com.projectswg.common.encoding.Encodable; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.objects.weapon.WeaponObject; import com.projectswg.holocore.resources.persistable.SWGObjectFactory; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.log.Log; public class Equipment implements Encodable, Persistable { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/GameObjectType.java b/src/main/java/com/projectswg/holocore/resources/objects/GameObjectType.java index 5f57b4f77..fa436ee50 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/GameObjectType.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/GameObjectType.java @@ -26,11 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; + import java.util.HashMap; import java.util.Map; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - public enum GameObjectType { GOT_NONE (0x00000000, null), GOT_CORPSE (0x00000001, BaselineType.TANO), diff --git a/src/main/java/com/projectswg/holocore/resources/objects/SWGObject.java b/src/main/java/com/projectswg/holocore/resources/objects/SWGObject.java index 4a886931a..d19819310 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/SWGObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/SWGObject.java @@ -26,14 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects; -import com.projectswg.common.concurrency.SynchronizedMap; import com.projectswg.common.data.CRC; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.swgfile.visitors.ObjectData.ObjectDataAttribute; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.SWGPacket; @@ -56,11 +53,11 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.services.CoreManager; import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.utilities.ScheduledUtilities; +import me.joshlarson.jlcommon.log.Log; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -71,10 +68,10 @@ public abstract class SWGObject extends BaselineObject implements Comparable containedObjects= new CopyOnWriteArraySet<>(); - private final Map slots = new SynchronizedMap<>(); - private final Map attributes = new SynchronizedMap<>(new LinkedHashMap<>()); + private final Map slots = Collections.synchronizedMap(new HashMap<>()); + private final Map attributes = Collections.synchronizedMap(new LinkedHashMap<>()); private final ObjectAware awareness = new ObjectAware(this); - private final Map dataAttributes = new ConcurrentHashMap<>(); + private final Map dataAttributes = new EnumMap<>(ObjectDataAttribute.class); private final AtomicInteger updateCounter = new AtomicInteger(1); private ObjectClassification classification = ObjectClassification.GENERATED; @@ -204,7 +201,7 @@ public abstract class SWGObject extends BaselineObject implements Comparable> awareness; private final AtomicReference chunk; - public ObjectAware(@Nonnull SWGObject obj) { + public ObjectAware(@NotNull SWGObject obj) { this.object = obj; this.awareness = new EnumMap<>(AwarenessType.class); this.chunk = new AtomicReference<>(null); @@ -55,7 +56,7 @@ public class ObjectAware { } } - public void setAware(@Nonnull AwarenessType type, @Nonnull Collection objects) { + public void setAware(@NotNull AwarenessType type, @NotNull Collection objects) { Set oldAware = awareness.put(type, createSet(objects)); Map awareCounts = getAwareCounts(); oldAware.removeAll(objects); @@ -77,18 +78,18 @@ public class ObjectAware { attemptFlush(); } - @Nonnull + @NotNull public Set getObservers() { return getAwareStream().map(SWGObject::getOwnerShallow).filter(Objects::nonNull).collect(Collectors.toSet()); } - @Nonnull + @NotNull public Set getAware() { return getAwareStream().collect(Collectors.toSet()); } - @Nonnull - public Set getAware(@Nonnull AwarenessType type) { + @NotNull + public Set getAware(@NotNull AwarenessType type) { return awareness.getOrDefault(type, EMPTY_SET); } @@ -96,12 +97,12 @@ public class ObjectAware { return this.chunk.getAndSet(chunk); } - @CheckForNull + @Nullable protected TerrainMapChunk getTerrainMapChunk() { return chunk.get(); } - private void addAware(@Nonnull AwarenessType type, @Nonnull SWGObject obj) { + private void addAware(@NotNull AwarenessType type, @NotNull SWGObject obj) { Set aware = awareness.get(type); if (aware.add(obj)) { Map awareCounts = getAwareCounts(); @@ -114,7 +115,7 @@ public class ObjectAware { } - private void removeAware(@Nonnull AwarenessType type, @Nonnull SWGObject obj) { + private void removeAware(@NotNull AwarenessType type, @NotNull SWGObject obj) { Set aware = awareness.get(type); if (aware.remove(obj)) { if (getAwareStream().noneMatch(test -> test.equals(obj))) { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/awareness/ObjectAwareness.java b/src/main/java/com/projectswg/holocore/resources/objects/awareness/ObjectAwareness.java index 1ec896b26..c9505eaf5 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/awareness/ObjectAwareness.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/awareness/ObjectAwareness.java @@ -33,9 +33,6 @@ import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.creature.CreatureState; -import javax.annotation.Nonnull; -import java.util.Collections; - public class ObjectAwareness { private final TerrainMap[] terrains; @@ -52,7 +49,7 @@ public class ObjectAwareness { * * @param obj the object created */ - public void createObject(@Nonnull SWGObject obj) { + public void createObject(@NotNull SWGObject obj) { if (AwarenessUtilities.isInAwareness(obj) && obj.getParent() == null) { TerrainMap map = getTerrainMap(obj); map.add(obj); @@ -65,7 +62,7 @@ public class ObjectAwareness { * * @param obj the object destroyed */ - public void destroyObject(@Nonnull SWGObject obj) { + public void destroyObject(@NotNull SWGObject obj) { TerrainMap map = getTerrainMap(obj); map.remove(obj); map.update(obj); @@ -76,7 +73,7 @@ public class ObjectAwareness { * * @param obj the object to update */ - public void updateObject(@Nonnull SWGObject obj) { + public void updateObject(@NotNull SWGObject obj) { SWGObject superParent = obj.getSuperParent(); TerrainMap map = getTerrainMap(obj); if (superParent != null) { @@ -89,12 +86,12 @@ public class ObjectAwareness { map.update(obj); } - @Nonnull + @NotNull private TerrainMap getTerrainMap(SWGObject obj) { return terrains[obj.getTerrain().ordinal()]; } - private static boolean isRider(@Nonnull SWGObject obj, SWGObject parent) { + private static boolean isRider(@NotNull SWGObject obj, SWGObject parent) { return obj.getParent() != parent && !(obj.getBaselineType() == BaselineType.CREO && ((CreatureObject) obj).isStatesBitmask(CreatureState.RIDING_MOUNT)); } diff --git a/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMap.java b/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMap.java index ef726b1d3..ca1ef851e 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMap.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMap.java @@ -27,11 +27,8 @@ package com.projectswg.holocore.resources.objects.awareness; import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.player.PlayerObject; -import javax.annotation.Nonnull; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -78,7 +75,7 @@ public class TerrainMap { } } - @Nonnull + @NotNull private Collection getAware(SWGObject obj) { SWGObject superParent = obj.getSuperParent(); Set aware; @@ -93,7 +90,7 @@ public class TerrainMap { return aware; } - @Nonnull + @NotNull private Set getNearbyAware(SWGObject obj) { if (obj.getAwareness().getTerrainMapChunk() == null || !AwarenessUtilities.isInAwareness(obj)) return new HashSet<>(); @@ -129,7 +126,7 @@ public class TerrainMap { return aware; } - private static void recursiveAdd(@Nonnull Collection aware, @Nonnull SWGObject obj) { + private static void recursiveAdd(@NotNull Collection aware, @NotNull SWGObject obj) { aware.add(obj); for (SWGObject child : obj.getSlottedObjects()) { recursiveAdd(aware, child); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMapChunk.java b/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMapChunk.java index 255c5e5dc..4715ce9d4 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMapChunk.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/awareness/TerrainMapChunk.java @@ -27,9 +27,7 @@ package com.projectswg.holocore.resources.objects.awareness; import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import javax.annotation.Nonnull; import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -42,16 +40,16 @@ class TerrainMapChunk { this.objects = new CopyOnWriteArrayList<>(); } - public void addObject(@Nonnull SWGObject obj) { + public void addObject(@NotNull SWGObject obj) { assert !objects.contains(obj) : "the chunk already contains this object"; objects.add(obj); } - public void removeObject(@Nonnull SWGObject obj) { + public void removeObject(@NotNull SWGObject obj) { objects.remove(obj); } - public void getWithinAwareness(@Nonnull SWGObject obj, @Nonnull Collection withinRange) { + public void getWithinAwareness(@NotNull SWGObject obj, @NotNull Collection withinRange) { int truncX = obj.getTruncX(); int truncZ = obj.getTruncZ(); int instance = obj.getInstanceLocation().getInstanceNumber(); @@ -74,7 +72,7 @@ class TerrainMapChunk { } } - private static void recursiveAdd(@Nonnull Collection withinRange, @Nonnull SWGObject obj, @Nonnull SWGObject test) { + private static void recursiveAdd(@NotNull Collection withinRange, @NotNull SWGObject obj, @NotNull SWGObject test) { if (!test.isVisible(obj)) return; withinRange.add(test); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/building/BuildingObject.java b/src/main/java/com/projectswg/holocore/resources/objects/building/BuildingObject.java index 833a00ea9..2aa1caa1f 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/building/BuildingObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/building/BuildingObject.java @@ -26,25 +26,21 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.building; +import com.projectswg.common.data.swgfile.ClientFactory; +import com.projectswg.common.data.swgfile.visitors.ObjectData.ObjectDataAttribute; +import com.projectswg.common.data.swgfile.visitors.PortalLayoutData; +import com.projectswg.common.network.NetBufferStream; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.objects.cell.CellObject; +import com.projectswg.holocore.resources.objects.tangible.TangibleObject; +import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.concurrency.SynchronizedMap; + import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import com.projectswg.common.concurrency.SynchronizedMap; -import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.data.swgfile.visitors.ObjectData.ObjectDataAttribute; -import com.projectswg.common.data.swgfile.visitors.PortalLayoutData; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.network.NetBufferStream; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.cell.CellObject; -import com.projectswg.holocore.resources.objects.tangible.TangibleObject; -import com.projectswg.holocore.resources.player.Player; -import com.projectswg.holocore.services.objects.ObjectCreator; public class BuildingObject extends TangibleObject { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/BuildoutLoader.java b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/BuildoutLoader.java index 8e136c235..41deff5d5 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/BuildoutLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/BuildoutLoader.java @@ -26,20 +26,14 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.buildouts; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; - import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.CrcStringTableData; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.resources.objects.SWGObject; +import me.joshlarson.jlcommon.log.Log; + +import java.util.*; public class BuildoutLoader { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SnapshotLoader.java b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SnapshotLoader.java index 36e67819a..9a84b4b68 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SnapshotLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SnapshotLoader.java @@ -26,17 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.buildouts; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.resources.objects.SWGObject; +import java.util.*; + public class SnapshotLoader { private static final Set TERRAINS = EnumSet.of( diff --git a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SwgBuildoutRow.java b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SwgBuildoutRow.java index 302b2d5bb..51f2a5495 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SwgBuildoutRow.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/SwgBuildoutRow.java @@ -26,12 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.buildouts; -import java.util.concurrent.atomic.AtomicReference; - import com.projectswg.common.data.CRC; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.swgfile.visitors.CrcStringTableData; +import java.util.concurrent.atomic.AtomicReference; + public class SwgBuildoutRow { private static final int cellCrc = CRC.getCrc("object/cell/shared_cell.iff"); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainBuildoutLoader.java b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainBuildoutLoader.java index 05dcf6eed..5f783d73b 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainBuildoutLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainBuildoutLoader.java @@ -26,22 +26,21 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.buildouts; -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.CrcStringTableData; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.SWGObject.ObjectClassification; import com.projectswg.holocore.resources.objects.cell.CellObject; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.log.Log; + +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; class TerrainBuildoutLoader { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainSnapshotLoader.java b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainSnapshotLoader.java index 0fffd3a34..7de9bcdb0 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainSnapshotLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/buildouts/TerrainSnapshotLoader.java @@ -26,23 +26,22 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.buildouts; -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.WorldSnapshotData; import com.projectswg.common.data.swgfile.visitors.WorldSnapshotData.Node; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.SWGObject.ObjectClassification; import com.projectswg.holocore.resources.objects.building.BuildingObject; import com.projectswg.holocore.resources.objects.cell.CellObject; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.log.Log; + +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; public class TerrainSnapshotLoader { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObject.java b/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObject.java index ad969f8eb..9f4479d67 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObject.java @@ -29,9 +29,6 @@ package com.projectswg.holocore.resources.objects.creature; import com.projectswg.common.data.CRC; import com.projectswg.common.data.HologramColour; import com.projectswg.common.data.encodables.tangible.Posture; -import com.projectswg.common.data.encodables.tangible.PvpFaction; -import com.projectswg.common.data.encodables.tangible.PvpStatus; -import com.projectswg.common.data.encodables.tangible.PvpFlag; import com.projectswg.common.data.encodables.tangible.Race; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBuffer; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectAwareness.java b/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectAwareness.java index 82dc41306..376ee9b22 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectAwareness.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectAwareness.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.objects.creature; import com.projectswg.common.data.encodables.tangible.PvpFlag; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.*; import com.projectswg.common.network.packets.swg.zone.building.UpdateCellPermissionMessage; import com.projectswg.holocore.intents.FactionIntent; @@ -38,7 +37,6 @@ import com.projectswg.holocore.resources.objects.cell.CellObject; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.player.Player; -import javax.annotation.Nonnull; import java.util.*; public class CreatureObjectAwareness { @@ -53,7 +51,7 @@ public class CreatureObjectAwareness { this.pendingRemove = new HashSet<>(); } - public synchronized void addAware(@Nonnull SWGObject obj) { + public synchronized void addAware(@NotNull SWGObject obj) { if (pendingRemove.remove(obj) || aware.contains(obj)) return; pendingAdd.add(obj); @@ -62,7 +60,7 @@ public class CreatureObjectAwareness { } } - public synchronized void removeAware(@Nonnull SWGObject obj) { + public synchronized void removeAware(@NotNull SWGObject obj) { if (pendingAdd.remove(obj) || !aware.contains(obj)) return; if (pendingRemove.add(obj)) { @@ -131,7 +129,7 @@ public class CreatureObjectAwareness { } } - private static void createObject(@Nonnull SWGObject obj, @Nonnull Player target) { + private static void createObject(@NotNull SWGObject obj, @NotNull Player target) { long id = obj.getObjectId(); { // SceneCreateObjectByCrc SceneCreateObjectByCrc create = new SceneCreateObjectByCrc(); @@ -181,7 +179,7 @@ public class CreatureObjectAwareness { } } - private static void destroyObject(@Nonnull SWGObject obj, @Nonnull Player target) { + private static void destroyObject(@NotNull SWGObject obj, @NotNull Player target) { target.sendPacket(new SceneDestroyObject(obj.getObjectId())); } diff --git a/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectSharedNP.java b/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectSharedNP.java index b4d1c15f1..1497d32ae 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectSharedNP.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/creature/CreatureObjectSharedNP.java @@ -26,18 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.creature; -import java.util.ArrayList; -import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.stream.Stream; - import com.projectswg.common.data.CRC; import com.projectswg.common.data.HologramColour; -import com.projectswg.common.debug.Assert; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.collections.SWGList; import com.projectswg.holocore.resources.collections.SWGMap; import com.projectswg.holocore.resources.network.BaselineBuilder; @@ -48,6 +41,11 @@ import com.projectswg.holocore.resources.persistable.SWGObjectFactory; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.services.group.GroupInviterData; +import java.util.ArrayList; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; + class CreatureObjectSharedNP implements Persistable { private transient GroupInviterData inviterData = new GroupInviterData(0, null, "", 0); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/custom/AIObject.java b/src/main/java/com/projectswg/holocore/resources/objects/custom/AIObject.java index 4c239ff93..b52d9b26f 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/custom/AIObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/custom/AIObject.java @@ -26,18 +26,17 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.custom; +import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import com.projectswg.holocore.utilities.ScheduledUtilities; + import java.util.Collections; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.utilities.ScheduledUtilities; - public abstract class AIObject extends CreatureObject { private final Set playersNearby; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/custom/LoiterAIObject.java b/src/main/java/com/projectswg/holocore/resources/objects/custom/LoiterAIObject.java index 081133442..42579d4bf 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/custom/LoiterAIObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/custom/LoiterAIObject.java @@ -26,14 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.custom; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; - import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Location.LocationBuilder; - import com.projectswg.holocore.intents.object.MoveObjectIntent; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; + /** * AI object that loiters the area */ diff --git a/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolAIObject.java b/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolAIObject.java index 95870e437..34131fbdb 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolAIObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolAIObject.java @@ -26,16 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.custom; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import com.projectswg.common.data.location.Location; - import com.projectswg.holocore.intents.object.MoveObjectIntent; import com.projectswg.holocore.resources.server_info.loader.npc.NpcPatrolRouteLoader.PatrolType; import com.projectswg.holocore.resources.spawn.Spawner.ResolvedPatrolWaypoint; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + /** * AI object that patrols the specified route */ diff --git a/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolGroup.java b/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolGroup.java index a09003a1a..6522b2460 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolGroup.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/custom/PatrolGroup.java @@ -26,12 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.custom; +import com.projectswg.holocore.resources.server_info.loader.spawn.StaticSpawnLoader.PatrolFormation; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.projectswg.holocore.resources.server_info.loader.spawn.StaticSpawnLoader.PatrolFormation; - public class PatrolGroup { private final List objects; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/custom/RandomAIObject.java b/src/main/java/com/projectswg/holocore/resources/objects/custom/RandomAIObject.java index b0352970c..6ac3190f1 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/custom/RandomAIObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/custom/RandomAIObject.java @@ -26,10 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.custom; -import java.util.concurrent.TimeUnit; - import com.projectswg.common.data.location.Location; +import java.util.concurrent.TimeUnit; + /** * Boring AI object that just sits in the same location. aiLoop() can be extended for other AI objects that want random movements */ diff --git a/src/main/java/com/projectswg/holocore/resources/objects/custom/TurningAIObject.java b/src/main/java/com/projectswg/holocore/resources/objects/custom/TurningAIObject.java index d73ba4bd6..204bbaea9 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/custom/TurningAIObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/custom/TurningAIObject.java @@ -26,13 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.custom; +import com.projectswg.common.data.location.Location; +import com.projectswg.holocore.intents.object.MoveObjectIntent; + import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; -import com.projectswg.common.data.location.Location; - -import com.projectswg.holocore.intents.object.MoveObjectIntent; - /** * AI object that loiters the area */ diff --git a/src/main/java/com/projectswg/holocore/resources/objects/factory/FactoryObject.java b/src/main/java/com/projectswg/holocore/resources/objects/factory/FactoryObject.java index 553c932f3..e16ea43f3 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/factory/FactoryObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/factory/FactoryObject.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.objects.factory; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.objects.tangible.TangibleObject; public class FactoryObject extends TangibleObject { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/group/GroupObject.java b/src/main/java/com/projectswg/holocore/resources/objects/group/GroupObject.java index ff90ff668..daaccbe21 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/group/GroupObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/group/GroupObject.java @@ -26,23 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.group; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import com.projectswg.common.concurrency.SynchronizedMap; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Assert; import com.projectswg.common.encoding.Encodable; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; - import com.projectswg.holocore.intents.GroupEventIntent; import com.projectswg.holocore.intents.GroupEventIntent.GroupEventType; import com.projectswg.holocore.resources.collections.SWGList; @@ -53,6 +41,12 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiMessageBox; +import me.joshlarson.jlcommon.concurrency.SynchronizedMap; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; +import java.util.stream.Collectors; public class GroupObject extends SWGObject { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/guild/GuildObject.java b/src/main/java/com/projectswg/holocore/resources/objects/guild/GuildObject.java index 66bb65d32..b61b9a7ff 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/guild/GuildObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/guild/GuildObject.java @@ -30,7 +30,6 @@ import com.projectswg.common.encoding.Encodable; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.collections.SWGMap; import com.projectswg.holocore.resources.collections.SWGSet; import com.projectswg.holocore.resources.network.BaselineBuilder; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/installation/InstallationObject.java b/src/main/java/com/projectswg/holocore/resources/objects/installation/InstallationObject.java index 7f4368a2b..44f0bd669 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/installation/InstallationObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/installation/InstallationObject.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.resources.objects.installation; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/intangible/IntangibleObject.java b/src/main/java/com/projectswg/holocore/resources/objects/intangible/IntangibleObject.java index 8d2c16250..6a456f737 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/intangible/IntangibleObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/intangible/IntangibleObject.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.resources.objects.intangible; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/manufacture/ManufactureSchematicObject.java b/src/main/java/com/projectswg/holocore/resources/objects/manufacture/ManufactureSchematicObject.java index bbf66091d..969dd4998 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/manufacture/ManufactureSchematicObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/manufacture/ManufactureSchematicObject.java @@ -26,19 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.manufacture; -import java.util.Map.Entry; - import com.projectswg.common.data.CRC; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.collections.SWGMap; import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.intangible.IntangibleObject; import com.projectswg.holocore.resources.player.Player; +import java.util.Map.Entry; + public class ManufactureSchematicObject extends IntangibleObject { private SWGMap attributes = new SWGMap<>(3, 5); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/mission/MissionObject.java b/src/main/java/com/projectswg/holocore/resources/objects/mission/MissionObject.java index 2731f6984..751472de4 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/mission/MissionObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/mission/MissionObject.java @@ -36,7 +36,6 @@ import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.intangible.IntangibleObject; import com.projectswg.holocore.resources.objects.waypoint.WaypointObject; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObject.java b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObject.java index b72a3e018..bfb056610 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObject.java @@ -31,8 +31,6 @@ import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; import com.projectswg.holocore.resources.collections.SWGMap; import com.projectswg.holocore.resources.network.BaselineBuilder; -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.creature.CreatureObjectAwareness; import com.projectswg.holocore.resources.objects.intangible.IntangibleObject; import com.projectswg.holocore.resources.objects.waypoint.WaypointObject; import com.projectswg.holocore.resources.player.AccessLevel; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivate.java b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivate.java index 12eba00d1..9b447ea37 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivate.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivate.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.resources.objects.player; import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.resources.collections.SWGBitSet; import com.projectswg.holocore.resources.collections.SWGMap; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivateNP.java b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivateNP.java index 4bc0983d6..aa77273ce 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivateNP.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectPrivateNP.java @@ -26,14 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.player; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - import com.projectswg.common.encoding.StringType; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.collections.SWGList; import com.projectswg.holocore.resources.collections.SWGMap; import com.projectswg.holocore.resources.collections.SWGSet; @@ -41,6 +36,10 @@ import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + class PlayerObjectPrivateNP implements Persistable { private int experimentFlag = 0; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectShared.java b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectShared.java index 16e270d05..271a7bbc9 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectShared.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectShared.java @@ -26,11 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.player; -import java.util.BitSet; - import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.collections.SWGBitSet; import com.projectswg.holocore.resources.collections.SWGFlag; import com.projectswg.holocore.resources.network.BaselineBuilder; @@ -39,6 +36,8 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.player.PlayerFlags; import com.projectswg.holocore.utilities.MathUtils; +import java.util.BitSet; + class PlayerObjectShared implements Persistable { private final SWGFlag flagsList = new SWGFlag(3, 5); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectSharedNP.java b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectSharedNP.java index 725d2f46e..a57216379 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectSharedNP.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/player/PlayerObjectSharedNP.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.objects.player; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.player.AccessLevel; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/resource/ResourceContainerObject.java b/src/main/java/com/projectswg/holocore/resources/objects/resource/ResourceContainerObject.java index e8e2d9442..2a877f230 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/resource/ResourceContainerObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/resource/ResourceContainerObject.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.objects.resource; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/ship/ShipObject.java b/src/main/java/com/projectswg/holocore/resources/objects/ship/ShipObject.java index 912efcdec..761a5bf45 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/ship/ShipObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/ship/ShipObject.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.objects.ship; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.objects.tangible.TangibleObject; public class ShipObject extends TangibleObject { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/sound/SoundObject.java b/src/main/java/com/projectswg/holocore/resources/objects/sound/SoundObject.java index b09b5e446..9901cfe7c 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/sound/SoundObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/sound/SoundObject.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.resources.objects.sound; import com.projectswg.common.network.NetBufferStream; - import com.projectswg.holocore.resources.objects.staticobject.StaticObject; public class SoundObject extends StaticObject { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/staticobject/StaticObject.java b/src/main/java/com/projectswg/holocore/resources/objects/staticobject/StaticObject.java index a042fbdd1..832772aaf 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/staticobject/StaticObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/staticobject/StaticObject.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.resources.objects.staticobject; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.objects.SWGObject; public class StaticObject extends SWGObject { diff --git a/src/main/java/com/projectswg/holocore/resources/objects/tangible/CreditObject.java b/src/main/java/com/projectswg/holocore/resources/objects/tangible/CreditObject.java index 9d9ec3066..ddfc41808 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/tangible/CreditObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/tangible/CreditObject.java @@ -26,19 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.tangible; -import java.util.Collections; -import java.util.Set; - -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.object.ContainerTransferIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.resources.containers.ContainerResult; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.player.Player; -import com.projectswg.holocore.utilities.AwarenessUtilities; +import me.joshlarson.jlcommon.log.Log; public class CreditObject extends TangibleObject { private long amount; diff --git a/src/main/java/com/projectswg/holocore/resources/objects/tangible/TangibleObject.java b/src/main/java/com/projectswg/holocore/resources/objects/tangible/TangibleObject.java index 2bc8c4576..1400088a7 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/tangible/TangibleObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/tangible/TangibleObject.java @@ -26,9 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.objects.tangible; -import java.util.Map; -import java.util.Set; - import com.projectswg.common.data.customization.CustomizationString; import com.projectswg.common.data.customization.CustomizationVariable; import com.projectswg.common.data.encodables.tangible.PvpFaction; @@ -48,6 +45,9 @@ import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; +import java.util.Map; +import java.util.Set; + public class TangibleObject extends SWGObject { private CustomizationString appearanceData = new CustomizationString(); diff --git a/src/main/java/com/projectswg/holocore/resources/objects/weapon/WeaponObject.java b/src/main/java/com/projectswg/holocore/resources/objects/weapon/WeaponObject.java index 41a5e5767..c587b5e8e 100644 --- a/src/main/java/com/projectswg/holocore/resources/objects/weapon/WeaponObject.java +++ b/src/main/java/com/projectswg/holocore/resources/objects/weapon/WeaponObject.java @@ -30,7 +30,6 @@ import com.projectswg.common.data.combat.DamageType; import com.projectswg.common.network.NetBuffer; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.resources.network.BaselineBuilder; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/persistable/SWGObjectFactory.java b/src/main/java/com/projectswg/holocore/resources/persistable/SWGObjectFactory.java index 8f7c088d3..217581ac9 100644 --- a/src/main/java/com/projectswg/holocore/resources/persistable/SWGObjectFactory.java +++ b/src/main/java/com/projectswg/holocore/resources/persistable/SWGObjectFactory.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.resources.persistable; import com.projectswg.common.network.NetBufferStream; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.services.objects.ObjectCreator; diff --git a/src/main/java/com/projectswg/holocore/resources/player/Player.java b/src/main/java/com/projectswg/holocore/resources/player/Player.java index 17f20ce55..72efcdd24 100644 --- a/src/main/java/com/projectswg/holocore/resources/player/Player.java +++ b/src/main/java/com/projectswg/holocore/resources/player/Player.java @@ -26,21 +26,20 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.player; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.atomic.AtomicBoolean; - -import com.projectswg.common.control.IntentChain; -import com.projectswg.common.control.Service; import com.projectswg.common.network.packets.SWGPacket; - import com.projectswg.common.network.packets.swg.zone.deltas.DeltasMessage; import com.projectswg.holocore.intents.network.OutboundPacketIntent; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.player.PlayerObject; import com.projectswg.holocore.services.player.PlayerManager; +import me.joshlarson.jlcommon.control.IntentChain; +import me.joshlarson.jlcommon.control.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.atomic.AtomicBoolean; public class Player implements Comparable { diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/BasicLogStream.java b/src/main/java/com/projectswg/holocore/resources/server_info/BasicLogStream.java index bcb5cb7a3..1cfe759e8 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/BasicLogStream.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/BasicLogStream.java @@ -26,17 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; +import me.joshlarson.jlcommon.log.Log; + +import java.io.*; import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; -import com.projectswg.common.debug.Log; - public class BasicLogStream { private final Object streamMutex; diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/CachedObjectDatabase.java b/src/main/java/com/projectswg/holocore/resources/server_info/CachedObjectDatabase.java index 87dd98f93..0d2614104 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/CachedObjectDatabase.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/CachedObjectDatabase.java @@ -26,18 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import com.projectswg.common.debug.Log; import com.projectswg.common.persistable.InputPersistenceStream; import com.projectswg.common.persistable.InputPersistenceStream.PersistableCreator; import com.projectswg.common.persistable.OutputPersistenceStream; import com.projectswg.common.persistable.OutputPersistenceStream.PersistableSaver; import com.projectswg.common.persistable.Persistable; +import me.joshlarson.jlcommon.log.Log; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; public class CachedObjectDatabase extends ObjectDatabase { diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/ConfigWatcher.java b/src/main/java/com/projectswg/holocore/resources/server_info/ConfigWatcher.java index 1a1e809d1..cb9dcbb4a 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/ConfigWatcher.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/ConfigWatcher.java @@ -26,38 +26,31 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; +import com.projectswg.common.data.info.Config; +import com.projectswg.holocore.intents.server.ConfigChangedIntent; +import com.projectswg.holocore.resources.config.ConfigFile; +import me.joshlarson.jlcommon.concurrency.BasicThread; +import me.joshlarson.jlcommon.log.Log; + import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardWatchEventKinds; -import java.nio.file.WatchEvent; -import java.nio.file.WatchKey; -import java.nio.file.WatchService; +import java.nio.file.*; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; -import com.projectswg.common.concurrency.PswgBasicThread; -import com.projectswg.common.data.info.Config; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.intents.server.ConfigChangedIntent; -import com.projectswg.holocore.resources.config.ConfigFile; - public final class ConfigWatcher { private static final String CFGPATH = "cfg/"; private final Map configMap; - private final PswgBasicThread watcherThread; + private final BasicThread watcherThread; private final AtomicBoolean running; private WatchService watcher; public ConfigWatcher(Map configMap) { this.configMap = configMap; - this.watcherThread = new PswgBasicThread("config-watcher", this::watch); + this.watcherThread = new BasicThread("config-watcher", this::watch); this.running = new AtomicBoolean(false); try { diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/DataManager.java b/src/main/java/com/projectswg/holocore/resources/server_info/DataManager.java index 1fb69ff01..27601d4bb 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/DataManager.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/DataManager.java @@ -26,19 +26,17 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; +import com.projectswg.common.data.info.Config; +import com.projectswg.common.data.info.RelationalServerFactory; +import com.projectswg.holocore.resources.config.ConfigFile; +import me.joshlarson.jlcommon.concurrency.SynchronizedMap; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import com.projectswg.common.concurrency.SynchronizedMap; -import com.projectswg.common.data.info.Config; -import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.config.ConfigFile; - public class DataManager { private static final Object instanceLock = new Object(); diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/ObjectDatabase.java b/src/main/java/com/projectswg/holocore/resources/server_info/ObjectDatabase.java index 28f302b64..db6257f6e 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/ObjectDatabase.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/ObjectDatabase.java @@ -26,18 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; +import com.projectswg.common.persistable.Persistable; +import me.joshlarson.jlcommon.concurrency.BasicScheduledThread; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.util.concurrent.TimeUnit; -import com.projectswg.common.concurrency.PswgBasicScheduledThread; -import com.projectswg.common.debug.Log; -import com.projectswg.common.persistable.Persistable; - public abstract class ObjectDatabase { private final File file; - private final PswgBasicScheduledThread autosaveThread; + private final BasicScheduledThread autosaveThread; public ObjectDatabase(String filename) { this(filename, TimeUnit.MINUTES.toMillis(5)); @@ -52,7 +52,7 @@ public abstract class ObjectDatabase { this.file = new File(filename); if (autosaveInterval < 60000) autosaveInterval = 60000; - this.autosaveThread = new PswgBasicScheduledThread("odb-autosave-"+file.getName(), this::save); + this.autosaveThread = new BasicScheduledThread("odb-autosave-"+file.getName(), this::save); this.autosaveThread.startWithFixedDelay(autosaveInterval, autosaveInterval); try { createFilesAndDirectories(); diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/SdbLoader.java b/src/main/java/com/projectswg/holocore/resources/server_info/SdbLoader.java index 87cd47cc0..3349f9428 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/SdbLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/SdbLoader.java @@ -26,7 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; -import com.projectswg.common.debug.Log; +import me.joshlarson.jlcommon.log.Log; import java.io.*; import java.util.*; @@ -84,8 +84,6 @@ public class SdbLoader { boolean next() throws IOException; List getColumns(); - T getObject(int index); - String getText(int index); String getText(String columnName); @@ -140,11 +138,6 @@ public class SdbLoader { return getResultSet().getColumns(); } - @Override - public T getObject(int index) { - return getResultSet().getObject(index); - } - @Override public String getText(int index) { return getResultSet().getText(index); @@ -209,7 +202,6 @@ public class SdbLoader { private final Map columnNames; private final AtomicLong lineNumber; private final BasicStringBuilder lineBuffer; - private Function [] columnParsers; private String [] columnValues; private BufferedInputStream input; private FileInputStream inputFile; @@ -219,7 +211,6 @@ public class SdbLoader { this.columnNames = new HashMap<>(); this.lineNumber = new AtomicLong(0); this.lineBuffer = new BasicStringBuilder(256); - this.columnParsers = null; this.columnValues = null; this.input = null; this.inputFile = null; @@ -252,16 +243,6 @@ public class SdbLoader { return new ArrayList<>(columnNames.keySet()); } - @SuppressWarnings("unchecked") - @Override - public T getObject(int index) { - try { - return (T) columnParsers[index].apply(columnValues[index]); - } catch (NumberFormatException e) { - throw new NumberFormatException("Failed to parse value in sdb: " + file + " on line " + lineNumber.get() + " in column " + (index+1)); - } - } - @Override public String getText(int index) { return columnValues[index]; @@ -269,12 +250,16 @@ public class SdbLoader { @Override public String getText(String columnName) { - return getText(columnNames.get(columnName)); + return columnValues[columnNames.get(columnName)]; } @Override public long getInt(int index) { - return getObject(index); + try { + return Long.parseLong(columnValues[index]); + } catch (NumberFormatException e) { + throw new NumberFormatException("Failed to parse value in sdb: " + file + " on line " + lineNumber.get() + " in column " + (index+1)); + } } @Override @@ -284,7 +269,11 @@ public class SdbLoader { @Override public double getReal(int index) { - return getObject(index); + try { + return Double.parseDouble(columnValues[index]); + } catch (NumberFormatException e) { + throw new NumberFormatException("Failed to parse value in sdb: " + file + " on line " + lineNumber.get() + " in column " + (index+1)); + } } @Override @@ -294,7 +283,7 @@ public class SdbLoader { @Override public boolean getBoolean(int index) { - return getObject(index); + return columnValues[index].equalsIgnoreCase("true"); } @Override @@ -361,48 +350,23 @@ public class SdbLoader { private void load() throws IOException { inputFile = new FileInputStream(file); input = new BufferedInputStream(inputFile); - loadHeader(fetchLine(), fetchLine()); + loadHeader(fetchLine()); + fetchLine(); } - @SuppressWarnings("unchecked") // stupid java not supporting generic arrays - private void loadHeader(String columnsStr, String typesStr) { - if (columnsStr == null || typesStr == null) { + private void loadHeader(String columnsStr) { + if (columnsStr == null) { Log.e("Invalid SDB header: %s - nonexistent", file); return; } String [] columns = columnsStr.split("\t"); - String [] types = typesStr.split("\t"); - if (columns.length != types.length) { - Log.e("Invalid SDB header: %s - invalid lengths!", file); - return; - } - columnParsers = new Function[columns.length]; columnValues = new String[columns.length]; for (int i = 0; i < columns.length; i++) { - columnParsers[i] = parseColumnType(types[i]).getTransformer(); columnNames.put(columns[i], i); } lineNumber.set(2); } - private DataType parseColumnType(String type) { - if (type.indexOf(' ') != -1) - type = type.substring(0, type.indexOf(' ')); - type = type.toLowerCase(Locale.US); - - if (type.equals("text")) - return DataType.TEXT; - if (type.equals("integer")) - return DataType.INTEGER; - if (type.equals("real")) - return DataType.REAL; - if (type.equals("bool") || type.equals("boolean")) - return DataType.BOOLEAN; - - Log.e("Unknown column type: %s for file %s", type, file); - return DataType.TEXT; - } - } private static class BasicStringBuilder { diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/StandardLog.java b/src/main/java/com/projectswg/holocore/resources/server_info/StandardLog.java index d6c423147..919322abb 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/StandardLog.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/StandardLog.java @@ -26,7 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info; -import com.projectswg.common.debug.Log; +import me.joshlarson.jlcommon.log.Log; public class StandardLog { diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/loader/BuildingLoader.java b/src/main/java/com/projectswg/holocore/resources/server_info/loader/BuildingLoader.java index 699679eca..77ed2cd94 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/loader/BuildingLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/loader/BuildingLoader.java @@ -26,6 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info.loader; +import com.projectswg.common.data.location.Terrain; +import com.projectswg.holocore.resources.server_info.SdbLoader; +import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.lang.ref.SoftReference; @@ -33,12 +38,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; -import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.server_info.SdbLoader; -import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; - public class BuildingLoader { private static final AtomicReference> CACHED_LOADER = new AtomicReference<>(null); @@ -81,7 +80,7 @@ public class BuildingLoader { private final Terrain terrain; public BuildingLoaderInfo(SdbResultSet set) { - this.name = set.getText(0); + this.name = set.getText(0).intern(); this.id = set.getInt(2); this.terrain = Terrain.valueOf(set.getText(1)); } diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcLoader.java b/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcLoader.java index d08ac00e1..b9dfa93c8 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcLoader.java @@ -26,6 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info.loader.npc; +import com.projectswg.holocore.resources.server_info.SdbLoader; +import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.util.Collection; @@ -34,11 +38,6 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.server_info.SdbLoader; -import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; - public class NpcLoader { private final Map npcMap; @@ -153,14 +152,14 @@ public class NpcLoader { public NpcInfo(SdbResultSet set) { this.id = set.getText("npc_id"); - this.attackable = set.getText("attackable"); - this.difficulty = set.getText("difficulty"); + this.attackable = set.getText("attackable").intern(); + this.difficulty = set.getText("difficulty").intern(); this.combatLevel = (int) set.getInt("combat_level"); - this.name = set.getText("npc_name"); + this.name = set.getText("npc_name").intern(); this.stfName = set.getText("stf_name"); - this.niche = set.getText("niche"); + this.niche = set.getText("niche").intern(); this.iff = set.getText("iff_template"); - this.faction = set.getText("faction"); + this.faction = set.getText("faction").intern(); this.specForce = set.getBoolean("spec_force"); this.attackSpeed = set.getReal("attack_speed"); this.movementSpeed = set.getReal("movement_speed"); diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcPatrolRouteLoader.java b/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcPatrolRouteLoader.java index c54ece84e..2c4c2c483 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcPatrolRouteLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcPatrolRouteLoader.java @@ -26,20 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info.loader.npc; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.function.Consumer; - import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.resources.server_info.SdbLoader; import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; +import me.joshlarson.jlcommon.log.Log; + +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.function.Consumer; public class NpcPatrolRouteLoader { diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcStatLoader.java b/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcStatLoader.java index 4f1664a79..d403daf5a 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcStatLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/loader/npc/NpcStatLoader.java @@ -26,16 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info.loader.npc; +import com.projectswg.holocore.resources.server_info.SdbLoader; +import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.server_info.SdbLoader; -import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; - public class NpcStatLoader { private final Map npcStatMap; diff --git a/src/main/java/com/projectswg/holocore/resources/server_info/loader/spawn/StaticSpawnLoader.java b/src/main/java/com/projectswg/holocore/resources/server_info/loader/spawn/StaticSpawnLoader.java index 20b2458da..8276c8785 100644 --- a/src/main/java/com/projectswg/holocore/resources/server_info/loader/spawn/StaticSpawnLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/server_info/loader/spawn/StaticSpawnLoader.java @@ -26,6 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.server_info.loader.spawn; +import com.projectswg.holocore.resources.server_info.SdbLoader; +import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -33,11 +37,6 @@ import java.util.List; import java.util.Locale; import java.util.function.Consumer; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.server_info.SdbLoader; -import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; - public class StaticSpawnLoader { private final List spawns; @@ -97,11 +96,11 @@ public class StaticSpawnLoader { this.z = set.getReal("z"); this.heading = (int) set.getInt("heading"); this.cellId = (int) set.getInt("cell_id"); - this.spawnerType = set.getText("spawner_type"); - this.npcId = set.getText("npc_id"); - this.buildingId = set.getText("building_id"); - this.mood = set.getText("mood"); - this.behavior = set.getText("behaviour"); + this.spawnerType = set.getText("spawner_type").intern(); + this.npcId = set.getText("npc_id").intern(); + this.buildingId = set.getText("building_id").intern(); + this.mood = set.getText("mood").intern(); + this.behavior = set.getText("behaviour").intern(); this.patrolId = (int) set.getInt("patrol_id"); this.patrolFormation = parsePatrolFormation(set.getText("patrol_formation")); this.loiterRadius = (int) set.getInt("loiter_radius"); diff --git a/src/main/java/com/projectswg/holocore/resources/spawn/Spawner.java b/src/main/java/com/projectswg/holocore/resources/spawn/Spawner.java index 1074323e9..1f6db4858 100644 --- a/src/main/java/com/projectswg/holocore/resources/spawn/Spawner.java +++ b/src/main/java/com/projectswg/holocore/resources/spawn/Spawner.java @@ -26,19 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.spawn; -import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicReference; - import com.projectswg.common.data.encodables.tangible.PvpFaction; import com.projectswg.common.data.location.Location; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureDifficulty; import com.projectswg.holocore.resources.objects.custom.AIBehavior; import com.projectswg.holocore.resources.server_info.loader.npc.NpcPatrolRouteLoader.PatrolType; import com.projectswg.holocore.resources.server_info.loader.spawn.StaticSpawnLoader.PatrolFormation; +import java.util.List; +import java.util.Random; +import java.util.concurrent.atomic.AtomicReference; + public final class Spawner { private final Random random; diff --git a/src/main/java/com/projectswg/holocore/resources/sui/SuiWindow.java b/src/main/java/com/projectswg/holocore/resources/sui/SuiWindow.java index 059852df8..1625fca67 100644 --- a/src/main/java/com/projectswg/holocore/resources/sui/SuiWindow.java +++ b/src/main/java/com/projectswg/holocore/resources/sui/SuiWindow.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.resources.sui; import com.projectswg.common.data.sui.ISuiCallback; import com.projectswg.common.data.sui.SuiBaseWindow; import com.projectswg.common.data.sui.SuiEvent; - import com.projectswg.holocore.intents.sui.SuiWindowIntent; import com.projectswg.holocore.resources.player.Player; diff --git a/src/main/java/com/projectswg/holocore/resources/zone/NameFilter.java b/src/main/java/com/projectswg/holocore/resources/zone/NameFilter.java index 99d221a72..f3aa68da3 100644 --- a/src/main/java/com/projectswg/holocore/resources/zone/NameFilter.java +++ b/src/main/java/com/projectswg/holocore/resources/zone/NameFilter.java @@ -26,14 +26,17 @@ ***********************************************************************************/ package com.projectswg.holocore.resources.zone; -import java.io.*; +import me.joshlarson.jlcommon.log.Log; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import com.projectswg.common.debug.Log; - public class NameFilter { diff --git a/src/main/java/com/projectswg/holocore/services/CoreManager.java b/src/main/java/com/projectswg/holocore/services/CoreManager.java index eff20ac74..f09dcf432 100644 --- a/src/main/java/com/projectswg/holocore/services/CoreManager.java +++ b/src/main/java/com/projectswg/holocore/services/CoreManager.java @@ -26,25 +26,16 @@ ***********************************************************************************/ package com.projectswg.holocore.services; -import java.io.File; -import java.time.OffsetTime; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.control.Manager; import com.projectswg.common.data.encodables.chat.ChatAvatar; import com.projectswg.common.data.encodables.galaxy.Galaxy; import com.projectswg.common.data.encodables.galaxy.Galaxy.GalaxyStatus; import com.projectswg.common.data.info.Config; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.admin.AdminShutdownServer; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline; import com.projectswg.common.network.packets.swg.zone.deltas.DeltasMessage; import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectController; import com.projectswg.common.utilities.ThreadUtilities; - import com.projectswg.holocore.intents.network.InboundPacketIntent; import com.projectswg.holocore.intents.network.OutboundPacketIntent; import com.projectswg.holocore.intents.server.ServerManagementIntent; @@ -55,6 +46,14 @@ import com.projectswg.holocore.resources.server_info.BasicLogStream; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.galaxy.GalacticManager; import com.projectswg.holocore.utilities.ScheduledUtilities; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.log.Log; + +import java.io.File; +import java.time.OffsetTime; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public class CoreManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/EngineManager.java b/src/main/java/com/projectswg/holocore/services/EngineManager.java index 24d8b2e7e..2522a6d23 100644 --- a/src/main/java/com/projectswg/holocore/services/EngineManager.java +++ b/src/main/java/com/projectswg/holocore/services/EngineManager.java @@ -26,19 +26,18 @@ ***********************************************************************************/ package com.projectswg.holocore.services; -import java.io.File; -import java.io.IOException; - -import com.projectswg.common.control.Manager; import com.projectswg.common.data.info.Config; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.resources.client_info.ServerFactory; import com.projectswg.holocore.resources.config.ConfigFile; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.network.NetworkManager; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.log.Log; + +import java.io.File; +import java.io.IOException; public class EngineManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/ShutdownService.java b/src/main/java/com/projectswg/holocore/services/ShutdownService.java index 6cdd83881..96a411dfc 100644 --- a/src/main/java/com/projectswg/holocore/services/ShutdownService.java +++ b/src/main/java/com/projectswg/holocore/services/ShutdownService.java @@ -26,6 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services; +import com.projectswg.common.utilities.ThreadUtilities; +import com.projectswg.holocore.intents.chat.SystemMessageIntent; +import com.projectswg.holocore.intents.server.ServerStatusIntent; +import com.projectswg.holocore.resources.control.ServerStatus; +import me.joshlarson.jlcommon.control.Service; + import java.util.Locale; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -33,13 +39,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import com.projectswg.common.control.Service; -import com.projectswg.common.utilities.ThreadUtilities; - -import com.projectswg.holocore.intents.chat.SystemMessageIntent; -import com.projectswg.holocore.intents.server.ServerStatusIntent; -import com.projectswg.holocore.resources.control.ServerStatus; - public class ShutdownService extends Service { private static final String SHUTDOWN_PERIODIC = "The server will be shutting down in %d %s."; diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatFriendService.java b/src/main/java/com/projectswg/holocore/services/chat/ChatFriendService.java new file mode 100644 index 000000000..3886a5825 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatFriendService.java @@ -0,0 +1,160 @@ +package com.projectswg.holocore.services.chat; + +import com.projectswg.common.data.encodables.chat.ChatAvatar; +import com.projectswg.common.data.encodables.oob.ProsePackage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatFriendsListUpdate; +import com.projectswg.holocore.intents.PlayerEventIntent; +import com.projectswg.holocore.intents.chat.ChatAvatarRequestIntent; +import com.projectswg.holocore.intents.chat.SystemMessageIntent; +import com.projectswg.holocore.resources.objects.player.PlayerObject; +import com.projectswg.holocore.resources.player.Player; +import com.projectswg.holocore.resources.player.PlayerState; +import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +import java.util.Locale; + +public class ChatFriendService extends Service { + + public ChatFriendService() { + + } + + @IntentHandler + private void handlePlayerEventIntent(PlayerEventIntent pei) { + switch (pei.getEvent()) { + case PE_FIRST_ZONE: + updateChatAvatarStatus(pei.getPlayer(), true); + break; + case PE_LOGGED_OUT: + updateChatAvatarStatus(pei.getPlayer(), false); + break; + default: + break; + } + } + + @IntentHandler + private void handleChatAvatarRequestIntent(ChatAvatarRequestIntent cari) { + switch (cari.getRequestType()) { + case TARGET_STATUS: + sendTargetAvatarStatus(cari.getPlayer(), new ChatAvatar(cari.getTarget())); + break; + case FRIEND_ADD_TARGET: + handleAddFriend(cari.getPlayer(), cari.getTarget()); + break; + case FRIEND_REMOVE_TARGET: + handleRemoveFriend(cari.getPlayer(), cari.getTarget()); + break; + case FRIEND_LIST: + handleRequestFriendList(cari.getPlayer()); + break; + case IGNORE_ADD_TARGET: + handleAddIgnored(cari.getPlayer(), cari.getTarget()); + break; + case IGNORE_REMOVE_TARGET: + handleRemoveIgnored(cari.getPlayer(), cari.getTarget()); + break; + case IGNORE_LIST: + handleRequestIgnoreList(cari.getPlayer()); + break; + } + } + + private void updateChatAvatarStatus(Player player, boolean online) { + if (online) { + for (String friend : player.getPlayerObject().getFriendsList()) { + sendTargetAvatarStatus(player, new ChatAvatar(friend)); + } + } + + String name = player.getCharacterFirstName().toLowerCase(Locale.US); + player.getPlayerManager().notifyPlayers(p -> p.getPlayerState() == PlayerState.ZONED_IN && p.getPlayerObject().isFriend(name), new ChatFriendsListUpdate(new ChatAvatar(name), online)); + } + + private void sendTargetAvatarStatus(Player player, ChatAvatar target) { + Player targetPlayer = PlayerLookup.getPlayerByFirstName(target.getName()); + + player.sendPacket(new ChatFriendsListUpdate(target, targetPlayer != null && targetPlayer.getPlayerState() == PlayerState.ZONED_IN)); + } + + private void handleAddFriend(Player player, String target) { + if (target.equalsIgnoreCase(player.getCharacterFirstName())) + return; + + PlayerObject ghost = player.getPlayerObject(); + if (ghost == null) + return; + + if (ghost.isIgnored(target)) { + sendSystemMessage(player, "@cmnty:friend_fail_is_ignored", target); + return; + } + + if (!player.getPlayerManager().playerExists(target)) { + sendSystemMessage(player, "@cmnty:friend_not_found", target); + return; + } + + if (!ghost.addFriend(target)) { + sendSystemMessage(player, "@cmnty:friend_duplicate", target); + return; + } + + sendSystemMessage(player, "@cmnty:friend_added", target); + sendTargetAvatarStatus(player, new ChatAvatar(target)); + } + + private void handleRemoveFriend(Player player, String target) { + if (!player.getPlayerObject().removeFriend(target)) { + sendSystemMessage(player, "@cmnty:friend_not_found", target); + return; + } + + sendSystemMessage(player, "@cmnty:friend_removed", target); + } + + private void handleRequestFriendList(Player player) { + player.getPlayerObject().sendFriendsList(); + } + + /* Ignore List */ + + private void handleAddIgnored(Player player, String target) { + if (target.equalsIgnoreCase(player.getCharacterFirstName())) + return; + + if (!player.getPlayerManager().playerExists(target)) { + sendSystemMessage(player, "@cmnty:ignore_not_found", target); + return; + } + + player.getPlayerObject().removeFriend(target); + + if (!player.getPlayerObject().addIgnored(target)) { + sendSystemMessage(player, "@cmnty:ignore_duplicate", target); + return; + } + + sendSystemMessage(player, "@cmnty:ignore_added", target); + } + + private void handleRemoveIgnored(Player player, String target) { + if (!player.getPlayerObject().removeIgnored(target)) { + sendSystemMessage(player, "@cmnty:ignore_not_found", target); + return; + } + + sendSystemMessage(player, "@cmnty:ignore_removed", target); + } + + private void handleRequestIgnoreList(Player player) { + player.getPlayerObject().sendIgnoreList(); + } + + private void sendSystemMessage(Player player, String stringId, String target) { + new SystemMessageIntent(player, new ProsePackage("StringId", stringId, "TT", target)).broadcast(); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatInstantMessageService.java b/src/main/java/com/projectswg/holocore/services/chat/ChatInstantMessageService.java new file mode 100644 index 000000000..4e3cf8d19 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatInstantMessageService.java @@ -0,0 +1,56 @@ +package com.projectswg.holocore.services.chat; + +import com.projectswg.common.data.encodables.chat.ChatResult; +import com.projectswg.common.network.packets.SWGPacket; +import com.projectswg.common.network.packets.swg.zone.chat.ChatInstantMessageToCharacter; +import com.projectswg.common.network.packets.swg.zone.chat.ChatInstantMessageToClient; +import com.projectswg.common.network.packets.swg.zone.chat.ChatOnSendInstantMessage; +import com.projectswg.holocore.intents.network.GalacticPacketIntent; +import com.projectswg.holocore.resources.player.Player; +import com.projectswg.holocore.resources.player.PlayerState; +import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +import java.util.Locale; + +public class ChatInstantMessageService extends Service { + + public ChatInstantMessageService() { + + } + + @IntentHandler + private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { + SWGPacket packet = gpi.getPacket(); + switch (packet.getPacketType()) { + case CHAT_INSTANT_MESSAGE_TO_CHARACTER: + if (packet instanceof ChatInstantMessageToCharacter) + handleInstantMessage(gpi.getPlayer(), (ChatInstantMessageToCharacter) packet); + break; + default: + break; + } + } + + private void handleInstantMessage(Player sender, ChatInstantMessageToCharacter request) { + String strReceiver = request.getCharacter().toLowerCase(Locale.ENGLISH); + String strSender = sender.getCharacterFirstName(); + + Player receiver = PlayerLookup.getPlayerByFirstName(strReceiver); + + ChatResult result = ChatResult.SUCCESS; + if (receiver == null || receiver.getPlayerState() != PlayerState.ZONED_IN) + result = ChatResult.TARGET_AVATAR_DOESNT_EXIST; + else if (receiver.getPlayerObject().isIgnored(strSender)) + result = ChatResult.IGNORED; + + sender.sendPacket(new ChatOnSendInstantMessage(result.getCode(), request.getSequence())); + + if (result != ChatResult.SUCCESS) + return; + + receiver.sendPacket(new ChatInstantMessageToClient(request.getGalaxy(), strSender, request.getMessage())); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatMailService.java b/src/main/java/com/projectswg/holocore/services/chat/ChatMailService.java index 41cb3d4e4..461d4706b 100644 --- a/src/main/java/com/projectswg/holocore/services/chat/ChatMailService.java +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatMailService.java @@ -26,30 +26,17 @@ ***********************************************************************************/ package com.projectswg.holocore.services.chat; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.atomic.AtomicReference; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.chat.ChatResult; import com.projectswg.common.data.encodables.player.Mail; import com.projectswg.common.data.info.RelationalServerData; import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; -import com.projectswg.common.network.packets.swg.zone.chat.ChatDeletePersistentMessage; -import com.projectswg.common.network.packets.swg.zone.chat.ChatOnSendPersistentMessage; -import com.projectswg.common.network.packets.swg.zone.chat.ChatPersistentMessageToClient; -import com.projectswg.common.network.packets.swg.zone.chat.ChatPersistentMessageToServer; -import com.projectswg.common.network.packets.swg.zone.chat.ChatRequestPersistentMessage; - +import com.projectswg.common.network.packets.swg.zone.chat.*; import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.chat.PersistentMessageIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; +import com.projectswg.holocore.resources.chat.ChatRange; +import com.projectswg.holocore.resources.chat.ChatType; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.player.PlayerObject; @@ -57,10 +44,19 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.server_info.CachedObjectDatabase; import com.projectswg.holocore.resources.server_info.ObjectDatabase; import com.projectswg.holocore.services.CoreManager; -import com.projectswg.holocore.services.chat.ChatManager.ChatRange; -import com.projectswg.holocore.services.chat.ChatManager.ChatType; import com.projectswg.holocore.services.player.PlayerManager; import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.atomic.AtomicReference; public class ChatMailService extends Service { @@ -75,9 +71,6 @@ public class ChatMailService extends Service { insertChatLog = chatLogs.prepareStatement("INSERT INTO chat_log VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); maxMailId = 1; - registerForIntent(GalacticPacketIntent.class, this::handleGalacticPacketIntent); - registerForIntent(PersistentMessageIntent.class, this::handlePersistentMessageIntent); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); } @Override @@ -96,6 +89,7 @@ public class ChatMailService extends Service { return super.terminate(); } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei) { Player player = pei.getPlayer(); if (player == null) @@ -110,6 +104,7 @@ public class ChatMailService extends Service { } } + @IntentHandler private void handleGalacticPacketIntent(GalacticPacketIntent gpi){ SWGPacket p = gpi.getPacket(); String galaxyName = CoreManager.getGalaxy().getName(); @@ -166,6 +161,7 @@ public class ChatMailService extends Service { } } + @IntentHandler private void handlePersistentMessageIntent(PersistentMessageIntent pmi) { if (pmi.getReceiver() == null) return; diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatManager.java b/src/main/java/com/projectswg/holocore/services/chat/ChatManager.java index e7d1de583..09a954982 100644 --- a/src/main/java/com/projectswg/holocore/services/chat/ChatManager.java +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatManager.java @@ -26,359 +26,21 @@ ***********************************************************************************/ package com.projectswg.holocore.services.chat; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.Locale; - -import com.projectswg.common.control.Manager; -import com.projectswg.common.data.encodables.chat.ChatAvatar; -import com.projectswg.common.data.encodables.chat.ChatResult; -import com.projectswg.common.data.encodables.oob.OutOfBandPackage; -import com.projectswg.common.data.encodables.oob.ProsePackage; -import com.projectswg.common.data.info.RelationalServerData; -import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; -import com.projectswg.common.network.packets.SWGPacket; -import com.projectswg.common.network.packets.swg.zone.chat.ChatFriendsListUpdate; -import com.projectswg.common.network.packets.swg.zone.chat.ChatInstantMessageToCharacter; -import com.projectswg.common.network.packets.swg.zone.chat.ChatInstantMessageToClient; -import com.projectswg.common.network.packets.swg.zone.chat.ChatOnSendInstantMessage; -import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage; -import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage.SystemChatType; -import com.projectswg.common.network.packets.swg.zone.object_controller.SpatialChat; - -import com.projectswg.holocore.intents.NotifyPlayersPacketIntent; -import com.projectswg.holocore.intents.PlayerEventIntent; -import com.projectswg.holocore.intents.chat.ChatAvatarRequestIntent; -import com.projectswg.holocore.intents.chat.SpatialChatIntent; -import com.projectswg.holocore.intents.chat.SystemMessageIntent; -import com.projectswg.holocore.intents.network.GalacticPacketIntent; -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.objects.player.PlayerObject; -import com.projectswg.holocore.resources.player.Player; -import com.projectswg.holocore.resources.player.PlayerState; -import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; +@ManagerStructure(children = { + ChatFriendService.class, + ChatInstantMessageService.class, + ChatSystemService.class, + ChatSpatialService.class, + ChatRoomService.class, + ChatMailService.class +}) public class ChatManager extends Manager { - private final RelationalServerData chatLogs; - private final PreparedStatement insertChatLog; - public ChatManager() { - chatLogs = RelationalServerFactory.getServerDatabase("chat/chat_log.db"); - insertChatLog = chatLogs.prepareStatement("INSERT INTO chat_log VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - addChildService(new ChatRoomService()); - addChildService(new ChatMailService()); - - registerForIntent(GalacticPacketIntent.class, this::handleGalacticPacketIntent); - registerForIntent(SpatialChatIntent.class, this::handleSpatialChatIntent); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); - registerForIntent(SystemMessageIntent.class, this::handleSystemMessageIntent); - registerForIntent(ChatAvatarRequestIntent.class, this::handleChatAvatarRequestIntent); - } - - private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { - SWGPacket packet = gpi.getPacket(); - switch (packet.getPacketType()) { - case CHAT_INSTANT_MESSAGE_TO_CHARACTER: - if (packet instanceof ChatInstantMessageToCharacter) - handleInstantMessage(gpi.getPlayer(), (ChatInstantMessageToCharacter) packet); - break; - default: - break; - } - } - - private void handlePlayerEventIntent(PlayerEventIntent pei) { - switch (pei.getEvent()) { - case PE_FIRST_ZONE: - updateChatAvatarStatus(pei.getPlayer(), true); - break; - case PE_LOGGED_OUT: - updateChatAvatarStatus(pei.getPlayer(), false); - break; - default: - break; - } - } - - private void handleSystemMessageIntent(SystemMessageIntent smi) { - switch (smi.getBroadcastType()) { - case AREA: - broadcastAreaMessage(smi.getMessage(), smi.getReceiver()); - logChat(smi.getReceiver(), ChatType.SYSTEM, ChatRange.LOCAL, smi.getMessage()); - break; - case PLANET: - broadcastPlanetMessage(smi.getMessage(), smi.getTerrain()); - logChat(smi.getReceiver(), ChatType.SYSTEM, ChatRange.TERRAIN, smi.getMessage()); - break; - case GALAXY: - broadcastGalaxyMessage(smi.getMessage()); - logChat(smi.getReceiver(), ChatType.SYSTEM, ChatRange.GALAXY, smi.getMessage()); - break; - case PERSONAL: - if (smi.getProse() != null) { - broadcastPersonalMessage(smi.getReceiver(), smi.getProse()); - logChat(smi.getReceiver(), ChatType.SYSTEM, ChatRange.PERSONAL, "**OOB DATA**"); - } else { - broadcastPersonalMessage(smi.getReceiver(), smi.getMessage()); - logChat(smi.getReceiver(), ChatType.SYSTEM, ChatRange.PERSONAL, smi.getMessage()); - } - break; - } - } - - private void handleChatAvatarRequestIntent(ChatAvatarRequestIntent cari) { - switch (cari.getRequestType()) { - case TARGET_STATUS: - sendTargetAvatarStatus(cari.getPlayer(), new ChatAvatar(cari.getTarget())); - break; - case FRIEND_ADD_TARGET: - handleAddFriend(cari.getPlayer(), cari.getTarget()); - break; - case FRIEND_REMOVE_TARGET: - handleRemoveFriend(cari.getPlayer(), cari.getTarget()); - break; - case FRIEND_LIST: - handleRequestFriendList(cari.getPlayer()); - break; - case IGNORE_ADD_TARGET: - handleAddIgnored(cari.getPlayer(), cari.getTarget()); - break; - case IGNORE_REMOVE_TARGET: - handleRemoveIgnored(cari.getPlayer(), cari.getTarget()); - break; - case IGNORE_LIST: - handleRequestIgnoreList(cari.getPlayer()); - break; - } - } - - /* Friends List */ - - private void handleAddFriend(Player player, String target) { - if (target.equalsIgnoreCase(player.getCharacterFirstName())) - return; - - PlayerObject ghost = player.getPlayerObject(); - if (ghost == null) - return; - - if (ghost.isIgnored(target)) { - sendSystemMessage(player, "@cmnty:friend_fail_is_ignored", target); - return; - } - - if (!player.getPlayerManager().playerExists(target)) { - sendSystemMessage(player, "@cmnty:friend_not_found", target); - return; - } - - if (!ghost.addFriend(target)) { - sendSystemMessage(player, "@cmnty:friend_duplicate", target); - return; - } - - sendSystemMessage(player, "@cmnty:friend_added", target); - sendTargetAvatarStatus(player, new ChatAvatar(target)); - } - - private void handleRemoveFriend(Player player, String target) { - if (!player.getPlayerObject().removeFriend(target)) { - sendSystemMessage(player, "@cmnty:friend_not_found", target); - return; - } - - sendSystemMessage(player, "@cmnty:friend_removed", target); - } - - private void handleRequestFriendList(Player player) { - player.getPlayerObject().sendFriendsList(); - } - - /* Ignore List */ - - private void handleAddIgnored(Player player, String target) { - if (target.equalsIgnoreCase(player.getCharacterFirstName())) - return; - - if (!player.getPlayerManager().playerExists(target)) { - sendSystemMessage(player, "@cmnty:ignore_not_found", target); - return; - } - - player.getPlayerObject().removeFriend(target); - - if (!player.getPlayerObject().addIgnored(target)) { - sendSystemMessage(player, "@cmnty:ignore_duplicate", target); - return; - } - - sendSystemMessage(player, "@cmnty:ignore_added", target); - } - - private void handleRemoveIgnored(Player player, String target) { - if (!player.getPlayerObject().removeIgnored(target)) { - sendSystemMessage(player, "@cmnty:ignore_not_found", target); - return; - } - - sendSystemMessage(player, "@cmnty:ignore_removed", target); - } - - private void handleRequestIgnoreList(Player player) { - player.getPlayerObject().sendIgnoreList(); - } - - /* Misc */ - - private void sendSystemMessage(Player player, String stringId, String target) { - new SystemMessageIntent(player, new ProsePackage("StringId", stringId, "TT", target)).broadcast(); - } - - private void handleSpatialChatIntent(SpatialChatIntent spi) { - Player sender = spi.getPlayer(); - SWGObject actor = sender.getCreatureObject(); - String senderName = sender.getCharacterFirstName(); - - // Send to self - SpatialChat message = new SpatialChat(actor.getObjectId(), actor.getObjectId(), 0, spi.getMessage(), (short) spi.getChatType(), (short) spi.getMoodId()); - logChat(sender, ChatType.SPATIAL, ChatRange.LOCAL, spi.getMessage()); - - // Notify observers of the chat message - for (Player owner : actor.getObservers()) { - if (owner.getPlayerObject().isIgnored(senderName)) - continue; - owner.sendPacket(new SpatialChat(owner.getCreatureObject().getObjectId(), message)); - } - } - - private void handleInstantMessage(Player sender, ChatInstantMessageToCharacter request) { - String strReceiver = request.getCharacter().toLowerCase(Locale.ENGLISH); - String strSender = sender.getCharacterFirstName(); - - Player receiver = PlayerLookup.getPlayerByFirstName(strReceiver); - - ChatResult result = ChatResult.SUCCESS; - if (receiver == null || receiver.getPlayerState() != PlayerState.ZONED_IN) - result = ChatResult.TARGET_AVATAR_DOESNT_EXIST; - else if (receiver.getPlayerObject().isIgnored(strSender)) - result = ChatResult.IGNORED; - - sender.sendPacket(new ChatOnSendInstantMessage(result.getCode(), request.getSequence())); - - if (result != ChatResult.SUCCESS) - return; - - receiver.sendPacket(new ChatInstantMessageToClient(request.getGalaxy(), strSender, request.getMessage())); - logChat(sender, receiver, ChatType.TELL, request.getMessage()); - } - - /* Friends */ - - private void updateChatAvatarStatus(Player player, boolean online) { - if (online) { - for (String friend : player.getPlayerObject().getFriendsList()) { - sendTargetAvatarStatus(player, new ChatAvatar(friend)); - } - } - - String name = player.getCharacterFirstName().toLowerCase(Locale.US); - player.getPlayerManager().notifyPlayers(p -> p.getPlayerState() == PlayerState.ZONED_IN && p.getPlayerObject().isFriend(name), new ChatFriendsListUpdate(new ChatAvatar(name), online)); - } - - private void sendTargetAvatarStatus(Player player, ChatAvatar target) { - Player targetPlayer = PlayerLookup.getPlayerByFirstName(target.getName()); - - player.sendPacket(new ChatFriendsListUpdate(target, targetPlayer != null && targetPlayer.getPlayerState() == PlayerState.ZONED_IN)); - } - - private void broadcastAreaMessage(String message, Player broadcaster) { - broadcaster.getCreatureObject().sendObservers(new ChatSystemMessage(SystemChatType.PERSONAL, message)); - } - - private void broadcastPlanetMessage(String message, Terrain terrain) { - ChatSystemMessage SWGPacket = new ChatSystemMessage(SystemChatType.PERSONAL, message); - new NotifyPlayersPacketIntent(SWGPacket, terrain).broadcast(); - } - - private void broadcastGalaxyMessage(String message) { - ChatSystemMessage SWGPacket = new ChatSystemMessage(SystemChatType.PERSONAL, message); - new NotifyPlayersPacketIntent(SWGPacket).broadcast(); - } - - private void broadcastPersonalMessage(Player player, String message) { - player.sendPacket(new ChatSystemMessage(SystemChatType.PERSONAL, message)); - } - - private void broadcastPersonalMessage(Player player, ProsePackage prose) { - player.sendPacket(new ChatSystemMessage(SystemChatType.PERSONAL, new OutOfBandPackage(prose))); - } - - private void logChat(Player broadcaster, ChatType type, ChatRange range, String message) { - long sendId = 0; - String sendName = ""; - if (broadcaster != null) { - CreatureObject creature = broadcaster.getCreatureObject(); - if (creature != null) { - sendId = creature.getObjectId(); - sendName = creature.getObjectName(); - } - } - logChat(sendId, sendName, 0, "", type.name(), range.name(), "", "", message); - } - - private void logChat(Player sender, Player receiver, ChatType type, String message) { - long sendId = 0, recvId = 0; - String sendName = "", recvName = ""; - if (sender != null) { - CreatureObject creature = sender.getCreatureObject(); - if (creature != null) { - sendId = creature.getObjectId(); - sendName = creature.getObjectName(); - } - } - if (receiver != null) { - CreatureObject creature = receiver.getCreatureObject(); - if (creature != null) { - recvId = creature.getObjectId(); - recvName = creature.getObjectName(); - } - } - logChat(sendId, sendName, recvId, recvName, type.name(), ChatRange.PERSONAL.name(), "", "", message); - } - - private void logChat(long sendId, String sendName, long recvId, String recvName, String type, String range, String room, String subject, String message) { - Assert.notNull(message, "Message cannot be null!"); - try { - synchronized (insertChatLog) { - insertChatLog.setLong(1, System.currentTimeMillis()); - insertChatLog.setLong(2, sendId); - insertChatLog.setString(3, sendName); - insertChatLog.setLong(4, recvId); - insertChatLog.setString(5, recvName); - insertChatLog.setString(6, type); - insertChatLog.setString(7, range); - insertChatLog.setString(8, room); - insertChatLog.setString(9, subject); - insertChatLog.setString(10, message); - insertChatLog.executeUpdate(); - } - } catch (SQLException e) { - Log.e(e); - } - } - - public enum ChatType { - MAIL, TELL, SYSTEM, SPATIAL, CHAT - } - - public enum ChatRange { - PERSONAL, ROOM, LOCAL, TERRAIN, GALAXY } } diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatMember.java b/src/main/java/com/projectswg/holocore/services/chat/ChatMember.java index 93bc3fbea..40b26fb6e 100644 --- a/src/main/java/com/projectswg/holocore/services/chat/ChatMember.java +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatMember.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.services.chat; import com.projectswg.common.data.encodables.chat.ChatAvatar; - import com.projectswg.holocore.resources.player.Player; public class ChatMember { diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatRoomContainer.java b/src/main/java/com/projectswg/holocore/services/chat/ChatRoomContainer.java index 2aae7780b..7211a2408 100644 --- a/src/main/java/com/projectswg/holocore/services/chat/ChatRoomContainer.java +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatRoomContainer.java @@ -26,15 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.services.chat; +import com.projectswg.common.data.encodables.chat.ChatRoom; +import me.joshlarson.jlcommon.log.Log; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.projectswg.common.data.encodables.chat.ChatRoom; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; - public class ChatRoomContainer { private final Object mapMutex; @@ -47,12 +47,11 @@ public class ChatRoomContainer { this.pathMap = new HashMap<>(); } - public boolean addRoom(ChatRoom room) { - Assert.notNull(room, "ChatRoom cannot be null!"); - Assert.test(room.getId() > 0, "ChatRoom ID must be > 0!"); - Assert.notNull(room.getPath(), "Path must not be null!"); - Assert.test(!room.getPath().isEmpty(), "Path must be non-empty!"); - Assert.test(room.getPath().startsWith("SWG."), "Path must start with \"SWG.\"!"); + public boolean addRoom(@NotNull ChatRoom room) { + assert room.getId() > 0 : "ChatRoom ID must be > 0"; + assert room.getPath() != null : "path must not be null"; + assert !room.getPath().isEmpty() : "path must be non-empty"; + assert room.getPath().startsWith("SWG.") : "Path must start with \"SWG.\"!"; synchronized (mapMutex) { ChatRoom overwrittenId = idMap.put(room.getId(), room); ChatRoom overwrittenPath = pathMap.put(room.getPath(), room); @@ -73,8 +72,7 @@ public class ChatRoomContainer { return true; } - public boolean destroyRoom(ChatRoom room) { - Assert.notNull(room, "ChatRoom cannot be null!"); + public boolean destroyRoom(@NotNull ChatRoom room) { synchronized (mapMutex) { boolean success = idMap.remove(room.getId()) != null; return pathMap.remove(room.getPath()) != null && success; @@ -88,32 +86,30 @@ public class ChatRoomContainer { } public ChatRoom getRoomById(int roomId) { - Assert.test(roomId > 0, "Room ID must be > 0!"); + assert roomId > 0 : "ChatRoom ID must be > 0"; synchronized (mapMutex) { return idMap.get(roomId); } } - public ChatRoom getRoomByPath(String path) { - Assert.notNull(path, "Path must not be null!"); - Assert.test(!path.isEmpty(), "Path must be non-empty!"); - Assert.test(path.startsWith("SWG."), "Path must start with \"SWG.\"!"); + public ChatRoom getRoomByPath(@NotNull String path) { + assert !path.isEmpty() : "path must be non-empty"; + assert path.startsWith("SWG.") : "Path must start with \"SWG.\"!"; synchronized (mapMutex) { return pathMap.get(path); } } public boolean hasRoomWithId(int roomId) { - Assert.test(roomId > 0, "Room ID must be > 0!"); + assert roomId > 0 : "ChatRoom ID must be > 0"; synchronized (mapMutex) { return idMap.containsKey(roomId); } } - public boolean hasRoomWithPath(String path) { - Assert.notNull(path, "Path must not be null!"); - Assert.test(!path.isEmpty(), "Path must be non-empty!"); - Assert.test(path.startsWith("SWG."), "Path must start with \"SWG.\"!"); + public boolean hasRoomWithPath(@NotNull String path) { + assert !path.isEmpty() : "path must be non-empty"; + assert path.startsWith("SWG.") : "Path must start with \"SWG.\"!"; synchronized (mapMutex) { return pathMap.containsKey(path); } diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatRoomHandler.java b/src/main/java/com/projectswg/holocore/services/chat/ChatRoomHandler.java index 104e2851f..24a8df798 100644 --- a/src/main/java/com/projectswg/holocore/services/chat/ChatRoomHandler.java +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatRoomHandler.java @@ -30,11 +30,7 @@ import com.projectswg.common.data.encodables.chat.ChatAvatar; import com.projectswg.common.data.encodables.chat.ChatResult; import com.projectswg.common.data.encodables.chat.ChatRoom; import com.projectswg.common.data.encodables.oob.OutOfBandPackage; -import com.projectswg.common.data.info.RelationalServerData; -import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.chat.*; import com.projectswg.common.network.packets.swg.zone.insertion.ChatRoomList; @@ -44,13 +40,10 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.server_info.CachedObjectDatabase; import com.projectswg.holocore.resources.server_info.ObjectDatabase; import com.projectswg.holocore.services.CoreManager; -import com.projectswg.holocore.services.chat.ChatManager.ChatRange; -import com.projectswg.holocore.services.chat.ChatManager.ChatType; import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import javax.annotation.CheckForNull; -import java.sql.PreparedStatement; -import java.sql.SQLException; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -62,9 +55,6 @@ public class ChatRoomHandler { private final AtomicInteger maxChatRoomId; private final Object roomCreationMutex; - private RelationalServerData chatLogs; - private PreparedStatement insertChatLog; - public ChatRoomHandler() { this.database = new CachedObjectDatabase<>("odb/chat_rooms.db", ChatRoom::create, ChatRoom::save); this.rooms = new ChatRoomContainer(); @@ -81,8 +71,6 @@ public class ChatRoomHandler { return; rooms.addRoom(room); }); - chatLogs = RelationalServerFactory.getServerDatabase("chat/chat_log.db"); - insertChatLog = chatLogs.prepareStatement("INSERT INTO chat_log VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); createSystemChannels(); return true; } @@ -90,7 +78,6 @@ public class ChatRoomHandler { public boolean terminate() { database.save(); database.close(); - chatLogs.close(); return true; } @@ -185,10 +172,9 @@ public class ChatRoomHandler { * @param persist If true then this channel will be saved in an {@link ObjectDatabase} * @return TRUE if the room was successfully created, FALSE otherwise */ - public boolean createRoom(ChatAvatar creator, boolean isPublic, boolean moderated, String path, String title, boolean persist) { - Assert.notNull(path, "Path cannot be empty!"); - Assert.test(!path.isEmpty(), "Path cannot be empty!"); - Assert.test(path.startsWith("SWG."+creator.getGalaxy()) && !path.equals("SWG."+creator.getGalaxy()), "Invalid path! " + path); + public boolean createRoom(@NotNull ChatAvatar creator, boolean isPublic, boolean moderated, @NotNull String path, @NotNull String title, boolean persist) { + assert !path.isEmpty() : "path must be non-empty"; + assert path.startsWith("SWG."+creator.getGalaxy()) && !path.equals("SWG."+creator.getGalaxy()) : "Invalid path! " + path; synchronized (roomCreationMutex) { if (rooms.getRoomByPath(path) != null) @@ -244,7 +230,6 @@ public class ChatRoomHandler { if (result == ChatResult.SUCCESS) { sendMessage(room, avatar, message, oobPackage); - logChat(player.getCreatureObject().getObjectId(), player.getCharacterName(), room.getId() + "/" + room.getPath(), message); } } @@ -307,7 +292,7 @@ public class ChatRoomHandler { return rooms.getRoomById(roomId); } - @CheckForNull + @Nullable public ChatRoom getRoomByPath(String path) { return rooms.getRoomByPath(path); } @@ -321,26 +306,6 @@ public class ChatRoomHandler { .collect(Collectors.toList()); } - public void logChat(long sendId, String sendName, String room, String message) { - try { - synchronized (insertChatLog) { - insertChatLog.setLong(1, System.currentTimeMillis()); - insertChatLog.setLong(2, sendId); - insertChatLog.setString(3, sendName); - insertChatLog.setLong(4, 0); - insertChatLog.setString(5, ""); - insertChatLog.setString(6, ChatType.CHAT.name()); - insertChatLog.setString(7, ChatRange.ROOM.name()); - insertChatLog.setString(8, room); - insertChatLog.setString(9, ""); - insertChatLog.setString(10, message); - insertChatLog.executeUpdate(); - } - } catch (SQLException e) { - Log.e(e); - } - } - private static void sendMessage(ChatRoom room, ChatAvatar sender, String message, OutOfBandPackage oob) { ChatRoomMessage chatRoomMessage = new ChatRoomMessage(sender, room.getId(), message, oob); for (ChatAvatar member : room.getMembers()) { diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatRoomService.java b/src/main/java/com/projectswg/holocore/services/chat/ChatRoomService.java index e65b9ef30..fc5a092f0 100644 --- a/src/main/java/com/projectswg/holocore/services/chat/ChatRoomService.java +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatRoomService.java @@ -27,7 +27,6 @@ package com.projectswg.holocore.services.chat; -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.chat.ChatAvatar; import com.projectswg.common.data.encodables.chat.ChatResult; import com.projectswg.common.data.encodables.chat.ChatRoom; @@ -41,19 +40,16 @@ import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.resources.player.AccessLevel; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.services.player.PlayerManager.PlayerLookup; - -import javax.annotation.Nonnull; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import org.jetbrains.annotations.NotNull; public class ChatRoomService extends Service { private final ChatRoomHandler chatRoomHandler; public ChatRoomService() { - chatRoomHandler = new ChatRoomHandler(); - - registerForIntent(ChatRoomUpdateIntent.class, this::handleChatRoomUpdateIntent); - registerForIntent(GalacticPacketIntent.class, this::handleGalacticPacketIntent); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); + this.chatRoomHandler = new ChatRoomHandler(); } @Override @@ -66,6 +62,7 @@ public class ChatRoomService extends Service { return chatRoomHandler.terminate() && super.terminate(); } + @IntentHandler private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { SWGPacket packet = gpi.getPacket(); Player player = gpi.getPlayer(); @@ -117,6 +114,7 @@ public class ChatRoomService extends Service { } } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei) { switch (pei.getEvent()) { case PE_FIRST_ZONE: @@ -127,6 +125,7 @@ public class ChatRoomService extends Service { } } + @IntentHandler private void handleChatRoomUpdateIntent(ChatRoomUpdateIntent crui) { switch (crui.getUpdateType()) { case CREATE: @@ -360,7 +359,7 @@ public class ChatRoomService extends Service { player.sendPacket(new ChatRoomList(chatRoomHandler.getRoomList(player))); } - private static void sendPacketToMembers(@Nonnull ChatRoom room, SWGPacket... packets) { + private static void sendPacketToMembers(@NotNull ChatRoom room, SWGPacket... packets) { for (ChatAvatar member : room.getMembers()) { Player player = PlayerLookup.getPlayerByFirstName(member.getName()); player.sendPacket(packets); diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatSpatialService.java b/src/main/java/com/projectswg/holocore/services/chat/ChatSpatialService.java new file mode 100644 index 000000000..e92b5078f --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatSpatialService.java @@ -0,0 +1,33 @@ +package com.projectswg.holocore.services.chat; + +import com.projectswg.common.network.packets.swg.zone.object_controller.SpatialChat; +import com.projectswg.holocore.intents.chat.SpatialChatIntent; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +public class ChatSpatialService extends Service { + + public ChatSpatialService() { + + } + + @IntentHandler + private void handleSpatialChatIntent(SpatialChatIntent spi) { + Player sender = spi.getPlayer(); + SWGObject actor = sender.getCreatureObject(); + String senderName = sender.getCharacterFirstName(); + + // Send to self + SpatialChat message = new SpatialChat(actor.getObjectId(), actor.getObjectId(), 0, spi.getMessage(), (short) spi.getChatType(), (short) spi.getMoodId()); + + // Notify observers of the chat message + for (Player owner : actor.getObservers()) { + if (owner.getPlayerObject().isIgnored(senderName)) + continue; + owner.sendPacket(new SpatialChat(owner.getCreatureObject().getObjectId(), message)); + } + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/chat/ChatSystemService.java b/src/main/java/com/projectswg/holocore/services/chat/ChatSystemService.java new file mode 100644 index 000000000..d6555e453 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/chat/ChatSystemService.java @@ -0,0 +1,64 @@ +package com.projectswg.holocore.services.chat; + +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.data.encodables.oob.ProsePackage; +import com.projectswg.common.data.location.Terrain; +import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage; +import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage.SystemChatType; +import com.projectswg.holocore.intents.NotifyPlayersPacketIntent; +import com.projectswg.holocore.intents.chat.SystemMessageIntent; +import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +public class ChatSystemService extends Service { + + public ChatSystemService() { + + } + + @IntentHandler + private void handleSystemMessageIntent(SystemMessageIntent smi) { + switch (smi.getBroadcastType()) { + case AREA: + broadcastAreaMessage(smi.getMessage(), smi.getReceiver()); + break; + case PLANET: + broadcastPlanetMessage(smi.getMessage(), smi.getTerrain()); + break; + case GALAXY: + broadcastGalaxyMessage(smi.getMessage()); + break; + case PERSONAL: + if (smi.getProse() != null) { + broadcastPersonalMessage(smi.getReceiver(), smi.getProse()); + } else { + broadcastPersonalMessage(smi.getReceiver(), smi.getMessage()); + } + break; + } + } + + private void broadcastAreaMessage(String message, Player broadcaster) { + broadcaster.getCreatureObject().sendObservers(new ChatSystemMessage(SystemChatType.PERSONAL, message)); + } + + private void broadcastPlanetMessage(String message, Terrain terrain) { + ChatSystemMessage SWGPacket = new ChatSystemMessage(SystemChatType.PERSONAL, message); + new NotifyPlayersPacketIntent(SWGPacket, terrain).broadcast(); + } + + private void broadcastGalaxyMessage(String message) { + ChatSystemMessage SWGPacket = new ChatSystemMessage(SystemChatType.PERSONAL, message); + new NotifyPlayersPacketIntent(SWGPacket).broadcast(); + } + + private void broadcastPersonalMessage(Player player, String message) { + player.sendPacket(new ChatSystemMessage(SystemChatType.PERSONAL, message)); + } + + private void broadcastPersonalMessage(Player player, ProsePackage prose) { + player.sendPacket(new ChatSystemMessage(SystemChatType.PERSONAL, new OutOfBandPackage(prose))); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/collections/CollectionBadgeManager.java b/src/main/java/com/projectswg/holocore/services/collections/CollectionBadgeManager.java index a91676ec3..5cf83c1a4 100644 --- a/src/main/java/com/projectswg/holocore/services/collections/CollectionBadgeManager.java +++ b/src/main/java/com/projectswg/holocore/services/collections/CollectionBadgeManager.java @@ -27,14 +27,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.collections; - -import java.util.BitSet; - -import com.projectswg.common.control.Manager; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; - import com.projectswg.holocore.intents.GrantBadgeIntent; import com.projectswg.holocore.intents.GrantClickyCollectionIntent; import com.projectswg.holocore.intents.SetTitleIntent; @@ -46,6 +41,9 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.player.PlayerObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.utilities.IntentFactory; +import me.joshlarson.jlcommon.control.Manager; + +import java.util.BitSet; public class CollectionBadgeManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/collections/CollectionService.java b/src/main/java/com/projectswg/holocore/services/collections/CollectionService.java index 3cdc48daa..4b0a96682 100644 --- a/src/main/java/com/projectswg/holocore/services/collections/CollectionService.java +++ b/src/main/java/com/projectswg/holocore/services/collections/CollectionService.java @@ -26,9 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.services.collections; -import com.projectswg.common.control.Service; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Log; import com.projectswg.holocore.resources.objects.collections.ClickyCollectionItem; import com.projectswg.holocore.resources.objects.collections.CollectionItem; import com.projectswg.holocore.resources.server_info.SdbLoader; @@ -36,6 +34,8 @@ import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.scripts.radial.RadialHandler; import com.projectswg.holocore.scripts.radial.collection.WorldItemRadial; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/projectswg/holocore/services/collections/ExplorationBadgeService.java b/src/main/java/com/projectswg/holocore/services/collections/ExplorationBadgeService.java index 3a2ad9ad2..11c9b318f 100644 --- a/src/main/java/com/projectswg/holocore/services/collections/ExplorationBadgeService.java +++ b/src/main/java/com/projectswg/holocore/services/collections/ExplorationBadgeService.java @@ -27,6 +27,15 @@ ***********************************************************************************/ package com.projectswg.holocore.services.collections; +import com.projectswg.common.data.info.RelationalServerData; +import com.projectswg.common.data.info.RelationalServerFactory; +import com.projectswg.common.data.location.Point3D; +import com.projectswg.holocore.intents.GrantBadgeIntent; +import com.projectswg.holocore.intents.player.PlayerTransformedIntent; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.Locale; @@ -34,16 +43,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; -import com.projectswg.common.control.Service; -import com.projectswg.common.data.info.RelationalServerData; -import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.data.location.Point3D; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.intents.GrantBadgeIntent; -import com.projectswg.holocore.intents.player.PlayerTransformedIntent; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; - public class ExplorationBadgeService extends Service { private static final String GET_BADGES_SQL = "SELECT * FROM explorationBadges"; diff --git a/src/main/java/com/projectswg/holocore/services/combat/CorpseService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatCloningService.java similarity index 72% rename from src/main/java/com/projectswg/holocore/services/combat/CorpseService.java rename to src/main/java/com/projectswg/holocore/services/combat/CombatCloningService.java index 6e4c5f815..5f16b518e 100644 --- a/src/main/java/com/projectswg/holocore/services/combat/CorpseService.java +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatCloningService.java @@ -1,42 +1,5 @@ -/*********************************************************************************** - * Copyright (c) 2018 /// Project SWG /// www.projectswg.com * - * * - * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * - * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * - * Our goal is to create an emulator which will provide a server for players to * - * continue playing a game similar to the one they used to play. We are basing * - * it on the final publish of the game prior to end-game events. * - * * - * This file is part of Holocore. * - * * - * --------------------------------------------------------------------------------* - * * - * Holocore is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * Holocore is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with Holocore. If not, see . * - ***********************************************************************************/ package com.projectswg.holocore.services.combat; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.*; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.Posture; @@ -49,15 +12,11 @@ import com.projectswg.common.data.location.Location.LocationBuilder; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.sui.SuiEvent; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; -import com.projectswg.common.utilities.ThreadUtilities; - import com.projectswg.holocore.intents.BuffIntent; import com.projectswg.holocore.intents.FactionIntent; import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.chat.SystemMessageIntent; -import com.projectswg.holocore.intents.combat.CorpseLootedIntent; import com.projectswg.holocore.intents.combat.CreatureKilledIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; @@ -71,47 +30,54 @@ import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiListBox; import com.projectswg.holocore.resources.sui.SuiWindow; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; -/** - * The {@code CorpseService} removes corpses from the world a while after - * they've died. It also lets players clone at a cloning facility. - * @author mads - */ -final class CorpseService extends Service { +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class CombatCloningService extends Service { private static final String DB_QUERY = "SELECT * FROM cloning_respawn"; - private static final byte CLONE_TIMER = 30; // Amount of minutes before a player is forced to clone + private static final long CLONE_TIMER = 30; // Amount of minutes before a player is forced to clone - private final ScheduledExecutorService executor; private final Map> reviveTimers; private final Map facilityDataMap; private final List cloningFacilities; + private final ScheduledThreadPool executor; private final Random random; - private final Map> deleteCorpseTasks; - - CorpseService() { - executor = Executors.newSingleThreadScheduledExecutor(ThreadUtilities.newThreadFactory("corpse-service")); - reviveTimers = new HashMap<>(); - facilityDataMap = new HashMap<>(); - cloningFacilities = new ArrayList<>(); - random = new Random(); - - deleteCorpseTasks = new HashMap<>(); - - registerForIntent(CreatureKilledIntent.class, this::handleCreatureKilledIntent); - registerForIntent(CorpseLootedIntent.class, this::handleCorpseLootedIntent); - registerForIntent(ObjectCreatedIntent.class, this::handleObjectCreatedIntent); - registerForIntent(DestroyObjectIntent.class, this::handleDestroyObjectIntent); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); - - loadFacilityData(); + public CombatCloningService() { + this.reviveTimers = new HashMap<>(); + this.facilityDataMap = new HashMap<>(); + this.cloningFacilities = new ArrayList<>(); + this.executor = new ScheduledThreadPool(1, "combat-cloning-service"); + this.random = new Random(); } - + @Override - public boolean terminate() { - executor.shutdown(); - return super.terminate(); + public boolean initialize() { + loadFacilityData(); + return true; + } + + @Override + public boolean start() { + executor.start(); + return true; + } + + @Override + public boolean stop() { + executor.stop(); + executor.awaitTermination(1000); + return true; } private void loadFacilityData() { @@ -159,39 +125,20 @@ final class CorpseService extends Service { } } + @IntentHandler private void handleCreatureKilledIntent(CreatureKilledIntent i) { CreatureObject corpse = i.getCorpse(); - - if(corpse.isPlayer()) { - Player corpseOwner = corpse.getOwner(); - new SystemMessageIntent(corpseOwner, new ProsePackage(new StringId("base_player", "prose_victim_dead"), "TT", i.getKiller().getObjectName())).broadcast(); - new SystemMessageIntent(corpseOwner, new ProsePackage(new StringId("base_player", "revive_exp_msg"), "TT", CLONE_TIMER + " minutes.")).broadcast(); - - scheduleCloneTimer(corpse); - } else { - // This is a NPC - schedule corpse for deletion - ScheduledFuture task = executor.schedule(() -> deleteCorpse(corpse), 120, TimeUnit.SECONDS); - deleteCorpseTasks.put(corpse.getObjectId(), task); - } - } - - private void handleCorpseLootedIntent(CorpseLootedIntent i) { - CreatureObject corpse = i.getCorpse(); - - ScheduledFuture task = deleteCorpseTasks.get(corpse.getObjectId()); - - if (task == null) { - Log.e("There should already be a deleteCorpse task for corpse %s!", corpse.toString()); - executor.schedule(() -> deleteCorpse(corpse), 5, TimeUnit.SECONDS); + if (!corpse.isPlayer()) return; - } - // if existing deleteCorpse task has more than 5 seconds remaining, cancel it - // if the cancel operation succeeds, schedule another deleteCorpse task for 5 seconds - if (task.getDelay(TimeUnit.SECONDS) > 5 && task.cancel(false)) - executor.schedule(() -> deleteCorpse(corpse), 5, TimeUnit.SECONDS); + Player corpseOwner = corpse.getOwner(); + new SystemMessageIntent(corpseOwner, new ProsePackage(new StringId("base_player", "prose_victim_dead"), "TT", i.getKiller().getObjectName())).broadcast(); + new SystemMessageIntent(corpseOwner, new ProsePackage(new StringId("base_player", "revive_exp_msg"), "TT", CLONE_TIMER + " minutes.")).broadcast(); + + scheduleCloneTimer(corpse); } + @IntentHandler private void handleObjectCreatedIntent(ObjectCreatedIntent i) { SWGObject createdObject = i.getObject(); @@ -209,6 +156,7 @@ final class CorpseService extends Service { } } + @IntentHandler private void handleDestroyObjectIntent(DestroyObjectIntent i) { synchronized(cloningFacilities) { SWGObject destroyedObject = i.getObject(); @@ -221,6 +169,7 @@ final class CorpseService extends Service { } } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent i) { switch(i.getEvent()) { case PE_DISAPPEAR: { @@ -262,7 +211,7 @@ final class CorpseService extends Service { cloningWindow.display(corpse.getOwner()); synchronized (reviveTimers) { - reviveTimers.put(corpse, executor.schedule(() -> expireCloneTimer(corpse, availableFacilities, cloningWindow), CLONE_TIMER, TimeUnit.MINUTES)); + reviveTimers.put(corpse, executor.execute(TimeUnit.MINUTES.toMillis(CLONE_TIMER), () -> expireCloneTimer(corpse, availableFacilities, cloningWindow))); } } @@ -299,50 +248,6 @@ final class CorpseService extends Service { return suiWindow; } - /** - * Only used for NPCs! - * @param creatureCorpse non-player creature to delete from the world - */ - private void deleteCorpse(CreatureObject creatureCorpse) { - if(creatureCorpse.isPlayer()) { - Log.e("Cannot delete the corpse of a player!", creatureCorpse); - } else { - new DestroyObjectIntent(creatureCorpse).broadcast(); - deleteCorpseTasks.remove(creatureCorpse.getObjectId()); - Log.d("Corpse of NPC %s was deleted from the world", creatureCorpse); - } - } - - /** - * - * @param corpse - * @return a sorted list of {@code BuildingObject}, ordered by distance - * to {@code corpse}. Order is reversed, so the closest facility is - * first. - */ - private List getAvailableFacilities(CreatureObject corpse) { - synchronized (cloningFacilities) { - Location corpseLocation = corpse.getWorldLocation(); - return cloningFacilities.stream() - .filter(facilityObject -> isValidTerrain(facilityObject, corpse) && isFactionAllowed(facilityObject, corpse)) - .sorted(Comparator.comparingDouble(facility -> corpseLocation.distanceTo(facility.getLocation()))) - .collect(Collectors.toList()); - - } - } - - // TODO below doesn't apply to a a player that died in a heroic. Cloning on Dathomir should be possible if you die during the Axkva Min heroic. - private boolean isValidTerrain(BuildingObject cloningFacility, CreatureObject corpse) { - return cloningFacility.getTerrain() == corpse.getTerrain(); - } - - private boolean isFactionAllowed(BuildingObject cloningFacility, CreatureObject corpse) { - FacilityData facilityData = facilityDataMap.get(cloningFacility.getTemplate()); - PvpFaction factionRestriction = facilityData.getFactionRestriction(); - - return factionRestriction == null || factionRestriction == corpse.getPvpFaction(); - } - private CloneResult reviveCorpse(CreatureObject corpse, BuildingObject selectedFacility) { FacilityData facilityData = facilityDataMap.get(selectedFacility.getTemplate()); @@ -446,6 +351,36 @@ final class CorpseService extends Service { } } + /** + * + * @param corpse + * @return a sorted list of {@code BuildingObject}, ordered by distance + * to {@code corpse}. Order is reversed, so the closest facility is + * first. + */ + private List getAvailableFacilities(CreatureObject corpse) { + synchronized (cloningFacilities) { + Location corpseLocation = corpse.getWorldLocation(); + return cloningFacilities.stream() + .filter(facilityObject -> isValidTerrain(facilityObject, corpse) && isFactionAllowed(facilityObject, corpse)) + .sorted(Comparator.comparingDouble(facility -> corpseLocation.distanceTo(facility.getLocation()))) + .collect(Collectors.toList()); + + } + } + + // TODO below doesn't apply to a a player that died in a heroic. Cloning on Dathomir should be possible if you die during the Axkva Min heroic. + private boolean isValidTerrain(BuildingObject cloningFacility, CreatureObject corpse) { + return cloningFacility.getTerrain() == corpse.getTerrain(); + } + + private boolean isFactionAllowed(BuildingObject cloningFacility, CreatureObject corpse) { + FacilityData facilityData = facilityDataMap.get(cloningFacility.getTemplate()); + PvpFaction factionRestriction = facilityData.getFactionRestriction(); + + return factionRestriction == null || factionRestriction == corpse.getPvpFaction(); + } + private static class FacilityData { private final PvpFaction factionRestriction; private final float x, y, z; diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatCommandService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatCommandService.java new file mode 100644 index 000000000..59641e22d --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatCommandService.java @@ -0,0 +1,334 @@ +package com.projectswg.holocore.services.combat; + +import com.projectswg.common.data.CRC; +import com.projectswg.common.data.RGB; +import com.projectswg.common.data.combat.*; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.data.encodables.oob.ProsePackage; +import com.projectswg.common.data.encodables.oob.StringId; +import com.projectswg.common.data.location.Location; +import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; +import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText; +import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction; +import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatAction.Defender; +import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatSpam; +import com.projectswg.holocore.intents.chat.ChatCommandIntent; +import com.projectswg.holocore.intents.object.DestroyObjectIntent; +import com.projectswg.holocore.intents.object.ObjectCreatedIntent; +import com.projectswg.holocore.resources.commands.CombatCommand; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import com.projectswg.holocore.resources.objects.weapon.WeaponObject; +import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +public class CombatCommandService extends Service { + + public CombatCommandService() { + + } + + @IntentHandler + private void handleChatCommandIntent(ChatCommandIntent cci) { + if (!cci.getCommand().isCombatCommand() || !(cci.getCommand() instanceof CombatCommand)) + return; + CombatCommand c = (CombatCommand) cci.getCommand(); + CreatureObject source = cci.getSource(); + SWGObject target = cci.getTarget(); + + // Regardless of HitType, the command might have action cost + addActionCost(source, c); + + // TODO implement support for remaining HitTypes + switch (c.getHitType()) { + case ATTACK: + handleAttack(source, target, null, c); + break; + case BUFF: + handleBuff(source, target, c); + break; + case HEAL: + handleHeal(source, target, c); + break; + case DELAY_ATTACK: + handleDelayAttack(source, target, c, cci.getArguments()); + break; + default: + handleStatus(source, CombatStatus.UNKNOWN); + break; + } + } + + private void handleAttack(CreatureObject source, SWGObject target, SWGObject delayEgg, CombatCommand command) { + if (!handleStatus(source, canPerform(source, target, command))) + return; + + WeaponObject weapon = source.getEquippedWeapon(); + + for (int i = 0; i < command.getAttackRolls(); i++) { + AttackInfo info = new AttackInfo(); + + switch (command.getAttackType()) { + case SINGLE_TARGET: + doCombatSingle(source, target, info, weapon, command); + break; + case AREA: + doCombatArea(source, source, info, weapon, command, false); + break; + case TARGET_AREA: + if (target != null) { + // Same as AREA, but the target is the destination for the AoE and can take damage + doCombatArea(source, delayEgg != null ? delayEgg : target, info, weapon, command, true); + } else { + // TODO AoE based on Location instead of delay egg + } + + break; + default: + break; + } + } + } + + private void handleBuff(CreatureObject source, SWGObject target, CombatCommand combatCommand) { + // TODO group buffs + addBuff(source, source, combatCommand.getBuffNameSelf()); + + if (!(target instanceof CreatureObject)) { + return; // Only CreatureObjects have buffs + } + + String buffNameTarget = combatCommand.getBuffNameTarget(); + + addBuff(source, (CreatureObject) target, buffNameTarget); + + CreatureObject creatureTarget = (CreatureObject) target; + CombatAction action = new CombatAction(source.getObjectId()); + WeaponObject weapon = source.getEquippedWeapon(); + String anim = combatCommand.getRandomAnimation(weapon.getType()); // Uses defaultAnim if it needs to + action.setPosture(source.getPosture()); + action.setAttackerId(source.getObjectId()); + action.setActionCrc(CRC.getCrc(anim)); + action.setWeaponId(weapon.getObjectId()); + action.setCommandCrc(combatCommand.getCrc()); + action.setTrail(TrailLocation.RIGHT_HAND); + action.setUseLocation(false); + + action.addDefender(new Defender(source.getObjectId(), source.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0)); + + if (!buffNameTarget.isEmpty()) { + action.addDefender(new Defender(creatureTarget.getObjectId(), creatureTarget.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0)); + } + + CombatSpam combatSpam = new CombatSpam(source.getObjectId()); + + combatSpam.setAttacker(source.getObjectId()); + combatSpam.setAttackerPosition(source.getLocation().getPosition()); + combatSpam.setWeapon(weapon.getObjectId()); + combatSpam.setDefender(target.getObjectId()); + combatSpam.setDefenderPosition(target.getLocation().getPosition()); + combatSpam.setInfo(new AttackInfo()); + combatSpam.setAttackName(new StringId("cmd_n", combatCommand.getName())); + combatSpam.setSpamType(CombatSpamFilterType.ALL); + // TODO doesn't look like a buff in the combat log + + source.sendObserversAndSelf(action, combatSpam); + } + + private void handleHeal(CreatureObject source, SWGObject target, CombatCommand combatCommand) { + int healAmount = combatCommand.getAddedDamage(); + int healingPotency = source.getSkillModValue("expertise_healing_all"); + + if (healingPotency > 0) { + healAmount *= healingPotency; + } + + switch (combatCommand.getAttackType()) { + case SINGLE_TARGET: { + switch (combatCommand.getTargetType()) { + case NONE: { // No target used, always heals self + doHeal(source, source, healAmount, combatCommand); + break; + } + case REQUIRED: { // Target is always used + if (target == null) { + return; + } + + // Same logic as OPTIONAL and ALL, so no break! + } + case OPTIONAL: // Appears to be the same as ALL + case ALL: { // Target is used IF supplied + if (target != null) { + if (!(target instanceof CreatureObject)) { + return; + } + + CreatureObject creatureTarget = (CreatureObject) target; + + if (source.isEnemyOf(creatureTarget)) { + doHeal(source, source, healAmount, combatCommand); + } else { + doHeal(source, creatureTarget, healAmount, combatCommand); + } + } else { + doHeal(source, source, healAmount, combatCommand); + } + + break; + } + } + break; + } + + case AREA: { + // Targets are never supplied for AoE heals + float range = combatCommand.getConeLength(); + Location sourceLocation = source.getWorldLocation(); + + for (SWGObject nearbyObject : source.getAware()) { + if (sourceLocation.isWithinDistance(nearbyObject.getLocation(), range)) { + if (!(nearbyObject instanceof CreatureObject)) { + // We can't heal something that's not a creature + continue; + } + + CreatureObject nearbyCreature = (CreatureObject) nearbyObject; + + if (source.isAttackable(nearbyCreature)) { + continue; + } + + // Heal nearby friendly + doHeal(source, nearbyCreature, healAmount, combatCommand); + } + } + + break; + } + } + } + + private void handleDelayAttack(CreatureObject source, SWGObject target, CombatCommand combatCommand, String arguments[]) { + Location eggLocation; + SWGObject eggParent; + + switch (combatCommand.getEggPosition()) { + case LOCATION: + if (arguments[0].equals("a") || arguments[0].equals("c")) { // is "c" in free-targeting mode + eggLocation = source.getLocation(); + } else { + eggLocation = new Location(Float.parseFloat(arguments[0]), Float.parseFloat(arguments[1]), Float.parseFloat(arguments[2]), source + .getTerrain()); + } + + eggParent = source.getParent(); + break; + default: + Log.w("Unrecognised delay egg position %s from command %s - defaulting to SELF", combatCommand.getEggPosition(), combatCommand + .getName()); + case SELF: + eggLocation = source.getLocation(); + eggParent = source.getParent(); + break; + case TARGET: + eggLocation = target.getLocation(); + eggParent = target.getParent(); + break; + } + + // Spawn delay egg object + String eggTemplate = combatCommand.getDelayAttackEggTemplate(); + SWGObject delayEgg = eggTemplate.endsWith("generic_egg_small.iff") ? null : ObjectCreator.createObjectFromTemplate(eggTemplate); + + if (delayEgg != null) { + delayEgg.setLocation(eggLocation); + delayEgg.moveToContainer(eggParent); + ObjectCreatedIntent.broadcast(delayEgg); + } + + long interval = (long) (combatCommand.getInitialDelayAttackInterval() * 1000); + executor.execute(interval, () -> delayEggLoop(delayEgg, source, target, combatCommand, 1)); + } + + private void delayEggLoop(final SWGObject delayEgg, final CreatureObject source, final SWGObject target, final CombatCommand combatCommand, final int currentLoop) { + String delayAttackParticle = combatCommand.getDelayAttackParticle(); + + // Show particle effect to everyone observing the delay egg, if one is defined + if (delayEgg != null && !delayAttackParticle.isEmpty()) + delayEgg.sendObservers(new PlayClientEffectObjectMessage(delayAttackParticle, "", delayEgg.getObjectId(), "")); + + // Handle the attack of this loop + handleAttack(source, target, delayEgg, combatCommand); + + if (currentLoop < combatCommand.getDelayAttackLoops()) { + // Recursively schedule another loop if that wouldn't exceed the amount of loops we need to perform + long interval = (long) (combatCommand.getDelayAttackInterval() * 1000); + executor.execute(interval, () -> delayEggLoop(delayEgg, source, target, combatCommand, currentLoop + 1)); + } else if (delayEgg != null) { + // The delayed attack has ended - destroy the egg + new DestroyObjectIntent(delayEgg).broadcast(); + } + } + + private void doHeal(CreatureObject healer, CreatureObject healed, int healAmount, CombatCommand combatCommand) { + String attribName; + int difference; + + switch (combatCommand.getHealAttrib()) { + case HEALTH: { + int currentHealth = healed.getHealth(); + healed.modifyHealth(healAmount); + difference = healed.getHealth() - currentHealth; + attribName = "HEALTH"; + break; + } + + case ACTION: { + int currentAction = healed.getAction(); + healed.modifyAction(healAmount); + difference = healed.getAction() - currentAction; + attribName = "ACTION"; + break; + } + + default: + return; + } + + CombatAction action = new CombatAction(healer.getObjectId()); + WeaponObject weapon = healer.getEquippedWeapon(); + String anim = combatCommand.getRandomAnimation(weapon.getType()); // Uses defaultAnim if it needs to + + action.setPosture(healed.getPosture()); + action.setAttackerId(healer.getObjectId()); + action.setActionCrc(CRC.getCrc(anim)); + action.setWeaponId(weapon.getObjectId()); + action.setCommandCrc(combatCommand.getCrc()); + action.setTrail(TrailLocation.RIGHT_HAND); + action.setUseLocation(false); + + action.addDefender(new Defender(healed.getObjectId(), healed.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0)); + + OutOfBandPackage oobp = new OutOfBandPackage(new ProsePackage("StringId", new StringId("healing", "heal_fly"), "DI", difference, "TO", attribName)); + ShowFlyText flyText = new ShowFlyText(healed.getObjectId(), oobp, Scale.MEDIUM, new RGB(46, 139, 87), ShowFlyText.Flag.IS_HEAL); + PlayClientEffectObjectMessage effect = new PlayClientEffectObjectMessage("appearance/pt_heal.prt", "root", healed.getObjectId(), ""); + CombatSpam combatSpam = new CombatSpam(healer.getObjectId()); + + combatSpam.setAttacker(healer.getObjectId()); + combatSpam.setAttackerPosition(healer.getLocation().getPosition()); + combatSpam.setWeapon(weapon.getObjectId()); + combatSpam.setWeaponName(weapon.getStringId()); + combatSpam.setDefender(healed.getObjectId()); + combatSpam.setDefenderPosition(healed.getLocation().getPosition()); + combatSpam.setInfo(new AttackInfo()); + combatSpam.setAttackName(new StringId("cmd_n", combatCommand.getName())); + combatSpam.setSpamType(CombatSpamFilterType.ALL); + // TODO doesn't look like a heal in the combat log + + healed.sendObserversAndSelf(action, flyText, effect, combatSpam); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatDeathblowService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatDeathblowService.java new file mode 100644 index 000000000..8876f5ab6 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatDeathblowService.java @@ -0,0 +1,137 @@ +package com.projectswg.holocore.services.combat; + +import com.projectswg.common.data.encodables.oob.ProsePackage; +import com.projectswg.common.data.encodables.oob.StringId; +import com.projectswg.common.data.encodables.tangible.Posture; +import com.projectswg.holocore.intents.BuffIntent; +import com.projectswg.holocore.intents.chat.SystemMessageIntent; +import com.projectswg.holocore.intents.combat.CreatureIncapacitatedIntent; +import com.projectswg.holocore.intents.combat.CreatureKilledIntent; +import com.projectswg.holocore.intents.combat.DeathblowIntent; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Future; + +public class CombatDeathblowService extends Service { + + private static final byte INCAP_TIMER = 10; // Amount of seconds to be incapacitated + + private final Map> incapacitatedCreatures; + + public CombatDeathblowService() { + this.incapacitatedCreatures = new ConcurrentHashMap<>(); + } + + @IntentHandler + private void handleDeathblowIntent(DeathblowIntent di) { + CreatureObject killer = di.getKiller(); + CreatureObject corpse = di.getCorpse(); + + // Only deathblowing players is allowed! + if (!corpse.isPlayer()) { + return; + } + + // They must be enemies + if (!corpse.isEnemyOf(killer)) { + return; + } + + // The target of the deathblow must be incapacitated! + if (corpse.getPosture() != Posture.INCAPACITATED) { + return; + } + + // If they're deathblown while incapacitated, their incapacitation expiration timer should cancel + Future incapacitationTimer = incapacitatedCreatures.remove(corpse); + + if (incapacitationTimer != null) { + if (incapacitationTimer.cancel(false)) { // If the task is running, let them get back up + killCreature(killer, corpse); + } + } else { + // Can't happen with the current code, but in case it's ever refactored... + Log.e("Incapacitation timer for player %s being deathblown unexpectedly didn't exist!", ""); + } + } + + private void doCreatureDeath(CreatureObject corpse, CreatureObject killer) { + corpse.setHealth(0); + killer.removeDefender(corpse); + + if (!killer.hasDefenders()) { + exitCombat(killer); + } + + // The creature should not be able to move or turn. + corpse.setTurnScale(0); + corpse.setMovementScale(0); + + if (corpse.isPlayer()) { + if (corpse.hasBuff("incapWeaken")) { + killCreature(killer, corpse); + } else { + incapacitatePlayer(killer, corpse); + } + } else { + killCreature(killer, corpse); + } + + exitCombat(corpse); + } + + private void incapacitatePlayer(CreatureObject incapacitator, CreatureObject incapacitated) { + incapacitated.setPosture(Posture.INCAPACITATED); + incapacitated.setCounter(INCAP_TIMER); + + Log.i("%s was incapacitated", incapacitated); + + // Once the incapacitation counter expires, revive them. + incapacitatedCreatures.put(incapacitated, executor.execute(INCAP_TIMER * 1000, () -> expireIncapacitation(incapacitated))); + + new BuffIntent("incapWeaken", incapacitator, incapacitated, false).broadcast(); + new SystemMessageIntent(incapacitator.getOwner(), new ProsePackage(new StringId("base_player", "prose_target_incap"), "TT", incapacitated + .getObjectName())).broadcast(); + new SystemMessageIntent(incapacitated.getOwner(), new ProsePackage(new StringId("base_player", "prose_victim_incap"), "TT", incapacitator + .getObjectName())).broadcast(); + new CreatureIncapacitatedIntent(incapacitator, incapacitated).broadcast(); + } + + private void expireIncapacitation(CreatureObject incapacitatedPlayer) { + incapacitatedCreatures.remove(incapacitatedPlayer); + reviveCreature(incapacitatedPlayer); + } + + private void reviveCreature(CreatureObject revivedCreature) { + if (revivedCreature.isPlayer()) + revivedCreature.setCounter(0); + + revivedCreature.setPosture(Posture.UPRIGHT); + + // The creature is now able to turn around and move + revivedCreature.setTurnScale(1); + revivedCreature.setMovementScale(1); + + // Give 'em a percentage of their health and schedule them for HAM regeneration. + revivedCreature.setHealth((int) (revivedCreature.getBaseHealth() * 0.1)); // Restores 10% health of their base health + startHealthRegeneration(revivedCreature); + startActionRegeneration(revivedCreature); + + Log.i("%s was revived", revivedCreature); + } + + private void killCreature(CreatureObject killer, CreatureObject corpse) { + // We don't want to kill a creature that is already dead + if (corpse.getPosture() == Posture.DEAD) + return; + + corpse.setPosture(Posture.DEAD); + new CreatureKilledIntent(killer, corpse).broadcast(); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/combat/DuelPlayerService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatDuelService.java similarity index 96% rename from src/main/java/com/projectswg/holocore/services/combat/DuelPlayerService.java rename to src/main/java/com/projectswg/holocore/services/combat/CombatDuelService.java index 83960a60e..006e7ca56 100644 --- a/src/main/java/com/projectswg/holocore/services/combat/DuelPlayerService.java +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatDuelService.java @@ -26,20 +26,45 @@ ***********************************************************************************/ package com.projectswg.holocore.services.combat; -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.PvpFlag; import com.projectswg.common.data.location.Location; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.combat.DuelPlayerIntent; import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; -final class DuelPlayerService extends Service { +public class CombatDuelService extends Service { - DuelPlayerService() { - registerForIntent(DuelPlayerIntent.class, this::handleDuelPlayerIntent); + public CombatDuelService() { + + } + + @IntentHandler + private void handleDuelPlayerIntent(DuelPlayerIntent dpi) { + if (dpi.getReciever() == null || !dpi.getReciever().isPlayer() || dpi.getSender().equals(dpi.getReciever())) { + return; + } + + switch (dpi.getEventType()) { + case ACCEPT: + handleAcceptDuel(dpi.getSender(), dpi.getReciever()); + break; + case CANCEL: + handleCancelDuel(dpi.getSender(), dpi.getReciever()); + break; + case DECLINE: + handleDeclineDuel(dpi.getSender(), dpi.getReciever()); + break; + case END: + handleEndDuel(dpi.getSender(), dpi.getReciever()); + break; + case REQUEST: + handleRequestDuel(dpi.getSender(), dpi.getReciever()); + break; + } } private void handleAcceptDuel(CreatureObject accepter, CreatureObject target) { @@ -107,30 +132,6 @@ final class DuelPlayerService extends Service { } } - private void handleDuelPlayerIntent(DuelPlayerIntent dpi) { - if (dpi.getReciever() == null || !dpi.getReciever().isPlayer() || dpi.getSender().equals(dpi.getReciever())) { - return; - } - - switch (dpi.getEventType()) { - case ACCEPT: - handleAcceptDuel(dpi.getSender(), dpi.getReciever()); - break; - case CANCEL: - handleCancelDuel(dpi.getSender(), dpi.getReciever()); - break; - case DECLINE: - handleDeclineDuel(dpi.getSender(), dpi.getReciever()); - break; - case END: - handleEndDuel(dpi.getSender(), dpi.getReciever()); - break; - case REQUEST: - handleRequestDuel(dpi.getSender(), dpi.getReciever()); - break; - } - } - private boolean isLocationValidToDuel(CreatureObject creature1, CreatureObject creature2) { Location location1 = creature1.getWorldLocation(); Location location2 = creature2.getWorldLocation(); diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatXpService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatExperienceService.java similarity index 92% rename from src/main/java/com/projectswg/holocore/services/combat/CombatXpService.java rename to src/main/java/com/projectswg/holocore/services/combat/CombatExperienceService.java index 75ef4090b..c57f4b7ba 100644 --- a/src/main/java/com/projectswg/holocore/services/combat/CombatXpService.java +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatExperienceService.java @@ -26,18 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.combat; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.baselines.Baseline.BaselineType; - import com.projectswg.holocore.intents.combat.CreatureKilledIntent; import com.projectswg.holocore.intents.experience.ExperienceIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; @@ -47,13 +38,22 @@ import com.projectswg.holocore.resources.objects.creature.CreatureDifficulty; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.group.GroupObject; import com.projectswg.holocore.resources.server_info.StandardLog; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; -final class CombatXpService extends Service { +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class CombatExperienceService extends Service { private final Map xpData; private final Map groupObjects; - CombatXpService() { + public CombatExperienceService() { xpData = new HashMap<>(); groupObjects = new ConcurrentHashMap<>(); } @@ -61,17 +61,7 @@ final class CombatXpService extends Service { @Override public boolean initialize() { loadXpData(); - return super.initialize(); - } - - @Override - public boolean start() { - // The objects we care about are only created/destroyed at this point anyways. - registerForIntent(ObjectCreatedIntent.class, this::handleObjectCreatedIntent); - registerForIntent(DestroyObjectIntent.class, this::handleDestroyObjectIntent); - registerForIntent(CreatureKilledIntent.class, this::handleCreatureKilledIntent); - - return super.start(); + return true; } private void loadXpData() { @@ -88,6 +78,7 @@ final class CombatXpService extends Service { StandardLog.onEndLoad(xpData.size(), "combat XP rates", startTime); } + @IntentHandler private void handleObjectCreatedIntent(ObjectCreatedIntent i) { SWGObject object = i.getObject(); @@ -96,6 +87,7 @@ final class CombatXpService extends Service { } } + @IntentHandler private void handleDestroyObjectIntent(DestroyObjectIntent i) { SWGObject object = i.getObject(); @@ -104,6 +96,7 @@ final class CombatXpService extends Service { } } + @IntentHandler private void handleCreatureKilledIntent(CreatureKilledIntent i) { CreatureObject corpse = i.getCorpse(); diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatManager.java b/src/main/java/com/projectswg/holocore/services/combat/CombatManager.java index 734c52b40..1387a6528 100644 --- a/src/main/java/com/projectswg/holocore/services/combat/CombatManager.java +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatManager.java @@ -26,17 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.services.combat; -import com.projectswg.common.concurrency.PswgScheduledThreadPool; -import com.projectswg.common.control.Manager; import com.projectswg.common.data.CRC; import com.projectswg.common.data.RGB; import com.projectswg.common.data.combat.*; import com.projectswg.common.data.encodables.oob.OutOfBandPackage; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; -import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.data.location.Location; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText; import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText.Scale; @@ -45,8 +41,9 @@ import com.projectswg.common.network.packets.swg.zone.object_controller.combat.C import com.projectswg.common.network.packets.swg.zone.object_controller.combat.CombatSpam; import com.projectswg.holocore.intents.BuffIntent; import com.projectswg.holocore.intents.chat.ChatCommandIntent; -import com.projectswg.holocore.intents.chat.SystemMessageIntent; -import com.projectswg.holocore.intents.combat.*; +import com.projectswg.holocore.intents.combat.DeathblowIntent; +import com.projectswg.holocore.intents.combat.IncapacitateCreatureIntent; +import com.projectswg.holocore.intents.combat.KillCreatureIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.commands.CombatCommand; @@ -55,40 +52,42 @@ import com.projectswg.holocore.resources.objects.awareness.AwarenessType; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.objects.weapon.WeaponObject; -import com.projectswg.holocore.services.loot.LootManager; +import com.projectswg.holocore.services.combat.loot.LootManager; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; +import me.joshlarson.jlcommon.log.Log; -import java.awt.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.Future; import java.util.stream.Collectors; +@ManagerStructure(children = { + CombatRegenerationService.class, + CombatDeathblowService.class, + CombatStatusService.class, + CombatCommandService.class, + CombatExperienceService.class, + CombatCloningService.class, + CombatNpcService.class, + CombatDuelService.class, + LootManager.class +}) public class CombatManager extends Manager { - private static final byte INCAP_TIMER = 10; // Amount of seconds to be incapacitated + private static final RGB COLOR_WHITE = new RGB(255, 255, 255); + private static final RGB COLOR_CYAN = new RGB(0, 255, 255); private final Map inCombat; - private final Set regeneratingHealthCreatures; // Only allowed outside of combat - private final Set regeneratingActionCreatures; // Always allowed - private final Map> incapacitatedCreatures; - private final PswgScheduledThreadPool executor; + private final ScheduledThreadPool executor; private final Random random; public CombatManager() { this.inCombat = new ConcurrentHashMap<>(); - this.regeneratingHealthCreatures = new CopyOnWriteArraySet<>(); - this.regeneratingActionCreatures = new CopyOnWriteArraySet<>(); - this.incapacitatedCreatures = new ConcurrentHashMap<>(); - this.executor = new PswgScheduledThreadPool(1, "combat-service"); + this.executor = new ScheduledThreadPool(1, "combat-service"); this.random = new Random(); - addChildService(new CorpseService()); - addChildService(new CombatXpService()); - addChildService(new DuelPlayerService()); - addChildService(new LootManager()); - registerForIntent(DeathblowIntent.class, this::handleDeathblowIntent); registerForIntent(ChatCommandIntent.class, this::handleChatCommandIntent); registerForIntent(IncapacitateCreatureIntent.class, ici -> incapacitatePlayer(ici.getIncapper(), ici.getIncappee())); @@ -114,346 +113,11 @@ public class CombatManager extends Manager { inCombat.values().stream().filter(c -> c.getTimeSinceCombat() >= 10E3).forEach(c -> exitCombat(c.getCreature())); } - private void periodicRegeneration() { - regeneratingHealthCreatures.forEach(this::regenerationHealthTick); - regeneratingActionCreatures.forEach(this::regenerationActionTick); - } - - private void regenerationActionTick(CreatureObject creature) { - if (creature.getAction() >= creature.getMaxAction()) { - if (!creature.isInCombat()) - stopActionRegeneration(creature); - return; - } - - int modification = creature.getSkillModValue("action_regen"); - - if (!creature.isInCombat()) - modification *= 4; - - creature.modifyAction(modification); - } - - private void regenerationHealthTick(CreatureObject creature) { - if (creature.getHealth() >= creature.getMaxHealth()) { - if (!creature.isInCombat()) - stopHealthRegeneration(creature); - return; - } - - int modification = creature.getSkillModValue("health_regen"); - - if (!creature.isInCombat()) - modification *= 4; - - creature.modifyHealth(modification); - } - - private void handleChatCommandIntent(ChatCommandIntent cci) { - if (!cci.getCommand().isCombatCommand() || !(cci.getCommand() instanceof CombatCommand)) - return; - CombatCommand c = (CombatCommand) cci.getCommand(); - CreatureObject source = cci.getSource(); - SWGObject target = cci.getTarget(); - - // Regardless of HitType, the command might have action cost - addActionCost(source, c); - - // TODO implement support for remaining HitTypes - switch (c.getHitType()) { - case ATTACK: - handleAttack(source, target, null, c); - break; - case BUFF: - handleBuff(source, target, c); - break; - case HEAL: - handleHeal(source, target, c); - break; - case DELAY_ATTACK: - handleDelayAttack(source, target, c, cci.getArguments()); - break; - default: - handleStatus(source, CombatStatus.UNKNOWN); - break; - } - } - private void updateCombatList(CreatureObject creature) { CombatCreature combat = inCombat.computeIfAbsent(creature.getObjectId(), s -> new CombatCreature(creature)); combat.updateLastCombat(); } - private void handleAttack(CreatureObject source, SWGObject target, SWGObject delayEgg, CombatCommand command) { - if (!handleStatus(source, canPerform(source, target, command))) - return; - - WeaponObject weapon = source.getEquippedWeapon(); - - for (int i = 0; i < command.getAttackRolls(); i++) { - AttackInfo info = new AttackInfo(); - - switch (command.getAttackType()) { - case SINGLE_TARGET: - doCombatSingle(source, target, info, weapon, command); - break; - case AREA: - doCombatArea(source, source, info, weapon, command, false); - break; - case TARGET_AREA: - if (target != null) { - // Same as AREA, but the target is the destination for the AoE and can take damage - doCombatArea(source, delayEgg != null ? delayEgg : target, info, weapon, command, true); - } else { - // TODO AoE based on Location instead of delay egg - } - - break; - default: - break; - } - } - } - - private void handleBuff(CreatureObject source, SWGObject target, CombatCommand combatCommand) { - // TODO group buffs - addBuff(source, source, combatCommand.getBuffNameSelf()); - - if (!(target instanceof CreatureObject)) { - return; // Only CreatureObjects have buffs - } - - String buffNameTarget = combatCommand.getBuffNameTarget(); - - addBuff(source, (CreatureObject) target, buffNameTarget); - - CreatureObject creatureTarget = (CreatureObject) target; - CombatAction action = new CombatAction(source.getObjectId()); - WeaponObject weapon = source.getEquippedWeapon(); - String anim = combatCommand.getRandomAnimation(weapon.getType()); // Uses defaultAnim if it needs to - action.setPosture(source.getPosture()); - action.setAttackerId(source.getObjectId()); - action.setActionCrc(CRC.getCrc(anim)); - action.setWeaponId(weapon.getObjectId()); - action.setCommandCrc(combatCommand.getCrc()); - action.setTrail(TrailLocation.RIGHT_HAND); - action.setUseLocation(false); - - action.addDefender(new Defender(source.getObjectId(), source.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0)); - - if (!buffNameTarget.isEmpty()) { - action.addDefender(new Defender(creatureTarget.getObjectId(), creatureTarget.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0)); - } - - CombatSpam combatSpam = new CombatSpam(source.getObjectId()); - - combatSpam.setAttacker(source.getObjectId()); - combatSpam.setAttackerPosition(source.getLocation().getPosition()); - combatSpam.setWeapon(weapon.getObjectId()); - combatSpam.setDefender(target.getObjectId()); - combatSpam.setDefenderPosition(target.getLocation().getPosition()); - combatSpam.setInfo(new AttackInfo()); - combatSpam.setAttackName(new StringId("cmd_n", combatCommand.getName())); - combatSpam.setSpamType(CombatSpamFilterType.ALL); - // TODO doesn't look like a buff in the combat log - - source.sendObservers(action, combatSpam); - } - - private void handleHeal(CreatureObject source, SWGObject target, CombatCommand combatCommand) { - int healAmount = combatCommand.getAddedDamage(); - int healingPotency = source.getSkillModValue("expertise_healing_all"); - - if (healingPotency > 0) { - healAmount *= healingPotency; - } - - switch (combatCommand.getAttackType()) { - case SINGLE_TARGET: { - switch (combatCommand.getTargetType()) { - case NONE: { // No target used, always heals self - doHeal(source, source, healAmount, combatCommand); - break; - } - case REQUIRED: { // Target is always used - if (target == null) { - return; - } - - // Same logic as OPTIONAL and ALL, so no break! - } - case OPTIONAL: // Appears to be the same as ALL - case ALL: { // Target is used IF supplied - if (target != null) { - if (!(target instanceof CreatureObject)) { - return; - } - - CreatureObject creatureTarget = (CreatureObject) target; - - if (source.isEnemyOf(creatureTarget)) { - doHeal(source, source, healAmount, combatCommand); - } else { - doHeal(source, creatureTarget, healAmount, combatCommand); - } - } else { - doHeal(source, source, healAmount, combatCommand); - } - - break; - } - } - break; - } - - case AREA: { - // Targets are never supplied for AoE heals - float range = combatCommand.getConeLength(); - Location sourceLocation = source.getWorldLocation(); - - for (SWGObject nearbyObject : source.getAware(AwarenessType.OBJECT)) { // The source is included in awareness - if (sourceLocation.isWithinDistance(nearbyObject.getLocation(), range)) { - if (!(nearbyObject instanceof CreatureObject)) { - // We can't heal something that's not a creature - continue; - } - - CreatureObject nearbyCreature = (CreatureObject) nearbyObject; - - if (source.isAttackable(nearbyCreature)) { - continue; - } - - // Heal nearby friendly - doHeal(source, nearbyCreature, healAmount, combatCommand); - } - } - - break; - } - } - } - - private void handleDelayAttack(CreatureObject source, SWGObject target, CombatCommand combatCommand, String arguments[]) { - Location eggLocation; - SWGObject eggParent; - - switch (combatCommand.getEggPosition()) { - case LOCATION: - if (arguments[0].equals("a") || arguments[0].equals("c")) { // is "c" in free-targeting mode - eggLocation = source.getLocation(); - } else { - eggLocation = new Location(Float.parseFloat(arguments[0]), Float.parseFloat(arguments[1]), Float.parseFloat(arguments[2]), source - .getTerrain()); - } - - eggParent = source.getParent(); - break; - default: - Log.w("Unrecognised delay egg position %s from command %s - defaulting to SELF", combatCommand.getEggPosition(), combatCommand - .getName()); - case SELF: - eggLocation = source.getLocation(); - eggParent = source.getParent(); - break; - case TARGET: - eggLocation = target.getLocation(); - eggParent = target.getParent(); - break; - } - - // Spawn delay egg object - String eggTemplate = combatCommand.getDelayAttackEggTemplate(); - SWGObject delayEgg = eggTemplate.endsWith("generic_egg_small.iff") ? null : ObjectCreator.createObjectFromTemplate(eggTemplate); - - if (delayEgg != null) { - delayEgg.setLocation(eggLocation); - delayEgg.moveToContainer(eggParent); - ObjectCreatedIntent.broadcast(delayEgg); - } - - long interval = (long) (combatCommand.getInitialDelayAttackInterval() * 1000); - executor.execute(interval, () -> delayEggLoop(delayEgg, source, target, combatCommand, 1)); - } - - private void delayEggLoop(final SWGObject delayEgg, final CreatureObject source, final SWGObject target, final CombatCommand combatCommand, final int currentLoop) { - String delayAttackParticle = combatCommand.getDelayAttackParticle(); - - // Show particle effect to everyone observing the delay egg, if one is defined - if (delayEgg != null && !delayAttackParticle.isEmpty()) - delayEgg.sendObservers(new PlayClientEffectObjectMessage(delayAttackParticle, "", delayEgg.getObjectId(), "")); - - // Handle the attack of this loop - handleAttack(source, target, delayEgg, combatCommand); - - if (currentLoop < combatCommand.getDelayAttackLoops()) { - // Recursively schedule another loop if that wouldn't exceed the amount of loops we need to perform - long interval = (long) (combatCommand.getDelayAttackInterval() * 1000); - executor.execute(interval, () -> delayEggLoop(delayEgg, source, target, combatCommand, currentLoop + 1)); - } else if (delayEgg != null) { - // The delayed attack has ended - destroy the egg - new DestroyObjectIntent(delayEgg).broadcast(); - } - } - - private void doHeal(CreatureObject healer, CreatureObject healed, int healAmount, CombatCommand combatCommand) { - String attribName; - int difference; - - switch (combatCommand.getHealAttrib()) { - case HEALTH: { - int currentHealth = healed.getHealth(); - healed.modifyHealth(healAmount); - difference = healed.getHealth() - currentHealth; - attribName = "HEALTH"; - break; - } - - case ACTION: { - int currentAction = healed.getAction(); - healed.modifyAction(healAmount); - difference = healed.getAction() - currentAction; - attribName = "ACTION"; - break; - } - - default: - return; - } - - CombatAction action = new CombatAction(healer.getObjectId()); - WeaponObject weapon = healer.getEquippedWeapon(); - String anim = combatCommand.getRandomAnimation(weapon.getType()); // Uses defaultAnim if it needs to - - action.setPosture(healed.getPosture()); - action.setAttackerId(healer.getObjectId()); - action.setActionCrc(CRC.getCrc(anim)); - action.setWeaponId(weapon.getObjectId()); - action.setCommandCrc(combatCommand.getCrc()); - action.setTrail(TrailLocation.RIGHT_HAND); - action.setUseLocation(false); - - action.addDefender(new Defender(healed.getObjectId(), healed.getPosture(), false, (byte) 0, HitLocation.HIT_LOCATION_BODY, (short) 0)); - - OutOfBandPackage oobp = new OutOfBandPackage(new ProsePackage("StringId", new StringId("healing", "heal_fly"), "DI", difference, "TO", attribName)); - ShowFlyText flyText = new ShowFlyText(healed.getObjectId(), oobp, Scale.MEDIUM, new RGB(46, 139, 87), ShowFlyText.Flag.IS_HEAL); - PlayClientEffectObjectMessage effect = new PlayClientEffectObjectMessage("appearance/pt_heal.prt", "root", healed.getObjectId(), ""); - CombatSpam combatSpam = new CombatSpam(healer.getObjectId()); - - combatSpam.setAttacker(healer.getObjectId()); - combatSpam.setAttackerPosition(healer.getLocation().getPosition()); - combatSpam.setWeapon(weapon.getObjectId()); - combatSpam.setWeaponName(weapon.getStringId()); - combatSpam.setDefender(healed.getObjectId()); - combatSpam.setDefenderPosition(healed.getLocation().getPosition()); - combatSpam.setInfo(new AttackInfo()); - combatSpam.setAttackName(new StringId("cmd_n", combatCommand.getName())); - combatSpam.setSpamType(CombatSpamFilterType.ALL); - // TODO doesn't look like a heal in the combat log - - healed.sendObservers(action, flyText, effect, combatSpam); - } - private void doCombatSingle(CreatureObject source, SWGObject target, AttackInfo info, WeaponObject weapon, CombatCommand command) { // TODO single target only defence rolls against target // TODO single target only offence rolls for source @@ -586,127 +250,21 @@ public class CombatManager extends Manager { } } - private void doCreatureDeath(CreatureObject corpse, CreatureObject killer) { - corpse.setHealth(0); - killer.removeDefender(corpse); - - if (!killer.hasDefenders()) { - exitCombat(killer); - } - - // The creature should not be able to move or turn. - corpse.setTurnScale(0); - corpse.setMovementScale(0); - - if (corpse.isPlayer()) { - if (corpse.hasBuff("incapWeaken")) { - killCreature(killer, corpse); - } else { - incapacitatePlayer(killer, corpse); - } - } else { - killCreature(killer, corpse); - } - - exitCombat(corpse); - } - - private void incapacitatePlayer(CreatureObject incapacitator, CreatureObject incapacitated) { - incapacitated.setPosture(Posture.INCAPACITATED); - incapacitated.setCounter(INCAP_TIMER); - - Log.i("%s was incapacitated", incapacitated); - - // Once the incapacitation counter expires, revive them. - incapacitatedCreatures.put(incapacitated, executor.execute(INCAP_TIMER * 1000, () -> expireIncapacitation(incapacitated))); - - new BuffIntent("incapWeaken", incapacitator, incapacitated, false).broadcast(); - new SystemMessageIntent(incapacitator.getOwner(), new ProsePackage(new StringId("base_player", "prose_target_incap"), "TT", incapacitated - .getObjectName())).broadcast(); - new SystemMessageIntent(incapacitated.getOwner(), new ProsePackage(new StringId("base_player", "prose_victim_incap"), "TT", incapacitator - .getObjectName())).broadcast(); - new CreatureIncapacitatedIntent(incapacitator, incapacitated).broadcast(); - } - - private void expireIncapacitation(CreatureObject incapacitatedPlayer) { - incapacitatedCreatures.remove(incapacitatedPlayer); - reviveCreature(incapacitatedPlayer); - } - - private void reviveCreature(CreatureObject revivedCreature) { - if (revivedCreature.isPlayer()) - revivedCreature.setCounter(0); - - revivedCreature.setPosture(Posture.UPRIGHT); - - // The creature is now able to turn around and move - revivedCreature.setTurnScale(1); - revivedCreature.setMovementScale(1); - - // Give 'em a percentage of their health and schedule them for HAM regeneration. - revivedCreature.setHealth((int) (revivedCreature.getBaseHealth() * 0.1)); // Restores 10% health of their base health - startHealthRegeneration(revivedCreature); - startActionRegeneration(revivedCreature); - - Log.i("%s was revived", revivedCreature); - } - - private void killCreature(CreatureObject killer, CreatureObject corpse) { - // We don't want to kill a creature that is already dead - if (corpse.getPosture() == Posture.DEAD) - return; - - corpse.setPosture(Posture.DEAD); - new CreatureKilledIntent(killer, corpse).broadcast(); - } - - private void handleDeathblowIntent(DeathblowIntent di) { - CreatureObject killer = di.getKiller(); - CreatureObject corpse = di.getCorpse(); - - // Only deathblowing players is allowed! - if (!corpse.isPlayer()) { - return; - } - - // They must be enemies - if (!corpse.isEnemyOf(killer)) { - return; - } - - // The target of the deathblow must be incapacitated! - if (corpse.getPosture() != Posture.INCAPACITATED) { - return; - } - - // If they're deathblown while incapacitated, their incapacitation expiration timer should cancel - Future incapacitationTimer = incapacitatedCreatures.remove(corpse); - - if (incapacitationTimer != null) { - if (incapacitationTimer.cancel(false)) { // If the task is running, let them get back up - killCreature(killer, corpse); - } - } else { - // Can't happen with the current code, but in case it's ever refactored... - Log.e("Incapacitation timer for player %s being deathblown unexpectedly didn't exist!", ""); - } - } - private boolean handleStatus(CreatureObject source, CombatStatus status) { switch (status) { case SUCCESS: return true; case NO_TARGET: - showFlyText(source, "@combat_effects:target_invalid_fly", Scale.MEDIUM, Color.WHITE, ShowFlyText.Flag.PRIVATE); + showFlyText(source, "@combat_effects:target_invalid_fly", Scale.MEDIUM, COLOR_WHITE, ShowFlyText.Flag.PRIVATE); return false; case TOO_FAR: - showFlyText(source, "@combat_effects:range_too_far", Scale.MEDIUM, Color.CYAN, ShowFlyText.Flag.PRIVATE); + showFlyText(source, "@combat_effects:range_too_far", Scale.MEDIUM, COLOR_CYAN, ShowFlyText.Flag.PRIVATE); return false; case INVALID_TARGET: - showFlyText(source, "@combat_effects:target_invalid_fly", Scale.MEDIUM, Color.CYAN, ShowFlyText.Flag.PRIVATE); + showFlyText(source, "@combat_effects:target_invalid_fly", Scale.MEDIUM, COLOR_CYAN, ShowFlyText.Flag.PRIVATE); return false; default: - showFlyText(source, "@combat_effects:action_failed", Scale.MEDIUM, Color.WHITE, ShowFlyText.Flag.PRIVATE); + showFlyText(source, "@combat_effects:action_failed", Scale.MEDIUM, COLOR_WHITE, ShowFlyText.Flag.PRIVATE); return false; } } @@ -792,24 +350,8 @@ public class CombatManager extends Manager { new BuffIntent(buffName, caster, receiver, false).broadcast(); } - private void showFlyText(TangibleObject obj, String text, Scale scale, Color c, ShowFlyText.Flag... flags) { - obj.sendSelf(new ShowFlyText(obj.getObjectId(), text, scale, new RGB(c), flags)); - } - - private void startActionRegeneration(CreatureObject creature) { - regeneratingActionCreatures.add(creature); - } - - private void startHealthRegeneration(CreatureObject creature) { - regeneratingHealthCreatures.add(creature); - } - - private void stopActionRegeneration(CreatureObject creature) { - regeneratingActionCreatures.remove(creature); - } - - private void stopHealthRegeneration(CreatureObject creature) { - regeneratingHealthCreatures.remove(creature); + private void showFlyText(TangibleObject obj, String text, Scale scale, RGB c, ShowFlyText.Flag... flags) { + obj.sendSelf(new ShowFlyText(obj.getObjectId(), text, scale, c, flags)); } private static class CombatCreature { diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatNpcService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatNpcService.java new file mode 100644 index 000000000..bd28194ad --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatNpcService.java @@ -0,0 +1,74 @@ +package com.projectswg.holocore.services.combat; + +import com.projectswg.holocore.intents.combat.CorpseLootedIntent; +import com.projectswg.holocore.intents.combat.CreatureKilledIntent; +import com.projectswg.holocore.intents.object.DestroyObjectIntent; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public class CombatNpcService extends Service { + + private final Map> deleteCorpseTasks; + private final ScheduledThreadPool executor; + + public CombatNpcService() { + this.deleteCorpseTasks = new HashMap<>(); + this.executor = new ScheduledThreadPool(1, "combat-npc-service"); + } + + @Override + public boolean start() { + executor.start(); + return true; + } + + @Override + public boolean stop() { + executor.stop(); + executor.awaitTermination(1000); + return true; + } + + @IntentHandler + private void handleCreatureKilledIntent(CreatureKilledIntent i) { + CreatureObject corpse = i.getCorpse(); + if (corpse.isPlayer()) + return; + + deleteCorpseTasks.put(corpse.getObjectId(), executor.execute(TimeUnit.SECONDS.toMillis(120), () -> deleteCorpse(corpse))); + } + + @IntentHandler + private void handleCorpseLootedIntent(CorpseLootedIntent i) { + CreatureObject corpse = i.getCorpse(); + assert !corpse.isPlayer() : "Cannot (shouldn't) loot a player"; + + ScheduledFuture task = deleteCorpseTasks.get(corpse.getObjectId()); + + if (task == null) { + Log.w("There should already be a deleteCorpse task for corpse %s!", corpse.toString()); + executor.execute(5000, () -> deleteCorpse(corpse)); + return; + } + + // if existing deleteCorpse task has more than 5 seconds remaining, cancel it + // if the cancel operation succeeds, schedule another deleteCorpse task for 5 seconds + if (task.getDelay(TimeUnit.SECONDS) > 5 && task.cancel(false)) + executor.execute(5000, () -> deleteCorpse(corpse)); + } + + private void deleteCorpse(CreatureObject creatureCorpse) { + DestroyObjectIntent.broadcast(creatureCorpse); + deleteCorpseTasks.remove(creatureCorpse.getObjectId()); + Log.d("Corpse of NPC %s was deleted from the world", creatureCorpse); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatRegenerationService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatRegenerationService.java new file mode 100644 index 000000000..392c2567d --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatRegenerationService.java @@ -0,0 +1,72 @@ +package com.projectswg.holocore.services.combat; + +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.control.Service; + +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; + +public class CombatRegenerationService extends Service { + + private final Set regeneratingHealthCreatures; // Only allowed outside of combat + private final Set regeneratingActionCreatures; // Always allowed + + public CombatRegenerationService() { + this.regeneratingHealthCreatures = new CopyOnWriteArraySet<>(); + this.regeneratingActionCreatures = new CopyOnWriteArraySet<>(); + + // TODO: executor.executeWithFixedRate(1000, 1000, this::periodicRegeneration); + } + + private void periodicRegeneration() { + regeneratingHealthCreatures.forEach(this::regenerationHealthTick); + regeneratingActionCreatures.forEach(this::regenerationActionTick); + } + + private void regenerationActionTick(CreatureObject creature) { + if (creature.getAction() >= creature.getMaxAction()) { + if (!creature.isInCombat()) + stopActionRegeneration(creature); + return; + } + + int modification = creature.getSkillModValue("action_regen"); + + if (!creature.isInCombat()) + modification *= 4; + + creature.modifyAction(modification); + } + + private void regenerationHealthTick(CreatureObject creature) { + if (creature.getHealth() >= creature.getMaxHealth()) { + if (!creature.isInCombat()) + stopHealthRegeneration(creature); + return; + } + + int modification = creature.getSkillModValue("health_regen"); + + if (!creature.isInCombat()) + modification *= 4; + + creature.modifyHealth(modification); + } + + private void startActionRegeneration(CreatureObject creature) { + regeneratingActionCreatures.add(creature); + } + + private void startHealthRegeneration(CreatureObject creature) { + regeneratingHealthCreatures.add(creature); + } + + private void stopActionRegeneration(CreatureObject creature) { + regeneratingActionCreatures.remove(creature); + } + + private void stopHealthRegeneration(CreatureObject creature) { + regeneratingHealthCreatures.remove(creature); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/combat/CombatStatusService.java b/src/main/java/com/projectswg/holocore/services/combat/CombatStatusService.java new file mode 100644 index 000000000..6df86157d --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/combat/CombatStatusService.java @@ -0,0 +1,11 @@ +package com.projectswg.holocore.services.combat; + +import me.joshlarson.jlcommon.control.Service; + +public class CombatStatusService extends Service { + + public CombatStatusService() { + + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/combat/loot/LootManager.java b/src/main/java/com/projectswg/holocore/services/combat/loot/LootManager.java new file mode 100644 index 000000000..58e19b373 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/combat/loot/LootManager.java @@ -0,0 +1,16 @@ +package com.projectswg.holocore.services.combat.loot; + +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; + +@ManagerStructure(children = { + LootService.class, + RareLootService.class +}) +public class LootManager extends Manager { + + public LootManager() { + + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/loot/LootManager.java b/src/main/java/com/projectswg/holocore/services/combat/loot/LootService.java similarity index 97% rename from src/main/java/com/projectswg/holocore/services/loot/LootManager.java rename to src/main/java/com/projectswg/holocore/services/combat/loot/LootService.java index 62975d107..4dff8722f 100644 --- a/src/main/java/com/projectswg/holocore/services/loot/LootManager.java +++ b/src/main/java/com/projectswg/holocore/services/combat/loot/LootService.java @@ -24,17 +24,14 @@ * You should have received a copy of the GNU Affero General Public License * * along with Holocore. If not, see . * ***********************************************************************************/ -package com.projectswg.holocore.services.loot; +package com.projectswg.holocore.services.combat.loot; -import com.projectswg.common.control.Manager; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.ClientOpenContainerMessage; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectTransformMessage; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; @@ -65,12 +62,15 @@ import com.projectswg.holocore.resources.server_info.loader.npc.NpcLoader.NpcInf import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.services.objects.ObjectManager.ObjectLookup; import com.projectswg.holocore.services.objects.StaticItemService; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; -public final class LootManager extends Manager { +public final class LootService extends Service { private static final String LOOT_TABLE_SELECTOR = "SELECT * FROM loot_table"; @@ -81,18 +81,11 @@ public final class LootManager extends Manager { private final Map npcLoot; // K: npc_id, V: possible loot private final Random random; - public LootManager() { + public LootService() { lootTables = new HashMap<>(); npcLoot = new HashMap<>(); random = new Random(); - addChildService(new RareLootService()); - - registerForIntent(ChatCommandIntent.class, this::handleChatCommand); - registerForIntent(ContainerTransferIntent.class, this::handleContainerTransfer); - registerForIntent(CreatureKilledIntent.class, this::handleCreatureKilled); - registerForIntent(LootRequestIntent.class, this::handleLootRequestIntent); - registerForIntent(LootItemIntent.class, this::handleLootItemIntent); } @Override @@ -230,6 +223,7 @@ public final class LootManager extends Manager { loot.addNPCTable(new NPCTable(chance, lootTable)); } + @IntentHandler private void handleContainerTransfer(ContainerTransferIntent cti) { SWGObject object = cti.getObject(); @@ -240,6 +234,7 @@ public final class LootManager extends Manager { object.setContainerPermissions(ContainerPermissionsType.DEFAULT); } + @IntentHandler private void handleCreatureKilled(CreatureKilledIntent cki) { CreatureObject corpse = cki.getCorpse(); @@ -278,6 +273,7 @@ public final class LootManager extends Manager { showLootDisc(killer, corpse); } + @IntentHandler private void handleChatCommand(ChatCommandIntent cci) { if (!cci.getCommand().getName().equalsIgnoreCase("loot")) { @@ -296,6 +292,7 @@ public final class LootManager extends Manager { lootAll(cci.getSource(), target); } + @IntentHandler private void handleLootRequestIntent(LootRequestIntent lri) { Player player = lri.getPlayer(); CreatureObject looter = player.getCreatureObject(); @@ -320,6 +317,7 @@ public final class LootManager extends Manager { } } + @IntentHandler private void handleLootItemIntent(LootItemIntent lii) { CreatureObject looter = lii.getLooter().getCreatureObject(); SWGObject item = lii.getItem(); @@ -432,7 +430,7 @@ public final class LootManager extends Manager { } private void showLootDisc(CreatureObject requester, SWGObject corpse) { - Assert.test(requester.isPlayer()); + assert requester.isPlayer(); Location effectLocation = Location.builder(corpse.getLocation()).setPosition(0, 0.5, 0).build(); diff --git a/src/main/java/com/projectswg/holocore/services/loot/RareLootService.java b/src/main/java/com/projectswg/holocore/services/combat/loot/RareLootService.java similarity index 97% rename from src/main/java/com/projectswg/holocore/services/loot/RareLootService.java rename to src/main/java/com/projectswg/holocore/services/combat/loot/RareLootService.java index 343928599..39be4d505 100644 --- a/src/main/java/com/projectswg/holocore/services/loot/RareLootService.java +++ b/src/main/java/com/projectswg/holocore/services/combat/loot/RareLootService.java @@ -24,10 +24,8 @@ * You should have received a copy of the GNU Affero General Public License * * along with Holocore. If not, see . * ***********************************************************************************/ -package com.projectswg.holocore.services.loot; +package com.projectswg.holocore.services.combat.loot; -import com.projectswg.common.control.Service; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; import com.projectswg.common.network.packets.swg.zone.object_controller.ShowLootBox; @@ -37,6 +35,8 @@ import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureDifficulty; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.util.Random; diff --git a/src/main/java/com/projectswg/holocore/services/commands/BuffService.java b/src/main/java/com/projectswg/holocore/services/commands/BuffService.java index fe82efb8f..855d50ff6 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/BuffService.java +++ b/src/main/java/com/projectswg/holocore/services/commands/BuffService.java @@ -26,11 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands; -import com.projectswg.common.concurrency.PswgBasicScheduledThread; -import com.projectswg.common.control.Service; import com.projectswg.common.data.CRC; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.holocore.ProjectSWG; import com.projectswg.holocore.intents.BuffIntent; @@ -42,6 +38,12 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.services.commands.buff.BuffData; import com.projectswg.holocore.services.commands.buff.BuffMap; +import me.joshlarson.jlcommon.concurrency.BasicScheduledThread; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.stream.Stream; @@ -56,18 +58,14 @@ public class BuffService extends Service { * Perform same check upon zoning in. Skillmod1 effect name is "group" */ - private final PswgBasicScheduledThread timerCheckThread; + private final BasicScheduledThread timerCheckThread; private final Set monitored; private final BuffMap dataMap; // All CRCs are lower-cased buff names! public BuffService() { - timerCheckThread = new PswgBasicScheduledThread("buff-timer-check", this::checkBuffTimers); + timerCheckThread = new BasicScheduledThread("buff-timer-check", this::checkBuffTimers); monitored = new HashSet<>(); dataMap = new BuffMap(); - - registerForIntent(BuffIntent.class, this::handleBuffIntent); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); - registerForIntent(CreatureKilledIntent.class, this::handleCreatureKilledIntent); } @Override @@ -100,10 +98,11 @@ public class BuffService extends Service { } } + @IntentHandler private void handleBuffIntent(BuffIntent bi) { BuffData buffData = getBuff(bi.getBuffName()); - Assert.notNull(buffData, "No known buff: " + bi.getBuffName()); - Assert.test(buffData.getName().equals(bi.getBuffName()), "BuffIntent name ["+bi.getBuffName()+"] does not match BuffData name ["+buffData.getName()+"]"); + Objects.requireNonNull(buffData, "No known buff: " + bi.getBuffName()); + assert buffData.getName().equals(bi.getBuffName()) : "BuffIntent name ["+bi.getBuffName()+"] does not match BuffData name ["+buffData.getName()+"]"; if (bi.isRemove()) { removeBuff(bi.getReceiver(), buffData, false); } else { @@ -111,6 +110,7 @@ public class BuffService extends Service { } } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei) { CreatureObject creature = pei.getPlayer().getCreatureObject(); @@ -137,6 +137,7 @@ public class BuffService extends Service { removeAllBuffs(creature, creature.getBuffEntries(buff -> !isBuffPersistent(buff))); } + @IntentHandler private void handleCreatureKilledIntent(CreatureKilledIntent cki) { CreatureObject corpse = cki.getCorpse(); @@ -205,9 +206,7 @@ public class BuffService extends Service { buffStream.forEach(buff -> removeBuff(creature, getBuff(buff), true)); } - private void addBuff(CreatureObject receiver, BuffData buffData, CreatureObject buffer) { - Assert.notNull(buffData); - + private void addBuff(CreatureObject receiver, @NotNull BuffData buffData, CreatureObject buffer) { String groupName = buffData.getGroupName(); Optional groupBuff = receiver.getBuffEntries(buff -> groupName.equals(getBuff(buff).getGroupName())).findAny(); @@ -235,9 +234,7 @@ public class BuffService extends Service { } } - private void removeBuff(CreatureObject creature, BuffData buffData, boolean expired) { - Assert.notNull(buffData); - + private void removeBuff(CreatureObject creature, @NotNull BuffData buffData, boolean expired) { Optional optionalEntry = creature.getBuffEntries(buff -> buff.getCrc() == buffData.getCrc()).findAny(); if (!optionalEntry.isPresent()) return; // Obique: Used to be an assertion, however if a service sends the removal after it expires it would assert - so I just removed it. @@ -247,7 +244,7 @@ public class BuffService extends Service { checkStackCount(creature, buff, calculatePlayTime(creature), buffData.getMaxStackCount()); } else { Buff removedBuff = creature.removeBuff(new CRC(buff.getCrc())); - Assert.notNull(removedBuff, "Buff must exist if being removed"); + Objects.requireNonNull(removedBuff, "Buff must exist if being removed"); checkSkillMods(buffData, creature, -removedBuff.getStackCount()); checkCallback(buffData, creature); @@ -260,7 +257,8 @@ public class BuffService extends Service { private void checkStackCount(CreatureObject receiver, Buff buff, int applyTime, int stackMod) { BuffData buffData = getBuff(buff); - Assert.notNull(buffData); + + Objects.requireNonNull(buffData, "No known buff: " + buff.getCrc()); // If it's the same buff, we need to check for stacks int maxStackCount = buffData.getMaxStackCount(); @@ -333,11 +331,13 @@ public class BuffService extends Service { new SkillModIntent(effectName, 0, (int) effectValue * valueFactor, creature).broadcast(); } + @Nullable private BuffData getBuff(String name) { return dataMap.getBuff(name); } - private BuffData getBuff(Buff buff) { + @Nullable + private BuffData getBuff(@NotNull Buff buff) { return dataMap.getBuff(buff.getCrc()); } diff --git a/src/main/java/com/projectswg/holocore/services/commands/CommandContainer.java b/src/main/java/com/projectswg/holocore/services/commands/CommandContainer.java index 62061971a..05cd8eec1 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/CommandContainer.java +++ b/src/main/java/com/projectswg/holocore/services/commands/CommandContainer.java @@ -26,18 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import com.projectswg.holocore.resources.commands.Command; + +import java.util.*; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import com.projectswg.common.debug.Assert; - -import com.projectswg.holocore.resources.commands.Command; - public class CommandContainer { private final ReadWriteLock commandLock; @@ -85,10 +79,10 @@ public class CommandContainer { String name = c.getName(); List scriptCommandList = getScriptListRaw(c.getDefaultScriptCallback()); - Assert.isNull(crcToCommand.get(crc), "Command is already in crc table! CRC="+crc + " Name="+name); - Assert.isNull(nameToCommand.get(name), "Command is already in name table! CRC="+crc + " Name="+name); - Assert.test(!scriptCommandList.contains(c), "Command is already in scripts table! CRC="+crc + " Name="+name); - Assert.test(name.equals(name.toLowerCase(Locale.US)), "Invalid command name - must be all lowercase"); + assert !crcToCommand.containsKey(crc) : "Command is already in crc table! CRC="+crc + " Name="+name; + assert !nameToCommand.containsKey(name) : "Command is already in name table! CRC="+crc + " Name="+name; + assert !scriptCommandList.contains(c) : "Command is already in scripts table! CRC="+crc + " Name="+name; + assert name.equals(name.toLowerCase(Locale.US)) : "Invalid command name - must be all lowercase"; crcToCommand.put(crc, c); nameToCommand.put(name, c); @@ -135,7 +129,7 @@ public class CommandContainer { /** Note: Not Thread-Safe */ private void createScriptCommandList(String script) { - List commands = scriptToCommand.computeIfAbsent(script, k -> new ArrayList<>()); + scriptToCommand.computeIfAbsent(script, k -> new ArrayList<>()); } /** Note: Not Thread-Safe */ diff --git a/src/main/java/com/projectswg/holocore/services/commands/CommandCooldownHandler.java b/src/main/java/com/projectswg/holocore/services/commands/CommandCooldownHandler.java index 99e4c87ee..4aa34d75c 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/CommandCooldownHandler.java +++ b/src/main/java/com/projectswg/holocore/services/commands/CommandCooldownHandler.java @@ -26,25 +26,24 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands; -import java.util.*; - -import com.projectswg.common.concurrency.PswgScheduledThreadPool; import com.projectswg.common.data.CRC; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.object_controller.CommandTimer; - import com.projectswg.holocore.resources.commands.Command; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.commands.CommandLauncher.EnqueuedCommand; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.log.Log; + +import java.util.*; public class CommandCooldownHandler { private final Map> cooldownMap; - private final PswgScheduledThreadPool cooldownThread; + private final ScheduledThreadPool cooldownThread; public CommandCooldownHandler() { this.cooldownMap = new HashMap<>(); - this.cooldownThread = new PswgScheduledThreadPool(1, "command-launcher-cooldown-thread"); + this.cooldownThread = new ScheduledThreadPool(1, "command-launcher-cooldown-thread"); } public void start() { diff --git a/src/main/java/com/projectswg/holocore/services/commands/CommandLauncher.java b/src/main/java/com/projectswg/holocore/services/commands/CommandLauncher.java index 61c5bb068..03d39b1e6 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/CommandLauncher.java +++ b/src/main/java/com/projectswg/holocore/services/commands/CommandLauncher.java @@ -26,10 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands; -import com.projectswg.common.concurrency.PswgScheduledThreadPool; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.object_controller.CommandQueueDequeue; import com.projectswg.common.network.packets.swg.zone.object_controller.CommandQueueEnqueue; import com.projectswg.holocore.intents.chat.ChatCommandIntent; @@ -40,6 +38,8 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.AccessLevel; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.services.galaxy.GalacticManager; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.log.Log; import java.util.HashMap; import java.util.Map; @@ -49,12 +49,12 @@ import java.util.Queue; public class CommandLauncher { private final Map> combatQueueMap; - private final PswgScheduledThreadPool combatQueueThread; + private final ScheduledThreadPool combatQueueThread; private final CommandCooldownHandler cooldownHandler; public CommandLauncher() { this.combatQueueMap = new HashMap<>(); - this.combatQueueThread = new PswgScheduledThreadPool(1, "command-combat-queue"); + this.combatQueueThread = new ScheduledThreadPool(1, "command-combat-queue"); this.cooldownHandler = new CommandCooldownHandler(); } diff --git a/src/main/java/com/projectswg/holocore/services/commands/CommandService.java b/src/main/java/com/projectswg/holocore/services/commands/CommandService.java index ab679947a..7085b8914 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/CommandService.java +++ b/src/main/java/com/projectswg/holocore/services/commands/CommandService.java @@ -26,19 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands; -import java.io.File; -import java.util.List; -import java.util.Locale; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.CRC; import com.projectswg.common.data.combat.*; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.object_controller.CommandQueueEnqueue; - import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.intents.player.PlayerTransformedIntent; @@ -46,30 +39,7 @@ import com.projectswg.holocore.resources.commands.CombatCommand; import com.projectswg.holocore.resources.commands.Command; import com.projectswg.holocore.resources.commands.DefaultPriority; import com.projectswg.holocore.resources.commands.ICmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.AdminTeleportCallback; -import com.projectswg.holocore.resources.commands.callbacks.AttributesCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.ChangeDanceCallback; -import com.projectswg.holocore.resources.commands.callbacks.FindFriendCallback; -import com.projectswg.holocore.resources.commands.callbacks.FlourishCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.GotoCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.JumpCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.KneelCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.LogoutCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.PlayerAppearanceCallback; -import com.projectswg.holocore.resources.commands.callbacks.ProneCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.QaToolCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.RequestBiographyCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.RequestDraftSlotsCallback; -import com.projectswg.holocore.resources.commands.callbacks.RequestWaypointCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.RevertAppearanceCallback; -import com.projectswg.holocore.resources.commands.callbacks.ServerCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.ServerDestroyObjectCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.SitOnObjectCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.SocialInternalCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.StandCmdCallback; -import com.projectswg.holocore.resources.commands.callbacks.StartDanceCallback; -import com.projectswg.holocore.resources.commands.callbacks.TransferItemCallback; -import com.projectswg.holocore.resources.commands.callbacks.WaypointCmdCallback; +import com.projectswg.holocore.resources.commands.callbacks.*; import com.projectswg.holocore.resources.config.ConfigFile; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; @@ -91,6 +61,12 @@ import com.projectswg.holocore.scripts.commands.survey.CmdRequestCoreSample; import com.projectswg.holocore.scripts.commands.survey.CmdRequestSurvey; import com.projectswg.holocore.services.commands.CommandLauncher.EnqueuedCommand; import com.projectswg.holocore.services.galaxy.GalacticManager; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.io.File; +import java.util.List; +import java.util.Locale; public class CommandService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/commands/EntertainmentService.java b/src/main/java/com/projectswg/holocore/services/commands/EntertainmentService.java index f6b24f80e..cd3615898 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/EntertainmentService.java +++ b/src/main/java/com/projectswg/holocore/services/commands/EntertainmentService.java @@ -26,25 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.object_controller.Animation; - import com.projectswg.holocore.intents.DanceIntent; import com.projectswg.holocore.intents.FlourishIntent; import com.projectswg.holocore.intents.PlayerEventIntent; @@ -55,6 +43,17 @@ import com.projectswg.holocore.intents.player.PlayerTransformedIntent; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * diff --git a/src/main/java/com/projectswg/holocore/services/commands/buff/BuffData.java b/src/main/java/com/projectswg/holocore/services/commands/buff/BuffData.java index cc48574a2..58e35b4c5 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/buff/BuffData.java +++ b/src/main/java/com/projectswg/holocore/services/commands/buff/BuffData.java @@ -26,10 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands.buff; -import java.util.Locale; - import com.projectswg.common.data.CRC; -import com.projectswg.common.debug.Assert; +import me.joshlarson.jlcommon.utilities.Arguments; + +import java.util.Locale; public class BuffData { @@ -80,12 +80,12 @@ public class BuffData { } public String getEffectName(int effect) { - Assert.test(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); + Arguments.validate(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); return effectNames[effect]; } public float getEffectValue(int effect) { - Assert.test(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); + Arguments.validate(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); return effectValues[effect]; } @@ -126,12 +126,12 @@ public class BuffData { } public void setEffectName(int effect, String name) { - Assert.test(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); + Arguments.validate(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); effectNames[effect] = name; } public void setEffectValue(int effect, float value) { - Assert.test(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); + Arguments.validate(effect >= 0 && effect < 5, "Effect # must be in range: [0, 5)"); effectValues[effect] = value; } diff --git a/src/main/java/com/projectswg/holocore/services/commands/buff/BuffMap.java b/src/main/java/com/projectswg/holocore/services/commands/buff/BuffMap.java index 8bbe3efde..6287500e5 100644 --- a/src/main/java/com/projectswg/holocore/services/commands/buff/BuffMap.java +++ b/src/main/java/com/projectswg/holocore/services/commands/buff/BuffMap.java @@ -26,20 +26,20 @@ ***********************************************************************************/ package com.projectswg.holocore.services.commands.buff; -import java.util.Locale; -import java.util.Map; - -import com.projectswg.common.concurrency.SynchronizedMap; import com.projectswg.common.data.CRC; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + public class BuffMap { private final Map buffMap; public BuffMap() { - this.buffMap = new SynchronizedMap<>(); + this.buffMap = new ConcurrentHashMap<>(); } public void load() { diff --git a/src/main/java/com/projectswg/holocore/services/crafting/CraftingManager.java b/src/main/java/com/projectswg/holocore/services/crafting/CraftingManager.java index 6cec8a643..1b187f2ac 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/CraftingManager.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/CraftingManager.java @@ -26,16 +26,19 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting; -import com.projectswg.common.control.Manager; - import com.projectswg.holocore.services.crafting.resource.ResourceService; import com.projectswg.holocore.services.crafting.survey.SurveyService; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; +@ManagerStructure(children = { + ResourceService.class, + SurveyService.class +}) public class CraftingManager extends Manager { public CraftingManager() { - addChildService(new ResourceService()); - addChildService(new SurveyService()); + } } diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/ResourceService.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/ResourceService.java index 7c6a92309..ed0f7144b 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/ResourceService.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/ResourceService.java @@ -26,15 +26,14 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.concurrency.PswgBasicScheduledThread; -import com.projectswg.common.control.Service; - import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResourceSpawner; import com.projectswg.holocore.services.crafting.resource.galactic.storage.GalacticResourceContainer; import com.projectswg.holocore.services.crafting.resource.raw.RawResource; import com.projectswg.holocore.services.crafting.resource.raw.RawResourceContainer; +import me.joshlarson.jlcommon.concurrency.BasicScheduledThread; +import me.joshlarson.jlcommon.control.Service; + +import java.util.concurrent.TimeUnit; /** * In charge of spawning, despawning, and overall management of resources @@ -43,12 +42,12 @@ public class ResourceService extends Service { private final RawResourceContainer container; private final GalacticResourceSpawner spawner; - private final PswgBasicScheduledThread spawnerUpdater; + private final BasicScheduledThread spawnerUpdater; public ResourceService() { this.container = new RawResourceContainer(); this.spawner = new GalacticResourceSpawner(); - this.spawnerUpdater = new PswgBasicScheduledThread("resource-spawn-updater", spawner::updateAllResources); + this.spawnerUpdater = new BasicScheduledThread("resource-spawn-updater", spawner::updateAllResources); } @Override diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResource.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResource.java index 2d6fda3b6..569bac24a 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResource.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResource.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.services.crafting.resource.galactic; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; - import com.projectswg.holocore.services.crafting.resource.raw.RawResource; public class GalacticResource implements Persistable { diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceLoader.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceLoader.java index b3cdb376e..f5905f7c0 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceLoader.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceLoader.java @@ -26,13 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.galactic; +import com.projectswg.holocore.resources.server_info.CachedObjectDatabase; +import me.joshlarson.jlcommon.log.Log; + import java.util.ArrayList; import java.util.List; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.server_info.CachedObjectDatabase; - public class GalacticResourceLoader { public GalacticResourceLoader() { diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawn.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawn.java index 4730daf1b..434c25692 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawn.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawn.java @@ -26,17 +26,16 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.galactic; -import java.util.Random; -import java.util.concurrent.TimeUnit; - import com.projectswg.common.data.location.Terrain; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; import com.projectswg.common.utilities.TimeUtilities; - import com.projectswg.holocore.resources.config.ConfigFile; import com.projectswg.holocore.resources.server_info.DataManager; +import java.util.Random; +import java.util.concurrent.TimeUnit; + public class GalacticResourceSpawn implements Persistable { private static final int MAP_SIZE = 16384; diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawner.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawner.java index ddf683237..ccfbb60a5 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawner.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceSpawner.java @@ -26,21 +26,20 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.galactic; -import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; - import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; -import com.projectswg.common.debug.Log.LogLevel; -import com.projectswg.common.debug.log_wrapper.ConsoleLogWrapper; - import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.services.crafting.resource.galactic.storage.GalacticResourceContainer; import com.projectswg.holocore.services.crafting.resource.raw.RawResource; import com.projectswg.holocore.services.crafting.resource.raw.RawResourceContainer; +import me.joshlarson.jlcommon.log.Log; +import me.joshlarson.jlcommon.log.Log.LogLevel; +import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper; + +import java.util.List; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; public class GalacticResourceSpawner { diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceStats.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceStats.java index d709f3ec8..42df2d355 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceStats.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/GalacticResourceStats.java @@ -26,11 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.galactic; -import java.util.Random; - import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.persistable.Persistable; +import java.util.Random; + public class GalacticResourceStats implements Persistable { private int coldResistance; diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/RawResourceType.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/RawResourceType.java index 59b7c7e70..a6c6ea49b 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/RawResourceType.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/RawResourceType.java @@ -26,14 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.galactic; -import java.util.ArrayList; -import java.util.List; - import com.projectswg.common.data.EnumLookup; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.services.crafting.resource.raw.RawResource; +import java.util.ArrayList; +import java.util.List; + public enum RawResourceType { RESOURCE ("resource", null), ORGANIC ("organic", RESOURCE), diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/storage/GalacticResourceContainer.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/storage/GalacticResourceContainer.java index 7863563ac..10f0af801 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/storage/GalacticResourceContainer.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/galactic/storage/GalacticResourceContainer.java @@ -26,24 +26,17 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.galactic.storage; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; - -import com.projectswg.common.concurrency.SynchronizedMap; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Assert; - import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResourceSpawn; import com.projectswg.holocore.services.crafting.resource.raw.RawResource; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; + public class GalacticResourceContainer { private static final GalacticResourceContainer CONTAINER = new GalacticResourceContainer(); @@ -54,9 +47,9 @@ public class GalacticResourceContainer { private final ResourceSpawnTreeGlobal resourceSpawns; public GalacticResourceContainer() { - this.rawResources = new SynchronizedMap<>(); - this.galacticResources = new SynchronizedMap<>(); - this.rawToGalactic = new SynchronizedMap<>(); + this.rawResources = new ConcurrentHashMap<>(); + this.galacticResources = new ConcurrentHashMap<>(); + this.rawToGalactic = new ConcurrentHashMap<>(); this.resourceSpawns = new ResourceSpawnTreeGlobal(); } @@ -69,11 +62,9 @@ public class GalacticResourceContainer { } public GalacticResource getGalacticResourceByName(String resourceName) { - synchronized (galacticResources) { - for (GalacticResource gr : galacticResources.values()) { - if (gr.getName().equals(resourceName)) - return gr; - } + for (GalacticResource gr : galacticResources.values()) { + if (gr.getName().equals(resourceName)) + return gr; } return null; } @@ -83,9 +74,7 @@ public class GalacticResourceContainer { } public List getGalacticResources(RawResource rawResource) { - synchronized (rawToGalactic) { - return copyImmutable(rawToGalactic.get(rawResource)); - } + return copyImmutable(rawToGalactic.get(rawResource)); } public int getSpawnedGalacticResources(RawResource rawResource) { @@ -97,24 +86,22 @@ public class GalacticResourceContainer { public void addRawResource(RawResource resource) { RawResource replaced = rawResources.put(resource.getId(), resource); - Assert.isNull(replaced); + assert replaced == null : "raw resource overwritten"; } public void addGalacticResource(GalacticResource resource) { RawResource raw = getRawResource(resource.getRawResourceId()); - Assert.notNull(raw, "Invalid raw resource ID in GalacticResource!"); - Assert.test(raw == resource.getRawResource(), "RawResource invalid with galactic resource"); - Assert.isNull(galacticResources.put(resource.getId(), resource), "Duplicate galactic resource!"); - synchronized (rawToGalactic) { - List list = rawToGalactic.computeIfAbsent(raw, k -> new ArrayList<>()); - list.add(resource); + Objects.requireNonNull(raw, "Invalid raw resource ID in GalacticResource!"); + assert raw == resource.getRawResource() : "RawResource invalid with galactic resource"; + { + GalacticResource replaced = galacticResources.put(resource.getId(), resource); + assert replaced == null : "Duplicate galactic resource!"; } + rawToGalactic.computeIfAbsent(raw, k -> new ArrayList<>()).add(resource); } public List getAllResources() { - synchronized (galacticResources) { - return copyImmutable(galacticResources.values()); - } + return copyImmutable(galacticResources.values()); } public List getAllResourceSpawns() { @@ -134,12 +121,12 @@ public class GalacticResourceContainer { } public boolean addResourceSpawn(GalacticResourceSpawn spawn) { - Assert.notNull(getGalacticResource(spawn.getResourceId()), "Invalid resourceId for GalacticResourceSpawn!"); + assert getGalacticResource(spawn.getResourceId()) != null : "Invalid resourceId for GalacticResourceSpawn!"; return resourceSpawns.addSpawn(spawn); } public boolean removeResourceSpawn(GalacticResourceSpawn spawn) { - Assert.notNull(getGalacticResource(spawn.getResourceId()), "Invalid resourceId for GalacticResourceSpawn!"); + assert getGalacticResource(spawn.getResourceId()) != null : "Invalid resourceId for GalacticResourceSpawn!"; return resourceSpawns.removeSpawn(spawn); } @@ -302,7 +289,8 @@ public class GalacticResourceContainer { public boolean addSpawn(GalacticResourceSpawn spawn) { synchronized (spawns) { - Assert.test(!depleted.get(), "Cannot add resource spawn when depleted!"); + if (depleted.get()) + throw new IllegalStateException("Cannot add resource spawn when depleted!"); if (depleted.get()) return false; return spawns.add(spawn); diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResource.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResource.java index b0f8ff921..4c31f85c9 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResource.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResource.java @@ -26,14 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.raw; +import com.projectswg.common.data.encodables.oob.StringId; +import com.projectswg.holocore.services.crafting.resource.galactic.RawResourceType; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.projectswg.common.data.encodables.oob.StringId; - -import com.projectswg.holocore.services.crafting.resource.galactic.RawResourceType; - public class RawResource { private final long id; diff --git a/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResourceContainer.java b/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResourceContainer.java index 4dbe4e7f2..0d7df2038 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResourceContainer.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/resource/raw/RawResourceContainer.java @@ -26,6 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.resource.raw; +import com.projectswg.holocore.resources.server_info.SdbLoader; +import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; +import com.projectswg.holocore.resources.server_info.StandardLog; +import com.projectswg.holocore.services.crafting.resource.raw.RawResource.RawResourceBuilder; +import me.joshlarson.jlcommon.log.Log; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -33,13 +39,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.server_info.SdbLoader; -import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; -import com.projectswg.holocore.resources.server_info.StandardLog; -import com.projectswg.holocore.services.crafting.resource.raw.RawResource.RawResourceBuilder; - public class RawResourceContainer { private final Map resources; diff --git a/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSampleManager.java b/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSampleManager.java index 3eac9996f..8c5ffd999 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSampleManager.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSampleManager.java @@ -26,12 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.survey; -import java.util.HashMap; -import java.util.Map; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; +import java.util.HashMap; +import java.util.Map; + public class InProgressSampleManager { private final Map surveySessions; diff --git a/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSurveyManager.java b/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSurveyManager.java index 9a317ed01..b8ba5f723 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSurveyManager.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/survey/InProgressSurveyManager.java @@ -26,12 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.survey; -import java.util.HashMap; -import java.util.Map; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; +import java.util.HashMap; +import java.util.Map; + public class InProgressSurveyManager { private final Map surveySessions; diff --git a/src/main/java/com/projectswg/holocore/services/crafting/survey/SampleSession.java b/src/main/java/com/projectswg/holocore/services/crafting/survey/SampleSession.java index 1fc162f39..95b8e2915 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/survey/SampleSession.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/survey/SampleSession.java @@ -26,20 +26,19 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.survey; -import java.util.List; - import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResourceSpawn; import com.projectswg.holocore.services.crafting.resource.galactic.RawResourceType; import com.projectswg.holocore.services.crafting.resource.galactic.storage.GalacticResourceContainer; import com.projectswg.holocore.services.crafting.resource.raw.RawResource; +import me.joshlarson.jlcommon.log.Log; + +import java.util.List; public class SampleSession { diff --git a/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveyService.java b/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveyService.java index 7cee5c4d4..212d76c3a 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveyService.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveyService.java @@ -26,12 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.survey; -import com.projectswg.common.control.Service; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; import com.projectswg.common.network.packets.swg.zone.crafting.resources.ResourceListForSurveyMessage; import com.projectswg.common.network.packets.swg.zone.crafting.resources.ResourceListForSurveyMessage.ResourceItem; - import com.projectswg.holocore.intents.crafting.survey.SampleResourceIntent; import com.projectswg.holocore.intents.crafting.survey.StartSurveyToolIntent; import com.projectswg.holocore.intents.crafting.survey.StartSurveyingIntent; @@ -41,6 +38,9 @@ import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResou import com.projectswg.holocore.services.crafting.resource.galactic.RawResourceType; import com.projectswg.holocore.services.crafting.resource.galactic.storage.GalacticResourceContainer; import com.projectswg.holocore.services.crafting.resource.raw.RawResource; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; /** * In charge of responding to survey requests @@ -53,13 +53,10 @@ public class SurveyService extends Service { public SurveyService() { this.inProgressSurveyManager = new InProgressSurveyManager(); this.inProgressSampleManager = new InProgressSampleManager(); - - registerForIntent(StartSurveyToolIntent.class, this::handleSurveyToolOpened); - registerForIntent(StartSurveyingIntent.class, this::handleStartSurveyingIntent); - registerForIntent(SampleResourceIntent.class, this::handleStartSamplingIntent); } - private void handleSurveyToolOpened(StartSurveyToolIntent ssti) { + @IntentHandler + private void handleStartSurveyToolIntent(StartSurveyToolIntent ssti) { CreatureObject creature = ssti.getCreature(); SWGObject surveyTool = ssti.getSurveyTool(); String resourceType = surveyTool.getTemplate().substring(47, surveyTool.getTemplate().length()-4); @@ -75,10 +72,12 @@ public class SurveyService extends Service { creature.getOwner().sendPacket(survey); } + @IntentHandler private void handleStartSurveyingIntent(StartSurveyingIntent ssi) { inProgressSurveyManager.startSession(ssi.getCreature(), ssi.getResource()); } + @IntentHandler private void handleStartSamplingIntent(SampleResourceIntent sri) { inProgressSampleManager.startSession(sri.getCreature(), sri.getResource()); } diff --git a/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveySession.java b/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveySession.java index 2b0adf7c4..d1732b1b2 100644 --- a/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveySession.java +++ b/src/main/java/com/projectswg/holocore/services/crafting/survey/SurveySession.java @@ -26,21 +26,20 @@ ***********************************************************************************/ package com.projectswg.holocore.services.crafting.survey; -import java.util.List; - import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; import com.projectswg.common.network.packets.swg.zone.crafting.surveying.SurveyMessage; import com.projectswg.common.network.packets.swg.zone.crafting.surveying.SurveyMessage.ResourceConcentration; - import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResource; import com.projectswg.holocore.services.crafting.resource.galactic.GalacticResourceSpawn; import com.projectswg.holocore.services.crafting.resource.galactic.RawResourceType; import com.projectswg.holocore.services.crafting.resource.galactic.storage.GalacticResourceContainer; import com.projectswg.holocore.services.crafting.resource.raw.RawResource; +import me.joshlarson.jlcommon.log.Log; + +import java.util.List; public class SurveySession { diff --git a/src/main/java/com/projectswg/holocore/services/dev/DeveloperService.java b/src/main/java/com/projectswg/holocore/services/dev/DeveloperService.java index 177d9e45e..aca8e86ae 100644 --- a/src/main/java/com/projectswg/holocore/services/dev/DeveloperService.java +++ b/src/main/java/com/projectswg/holocore/services/dev/DeveloperService.java @@ -26,11 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.dev; -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.tangible.PvpFlag; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.config.ConfigFile; import com.projectswg.holocore.resources.objects.SWGObject; @@ -38,6 +36,7 @@ import com.projectswg.holocore.resources.objects.custom.RandomAIObject; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.control.Service; public class DeveloperService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/experience/ExpertiseService.java b/src/main/java/com/projectswg/holocore/services/experience/ExperienceExpertiseService.java similarity index 96% rename from src/main/java/com/projectswg/holocore/services/experience/ExpertiseService.java rename to src/main/java/com/projectswg/holocore/services/experience/ExperienceExpertiseService.java index 9615cb605..3351dda4e 100644 --- a/src/main/java/com/projectswg/holocore/services/experience/ExpertiseService.java +++ b/src/main/java/com/projectswg/holocore/services/experience/ExperienceExpertiseService.java @@ -26,23 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.experience; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import com.projectswg.common.control.Intent; -import com.projectswg.common.control.Service; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.ExpertiseRequestMessage; - import com.projectswg.holocore.intents.experience.GrantSkillIntent; import com.projectswg.holocore.intents.experience.LevelChangedIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; @@ -51,12 +40,23 @@ import com.projectswg.holocore.resources.objects.player.PlayerObject; import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiMessageBox; +import me.joshlarson.jlcommon.control.Intent; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; /** * * @author Mads */ -public final class ExpertiseService extends Service { +public class ExperienceExpertiseService extends Service { private static final String EXPERTISE_ABILITIES_QUERY = "SELECT * FROM expertise_abilities"; @@ -65,15 +65,11 @@ public final class ExpertiseService extends Service { private final Map> expertiseAbilities; // Expertise skill to abilities private final Map pointsForLevel; // Level to points available - public ExpertiseService() { + public ExperienceExpertiseService() { trees = new HashMap<>(); expertiseSkills = new HashMap<>(); expertiseAbilities = new HashMap<>(); pointsForLevel = new HashMap<>(); - - registerForIntent(GalacticPacketIntent.class, this::handleGalacticPacketIntent); - registerForIntent(LevelChangedIntent.class, this::handleLevelChangedIntent); - registerForIntent(GrantSkillIntent.class, this::handleGrantSkillIntent); } @Override @@ -164,6 +160,7 @@ public final class ExpertiseService extends Service { } } + @IntentHandler private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { SWGPacket packet = gpi.getPacket(); @@ -213,6 +210,7 @@ public final class ExpertiseService extends Service { checkExtraAbilities(creatureObject); } + @IntentHandler private void handleLevelChangedIntent(LevelChangedIntent lci) { int newLevel = lci.getNewLevel(); CreatureObject creatureObject = lci.getCreatureObject(); @@ -229,6 +227,7 @@ public final class ExpertiseService extends Service { checkExtraAbilities(creatureObject); } + @IntentHandler private void handleGrantSkillIntent(GrantSkillIntent gsi) { if (gsi.getIntentType() == GrantSkillIntent.IntentType.GIVEN) { return; diff --git a/src/main/java/com/projectswg/holocore/services/experience/ExperienceLevelService.java b/src/main/java/com/projectswg/holocore/services/experience/ExperienceLevelService.java new file mode 100644 index 000000000..6e2408256 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/experience/ExperienceLevelService.java @@ -0,0 +1,105 @@ +package com.projectswg.holocore.services.experience; + +import com.projectswg.common.data.RGB; +import com.projectswg.common.data.encodables.oob.OutOfBandPackage; +import com.projectswg.common.data.encodables.oob.ProsePackage; +import com.projectswg.common.data.encodables.oob.StringId; +import com.projectswg.common.data.swgfile.ClientFactory; +import com.projectswg.common.data.swgfile.visitors.DatatableData; +import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText; +import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText.Scale; +import com.projectswg.holocore.intents.experience.ExperienceIntent; +import com.projectswg.holocore.intents.experience.LevelChangedIntent; +import com.projectswg.holocore.resources.config.ConfigFile; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import com.projectswg.holocore.resources.objects.player.PlayerObject; +import com.projectswg.holocore.resources.server_info.DataManager; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.HashMap; +import java.util.Map; + +public class ExperienceLevelService extends Service { + + private final Map levelXpMap; + private final double xpMultiplier; + + public ExperienceLevelService() { + levelXpMap = new HashMap<>(); + xpMultiplier = DataManager.getConfig(ConfigFile.FEATURES).getDouble("XP-MULTIPLIER", 1); + } + + @Override + public boolean initialize() { + DatatableData skillTemplateTable = (DatatableData) ClientFactory.getInfoFromFile("datatables/player/player_level.iff"); + + for (int row = 0; row < skillTemplateTable.getRowCount(); row++) { + int level = (int) skillTemplateTable.getCell(row, 0); + int xpRequired = (int) skillTemplateTable.getCell(row, 1); + + levelXpMap.put((short) level, xpRequired); + } + + return true; + } + + @IntentHandler + private void handleExperienceIntent(ExperienceIntent ei) { + CreatureObject creatureObject = ei.getCreatureObject(); + PlayerObject playerObject = creatureObject.getPlayerObject(); + + if (playerObject != null) { + int newXpTotal = awardExperience(creatureObject, playerObject, ei.getXpType(), ei.getExperienceGained()); + + // At this point, we check if their level should be adjusted. + short oldLevel = creatureObject.getLevel(); + short newLevel = attemptLevelUp(creatureObject.getLevel(), creatureObject, newXpTotal); + + if (oldLevel < newLevel) { // If we've leveled up at least once + creatureObject.setLevel(newLevel); + new LevelChangedIntent(creatureObject, oldLevel, newLevel).broadcast(); + // TODO NGE: system message health and action differences. @spam:level_up_stat_gain_# + Log.i("%s leveled from %d to %d", creatureObject, oldLevel, newLevel); + } + } + } + + private int awardExperience(CreatureObject creatureObject, PlayerObject playerObject, String xpType, int xpGained) { + int currentXp = playerObject.getExperiencePoints(xpType); + int newXpTotal = currentXp + (int) (xpGained * xpMultiplier); + + playerObject.setExperiencePoints(xpType, newXpTotal); + creatureObject.setTotalLevelXp(newXpTotal); + Log.d("%s gained %d %s XP", creatureObject, xpGained, xpType); + + // Show flytext above the creature that received XP, but only to them + creatureObject.sendSelf(new ShowFlyText(creatureObject.getObjectId(), new OutOfBandPackage(new ProsePackage(new StringId("base_player", "prose_flytext_xp"), "DI", xpGained)), Scale.MEDIUM, new RGB(255, 0, 255))); + + return newXpTotal; + } + + private short attemptLevelUp(short currentLevel, CreatureObject creatureObject, int newXpTotal) { + if (currentLevel >= getMaxLevel()) { + return currentLevel; + } + + short nextLevel = (short) (currentLevel + 1); + Integer xpNextLevel = levelXpMap.get(nextLevel); + + if (xpNextLevel == null) { + Log.e("%s couldn't level up to %d because there's no XP requirement", creatureObject, nextLevel); + return currentLevel; + } + + // Recursively attempt to level up again, in case we've gained enough XP to level up multiple times. + return newXpTotal >= xpNextLevel ? attemptLevelUp(nextLevel, creatureObject, newXpTotal) : currentLevel; + } + + + private int getMaxLevel() { + return levelXpMap.size(); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/experience/ExperienceManager.java b/src/main/java/com/projectswg/holocore/services/experience/ExperienceManager.java index c54dfe49e..aa181fe19 100644 --- a/src/main/java/com/projectswg/holocore/services/experience/ExperienceManager.java +++ b/src/main/java/com/projectswg/holocore/services/experience/ExperienceManager.java @@ -26,115 +26,24 @@ ***********************************************************************************/ package com.projectswg.holocore.services.experience; -import java.awt.Color; -import java.util.HashMap; -import java.util.Map; - -import com.projectswg.common.control.Manager; -import com.projectswg.common.data.RGB; -import com.projectswg.common.data.encodables.oob.OutOfBandPackage; -import com.projectswg.common.data.encodables.oob.ProsePackage; -import com.projectswg.common.data.encodables.oob.StringId; -import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; -import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText; -import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText.Scale; - import com.projectswg.holocore.intents.experience.ExperienceIntent; -import com.projectswg.holocore.intents.experience.LevelChangedIntent; -import com.projectswg.holocore.resources.config.ConfigFile; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.objects.player.PlayerObject; -import com.projectswg.holocore.resources.server_info.DataManager; +import com.projectswg.holocore.services.experience.skills.SkillManager; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; /** * The {@code ExperienceManager} listens for {@link ExperienceIntent} and * grants XP based on it. * @author Mads */ -public final class ExperienceManager extends Manager { +@ManagerStructure(children = { + ExperienceRoleService.class, + ExperienceExpertiseService.class, + SkillManager.class +}) +public class ExperienceManager extends Manager { - private final Map levelXpMap; - private final double xpMultiplier; - public ExperienceManager() { - levelXpMap = new HashMap<>(); - xpMultiplier = DataManager.getConfig(ConfigFile.FEATURES).getDouble("XP-MULTIPLIER", 1); - - registerForIntent(ExperienceIntent.class, this::handleExperienceIntent); - addChildService(new SkillManager()); - addChildService(new SkillTemplateService()); - } - - @Override - public boolean initialize() { - DatatableData skillTemplateTable = (DatatableData) ClientFactory.getInfoFromFile("datatables/player/player_level.iff"); - - for (int row = 0; row < skillTemplateTable.getRowCount(); row++) { - int level = (int) skillTemplateTable.getCell(row, 0); - int xpRequired = (int) skillTemplateTable.getCell(row, 1); - - levelXpMap.put((short) level, xpRequired); - } - - return super.initialize(); - } - - private void handleExperienceIntent(ExperienceIntent ei) { - CreatureObject creatureObject = ei.getCreatureObject(); - PlayerObject playerObject = creatureObject.getPlayerObject(); - - if (playerObject != null) { - int newXpTotal = awardExperience(creatureObject, playerObject, ei.getXpType(), ei.getExperienceGained()); - - // At this point, we check if their level should be adjusted. - short oldLevel = creatureObject.getLevel(); - short newLevel = attemptLevelUp(creatureObject.getLevel(), creatureObject, newXpTotal); - - if (oldLevel < newLevel) { // If we've leveled up at least once - creatureObject.setLevel(newLevel); - new LevelChangedIntent(creatureObject, oldLevel, newLevel).broadcast(); - // TODO NGE: system message health and action differences. @spam:level_up_stat_gain_# - Log.i("%s leveled from %d to %d", creatureObject, oldLevel, newLevel); - } - } - } - - private int awardExperience(CreatureObject creatureObject, PlayerObject playerObject, String xpType, int xpGained) { - int currentXp = playerObject.getExperiencePoints(xpType); - int newXpTotal = currentXp + (int) (xpGained * xpMultiplier); - - playerObject.setExperiencePoints(xpType, newXpTotal); - creatureObject.setTotalLevelXp(newXpTotal); - Log.d("%s gained %d %s XP", creatureObject, xpGained, xpType); - - // Show flytext above the creature that received XP, but only to them - creatureObject.sendSelf(new ShowFlyText(creatureObject.getObjectId(), new OutOfBandPackage(new ProsePackage(new StringId("base_player", "prose_flytext_xp"), "DI", xpGained)), Scale.MEDIUM, new RGB(Color.magenta))); - - return newXpTotal; - } - - private short attemptLevelUp(short currentLevel, CreatureObject creatureObject, int newXpTotal) { - if (currentLevel >= getMaxLevel()) { - return currentLevel; - } - - short nextLevel = (short) (currentLevel + 1); - Integer xpNextLevel = levelXpMap.get(nextLevel); - - if (xpNextLevel == null) { - Log.e("%s couldn't level up to %d because there's no XP requirement", creatureObject, nextLevel); - return currentLevel; - } - - // Recursively attempt to level up again, in case we've gained enough XP to level up multiple times. - return newXpTotal >= xpNextLevel ? attemptLevelUp(nextLevel, creatureObject, newXpTotal) : currentLevel; - } - - - private int getMaxLevel() { - return levelXpMap.size(); } } diff --git a/src/main/java/com/projectswg/holocore/services/experience/ExperienceRoleService.java b/src/main/java/com/projectswg/holocore/services/experience/ExperienceRoleService.java new file mode 100644 index 000000000..341c77f03 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/experience/ExperienceRoleService.java @@ -0,0 +1,69 @@ +package com.projectswg.holocore.services.experience; + +import com.projectswg.common.data.swgfile.ClientFactory; +import com.projectswg.common.data.swgfile.visitors.DatatableData; +import com.projectswg.common.network.packets.SWGPacket; +import com.projectswg.common.network.packets.swg.zone.object_controller.ChangeRoleIconChoice; +import com.projectswg.holocore.intents.network.GalacticPacketIntent; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import com.projectswg.holocore.resources.objects.player.PlayerObject; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class ExperienceRoleService extends Service { + + private final Map> roleIconMap; + + public ExperienceRoleService() { + roleIconMap = new HashMap<>(); + } + + @Override + public boolean initialize() { + DatatableData roleIconTable = (DatatableData) ClientFactory.getInfoFromFile("datatables/role/role.iff"); + + for (int i = 0; i < roleIconTable.getRowCount(); i++) { + int iconIndex = (int) roleIconTable.getCell(i, 0); + String qualifyingSkill = (String) roleIconTable.getCell(i, 2); + + Set qualifyingSkills = roleIconMap.computeIfAbsent(iconIndex, k -> new HashSet<>()); + + qualifyingSkills.add(qualifyingSkill); + } + return true; + } + + @IntentHandler + private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { + SWGPacket SWGPacket = gpi.getPacket(); + if (SWGPacket instanceof ChangeRoleIconChoice) { + ChangeRoleIconChoice iconChoice = (ChangeRoleIconChoice) SWGPacket; + changeRoleIcon(gpi.getPlayer().getCreatureObject(), iconChoice.getIconChoice()); + } + } + + private void changeRoleIcon(CreatureObject creature, int chosenIcon) { + Set qualifyingSkills = roleIconMap.get(chosenIcon); + if (qualifyingSkills == null) { + Log.w("%s tried to use undefined role icon %d", creature, chosenIcon); + return; + } + PlayerObject playerObject = creature.getPlayerObject(); + assert playerObject != null; + + for (String qualifyingSkill : qualifyingSkills) { + if (creature.hasSkill(qualifyingSkill)) { + playerObject.setProfessionIcon(chosenIcon); + return; + } + } + Log.e("%s could not be given role icon %d - does not have qualifying skill! Qualifying: %s", creature, chosenIcon, qualifyingSkills); + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/experience/skills/SkillManager.java b/src/main/java/com/projectswg/holocore/services/experience/skills/SkillManager.java new file mode 100644 index 000000000..576b364e7 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/experience/skills/SkillManager.java @@ -0,0 +1,42 @@ +/*********************************************************************************** + * Copyright (c) 2018 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * --------------------------------------------------------------------------------* + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + ***********************************************************************************/ +package com.projectswg.holocore.services.experience.skills; + +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; + +@ManagerStructure(children = { + SkillService.class, + SkillTemplateService.class +}) +public final class SkillManager extends Manager { + + public SkillManager() { + + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/experience/SkillManager.java b/src/main/java/com/projectswg/holocore/services/experience/skills/SkillService.java similarity index 54% rename from src/main/java/com/projectswg/holocore/services/experience/SkillManager.java rename to src/main/java/com/projectswg/holocore/services/experience/skills/SkillService.java index 8227c3d64..89cd3b5c1 100644 --- a/src/main/java/com/projectswg/holocore/services/experience/SkillManager.java +++ b/src/main/java/com/projectswg/holocore/services/experience/skills/SkillService.java @@ -1,91 +1,28 @@ -/*********************************************************************************** - * Copyright (c) 2018 /// Project SWG /// www.projectswg.com * - * * - * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * - * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * - * Our goal is to create an emulator which will provide a server for players to * - * continue playing a game similar to the one they used to play. We are basing * - * it on the final publish of the game prior to end-game events. * - * * - * This file is part of Holocore. * - * * - * --------------------------------------------------------------------------------* - * * - * Holocore is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * Holocore is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with Holocore. If not, see . * - ***********************************************************************************/ -package com.projectswg.holocore.services.experience; +package com.projectswg.holocore.services.experience.skills; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.projectswg.common.control.Manager; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; -import com.projectswg.common.network.packets.SWGPacket; -import com.projectswg.common.network.packets.swg.zone.object_controller.ChangeRoleIconChoice; - import com.projectswg.holocore.intents.SetTitleIntent; import com.projectswg.holocore.intents.SkillModIntent; import com.projectswg.holocore.intents.experience.GrantSkillIntent; -import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.objects.player.PlayerObject; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; -/** - * - * @author Mads - */ -public final class SkillManager extends Manager { +import java.util.HashMap; +import java.util.Map; + +public class SkillService extends Service { - // Maps icon index to qualifying skill. - private final Map> roleIconMap; private final Map skillDataMap; - public SkillManager() { - roleIconMap = new HashMap<>(); + public SkillService() { skillDataMap = new HashMap<>(); - - addChildService(new ExpertiseService()); - - registerForIntent(GrantSkillIntent.class, this::handleGrantSkillIntent); - registerForIntent(GalacticPacketIntent.class, this::handleGalacticPacketIntent); - registerForIntent(SetTitleIntent.class, this::handleSetTitleIntent); } @Override public boolean initialize() { - DatatableData roleIconTable = (DatatableData) ClientFactory.getInfoFromFile("datatables/role/role.iff"); - - for (int i = 0; i < roleIconTable.getRowCount(); i++) { - int iconIndex = (int) roleIconTable.getCell(i, 0); - String qualifyingSkill = (String) roleIconTable.getCell(i, 2); - - Set qualifyingSkills = roleIconMap.computeIfAbsent(iconIndex, k -> new HashSet<>()); - - qualifyingSkills.add(qualifyingSkill); - } - - loadSkills(); - - return super.initialize(); - } - - private void loadSkills() { DatatableData skillsTable = (DatatableData) ClientFactory.getInfoFromFile("datatables/skill/skills.iff"); for (int i = 0; i < skillsTable.getRowCount(); i++) { @@ -110,6 +47,10 @@ public final class SkillManager extends Manager { skillDataMap.put(skillName, skillData); } + return true; + } + + private void loadSkills() { } private String [] splitCsv(String str) { @@ -120,6 +61,7 @@ public final class SkillManager extends Manager { return str.split(","); } + @IntentHandler private void handleGrantSkillIntent(GrantSkillIntent gsi) { if (gsi.getIntentType() != GrantSkillIntent.IntentType.GRANT) { return; @@ -141,14 +83,7 @@ public final class SkillManager extends Manager { grantSkill(skillData, skillName, target); } - private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { - SWGPacket SWGPacket = gpi.getPacket(); - if (SWGPacket instanceof ChangeRoleIconChoice) { - ChangeRoleIconChoice iconChoice = (ChangeRoleIconChoice) SWGPacket; - changeRoleIcon(gpi.getPlayer().getCreatureObject(), iconChoice.getIconChoice()); - } - } - + @IntentHandler private void handleSetTitleIntent(SetTitleIntent sti) { String title = sti.getTitle(); @@ -206,23 +141,6 @@ public final class SkillManager extends Manager { new GrantSkillIntent(GrantSkillIntent.IntentType.GIVEN, skillName, target, false).broadcast(); } - private void changeRoleIcon(CreatureObject creature, int chosenIcon) { - Set qualifyingSkills = roleIconMap.get(chosenIcon); - if (qualifyingSkills == null) { - Log.w("%s tried to use undefined role icon %d", creature, chosenIcon); - return; - } - Assert.notNull(creature.getPlayerObject()); - - for (String qualifyingSkill : qualifyingSkills) { - if (creature.hasSkill(qualifyingSkill)) { - creature.getPlayerObject().setProfessionIcon(chosenIcon); - return; - } - } - Log.e("%s could not be given role icon %d - does not have qualifying skill! Qualifying: %s", creature, chosenIcon, qualifyingSkills); - } - private static class SkillData { private boolean title; private String[] requiredSkills; diff --git a/src/main/java/com/projectswg/holocore/services/experience/SkillTemplateService.java b/src/main/java/com/projectswg/holocore/services/experience/skills/SkillTemplateService.java similarity index 97% rename from src/main/java/com/projectswg/holocore/services/experience/SkillTemplateService.java rename to src/main/java/com/projectswg/holocore/services/experience/skills/SkillTemplateService.java index 4ce197359..19a12f430 100644 --- a/src/main/java/com/projectswg/holocore/services/experience/SkillTemplateService.java +++ b/src/main/java/com/projectswg/holocore/services/experience/skills/SkillTemplateService.java @@ -24,26 +24,17 @@ * You should have received a copy of the GNU Affero General Public License * * along with Holocore. If not, see . * ***********************************************************************************/ -package com.projectswg.holocore.services.experience; +package com.projectswg.holocore.services.experience.skills; -import java.awt.Color; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.RGB; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.Race; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText; import com.projectswg.common.network.packets.swg.zone.object_controller.ShowFlyText.Scale; - import com.projectswg.holocore.intents.GrantBadgeIntent; import com.projectswg.holocore.intents.experience.GrantSkillIntent; import com.projectswg.holocore.intents.experience.LevelChangedIntent; @@ -57,6 +48,14 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.rewards.RoadmapReward; import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.services.objects.StaticItemService; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; /** * This is a service that listens for {@link LevelChangedIntent} and grants @@ -87,8 +86,6 @@ public final class SkillTemplateService extends Service { badgeNames.put("trader_0b", new String[]{"new_prof_crafting_merchant_master", "new_prof_crafting_artisan_master", "new_prof_crafting_architect_master"}); badgeNames.put("trader_0c", new String[]{"new_prof_crafting_merchant_master", "new_prof_crafting_artisan_master", "new_prof_crafting_armorsmith_master", "new_prof_crafting_weaponsmith_master"}); badgeNames.put("trader_0d", new String[]{"new_prof_crafting_merchant_master", "new_prof_crafting_artisan_master", "new_prof_crafting_droidengineer_master"}); - - registerForIntent(LevelChangedIntent.class, this::handleLevelChangedIntent); } @Override @@ -106,7 +103,8 @@ public final class SkillTemplateService extends Service { return super.initialize(); } - + + @IntentHandler private void handleLevelChangedIntent(LevelChangedIntent lci) { short oldLevel = lci.getPreviousLevel(); short newLevel = lci.getNewLevel(); @@ -148,11 +146,11 @@ public final class SkillTemplateService extends Service { if (skillUp) { effectFile = "clienteffect/skill_granted.cef"; flyText = "skill_up"; - flyTextColor = new RGB(Color.GREEN); + flyTextColor = new RGB(0, 255, 0); } else { effectFile = "clienteffect/level_granted.cef"; flyText = "level_up"; - flyTextColor = new RGB(Color.BLUE); + flyTextColor = new RGB(0, 0, 255); } creatureObject.sendObservers(new PlayClientEffectObjectMessage(effectFile, "", objectId, "")); diff --git a/src/main/java/com/projectswg/holocore/services/faction/CivilWarService.java b/src/main/java/com/projectswg/holocore/services/faction/CivilWarService.java index c80d6de71..0a84c9049 100644 --- a/src/main/java/com/projectswg/holocore/services/faction/CivilWarService.java +++ b/src/main/java/com/projectswg/holocore/services/faction/CivilWarService.java @@ -28,13 +28,10 @@ package com.projectswg.holocore.services.faction; -import com.projectswg.common.concurrency.PswgScheduledThreadPool; -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.PvpFaction; import com.projectswg.common.data.encodables.tangible.PvpStatus; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage; import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage; import com.projectswg.holocore.intents.CivilWarPointIntent; @@ -50,45 +47,45 @@ import com.projectswg.holocore.resources.objects.player.PlayerObject; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.server_info.SdbLoader; import com.projectswg.holocore.resources.server_info.StandardLog; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.io.File; import java.io.IOException; import java.time.*; +import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; +import java.time.temporal.TemporalUnit; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -final class CivilWarService extends Service { +public class CivilWarService extends Service { private static final int IMPERIAL_INDEX = 0; private static final int REBEL_INDEX = 1; private final Map rankAbilities; private final Set playerObjects; - private final PswgScheduledThreadPool threadPool; + private final ScheduledThreadPool threadPool; private final DayOfWeek updateWeekDay; private final LocalTime updateTime; private final ZoneOffset updateOffset; private int rankEpoch; - CivilWarService() { + public CivilWarService() { rankAbilities = new HashMap<>(); playerObjects = ConcurrentHashMap.newKeySet(); - threadPool = new PswgScheduledThreadPool(1, "civil-war-service"); + threadPool = new ScheduledThreadPool(1, "civil-war-service"); // Rank update time is the night between Thursday and Friday at 00:00 UTC updateWeekDay = DayOfWeek.FRIDAY; updateTime = LocalTime.MIDNIGHT; updateOffset = OffsetDateTime.now().getOffset(); loadRankAbilities(); - - registerForIntent(CivilWarPointIntent.class, this::handleCivilWarPointIntent); - registerForIntent(CreatureKilledIntent.class, this::handleCreatureKilledIntent); - registerForIntent(DestroyObjectIntent.class, this::handleDestroyObjectIntent); - registerForIntent(FactionIntent.class, this::handleFactionIntent); - registerForIntent(ObjectCreatedIntent.class, this::handleObjectCreatedIntent); } @Override @@ -118,7 +115,7 @@ final class CivilWarService extends Service { int nextUpdateTime(LocalDate now) { LocalDate nextUpdateDate = now.with(TemporalAdjusters.next(updateWeekDay)); - return (int) nextUpdateDate.toEpochSecond(updateTime, updateOffset); + return (int) nextUpdateDate.atStartOfDay().plus(updateTime.toSecondOfDay(), ChronoUnit.SECONDS).toEpochSecond(updateOffset); } boolean isDecayRank(int rank) { @@ -194,7 +191,7 @@ final class CivilWarService extends Service { private void scheduleRankUpdate() { LocalDate nowDate = LocalDate.now(); LocalTime nowTime = LocalTime.now(); - int nowEpoch = (int) nowDate.toEpochSecond(nowTime, updateOffset); + int nowEpoch = (int) nowDate.atStartOfDay().plus(nowTime.toSecondOfDay(), ChronoUnit.SECONDS).toEpochSecond(updateOffset); rankEpoch = nextUpdateTime(nowDate); // Is in the future int delay = (rankEpoch - nowEpoch) * 1000; // Must be milliseconds @@ -346,6 +343,7 @@ final class CivilWarService extends Service { SystemMessageIntent.broadcastPersonal(receiver.getOwner(), prose); } + @IntentHandler private void handleCivilWarPointIntent(CivilWarPointIntent cwpi) { int points = cwpi.getPoints(); PlayerObject receiver = cwpi.getReceiver(); @@ -354,6 +352,7 @@ final class CivilWarService extends Service { grantPoints(prose, receiver, points); } + @IntentHandler private void handleCreatureKilledIntent(CreatureKilledIntent cki) { CreatureObject corpseCreature = cki.getCorpse(); CreatureObject killerCreature = cki.getKiller(); @@ -410,6 +409,7 @@ final class CivilWarService extends Service { grantPoints(prose, killerPlayer, granted); } + @IntentHandler private void handleFactionIntent(FactionIntent fi) { if (fi.getUpdateType() != FactionIntent.FactionIntentType.FACTIONUPDATE) { return; @@ -443,6 +443,7 @@ final class CivilWarService extends Service { } } + @IntentHandler private void handleDestroyObjectIntent(DestroyObjectIntent doi) { SWGObject object = doi.getObject(); @@ -453,6 +454,7 @@ final class CivilWarService extends Service { playerObjects.remove(object); } + @IntentHandler private void handleObjectCreatedIntent(ObjectCreatedIntent oci) { SWGObject object = oci.getObject(); diff --git a/src/main/java/com/projectswg/holocore/services/faction/FactionFlagService.java b/src/main/java/com/projectswg/holocore/services/faction/FactionFlagService.java new file mode 100644 index 000000000..5d95ddbf6 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/services/faction/FactionFlagService.java @@ -0,0 +1,219 @@ +package com.projectswg.holocore.services.faction; + +import com.projectswg.common.data.encodables.tangible.PvpFaction; +import com.projectswg.common.data.encodables.tangible.PvpFlag; +import com.projectswg.common.data.encodables.tangible.PvpStatus; +import com.projectswg.common.network.packets.swg.zone.UpdatePvpStatusMessage; +import com.projectswg.holocore.intents.FactionIntent; +import com.projectswg.holocore.intents.chat.SystemMessageIntent; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.objects.cell.CellObject; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import com.projectswg.holocore.resources.objects.tangible.TangibleObject; +import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Future; + +public class FactionFlagService extends Service { + + private final Map> statusChangers; + private final ScheduledThreadPool executor; + + public FactionFlagService() { + statusChangers = new ConcurrentHashMap<>(); + executor = new ScheduledThreadPool(1, "faction-service"); + } + + @Override + public boolean start() { + executor.start(); + return true; + } + + @Override + public boolean stop() { + executor.stop(); + executor.awaitTermination(1000); + return true; + } + + @IntentHandler + private void handleFactionIntent(FactionIntent fi) { + TangibleObject target = fi.getTarget(); + + if (!(target instanceof CreatureObject) && !(target.getParent() instanceof CellObject)) // We don't deal with faction updates for inventory items and the like + return; + + switch (fi.getUpdateType()) { + case FACTIONUPDATE: + handleTypeChange(fi); + break; + case SWITCHUPDATE: + handleSwitchChange(fi); + break; + case STATUSUPDATE: + handleStatusChange(fi); + break; + case FLAGUPDATE: + handleFlagChange(target); + break; + } + } + + private void handleTypeChange(FactionIntent fi) { + TangibleObject target = fi.getTarget(); + PvpFaction newFaction = fi.getNewFaction(); + + target.setPvpFaction(newFaction); + handleFlagChange(target); + } + + private void handleSwitchChange(FactionIntent fi) { + final PvpFlag pvpFlag; + final TangibleObject target = fi.getTarget(); + final PvpStatus oldStatus = target.getPvpStatus(); + final PvpStatus newStatus; + + if(target.hasPvpFlag(PvpFlag.GOING_COVERT) || target.hasPvpFlag(PvpFlag.GOING_OVERT)) { + SystemMessageIntent.broadcastPersonal(target.getOwner(), "@faction_recruiter:pvp_status_changing"); + } else { + if(oldStatus == PvpStatus.COMBATANT) { + pvpFlag = PvpFlag.GOING_OVERT; + newStatus = PvpStatus.SPECIALFORCES; + } else { // Covers both ONLEAVE and SPECIALFORCES + pvpFlag = PvpFlag.GOING_COVERT; + newStatus = PvpStatus.COMBATANT; + } + + target.setPvpFlags(pvpFlag); + SystemMessageIntent.broadcastPersonal(target.getOwner(), getBeginMessage(oldStatus, newStatus)); + statusChangers.put(target, executor.execute(getDelay(oldStatus, newStatus) * 1000, () -> completeChange(target, pvpFlag, oldStatus, newStatus))); + } + } + + // Forces the target into the given PvpStatus + private void handleStatusChange(FactionIntent fi) { + TangibleObject target = fi.getTarget(); + PvpStatus oldStatus = target.getPvpStatus(); + PvpStatus newStatus = fi.getNewStatus(); + + // No reason to send deltas and all that if the status isn't effectively changing + if(oldStatus == newStatus) + return; + + // Let's clear PvP flags in case they were in the middle of going covert/overt + Future future = statusChangers.remove(target); + + if (future != null) { + if (future.cancel(false)) { + target.clearPvpFlags(PvpFlag.GOING_COVERT, PvpFlag.GOING_OVERT); + } else if (target.getPvpStatus() != newStatus) { + // Their new status does not equal the one we want - apply the new one + changeStatus(target, newStatus); + } + } else { + // They're not currently waiting to switch to a new status - change now + changeStatus(target, newStatus); + } + } + + private void handleFlagChange(TangibleObject target) { + Player targetOwner = target.getOwner(); + + for (SWGObject objectAware : target.getObjectsAware()) { + if (!(objectAware instanceof TangibleObject)) { + continue; + } + + TangibleObject tangibleAware = (TangibleObject) objectAware; + + if (tangibleAware.getPvpFaction() == PvpFaction.NEUTRAL) { + continue; + } + + Player observerOwner = tangibleAware.getOwner(); + + int pvpBitmask = getPvpBitmask(target, tangibleAware); + + if (targetOwner != null) // Send the PvP information about this observer to the owner + targetOwner.sendPacket(createPvpStatusMessage(tangibleAware, tangibleAware.getPvpFlags() | pvpBitmask)); + + if (observerOwner != null) // Send the pvp information about the owner to this observer + observerOwner.sendPacket(createPvpStatusMessage(target, target.getPvpFlags() | pvpBitmask)); + } + } + + private void completeChange(TangibleObject target, PvpFlag pvpFlag, PvpStatus oldStatus, PvpStatus newStatus) { + statusChangers.remove(target); + + SystemMessageIntent.broadcastPersonal(target.getOwner(), getCompletionMessage(oldStatus, newStatus)); + target.clearPvpFlags(pvpFlag); + changeStatus(target, newStatus); + } + + private void changeStatus(TangibleObject target, PvpStatus newStatus) { + target.setPvpStatus(newStatus); + handleFlagChange(target); + } + + private static String getBeginMessage(PvpStatus oldStatus, PvpStatus newStatus) { + String message = "@faction_recruiter:"; + + if(oldStatus == PvpStatus.ONLEAVE && newStatus == PvpStatus.COMBATANT) + message += "on_leave_to_covert"; + else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.SPECIALFORCES) + message += "covert_to_overt"; + else if(oldStatus == PvpStatus.SPECIALFORCES && newStatus == PvpStatus.COMBATANT) + message += "overt_to_covert"; + + return message; + } + + private static String getCompletionMessage(PvpStatus oldStatus, PvpStatus newStatus) { + String message = "@faction_recruiter:"; + + if((oldStatus == PvpStatus.ONLEAVE || oldStatus == PvpStatus.SPECIALFORCES) && newStatus == PvpStatus.COMBATANT) + message += "covert_complete"; + else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.SPECIALFORCES) + message += "overt_complete"; + else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.ONLEAVE ) + message += "on_leave_complete"; + + return message; + } + + private static long getDelay(PvpStatus oldStatus, PvpStatus newStatus) { + long delay = 0; + + if(oldStatus == PvpStatus.ONLEAVE && newStatus == PvpStatus.COMBATANT) + delay = 1; + else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.SPECIALFORCES) + delay = 30; + else if(oldStatus == PvpStatus.SPECIALFORCES && newStatus == PvpStatus.COMBATANT) + delay = 300; + + return delay; + } + + private static UpdatePvpStatusMessage createPvpStatusMessage(TangibleObject target, int flags) { + Set flagSet = PvpFlag.getFlags(flags); + return new UpdatePvpStatusMessage(target.getPvpFaction(), target.getObjectId(), flagSet.toArray(new PvpFlag[0])); + } + + private static int getPvpBitmask(TangibleObject target, TangibleObject observer) { + int pvpBitmask = 0; + + if(target.isEnemyOf(observer)) { + pvpBitmask |= PvpFlag.AGGRESSIVE.getBitmask() | PvpFlag.ATTACKABLE.getBitmask() | PvpFlag.ENEMY.getBitmask(); + } + + return pvpBitmask; + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/faction/FactionManager.java b/src/main/java/com/projectswg/holocore/services/faction/FactionManager.java index 75023bb94..fc6e6b276 100644 --- a/src/main/java/com/projectswg/holocore/services/faction/FactionManager.java +++ b/src/main/java/com/projectswg/holocore/services/faction/FactionManager.java @@ -26,225 +26,17 @@ ***********************************************************************************/ package com.projectswg.holocore.services.faction; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Future; - -import com.projectswg.common.concurrency.PswgScheduledThreadPool; -import com.projectswg.common.control.Manager; -import com.projectswg.common.data.encodables.tangible.PvpFaction; -import com.projectswg.common.data.encodables.tangible.PvpFlag; -import com.projectswg.common.data.encodables.tangible.PvpStatus; -import com.projectswg.common.network.packets.swg.zone.UpdatePvpStatusMessage; - -import com.projectswg.holocore.intents.FactionIntent; -import com.projectswg.holocore.intents.chat.SystemMessageIntent; -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.cell.CellObject; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.objects.tangible.TangibleObject; -import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.control.ManagerStructure; +@ManagerStructure(children = { + FactionFlagService.class, + CivilWarService.class +}) public final class FactionManager extends Manager { - private final Map> statusChangers; - private final PswgScheduledThreadPool executor; - public FactionManager() { - statusChangers = new ConcurrentHashMap<>(); - executor = new PswgScheduledThreadPool(1, "faction-service"); - addChildService(new CivilWarService()); - - registerForIntent(FactionIntent.class, this::handleFactionIntent); - } - - @Override - public boolean initialize() { - executor.start(); - return super.initialize(); - } - - @Override - public boolean terminate() { - executor.stop(); - executor.awaitTermination(500); - - return super.terminate(); - } - - private void handleFactionIntent(FactionIntent fi) { - TangibleObject target = fi.getTarget(); - - if (!(target instanceof CreatureObject) && !(target.getParent() instanceof CellObject)) { // We don't deal with faction updates for inventory items and the like - return; - } - - switch (fi.getUpdateType()) { - case FACTIONUPDATE: - handleTypeChange(fi); - break; - case SWITCHUPDATE: - handleSwitchChange(fi); - break; - case STATUSUPDATE: - handleStatusChange(fi); - break; - case FLAGUPDATE: - handleFlagChange(target); - break; - } - } - - private void handleTypeChange(FactionIntent fi) { - TangibleObject target = fi.getTarget(); - PvpFaction newFaction = fi.getNewFaction(); - - target.setPvpFaction(newFaction); - handleFlagChange(target); - } - - private void handleSwitchChange(FactionIntent fi) { - final PvpFlag pvpFlag; - final TangibleObject target = fi.getTarget(); - final PvpStatus oldStatus = target.getPvpStatus(); - final PvpStatus newStatus; - - if(target.hasPvpFlag(PvpFlag.GOING_COVERT) || target.hasPvpFlag(PvpFlag.GOING_OVERT)) { - SystemMessageIntent.broadcastPersonal(target.getOwner(), "@faction_recruiter:pvp_status_changing"); - } else { - if(oldStatus == PvpStatus.COMBATANT) { - pvpFlag = PvpFlag.GOING_OVERT; - newStatus = PvpStatus.SPECIALFORCES; - } else { // Covers both ONLEAVE and SPECIALFORCES - pvpFlag = PvpFlag.GOING_COVERT; - newStatus = PvpStatus.COMBATANT; - } - - target.setPvpFlags(pvpFlag); - SystemMessageIntent.broadcastPersonal(target.getOwner(), getBeginMessage(oldStatus, newStatus)); - statusChangers.put(target, executor.execute(getDelay(oldStatus, newStatus) * 1000, () -> completeChange(target, pvpFlag, oldStatus, newStatus))); - } - } - - // Forces the target into the given PvpStatus - private void handleStatusChange(FactionIntent fi) { - TangibleObject target = fi.getTarget(); - PvpStatus oldStatus = target.getPvpStatus(); - PvpStatus newStatus = fi.getNewStatus(); - - // No reason to send deltas and all that if the status isn't effectively changing - if(oldStatus == newStatus) - return; - - // Let's clear PvP flags in case they were in the middle of going covert/overt - Future future = statusChangers.remove(target); - - if (future != null) { - if (future.cancel(false)) { - target.clearPvpFlags(PvpFlag.GOING_COVERT, PvpFlag.GOING_OVERT); - } else if (target.getPvpStatus() != newStatus) { - // Their new status does not equal the one we want - apply the new one - changeStatus(target, newStatus); - } - } else { - // They're not currently waiting to switch to a new status - change now - changeStatus(target, newStatus); - } - } - - private void handleFlagChange(TangibleObject target) { - Player targetOwner = target.getOwner(); - - for (SWGObject objectAware : target.getObjectsAware()) { - if (!(objectAware instanceof TangibleObject)) { - continue; - } - - TangibleObject tangibleAware = (TangibleObject) objectAware; - - if (tangibleAware.getPvpFaction() == PvpFaction.NEUTRAL) { - continue; - } - - Player observerOwner = tangibleAware.getOwner(); - - int pvpBitmask = getPvpBitmask(target, tangibleAware); - - if (targetOwner != null) // Send the PvP information about this observer to the owner - targetOwner.sendPacket(createPvpStatusMessage(tangibleAware, tangibleAware.getPvpFlags() | pvpBitmask)); - - if (observerOwner != null) // Send the pvp information about the owner to this observer - observerOwner.sendPacket(createPvpStatusMessage(target, target.getPvpFlags() | pvpBitmask)); - } - } - - private void completeChange(TangibleObject target, PvpFlag pvpFlag, PvpStatus oldStatus, PvpStatus newStatus) { - statusChangers.remove(target); - - SystemMessageIntent.broadcastPersonal(target.getOwner(), getCompletionMessage(oldStatus, newStatus)); - target.clearPvpFlags(pvpFlag); - changeStatus(target, newStatus); - } - - private void changeStatus(TangibleObject target, PvpStatus newStatus) { - target.setPvpStatus(newStatus); - handleFlagChange(target); - } - - private static String getBeginMessage(PvpStatus oldStatus, PvpStatus newStatus) { - String message = "@faction_recruiter:"; - - if(oldStatus == PvpStatus.ONLEAVE && newStatus == PvpStatus.COMBATANT) - message += "on_leave_to_covert"; - else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.SPECIALFORCES) - message += "covert_to_overt"; - else if(oldStatus == PvpStatus.SPECIALFORCES && newStatus == PvpStatus.COMBATANT) - message += "overt_to_covert"; - - return message; - } - - private static String getCompletionMessage(PvpStatus oldStatus, PvpStatus newStatus) { - String message = "@faction_recruiter:"; - - if((oldStatus == PvpStatus.ONLEAVE || oldStatus == PvpStatus.SPECIALFORCES) && newStatus == PvpStatus.COMBATANT) - message += "covert_complete"; - else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.SPECIALFORCES) - message += "overt_complete"; - else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.ONLEAVE ) - message += "on_leave_complete"; - - return message; - } - - private static long getDelay(PvpStatus oldStatus, PvpStatus newStatus) { - long delay = 0; - - if(oldStatus == PvpStatus.ONLEAVE && newStatus == PvpStatus.COMBATANT) - delay = 1; - else if(oldStatus == PvpStatus.COMBATANT && newStatus == PvpStatus.SPECIALFORCES) - delay = 30; - else if(oldStatus == PvpStatus.SPECIALFORCES && newStatus == PvpStatus.COMBATANT) - delay = 300; - - return delay; - } - - private static UpdatePvpStatusMessage createPvpStatusMessage(TangibleObject target, int flags) { - Set flagSet = PvpFlag.getFlags(flags); - return new UpdatePvpStatusMessage(target.getPvpFaction(), target.getObjectId(), flagSet.toArray(new PvpFlag[flagSet.size()])); - } - - private static int getPvpBitmask(TangibleObject target, TangibleObject observer) { - int pvpBitmask = 0; - - if(target.isEnemyOf(observer)) { - pvpBitmask |= PvpFlag.AGGRESSIVE.getBitmask() | PvpFlag.ATTACKABLE.getBitmask() | PvpFlag.ENEMY.getBitmask(); - } - - return pvpBitmask; } } diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/ConnectionService.java b/src/main/java/com/projectswg/holocore/services/galaxy/ConnectionService.java index 84504da7d..5de789a54 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/ConnectionService.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/ConnectionService.java @@ -26,20 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy; -import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.concurrency.SynchronizedSet; -import com.projectswg.common.control.IntentChain; -import com.projectswg.common.control.Service; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.HeartBeat; import com.projectswg.common.utilities.ThreadUtilities; - import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.connection.ForceLogoutIntent; import com.projectswg.holocore.intents.network.CloseConnectionIntent; @@ -51,6 +39,18 @@ import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.player.PlayerEvent; import com.projectswg.holocore.resources.player.PlayerFlags; import com.projectswg.holocore.services.CoreManager; +import me.joshlarson.jlcommon.control.IntentChain; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.Iterator; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public class ConnectionService extends Service { @@ -63,8 +63,8 @@ public class ConnectionService extends Service { public ConnectionService() { updateService = Executors.newSingleThreadScheduledExecutor(ThreadUtilities.newThreadFactory("conn-update-service")); - zonedInPlayers = new SynchronizedSet<>(); - disappearPlayers = new SynchronizedSet<>(); + zonedInPlayers = ConcurrentHashMap.newKeySet(); + disappearPlayers = ConcurrentHashMap.newKeySet(); disappearRunnable = () -> { synchronized (disappearPlayers) { Iterator iter = disappearPlayers.iterator(); @@ -77,10 +77,6 @@ public class ConnectionService extends Service { } } }; - - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); - registerForIntent(GalacticPacketIntent.class, this::handleGalacticPacketIntent); - registerForIntent(ForceLogoutIntent.class, this::handleForceLogoutIntent); } @Override @@ -95,6 +91,7 @@ public class ConnectionService extends Service { return super.terminate() && success; } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei) { Player p = pei.getPlayer(); switch (pei.getEvent()) { @@ -109,6 +106,7 @@ public class ConnectionService extends Service { } } + @IntentHandler private void handleGalacticPacketIntent(GalacticPacketIntent gpi) { Player p = gpi.getPlayer(); p.updateLastPacketTimestamp(); @@ -116,9 +114,10 @@ public class ConnectionService extends Service { p.sendPacket(gpi.getPacket()); } + @IntentHandler private void handleForceLogoutIntent(ForceLogoutIntent fli) { Player player = fli.getPlayer(); - Assert.notNull(player.getCreatureObject(), "ForceLogoutIntent must have a valid player with creature object!"); + Objects.requireNonNull(player.getCreatureObject(), "ForceLogoutIntent must have a valid player with creature object!"); logOut(player); disappear(player, false, DisconnectReason.APPLICATION); } @@ -141,7 +140,8 @@ public class ConnectionService extends Service { CoreManager.getGalaxy().incrementPopulationCount(); clearPlayerFlag(p, PlayerFlags.LD); removeFromDisappear(p); - Assert.test(zonedInPlayers.add(p)); + boolean unique = zonedInPlayers.add(p); + assert unique; } private void logOut(Player p) { diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/EnvironmentService.java b/src/main/java/com/projectswg/holocore/services/galaxy/EnvironmentService.java index 71d813c64..4b88fbc3b 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/EnvironmentService.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/EnvironmentService.java @@ -26,26 +26,26 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.WeatherType; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.ServerTimeMessage; import com.projectswg.common.network.packets.swg.zone.ServerWeatherMessage; import com.projectswg.common.utilities.ThreadUtilities; - +import com.projectswg.holocore.ProjectSWG; import com.projectswg.holocore.intents.NotifyPlayersPacketIntent; import com.projectswg.holocore.intents.PlayerEventIntent; -import com.projectswg.holocore.ProjectSWG; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.player.PlayerEvent; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public final class EnvironmentService extends Service { @@ -63,7 +63,6 @@ public final class EnvironmentService extends Service { weatherForTerrain = new HashMap<>(); weatherTypes = WeatherType.values(); random = new Random(); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); } @Override @@ -95,6 +94,7 @@ public final class EnvironmentService extends Service { return super.terminate(); } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei){ if(pei.getEvent().equals(PlayerEvent.PE_ZONE_IN_CLIENT)) handleZoneIn(pei); diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/GalacticManager.java b/src/main/java/com/projectswg/holocore/services/galaxy/GalacticManager.java index e9dd3e866..fd63fc3b2 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/GalacticManager.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/GalacticManager.java @@ -26,9 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy; -import com.projectswg.common.control.IntentChain; -import com.projectswg.common.control.Manager; -import com.projectswg.common.debug.Assert; import com.projectswg.holocore.intents.network.ConnectionClosedIntent; import com.projectswg.holocore.intents.network.ConnectionOpenedIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; @@ -42,6 +39,9 @@ import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.objects.UniformBoxService; import com.projectswg.holocore.services.player.PlayerManager; import com.projectswg.holocore.services.trade.TradeService; +import me.joshlarson.jlcommon.control.IntentChain; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Manager; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -65,10 +65,6 @@ public class GalacticManager extends Manager { addChildService(new DeveloperService()); addChildService(new UniformBoxService()); addChildService(new TradeService()); - - registerForIntent(InboundPacketIntent.class, this::handleInboundPacketIntent); - registerForIntent(ConnectionOpenedIntent.class, this::handleConnectionOpenedIntent); - registerForIntent(ConnectionClosedIntent.class, this::handleConnectionClosedIntent); } @Override @@ -77,6 +73,7 @@ public class GalacticManager extends Manager { return super.initialize(); } + @IntentHandler private void handleInboundPacketIntent(InboundPacketIntent ipi){ Player player = playerManager.getPlayerFromNetworkId(ipi.getNetworkId()); Assert.notNull(player); @@ -85,10 +82,12 @@ public class GalacticManager extends Manager { prevIntentMap.get(player.getNetworkId()).broadcastAfter(g); } + @IntentHandler private void handleConnectionOpenedIntent(ConnectionOpenedIntent coi){ prevIntentMap.put(coi.getNetworkId(), new IntentChain(coi)); } + @IntentHandler private void handleConnectionClosedIntent(ConnectionClosedIntent cci){ prevIntentMap.remove(cci.getNetworkId()).reset(); } diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/GameManager.java b/src/main/java/com/projectswg/holocore/services/galaxy/GameManager.java index 24df2f667..ef3e39a56 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/GameManager.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/GameManager.java @@ -26,8 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy; -import com.projectswg.common.control.Manager; - import com.projectswg.holocore.services.collections.CollectionBadgeManager; import com.projectswg.holocore.services.collections.CollectionService; import com.projectswg.holocore.services.combat.CombatManager; @@ -39,6 +37,7 @@ import com.projectswg.holocore.services.experience.ExperienceManager; import com.projectswg.holocore.services.faction.FactionManager; import com.projectswg.holocore.services.group.GroupService; import com.projectswg.holocore.services.sui.SuiService; +import me.joshlarson.jlcommon.control.Manager; public class GameManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/SkillModService.java b/src/main/java/com/projectswg/holocore/services/galaxy/SkillModService.java index d8d68fb8f..37463e8fc 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/SkillModService.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/SkillModService.java @@ -26,17 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Map; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.tangible.Race; import com.projectswg.common.data.info.RelationalServerData; import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.ProjectSWG; import com.projectswg.holocore.intents.SkillModIntent; import com.projectswg.holocore.intents.experience.LevelChangedIntent; @@ -46,6 +38,14 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.player.PlayerObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.utilities.IntentFactory; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Map; public class SkillModService extends Service { @@ -73,11 +73,6 @@ public class SkillModService extends Service { throw new ProjectSWG.CoreException("Unable to load racial_stats.sdb file for SkillTemplateService"); getRacialStatsStatement = racialStatsDatabase.prepareStatement(GET_RACIAL_STATS_SQL); - - registerForIntent(ContainerTransferIntent.class, this::handleContainerTransferIntent); - registerForIntent(LevelChangedIntent.class, this::handleLevelChangedIntent); - registerForIntent(CreatedCharacterIntent.class, this::handleCreatedCharacterIntent); - registerForIntent(SkillModIntent.class, this::handleSkillModIntent); } @Override @@ -87,6 +82,7 @@ public class SkillModService extends Service { return super.terminate(); } + @IntentHandler private void handleContainerTransferIntent(ContainerTransferIntent cti){ if (cti.getObject().getOwner() == null) @@ -113,6 +109,7 @@ public class SkillModService extends Service { } } + @IntentHandler private void handleCreatedCharacterIntent(CreatedCharacterIntent cci){ CreatureObject creature = cci.getCreatureObject(); PlayerObject playerObject = creature.getPlayerObject(); @@ -125,6 +122,7 @@ public class SkillModService extends Service { updateLevelSkillModValues(creature, newLevel, profession, race); } + @IntentHandler private void handleLevelChangedIntent(LevelChangedIntent lci){ CreatureObject creature = lci.getCreatureObject(); PlayerObject playerObject = creature.getPlayerObject(); @@ -137,6 +135,7 @@ public class SkillModService extends Service { updateLevelSkillModValues(creature, newLevel, profession, race); } + @IntentHandler private void handleSkillModIntent(SkillModIntent smi) { for (CreatureObject creature : smi.getAffectedCreatures()) { int adjustModifier = smi.getAdjustModifier(); diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelGroup.java b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelGroup.java index a67eceaac..7f996aa7f 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelGroup.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelGroup.java @@ -26,16 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy.travel; +import com.projectswg.common.data.encodables.tangible.Posture; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.concurrency.Delay; +import me.joshlarson.jlcommon.log.Log; + import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import com.projectswg.common.concurrency.Delay; -import com.projectswg.common.data.encodables.tangible.Posture; -import com.projectswg.common.debug.Log; - -import com.projectswg.holocore.resources.objects.creature.CreatureObject; - public class TravelGroup implements Runnable { private final List points; diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelHelper.java b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelHelper.java index fff8a27b7..5e76faf13 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelHelper.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelHelper.java @@ -26,15 +26,6 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy.travel; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.projectswg.common.concurrency.PswgThreadPool; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.info.Config; @@ -42,8 +33,6 @@ import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; @@ -57,17 +46,23 @@ import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.resources.server_info.SdbLoader; import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; import com.projectswg.holocore.services.galaxy.travel.TravelGroup.ShuttleStatus; +import me.joshlarson.jlcommon.concurrency.ThreadPool; +import me.joshlarson.jlcommon.log.Log; + +import java.io.File; +import java.io.IOException; +import java.util.*; class TravelHelper { private final Map travel; - private final PswgThreadPool travelExecutor; + private final ThreadPool travelExecutor; private final AllowedRouteManager routeManager; private final TravelPointManager pointManager; public TravelHelper() { this.travel = new HashMap<>(); - this.travelExecutor = new PswgThreadPool(3, "travel-shuttles-%d"); + this.travelExecutor = new ThreadPool(3, "travel-shuttles-%d"); this.routeManager = new AllowedRouteManager(); this.pointManager = new TravelPointManager(); @@ -126,7 +121,7 @@ class TravelHelper { public void grantTicket(TravelPoint departure, TravelPoint destination, SWGObject receiver) { // Create the ticket object SWGObject ticket = SpecificObject.SO_TRAVEL_TICKET.createType(); - Log.v("Granting ticket for departure: %s/%s and destination: %s/%s", departure.getLocation(), departure.getName(), destination.getLocation(), destination.getName()); + Log.t("Granting ticket for departure: %s/%s and destination: %s/%s", departure.getLocation(), departure.getName(), destination.getLocation(), destination.getName()); // Departure attributes ticket.addAttribute("@obj_attr_n:travel_departure_planet", "@planet_n:" + departure.getTerrain().getName()); diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPoint.java b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPoint.java index 6ae43b406..2ef7b9b8d 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPoint.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPoint.java @@ -28,7 +28,6 @@ package com.projectswg.holocore.services.galaxy.travel; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPointManager.java b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPointManager.java index b5ef3595d..821271c95 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPointManager.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelPointManager.java @@ -26,14 +26,14 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy.travel; +import com.projectswg.common.data.location.Location; +import com.projectswg.common.data.location.Terrain; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.projectswg.common.data.location.Location; -import com.projectswg.common.data.location.Terrain; - public class TravelPointManager { private final Map> shuttlePoints; diff --git a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelService.java b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelService.java index eb3659211..2cd6fc373 100644 --- a/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelService.java +++ b/src/main/java/com/projectswg/holocore/services/galaxy/travel/TravelService.java @@ -26,23 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.services.galaxy.travel; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.tangible.Posture; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.EnterTicketPurchaseModeMessage; import com.projectswg.common.network.packets.swg.zone.PlanetTravelPointListRequest; import com.projectswg.common.network.packets.swg.zone.PlanetTravelPointListResponse; import com.projectswg.common.network.packets.swg.zone.PlanetTravelPointListResponse.PlanetTravelPoint; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; @@ -60,6 +52,13 @@ import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiListBox; import com.projectswg.holocore.resources.sui.SuiMessageBox; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; public class TravelService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/group/GroupInviterData.java b/src/main/java/com/projectswg/holocore/services/group/GroupInviterData.java index 53fbc6614..555f9d095 100644 --- a/src/main/java/com/projectswg/holocore/services/group/GroupInviterData.java +++ b/src/main/java/com/projectswg/holocore/services/group/GroupInviterData.java @@ -29,7 +29,6 @@ package com.projectswg.holocore.services.group; import com.projectswg.common.encoding.Encodable; import com.projectswg.common.network.NetBuffer; - import com.projectswg.holocore.resources.player.Player; public class GroupInviterData implements Encodable { diff --git a/src/main/java/com/projectswg/holocore/services/group/GroupService.java b/src/main/java/com/projectswg/holocore/services/group/GroupService.java index 46fca2787..32364c497 100644 --- a/src/main/java/com/projectswg/holocore/services/group/GroupService.java +++ b/src/main/java/com/projectswg/holocore/services/group/GroupService.java @@ -26,16 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.group; -import java.util.Map; -import java.util.Set; - -import com.projectswg.common.concurrency.SynchronizedMap; -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.chat.ChatAvatar; import com.projectswg.common.data.encodables.oob.ProsePackage; import com.projectswg.common.data.sui.SuiEvent; -import com.projectswg.common.debug.Assert; - import com.projectswg.holocore.intents.GroupEventIntent; import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.chat.ChatRoomUpdateIntent; @@ -52,17 +45,23 @@ import com.projectswg.holocore.resources.sui.SuiListBox; import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.services.objects.ObjectManager.ObjectLookup; import com.projectswg.holocore.utilities.IntentFactory; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; + +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; public class GroupService extends Service { private final Map groups; public GroupService() { - groups = new SynchronizedMap<>(); - registerForIntent(GroupEventIntent.class, this::handleGroupEventIntent); - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); + groups = new ConcurrentHashMap<>(); } + @IntentHandler private void handleGroupEventIntent(GroupEventIntent gei) { switch (gei.getEventType()) { case GROUP_INVITE: @@ -98,6 +97,7 @@ public class GroupService extends Service { } } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei) { switch (pei.getEvent()) { case PE_ZONE_IN_SERVER: @@ -165,7 +165,7 @@ public class GroupService extends Service { private void handleMemberDisappeared(Player player) { CreatureObject creature = player.getCreatureObject(); - Assert.notNull(creature); + Objects.requireNonNull(creature); if (creature.getGroupId() == 0) return; // Ignore anyone without a group @@ -174,9 +174,9 @@ public class GroupService extends Service { private void handleGroupDisband(Player player) { CreatureObject creo = player.getCreatureObject(); - Assert.notNull(creo); + Objects.requireNonNull(creo); GroupObject group = getGroup(creo.getGroupId()); - Assert.notNull(group); + Objects.requireNonNull(group); if (group.getLeaderId() != creo.getObjectId()) { sendSystemMessage(player, "must_be_leader"); @@ -192,7 +192,7 @@ public class GroupService extends Service { private void handleGroupInvite(Player player, CreatureObject target) { CreatureObject creature = player.getCreatureObject(); - Assert.notNull(creature); + Objects.requireNonNull(creature); if (target == null || !target.isPlayer() || creature.equals(target)) { sendSystemMessage(player, "invite_no_target_self"); return; @@ -205,7 +205,7 @@ public class GroupService extends Service { long groupId = creature.getGroupId(); if (groupId != 0) { GroupObject group = getGroup(groupId); - Assert.notNull(group); + Objects.requireNonNull(group); if (!handleInviteToExistingGroup(player, target, group)) return; @@ -242,7 +242,7 @@ public class GroupService extends Service { } Player targetOwner = target.getOwner(); - Assert.notNull(targetOwner); + Objects.requireNonNull(targetOwner); String targetName = targetOwner.getCharacterName(); if (target.getInviterData() == null) { @@ -292,10 +292,10 @@ public class GroupService extends Service { private void handleMakeLeader(Player currentLeader, CreatureObject newLeader) { CreatureObject currentLeaderCreature = currentLeader.getCreatureObject(); - Assert.notNull(currentLeaderCreature); - Assert.test(newLeader.getGroupId() != 0); + Objects.requireNonNull(currentLeaderCreature); + assert newLeader.getGroupId() != 0 : "new leader is not a part of a group"; GroupObject group = getGroup(newLeader.getGroupId()); - Assert.notNull(group); + Objects.requireNonNull(group); if (group.getLeaderId() != currentLeaderCreature.getObjectId()) { sendSystemMessage(currentLeader, "must_be_leader"); @@ -322,16 +322,16 @@ public class GroupService extends Service { } GroupObject group = getGroup(creature.getGroupId()); - Assert.notNull(group); + Objects.requireNonNull(group); group.setLootMaster(target.getObjectId()); sendGroupSystemMessage(group,"new_master_looter", "TU", target.getObjectName()); } private void handleKick(Player leader, CreatureObject kickedCreature) { - Assert.notNull(kickedCreature); + Objects.requireNonNull(kickedCreature); CreatureObject leaderCreature = leader.getCreatureObject(); - Assert.notNull(leaderCreature); + Objects.requireNonNull(leaderCreature); long groupId = leaderCreature.getGroupId(); if (groupId == 0) { // Requester is not in a group sendSystemMessage(leader, "group_only"); @@ -343,7 +343,7 @@ public class GroupService extends Service { } GroupObject group = getGroup(groupId); - Assert.notNull(group); + Objects.requireNonNull(group); if (group.getLeaderId() != leaderCreature.getObjectId()) { // Requester is not leader of group sendSystemMessage(leader, "must_be_leader"); return; @@ -354,7 +354,7 @@ public class GroupService extends Service { private void createGroup(Player leader, Player member) { GroupObject group = (GroupObject) ObjectCreator.createObjectFromTemplate("object/group/shared_group_object.iff"); - Assert.notNull(group); + Objects.requireNonNull(group); groups.put(group.getObjectId(), group); group.formGroup(leader.getCreatureObject(), member.getCreatureObject()); @@ -374,14 +374,14 @@ public class GroupService extends Service { sendGroupSystemMessage(group, "disbanded"); group.disbandGroup(); new DestroyObjectIntent(group).broadcast(); - Assert.notNull(groups.remove(group.getObjectId())); + Objects.requireNonNull(groups.remove(group.getObjectId())); } private void joinGroup(CreatureObject inviter, CreatureObject creature, long groupId) { Player player = creature.getOwner(); - Assert.notNull(player); + Objects.requireNonNull(player); GroupObject group = getGroup(groupId); - Assert.notNull(group); + Objects.requireNonNull(group); if (group.getLeaderId() != inviter.getObjectId()) { sendSystemMessage(player, "join_inviter_not_leader", "TT", inviter.getObjectName()); @@ -398,16 +398,16 @@ public class GroupService extends Service { private void onJoinGroup(CreatureObject creature, GroupObject group) { Player player = creature.getOwner(); - Assert.notNull(player); + Objects.requireNonNull(player); sendSystemMessage(player, "joined_self"); updateChatRoom(player, group, UpdateType.JOIN); } private void removePlayerFromGroup(CreatureObject creature) { - Assert.notNull(creature); - Assert.test(creature.getGroupId() != 0); + Objects.requireNonNull(creature); + assert creature.getGroupId() != 0 : "creature is not within a group"; GroupObject group = getGroup(creature.getGroupId()); - Assert.notNull(group); + Objects.requireNonNull(group); // Check size of the group, if it only has two members, destroy the group if (group.getGroupMembers().size() <= 2) { @@ -442,7 +442,7 @@ public class GroupService extends Service { Set members = group.getGroupMemberObjects(); for (CreatureObject member : members) { - Assert.notNull(member.getOwner()); + Objects.requireNonNull(member.getOwner()); sendSystemMessage(member.getOwner(), id); } } @@ -451,7 +451,7 @@ public class GroupService extends Service { Set members = group.getGroupMemberObjects(); for (CreatureObject member : members) { - Assert.notNull(member.getOwner()); + Objects.requireNonNull(member.getOwner()); sendSystemMessage(member.getOwner(), id, objects); } } diff --git a/src/main/java/com/projectswg/holocore/services/map/CityService.java b/src/main/java/com/projectswg/holocore/services/map/CityService.java index 7b68f5a67..db8d53c24 100644 --- a/src/main/java/com/projectswg/holocore/services/map/CityService.java +++ b/src/main/java/com/projectswg/holocore/services/map/CityService.java @@ -26,21 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.services.map; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.object_controller.DataTransform; - import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; @@ -49,6 +39,15 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.player.PlayerEvent; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class CityService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/map/MapManager.java b/src/main/java/com/projectswg/holocore/services/map/MapManager.java index d6a0fc02e..ee02208af 100644 --- a/src/main/java/com/projectswg/holocore/services/map/MapManager.java +++ b/src/main/java/com/projectswg/holocore/services/map/MapManager.java @@ -27,26 +27,25 @@ package com.projectswg.holocore.services.map; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -import com.projectswg.common.control.Manager; import com.projectswg.common.data.encodables.map.MapLocation; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.spatial.GetMapLocationsMessage; import com.projectswg.common.network.packets.swg.zone.spatial.GetMapLocationsResponseMessage; - import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.client_info.ServerFactory; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Manager; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; public class MapManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/network/HolocoreSessionManager.java b/src/main/java/com/projectswg/holocore/services/network/HolocoreSessionManager.java index 462a33b63..6dbafeaed 100644 --- a/src/main/java/com/projectswg/holocore/services/network/HolocoreSessionManager.java +++ b/src/main/java/com/projectswg/holocore/services/network/HolocoreSessionManager.java @@ -26,14 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.services.network; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.NetworkProtocol; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.holo.HoloConnectionStopped; import com.projectswg.common.network.packets.swg.holo.HoloPacket; import com.projectswg.common.network.packets.swg.holo.HoloSetProtocolVersion; - import com.projectswg.holocore.services.network.HolocoreSessionManager.HolocoreSessionException.SessionExceptionReason; +import me.joshlarson.jlcommon.log.Log; public class HolocoreSessionManager { diff --git a/src/main/java/com/projectswg/holocore/services/network/NetworkClient.java b/src/main/java/com/projectswg/holocore/services/network/NetworkClient.java index 20853b989..2691a9112 100644 --- a/src/main/java/com/projectswg/holocore/services/network/NetworkClient.java +++ b/src/main/java/com/projectswg/holocore/services/network/NetworkClient.java @@ -26,11 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.network; -import com.projectswg.common.control.IntentChain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.NetBufferStream; import com.projectswg.common.network.NetworkProtocol; -import com.projectswg.common.network.TCPServer.TCPSession; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.ErrorMessage; import com.projectswg.common.network.packets.swg.admin.AdminPacket; @@ -41,10 +38,12 @@ import com.projectswg.holocore.intents.network.ConnectionClosedIntent; import com.projectswg.holocore.intents.network.ConnectionOpenedIntent; import com.projectswg.holocore.intents.network.InboundPacketIntent; import com.projectswg.holocore.intents.network.InboundPacketPendingIntent; -import com.projectswg.holocore.services.network.HolocoreSessionManager; import com.projectswg.holocore.services.network.HolocoreSessionManager.HolocoreSessionException; import com.projectswg.holocore.services.network.HolocoreSessionManager.HolocoreSessionException.SessionExceptionReason; import com.projectswg.holocore.services.network.HolocoreSessionManager.SessionStatus; +import me.joshlarson.jlcommon.control.IntentChain; +import me.joshlarson.jlcommon.log.Log; +import me.joshlarson.jlcommon.network.TCPServer.TCPSession; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/src/main/java/com/projectswg/holocore/services/network/NetworkClientManager.java b/src/main/java/com/projectswg/holocore/services/network/NetworkClientManager.java index 11734427e..1bd617686 100644 --- a/src/main/java/com/projectswg/holocore/services/network/NetworkClientManager.java +++ b/src/main/java/com/projectswg/holocore/services/network/NetworkClientManager.java @@ -26,21 +26,22 @@ ***********************************************************************************/ package com.projectswg.holocore.services.network; -import com.projectswg.common.control.Manager; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.NetBuffer; -import com.projectswg.common.network.TCPServer; import com.projectswg.common.network.packets.swg.holo.HoloConnectionStopped.ConnectionStoppedReason; +import com.projectswg.holocore.ProjectSWG.CoreException; import com.projectswg.holocore.intents.network.CloseConnectionIntent; import com.projectswg.holocore.intents.network.ConnectionClosedIntent; import com.projectswg.holocore.intents.network.InboundPacketPendingIntent; import com.projectswg.holocore.intents.network.OutboundPacketIntent; -import com.projectswg.holocore.ProjectSWG.CoreException; import com.projectswg.holocore.resources.config.ConfigFile; import com.projectswg.holocore.resources.network.UDPServer; import com.projectswg.holocore.resources.network.UDPServer.UDPPacket; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.CoreManager; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; +import me.joshlarson.jlcommon.network.TCPServer; import java.io.IOException; import java.net.BindException; @@ -48,7 +49,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketException; -public class NetworkClientManager extends Manager { +public class NetworkClientManager extends Service { private final TCPServer tcpServer; private final TCPServer adminServer; @@ -73,11 +74,6 @@ public class NetworkClientManager extends Manager { else adminServer = new TCPServer<>(new InetSocketAddress(InetAddress.getLoopbackAddress(), adminServerPort), 1024, AdminNetworkClient::new); } - - registerForIntent(CloseConnectionIntent.class, this::handleCloseConnectionIntent); - registerForIntent(ConnectionClosedIntent.class, this::handleConnectionClosedIntent); - registerForIntent(InboundPacketPendingIntent.class, NetworkClientManager::handleInboundPacketPendingIntent); - registerForIntent(OutboundPacketIntent.class, this::handleOutboundPacketIntent); } @Override @@ -143,14 +139,17 @@ public class NetworkClientManager extends Manager { udpServer.send(port, addr, data.array()); } + @IntentHandler private void handleCloseConnectionIntent(CloseConnectionIntent ccii) { disconnect(ccii.getNetworkId()); } + @IntentHandler private void handleConnectionClosedIntent(ConnectionClosedIntent cci) { disconnect(cci.getNetworkId()); } + @IntentHandler private void handleOutboundPacketIntent(OutboundPacketIntent opi) { NetworkClient client = getClient(opi.getNetworkId()); if (client == null) @@ -166,6 +165,7 @@ public class NetworkClientManager extends Manager { return adminServer.getSession(id); } + @IntentHandler private static void handleInboundPacketPendingIntent(InboundPacketPendingIntent ippi) { ippi.getClient().processInbound(); } diff --git a/src/main/java/com/projectswg/holocore/services/network/NetworkManager.java b/src/main/java/com/projectswg/holocore/services/network/NetworkManager.java index 376b22dd6..dfa2b6e3e 100644 --- a/src/main/java/com/projectswg/holocore/services/network/NetworkManager.java +++ b/src/main/java/com/projectswg/holocore/services/network/NetworkManager.java @@ -26,7 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.services.network; -import com.projectswg.common.control.Manager; +import me.joshlarson.jlcommon.control.Manager; public class NetworkManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/objects/AwarenessService.java b/src/main/java/com/projectswg/holocore/services/objects/AwarenessService.java index 733709436..9d0ef4958 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/AwarenessService.java +++ b/src/main/java/com/projectswg/holocore/services/objects/AwarenessService.java @@ -26,12 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.objects; -import com.projectswg.common.control.Intent; -import com.projectswg.common.control.Service; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.CmdSceneReady; import com.projectswg.common.network.packets.swg.zone.HeartBeat; @@ -63,6 +59,10 @@ import com.projectswg.holocore.resources.player.PlayerEvent; import com.projectswg.holocore.resources.player.PlayerState; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.objects.ObjectManager.ObjectLookup; +import me.joshlarson.jlcommon.control.Intent; +import me.joshlarson.jlcommon.control.IntentHandler; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.util.Collections; @@ -77,18 +77,9 @@ public class AwarenessService extends Service { this.awareness = new ObjectAwareness(); dataTransformHandler = new DataTransformHandler(); dataTransformHandler.setSpeedCheck(DataManager.getConfig(ConfigFile.FEATURES).getBoolean("SPEED-HACK-CHECK", true)); - - registerForIntent(PlayerEventIntent.class, this::handlePlayerEventIntent); - registerForIntent(ObjectCreatedIntent.class, this::handleObjectCreatedIntent); - registerForIntent(DestroyObjectIntent.class, this::handleDestroyObjectIntent); - registerForIntent(ObjectTeleportIntent.class, this::processObjectTeleportIntent); - registerForIntent(GalacticPacketIntent.class, this::processGalacticPacketIntent); - registerForIntent(MoveObjectIntent.class, this::processMoveObjectIntent); - registerForIntent(ContainerTransferIntent.class, this::processContainerTransferIntent); - registerForIntent(RequestZoneInIntent.class, rzii -> handleZoneIn(rzii.getCreature(), rzii.getCreature().getLocation(), rzii.getCreature().getParent())); - registerForIntent(ForceAwarenessUpdateIntent.class, this::handleForceUpdate); } + @IntentHandler private void handlePlayerEventIntent(PlayerEventIntent pei) { Player p = pei.getPlayer(); CreatureObject creature = p.getCreatureObject(); @@ -103,16 +94,19 @@ public class AwarenessService extends Service { } } + @IntentHandler private void handleObjectCreatedIntent(ObjectCreatedIntent oci) { awareness.createObject(oci.getObject()); } + @IntentHandler private void handleDestroyObjectIntent(DestroyObjectIntent doi) { SWGObject obj = doi.getObject(); obj.systemMove(null, GONE_LOCATION); awareness.destroyObject(doi.getObject()); } + @IntentHandler private void processObjectTeleportIntent(ObjectTeleportIntent oti) { SWGObject obj = oti.getObject(); if (obj instanceof CreatureObject && ((CreatureObject) obj).isLoggedInPlayer()) { @@ -123,6 +117,7 @@ public class AwarenessService extends Service { } } + @IntentHandler private void processGalacticPacketIntent(GalacticPacketIntent gpi) { SWGPacket packet = gpi.getPacket(); if (packet instanceof DataTransform) { @@ -134,10 +129,12 @@ public class AwarenessService extends Service { } } + @IntentHandler private void processMoveObjectIntent(MoveObjectIntent moi) { moveObjectWithTransform(moi.getObject(), moi.getParent(), moi.getNewLocation(), moi.getSpeed(), moi.getUpdateCounter()); } + @IntentHandler private void processContainerTransferIntent(ContainerTransferIntent cti) { SWGObject obj = cti.getObject(); SWGObject oldContainer = cti.getOldContainer(); @@ -148,10 +145,16 @@ public class AwarenessService extends Service { obj.sendObservers(new UpdateContainmentMessage(obj.getObjectId(), newContainer == null ? 0 : newContainer.getObjectId(), obj.getSlotArrangement())); } - private void handleForceUpdate(ForceAwarenessUpdateIntent faui) { + @IntentHandler + private void handleForceAwarenessUpdateIntent(ForceAwarenessUpdateIntent faui) { awareness.updateObject(faui.getObject()); } + @IntentHandler + private void handleRequestZoneInIntent(RequestZoneInIntent rzii) { + handleZoneIn(rzii.getCreature(), rzii.getCreature().getLocation(), rzii.getCreature().getParent()); + } + private void handleZoneIn(CreatureObject creature, Location loc, SWGObject parent) { Player player = creature.getOwner(); @@ -193,7 +196,7 @@ public class AwarenessService extends Service { } private void handleCmdSceneReady(Player player, CmdSceneReady p) { - Assert.test(player.getPlayerState() == PlayerState.ZONING_IN); + assert player.getPlayerState() == PlayerState.ZONING_IN; player.setPlayerState(PlayerState.ZONED_IN); Log.i("%s with character %s zoned in from %s", player.getUsername(), player.getCharacterName(), p.getSocketAddress()); new PlayerEventIntent(player, PlayerEvent.PE_ZONE_IN_SERVER).broadcast(); diff --git a/src/main/java/com/projectswg/holocore/services/objects/ClientBuildoutService.java b/src/main/java/com/projectswg/holocore/services/objects/ClientBuildoutService.java index 9908ac088..fd4896ee1 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/ClientBuildoutService.java +++ b/src/main/java/com/projectswg/holocore/services/objects/ClientBuildoutService.java @@ -26,11 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.objects; -import com.projectswg.common.control.Service; import com.projectswg.common.data.CrcDatabase; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.buildout.BuildoutArea; import com.projectswg.holocore.resources.buildout.BuildoutArea.BuildoutAreaBuilder; @@ -46,6 +44,8 @@ import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.resources.server_info.loader.BuildingLoader; import com.projectswg.holocore.resources.server_info.loader.BuildingLoader.BuildingLoaderInfo; import com.projectswg.holocore.services.objects.ObjectCreator.ObjectCreationException; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.io.File; import java.io.IOException; @@ -69,7 +69,7 @@ public class ClientBuildoutService extends Service { @Override public boolean start() { - objects.forEach(ClientBuildoutService::broadcast); + objects.parallelStream().forEach(ClientBuildoutService::broadcast); objects.clear(); return super.start(); } @@ -291,9 +291,8 @@ public class ClientBuildoutService extends Service { } currentArea = area; } - if (currentArea.getTerrain() != terrain) - continue; - createObject(objects, set, currentArea); + if (currentArea.getTerrain() == terrain) + createObject(objects, set, currentArea); } } catch (IOException e) { Log.e(e); diff --git a/src/main/java/com/projectswg/holocore/services/objects/ObjectCreator.java b/src/main/java/com/projectswg/holocore/services/objects/ObjectCreator.java index dd6e45917..426c4ada2 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/ObjectCreator.java +++ b/src/main/java/com/projectswg/holocore/services/objects/ObjectCreator.java @@ -52,8 +52,8 @@ import com.projectswg.holocore.resources.objects.staticobject.StaticObject; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.objects.waypoint.WaypointObject; import com.projectswg.holocore.resources.objects.weapon.WeaponObject; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.lang.reflect.InvocationTargetException; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicLong; @@ -70,7 +70,7 @@ public final class ObjectCreator { return OBJECT_ID.incrementAndGet(); } - @Nonnull + @NotNull public static SWGObject createObjectFromTemplate(long objectId, String template) { assert template.startsWith("object/") && template.endsWith(".iff") : "Invalid template for createObjectFromTemplate: '" + template + "'"; template = ClientFactory.formatToSharedFile(template); @@ -85,7 +85,7 @@ public final class ObjectCreator { return obj; } - @Nonnull + @NotNull public static T createObjectFromTemplate(long objectId, String template, Class c) { T obj; try { @@ -101,24 +101,23 @@ public final class ObjectCreator { return obj; } - @Nonnull + @NotNull public static SWGObject createObjectFromTemplate(String template) { return createObjectFromTemplate(getNextObjectId(), template); } - @Nonnull + @NotNull public static T createObjectFromTemplate(String template, Class c) { return createObjectFromTemplate(getNextObjectId(), template, c); } - @Nonnull + @NotNull private static SWGObject createObjectFromType(long objectId, String template, ObjectData attributes) { Integer gotInt = (Integer) attributes.getAttribute(ObjectDataAttribute.GAME_OBJECT_TYPE); if (gotInt == null) throw new ObjectCreationException(template, "No GOT"); - GameObjectType got = GameObjectType.getTypeFromId(gotInt); - BaselineType baseline = got.getBaselineType(); + BaselineType baseline = GameObjectType.getTypeFromId(gotInt).getBaselineType(); if (baseline == null) { return createSlowFromType(objectId, template); } @@ -146,7 +145,7 @@ public final class ObjectCreator { } } - @Nonnull + @NotNull private static SWGObject createSlowFromType(long objectId, String template) { String type = getObjectType(template); switch (type) { diff --git a/src/main/java/com/projectswg/holocore/services/objects/ObjectManager.java b/src/main/java/com/projectswg/holocore/services/objects/ObjectManager.java index cf53ebf2d..3eb1a307c 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/ObjectManager.java +++ b/src/main/java/com/projectswg/holocore/services/objects/ObjectManager.java @@ -26,16 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.objects; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -import com.projectswg.common.control.Manager; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.object_controller.IntendedTarget; - import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; @@ -51,8 +43,15 @@ import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.services.map.MapManager; import com.projectswg.holocore.services.spawn.SpawnerService; import com.projectswg.holocore.services.spawn.StaticService; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.log.Log; +import org.jetbrains.annotations.Nullable; import javax.annotation.CheckForNull; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; public class ObjectManager extends Manager { @@ -237,7 +236,7 @@ public class ObjectManager extends Manager { OBJECT_MANAGER.set(objManager); } - @CheckForNull + @Nullable public static SWGObject getObjectById(long id) { return OBJECT_MANAGER.get().getObjectById(id); } diff --git a/src/main/java/com/projectswg/holocore/services/objects/RadialService.java b/src/main/java/com/projectswg/holocore/services/objects/RadialService.java index ac08e415a..fac145ea2 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/RadialService.java +++ b/src/main/java/com/projectswg/holocore/services/objects/RadialService.java @@ -26,10 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.objects; -import com.projectswg.common.control.Service; import com.projectswg.common.data.radial.RadialItem; import com.projectswg.common.data.radial.RadialOption; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.ObjectMenuSelect; import com.projectswg.common.network.packets.swg.zone.object_controller.ObjectMenuRequest; @@ -40,6 +38,8 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.scripts.radial.RadialHandler; import com.projectswg.holocore.services.galaxy.GalacticManager; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/projectswg/holocore/services/objects/StaticItemService.java b/src/main/java/com/projectswg/holocore/services/objects/StaticItemService.java index d0832aced..bb7f4ec1c 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/StaticItemService.java +++ b/src/main/java/com/projectswg/holocore/services/objects/StaticItemService.java @@ -26,20 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.objects; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.combat.DamageType; import com.projectswg.common.data.customization.CustomizationVariable; import com.projectswg.common.data.info.RelationalServerData; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.object_controller.ShowLootBox; - import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.object.CreateStaticItemIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; @@ -54,6 +46,13 @@ import com.projectswg.holocore.resources.objects.weapon.WeaponType; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.resources.server_info.StandardLog; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; /** * @author mads diff --git a/src/main/java/com/projectswg/holocore/services/objects/UniformBoxService.java b/src/main/java/com/projectswg/holocore/services/objects/UniformBoxService.java index 3f8a2ab67..8a8d0cf03 100644 --- a/src/main/java/com/projectswg/holocore/services/objects/UniformBoxService.java +++ b/src/main/java/com/projectswg/holocore/services/objects/UniformBoxService.java @@ -26,26 +26,23 @@ ***********************************************************************************/ package com.projectswg.holocore.services.objects; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.info.RelationalServerData; import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.data.radial.RadialItem; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.ProjectSWG; import com.projectswg.holocore.intents.object.CreateStaticItemIntent; -import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.player.uniform.OpenUniformBoxIntent; import com.projectswg.holocore.resources.containers.ContainerPermissionsType; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; public class UniformBoxService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/player/CharacterCreationRestriction.java b/src/main/java/com/projectswg/holocore/services/player/CharacterCreationRestriction.java index b0da6df34..b51ea3fd4 100644 --- a/src/main/java/com/projectswg/holocore/services/player/CharacterCreationRestriction.java +++ b/src/main/java/com/projectswg/holocore/services/player/CharacterCreationRestriction.java @@ -26,16 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player; -import java.util.Arrays; -import java.util.Deque; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.log.Log; + +import java.util.*; +import java.util.concurrent.TimeUnit; public class CharacterCreationRestriction { diff --git a/src/main/java/com/projectswg/holocore/services/player/CharacterCreationService.java b/src/main/java/com/projectswg/holocore/services/player/CharacterCreationService.java index b47657af4..037823a6f 100644 --- a/src/main/java/com/projectswg/holocore/services/player/CharacterCreationService.java +++ b/src/main/java/com/projectswg/holocore/services/player/CharacterCreationService.java @@ -26,34 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.tangible.Race; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.ProfTemplateData; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; -import com.projectswg.common.network.packets.swg.login.creation.ClientCreateCharacter; -import com.projectswg.common.network.packets.swg.login.creation.ClientVerifyAndLockNameRequest; -import com.projectswg.common.network.packets.swg.login.creation.ClientVerifyAndLockNameResponse; +import com.projectswg.common.network.packets.swg.login.creation.*; import com.projectswg.common.network.packets.swg.login.creation.ClientVerifyAndLockNameResponse.ErrorMessage; -import com.projectswg.common.network.packets.swg.login.creation.CreateCharacterFailure; import com.projectswg.common.network.packets.swg.login.creation.CreateCharacterFailure.NameFailureReason; -import com.projectswg.common.network.packets.swg.login.creation.CreateCharacterSuccess; -import com.projectswg.common.network.packets.swg.login.creation.RandomNameRequest; -import com.projectswg.common.network.packets.swg.login.creation.RandomNameResponse; - import com.projectswg.holocore.intents.GalacticIntent; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.player.CreatedCharacterIntent; @@ -68,6 +49,17 @@ import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.player.TerrainZoneInsertion.SpawnInformation; import com.projectswg.holocore.services.player.creation.CharacterCreation; import com.projectswg.holocore.utilities.namegen.SWGNameGenerator; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; public class CharacterCreationService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/player/LoginService.java b/src/main/java/com/projectswg/holocore/services/player/LoginService.java index 8f90779b8..1d058e6c6 100644 --- a/src/main/java/com/projectswg/holocore/services/player/LoginService.java +++ b/src/main/java/com/projectswg/holocore/services/player/LoginService.java @@ -26,15 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player; -import com.projectswg.common.control.Service; import com.projectswg.common.data.BCrypt; import com.projectswg.common.data.encodables.galaxy.Galaxy; import com.projectswg.common.data.encodables.tangible.Race; import com.projectswg.common.data.info.Config; import com.projectswg.common.data.info.RelationalDatabase; import com.projectswg.common.data.info.RelationalServerFactory; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.ErrorMessage; import com.projectswg.common.network.packets.swg.login.*; @@ -59,6 +56,8 @@ import com.projectswg.holocore.resources.player.PlayerState; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.CoreManager; import com.projectswg.holocore.services.objects.ObjectManager.ObjectLookup; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/src/main/java/com/projectswg/holocore/services/player/PlayerManager.java b/src/main/java/com/projectswg/holocore/services/player/PlayerManager.java index ae094c627..37cb7e515 100644 --- a/src/main/java/com/projectswg/holocore/services/player/PlayerManager.java +++ b/src/main/java/com/projectswg/holocore/services/player/PlayerManager.java @@ -26,18 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.BiConsumer; - -import com.projectswg.common.control.Manager; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Assert; import com.projectswg.common.network.packets.SWGPacket; - import com.projectswg.holocore.intents.NotifyPlayersPacketIntent; import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.network.ConnectionClosedIntent; @@ -51,6 +41,14 @@ import com.projectswg.holocore.resources.player.Player.PlayerServer; import com.projectswg.holocore.resources.player.PlayerEvent; import com.projectswg.holocore.resources.player.PlayerState; import com.projectswg.holocore.services.CoreManager; +import me.joshlarson.jlcommon.control.Manager; + +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiConsumer; public class PlayerManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/player/TerrainZoneInsertion.java b/src/main/java/com/projectswg/holocore/services/player/TerrainZoneInsertion.java index 5ada7faac..f6093ad0a 100644 --- a/src/main/java/com/projectswg/holocore/services/player/TerrainZoneInsertion.java +++ b/src/main/java/com/projectswg/holocore/services/player/TerrainZoneInsertion.java @@ -26,16 +26,16 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player; -import java.sql.ResultSet; -import java.sql.SQLException; - import com.projectswg.common.data.info.RelationalServerData; import com.projectswg.common.data.info.RelationalServerFactory; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Location.LocationBuilder; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.holocore.ProjectSWG; +import me.joshlarson.jlcommon.log.Log; + +import java.sql.ResultSet; +import java.sql.SQLException; public class TerrainZoneInsertion { diff --git a/src/main/java/com/projectswg/holocore/services/player/ZoneManager.java b/src/main/java/com/projectswg/holocore/services/player/ZoneManager.java index 83212dd0d..ed0715a1f 100644 --- a/src/main/java/com/projectswg/holocore/services/player/ZoneManager.java +++ b/src/main/java/com/projectswg/holocore/services/player/ZoneManager.java @@ -26,22 +26,15 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player; -import com.projectswg.common.control.Manager; import com.projectswg.common.data.encodables.oob.waypoint.WaypointColor; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.login.AccountFeatureBits; import com.projectswg.common.network.packets.swg.login.ClientIdMsg; import com.projectswg.common.network.packets.swg.login.ClientPermissionsMessage; import com.projectswg.common.network.packets.swg.login.ConnectionServerLagResponse; -import com.projectswg.common.network.packets.swg.zone.HeartBeat; -import com.projectswg.common.network.packets.swg.zone.LagRequest; -import com.projectswg.common.network.packets.swg.zone.SetWaypointColor; -import com.projectswg.common.network.packets.swg.zone.ShowBackpack; -import com.projectswg.common.network.packets.swg.zone.ShowHelmet; +import com.projectswg.common.network.packets.swg.zone.*; import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage; import com.projectswg.common.network.packets.swg.zone.insertion.SelectCharacter; - import com.projectswg.holocore.ProjectSWG; import com.projectswg.holocore.intents.GalacticIntent; import com.projectswg.holocore.intents.PlayerEventIntent; @@ -58,6 +51,8 @@ import com.projectswg.holocore.resources.player.PlayerEvent; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.player.zone.ZoneRequester; +import me.joshlarson.jlcommon.control.Manager; +import me.joshlarson.jlcommon.log.Log; public class ZoneManager extends Manager { diff --git a/src/main/java/com/projectswg/holocore/services/player/creation/CharacterCreation.java b/src/main/java/com/projectswg/holocore/services/player/creation/CharacterCreation.java index 85cdeb619..bb7369c36 100644 --- a/src/main/java/com/projectswg/holocore/services/player/creation/CharacterCreation.java +++ b/src/main/java/com/projectswg/holocore/services/player/creation/CharacterCreation.java @@ -26,17 +26,12 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player.creation; -import java.util.Calendar; - import com.projectswg.common.data.customization.CustomizationString; import com.projectswg.common.data.encodables.tangible.PvpFlag; import com.projectswg.common.data.encodables.tangible.Race; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.ProfTemplateData; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.login.creation.ClientCreateCharacter; - import com.projectswg.holocore.intents.experience.GrantSkillIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.containers.ContainerPermissionsType; @@ -52,6 +47,9 @@ import com.projectswg.holocore.resources.player.AccessLevel; import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.player.TerrainZoneInsertion.SpawnInformation; +import me.joshlarson.jlcommon.log.Log; + +import java.util.Calendar; public class CharacterCreation { diff --git a/src/main/java/com/projectswg/holocore/services/player/zone/ZoneRequester.java b/src/main/java/com/projectswg/holocore/services/player/zone/ZoneRequester.java index 8d75c297a..c939ff5dd 100644 --- a/src/main/java/com/projectswg/holocore/services/player/zone/ZoneRequester.java +++ b/src/main/java/com/projectswg/holocore/services/player/zone/ZoneRequester.java @@ -26,12 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.player.zone; -import java.util.concurrent.TimeUnit; - import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.ErrorMessage; - import com.projectswg.holocore.intents.RequestZoneInIntent; import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.resources.config.ConfigFile; @@ -40,6 +36,9 @@ import com.projectswg.holocore.resources.objects.creature.CreatureObject; import com.projectswg.holocore.resources.player.Player; import com.projectswg.holocore.resources.server_info.DataManager; import com.projectswg.holocore.utilities.ScheduledUtilities; +import me.joshlarson.jlcommon.log.Log; + +import java.util.concurrent.TimeUnit; public class ZoneRequester { diff --git a/src/main/java/com/projectswg/holocore/services/spawn/NPCCreator.java b/src/main/java/com/projectswg/holocore/services/spawn/NPCCreator.java index 804739241..45bd6f095 100644 --- a/src/main/java/com/projectswg/holocore/services/spawn/NPCCreator.java +++ b/src/main/java/com/projectswg/holocore/services/spawn/NPCCreator.java @@ -26,28 +26,23 @@ ***********************************************************************************/ package com.projectswg.holocore.services.spawn; -import java.util.Random; - import com.projectswg.common.data.encodables.tangible.PvpFaction; import com.projectswg.common.data.encodables.tangible.PvpFlag; import com.projectswg.common.data.encodables.tangible.PvpStatus; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Location.LocationBuilder; - import com.projectswg.holocore.intents.FactionIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.objects.creature.CreatureObject; -import com.projectswg.holocore.resources.objects.custom.AIObject; -import com.projectswg.holocore.resources.objects.custom.LoiterAIObject; -import com.projectswg.holocore.resources.objects.custom.PatrolAIObject; -import com.projectswg.holocore.resources.objects.custom.RandomAIObject; -import com.projectswg.holocore.resources.objects.custom.TurningAIObject; +import com.projectswg.holocore.resources.objects.custom.*; import com.projectswg.holocore.resources.objects.tangible.OptionFlag; import com.projectswg.holocore.resources.objects.tangible.TangibleObject; import com.projectswg.holocore.resources.spawn.Spawner; import com.projectswg.holocore.resources.spawn.Spawner.SpawnerFlag; import com.projectswg.holocore.services.objects.ObjectCreator; +import java.util.Random; + class NPCCreator { private static final Random RANDOM = new Random(); diff --git a/src/main/java/com/projectswg/holocore/services/spawn/SpawnerService.java b/src/main/java/com/projectswg/holocore/services/spawn/SpawnerService.java index 38155c3f8..bbf88ed6a 100644 --- a/src/main/java/com/projectswg/holocore/services/spawn/SpawnerService.java +++ b/src/main/java/com/projectswg/holocore/services/spawn/SpawnerService.java @@ -26,12 +26,9 @@ ***********************************************************************************/ package com.projectswg.holocore.services.spawn; -import com.projectswg.common.concurrency.PswgScheduledThreadPool; -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.tangible.PvpFaction; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Log; import com.projectswg.holocore.intents.object.DestroyObjectIntent; import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.intents.server.ConfigChangedIntent; @@ -61,6 +58,9 @@ import com.projectswg.holocore.resources.spawn.Spawner.SpawnerFlag; import com.projectswg.holocore.resources.spawn.SpawnerType; import com.projectswg.holocore.services.objects.ObjectCreator; import com.projectswg.holocore.services.objects.ObjectManager.ObjectLookup; +import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.util.HashMap; import java.util.List; @@ -73,11 +73,11 @@ public final class SpawnerService extends Service { private static final String IDLE_MOOD = "idle"; private final Map spawnerMap; - private final PswgScheduledThreadPool executor; + private final ScheduledThreadPool executor; public SpawnerService() { this.spawnerMap = new HashMap<>(); - this.executor = new PswgScheduledThreadPool(1, "spawner-service"); + this.executor = new ScheduledThreadPool(1, "spawner-service"); registerForIntent(ConfigChangedIntent.class, this::handleConfigChangedIntent); registerForIntent(DestroyObjectIntent.class, this::handleDestroyObjectIntent); @@ -271,7 +271,7 @@ public final class SpawnerService extends Service { waypoints = null; } else { waypoints = npcPatrolRouteLoader.getPatrolRoute(spawn.getPatrolId()) - .parallelStream() + .stream() .map(route -> new ResolvedPatrolWaypoint(getPatrolWaypointParent(route), getPatrolWaypointLocation(route), route.getDelay(), route.getPatrolType())) .collect(Collectors.toList()); } @@ -283,7 +283,7 @@ public final class SpawnerService extends Service { Spawner spawner = new Spawner(spawn.getId()); spawner.setCreatureId(npc.getId()); spawner.setIffTemplates(createTemplateList(npc.getIff())); - spawner.setCreatureName(npc.getName().intern()); + spawner.setCreatureName(npc.getName()); spawner.setCombatLevel((short) npc.getCombatLevel()); spawner.setSpawnerFlag(SpawnerFlag.valueOf(npc.getAttackable())); spawner.setPatrolRoute(waypoints); @@ -307,8 +307,8 @@ public final class SpawnerService extends Service { SpawnerType spawnerType = SpawnerType.valueOf(spawn.getSpawnerType()); SWGObject egg = ObjectCreator.createObjectFromTemplate(spawnerType.getObjectTemplate()); egg.setContainerPermissions(ContainerPermissionsType.ADMIN); - egg.moveToContainer(getCell(spawner.getSpawnerId(), spawn.getCellId(), building)); egg.setLocation(spawner.getLocation()); + egg.moveToContainer(getCell(spawner.getSpawnerId(), spawn.getCellId(), building)); spawner.setSpawnerObject(egg); ObjectCreatedIntent.broadcast(egg); } @@ -373,7 +373,7 @@ public final class SpawnerService extends Service { } private void setMoodAnimation(Spawner spawner, StaticSpawnInfo spawn) { - String moodAnimation = spawn.getMood().intern(); + String moodAnimation = spawn.getMood(); if (moodAnimation.equals(IDLE_MOOD)) moodAnimation = "neutral"; @@ -413,9 +413,23 @@ public final class SpawnerService extends Service { } private String [] createTemplateList(String templates) { - String [] templateList = templates.split(";"); - for (int i = 0; i < templateList.length; ++i) { - templateList[i] = ClientFactory.formatToSharedFile("object/mobile/"+templateList[i]); + int count = 0; + int ind = -1; + while (ind < templates.length()) { + ind = templates.indexOf(';', ind + 1); + count++; + if (ind == -1) + break; + } + + ind = 0; + String[] templateList = new String[count]; + for (int i = 0; i < count; i++) { + int next = templates.indexOf(';', ind); + if (next == -1) + next = templates.length(); + templateList[i] = ClientFactory.formatToSharedFile("object/mobile/" + templates.substring(ind, next)); + ind = next + 1; } return templateList; } diff --git a/src/main/java/com/projectswg/holocore/services/spawn/StaticService.java b/src/main/java/com/projectswg/holocore/services/spawn/StaticService.java index f98a22c83..2280b0e30 100644 --- a/src/main/java/com/projectswg/holocore/services/spawn/StaticService.java +++ b/src/main/java/com/projectswg/holocore/services/spawn/StaticService.java @@ -26,19 +26,8 @@ ***********************************************************************************/ package com.projectswg.holocore.services.spawn; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.swgfile.ClientFactory; -import com.projectswg.common.debug.Assert; -import com.projectswg.common.debug.Log; - import com.projectswg.holocore.intents.object.ObjectCreatedIntent; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.building.BuildingObject; @@ -46,6 +35,15 @@ import com.projectswg.holocore.resources.server_info.SdbLoader; import com.projectswg.holocore.resources.server_info.SdbLoader.SdbResultSet; import com.projectswg.holocore.resources.server_info.StandardLog; import com.projectswg.holocore.services.objects.ObjectCreator; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class StaticService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/sui/SuiService.java b/src/main/java/com/projectswg/holocore/services/sui/SuiService.java index 4f680c91d..f9be758e9 100644 --- a/src/main/java/com/projectswg/holocore/services/sui/SuiService.java +++ b/src/main/java/com/projectswg/holocore/services/sui/SuiService.java @@ -26,12 +26,10 @@ ***********************************************************************************/ package com.projectswg.holocore.services.sui; -import com.projectswg.common.control.Service; import com.projectswg.common.data.sui.ISuiCallback; import com.projectswg.common.data.sui.SuiBaseWindow; import com.projectswg.common.data.sui.SuiComponent; import com.projectswg.common.data.sui.SuiEvent; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.server_ui.SuiCreatePageMessage; import com.projectswg.common.network.packets.swg.zone.server_ui.SuiEventNotification; @@ -39,6 +37,8 @@ import com.projectswg.common.network.packets.swg.zone.server_ui.SuiForceClosePag import com.projectswg.holocore.intents.network.GalacticPacketIntent; import com.projectswg.holocore.intents.sui.SuiWindowIntent; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/com/projectswg/holocore/services/trade/TradeService.java b/src/main/java/com/projectswg/holocore/services/trade/TradeService.java index 0d21f339b..94d66896d 100644 --- a/src/main/java/com/projectswg/holocore/services/trade/TradeService.java +++ b/src/main/java/com/projectswg/holocore/services/trade/TradeService.java @@ -27,22 +27,10 @@ package com.projectswg.holocore.services.trade; -import java.util.ArrayList; -import java.util.List; - -import com.projectswg.common.control.Service; import com.projectswg.common.data.encodables.tangible.Posture; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.SWGPacket; import com.projectswg.common.network.packets.swg.zone.object_controller.SecureTrade; -import com.projectswg.common.network.packets.swg.zone.trade.AbortTradeMessage; -import com.projectswg.common.network.packets.swg.zone.trade.AcceptTransactionMessage; -import com.projectswg.common.network.packets.swg.zone.trade.AddItemMessage; -import com.projectswg.common.network.packets.swg.zone.trade.DenyTradeMessage; -import com.projectswg.common.network.packets.swg.zone.trade.GiveMoneyMessage; -import com.projectswg.common.network.packets.swg.zone.trade.UnAcceptTransactionMessage; -import com.projectswg.common.network.packets.swg.zone.trade.VerifyTradeMessage; - +import com.projectswg.common.network.packets.swg.zone.trade.*; import com.projectswg.holocore.intents.PlayerEventIntent; import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.intents.network.GalacticPacketIntent; @@ -53,6 +41,11 @@ import com.projectswg.holocore.resources.sui.SuiButtons; import com.projectswg.holocore.resources.sui.SuiMessageBox; import com.projectswg.holocore.services.objects.ObjectManager; import com.projectswg.holocore.services.objects.ObjectManager.ObjectLookup; +import me.joshlarson.jlcommon.control.Service; +import me.joshlarson.jlcommon.log.Log; + +import java.util.ArrayList; +import java.util.List; public class TradeService extends Service { diff --git a/src/main/java/com/projectswg/holocore/services/trade/TradeSession.java b/src/main/java/com/projectswg/holocore/services/trade/TradeSession.java index a2256100f..09458cf13 100644 --- a/src/main/java/com/projectswg/holocore/services/trade/TradeSession.java +++ b/src/main/java/com/projectswg/holocore/services/trade/TradeSession.java @@ -27,40 +27,27 @@ package com.projectswg.holocore.services.trade; +import com.projectswg.common.network.packets.SWGPacket; +import com.projectswg.common.network.packets.swg.zone.trade.*; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.objects.awareness.AwarenessType; +import com.projectswg.holocore.resources.objects.creature.CreatureObject; +import me.joshlarson.jlcommon.log.Log; + import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; -import com.projectswg.common.debug.Log; -import com.projectswg.common.network.packets.SWGPacket; -import com.projectswg.common.network.packets.swg.zone.trade.AbortTradeMessage; -import com.projectswg.common.network.packets.swg.zone.trade.AcceptTransactionMessage; -import com.projectswg.common.network.packets.swg.zone.trade.AddItemMessage; -import com.projectswg.common.network.packets.swg.zone.trade.BeginTradeMessage; -import com.projectswg.common.network.packets.swg.zone.trade.BeginVerificationMessage; -import com.projectswg.common.network.packets.swg.zone.trade.DenyTradeMessage; -import com.projectswg.common.network.packets.swg.zone.trade.GiveMoneyMessage; -import com.projectswg.common.network.packets.swg.zone.trade.TradeCompleteMessage; -import com.projectswg.common.network.packets.swg.zone.trade.UnAcceptTransactionMessage; -import com.projectswg.common.network.packets.swg.zone.trade.VerifyTradeMessage; - -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.awareness.AwarenessType; -import com.projectswg.holocore.resources.objects.creature.CreatureObject; - -import javax.annotation.Nonnull; - public class TradeSession { private final TradeMember initiator; private final TradeMember receiver; private final AtomicReference status; - public TradeSession(@Nonnull CreatureObject initiator, @Nonnull CreatureObject receiver) { + public TradeSession(@NotNull CreatureObject initiator, @NotNull CreatureObject receiver) { this.initiator = new TradeMember(initiator, receiver); this.receiver = new TradeMember(receiver, initiator); this.status = new AtomicReference<>(TradeStatus.STARTED); diff --git a/src/main/java/com/projectswg/holocore/utilities/AwarenessUtilities.java b/src/main/java/com/projectswg/holocore/utilities/AwarenessUtilities.java index 2b243575f..49736d23e 100644 --- a/src/main/java/com/projectswg/holocore/utilities/AwarenessUtilities.java +++ b/src/main/java/com/projectswg/holocore/utilities/AwarenessUtilities.java @@ -26,11 +26,11 @@ ***********************************************************************************/ package com.projectswg.holocore.utilities; -import java.util.Set; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.player.Player; +import java.util.Set; + public class AwarenessUtilities { public static void handleUpdateAwarenessManual(SWGObject obj, Set oldAware, Set oldObservers, Set newAware, Set newObservers) { diff --git a/src/main/java/com/projectswg/holocore/utilities/BuildoutGenerator.java b/src/main/java/com/projectswg/holocore/utilities/BuildoutGenerator.java index 6433f36ce..953253573 100644 --- a/src/main/java/com/projectswg/holocore/utilities/BuildoutGenerator.java +++ b/src/main/java/com/projectswg/holocore/utilities/BuildoutGenerator.java @@ -26,28 +26,23 @@ ***********************************************************************************/ package com.projectswg.holocore.utilities; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map.Entry; - import com.projectswg.common.data.CRC; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Quaternion; import com.projectswg.common.data.location.Terrain; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; - import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.buildouts.BuildoutLoader; import com.projectswg.holocore.resources.objects.buildouts.SnapshotLoader; import com.projectswg.holocore.resources.objects.buildouts.SwgBuildoutArea; import com.projectswg.holocore.resources.objects.cell.CellObject; +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.Map.Entry; + public class BuildoutGenerator { private static final String floatType = "REAL NOT NULL"; diff --git a/src/main/java/com/projectswg/holocore/utilities/IntentFactory.java b/src/main/java/com/projectswg/holocore/utilities/IntentFactory.java index 79e48eed1..684c52103 100644 --- a/src/main/java/com/projectswg/holocore/utilities/IntentFactory.java +++ b/src/main/java/com/projectswg/holocore/utilities/IntentFactory.java @@ -32,14 +32,13 @@ import com.projectswg.common.data.encodables.oob.StringId; import com.projectswg.common.data.encodables.oob.waypoint.WaypointPackage; import com.projectswg.common.data.encodables.player.Mail; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Log; import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage; - import com.projectswg.holocore.intents.chat.PersistentMessageIntent; import com.projectswg.holocore.intents.chat.SystemMessageIntent; import com.projectswg.holocore.resources.objects.SWGObject; import com.projectswg.holocore.resources.objects.waypoint.WaypointObject; import com.projectswg.holocore.resources.player.Player; +import me.joshlarson.jlcommon.log.Log; /** * @author Mads diff --git a/src/main/java/com/projectswg/holocore/utilities/ScheduledUtilities.java b/src/main/java/com/projectswg/holocore/utilities/ScheduledUtilities.java index 0c770acc0..16bfd64e7 100644 --- a/src/main/java/com/projectswg/holocore/utilities/ScheduledUtilities.java +++ b/src/main/java/com/projectswg/holocore/utilities/ScheduledUtilities.java @@ -26,13 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.utilities; +import com.projectswg.common.utilities.ThreadUtilities; + import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import com.projectswg.common.utilities.ThreadUtilities; - public class ScheduledUtilities { private static final Object mutex = new Object(); diff --git a/src/main/java/com/projectswg/holocore/utilities/SdbGenerator.java b/src/main/java/com/projectswg/holocore/utilities/SdbGenerator.java index 8ff279622..002e1a456 100644 --- a/src/main/java/com/projectswg/holocore/utilities/SdbGenerator.java +++ b/src/main/java/com/projectswg/holocore/utilities/SdbGenerator.java @@ -26,13 +26,7 @@ ***********************************************************************************/ package com.projectswg.holocore.utilities; -import java.io.BufferedWriter; -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; +import java.io.*; import java.nio.charset.Charset; public class SdbGenerator implements Closeable { diff --git a/src/main/java/com/projectswg/holocore/utilities/buildouts/BuildingListGenerator.java b/src/main/java/com/projectswg/holocore/utilities/buildouts/BuildingListGenerator.java index 36f33e0a2..3d5a94bbb 100644 --- a/src/main/java/com/projectswg/holocore/utilities/buildouts/BuildingListGenerator.java +++ b/src/main/java/com/projectswg/holocore/utilities/buildouts/BuildingListGenerator.java @@ -26,6 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.utilities.buildouts; +import com.projectswg.common.data.location.Terrain; +import com.projectswg.holocore.resources.objects.SWGObject; +import com.projectswg.holocore.resources.objects.building.BuildingObject; +import com.projectswg.holocore.resources.server_info.DataManager; +import com.projectswg.holocore.services.objects.ClientBuildoutService; +import com.projectswg.holocore.utilities.SdbGenerator; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -33,14 +40,6 @@ import java.util.Collection; import java.util.List; import java.util.Locale; -import com.projectswg.common.data.location.Terrain; - -import com.projectswg.holocore.resources.objects.SWGObject; -import com.projectswg.holocore.resources.objects.building.BuildingObject; -import com.projectswg.holocore.resources.server_info.DataManager; -import com.projectswg.holocore.services.objects.ClientBuildoutService; -import com.projectswg.holocore.utilities.SdbGenerator; - public class BuildingListGenerator { public static void main(String [] args) throws IOException { diff --git a/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterCommands.java b/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterCommands.java index 251c33104..7bdfd73ff 100644 --- a/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterCommands.java +++ b/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterCommands.java @@ -26,13 +26,13 @@ ***********************************************************************************/ package com.projectswg.holocore.utilities.clientdata_printer; -import java.util.*; - import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; -import com.projectswg.common.debug.Log.LogLevel; -import com.projectswg.common.debug.log_wrapper.ConsoleLogWrapper; +import me.joshlarson.jlcommon.log.Log; +import me.joshlarson.jlcommon.log.Log.LogLevel; +import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper; + +import java.util.*; public class ClientdataPrinterCommands { diff --git a/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterDatatable.java b/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterDatatable.java index 982af74dc..71bdc89f3 100644 --- a/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterDatatable.java +++ b/src/main/java/com/projectswg/holocore/utilities/clientdata_printer/ClientdataPrinterDatatable.java @@ -28,9 +28,9 @@ package com.projectswg.holocore.utilities.clientdata_printer; import com.projectswg.common.data.swgfile.ClientFactory; import com.projectswg.common.data.swgfile.visitors.DatatableData; -import com.projectswg.common.debug.Log; -import com.projectswg.common.debug.Log.LogLevel; -import com.projectswg.common.debug.log_wrapper.ConsoleLogWrapper; +import me.joshlarson.jlcommon.log.Log; +import me.joshlarson.jlcommon.log.Log.LogLevel; +import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper; public class ClientdataPrinterDatatable { diff --git a/src/main/java/com/projectswg/holocore/utilities/namegen/SWGNameGenerator.java b/src/main/java/com/projectswg/holocore/utilities/namegen/SWGNameGenerator.java index e6adac68c..48270b8c7 100644 --- a/src/main/java/com/projectswg/holocore/utilities/namegen/SWGNameGenerator.java +++ b/src/main/java/com/projectswg/holocore/utilities/namegen/SWGNameGenerator.java @@ -28,8 +28,8 @@ package com.projectswg.holocore.utilities.namegen; import com.projectswg.common.data.encodables.tangible.Race; -import com.projectswg.common.debug.Log; import com.projectswg.holocore.resources.zone.NameFilter; +import me.joshlarson.jlcommon.log.Log; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/test/java/com/projectswg/holocore/TestAll.java b/src/test/java/com/projectswg/holocore/TestAll.java index 4dce9c7eb..15ff60750 100644 --- a/src/test/java/com/projectswg/holocore/TestAll.java +++ b/src/test/java/com/projectswg/holocore/TestAll.java @@ -32,7 +32,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; -import com.projectswg.common.control.IntentManager; +import me.joshlarson.jlcommon.control.IntentManager; import com.projectswg.holocore.resources.TestResources; import com.projectswg.holocore.resources.server_info.DataManager; diff --git a/src/test/java/com/projectswg/holocore/resources/objects/TestSWGObject.java b/src/test/java/com/projectswg/holocore/resources/objects/TestSWGObject.java index 5dc245874..2a1a21aec 100644 --- a/src/test/java/com/projectswg/holocore/resources/objects/TestSWGObject.java +++ b/src/test/java/com/projectswg/holocore/resources/objects/TestSWGObject.java @@ -34,7 +34,7 @@ import org.junit.runners.JUnit4; import com.projectswg.common.data.location.Location; import com.projectswg.common.data.location.Terrain; -import com.projectswg.common.debug.Assert.AssertionException; +import me.joshlarson.jlcommon.log.Assert.AssertionException; import com.projectswg.holocore.test_resources.GenericCreatureObject; diff --git a/src/test/java/com/projectswg/holocore/resources/services/TestConfig.java b/src/test/java/com/projectswg/holocore/resources/services/TestConfig.java index bcd75ce9d..d0ec850f9 100644 --- a/src/test/java/com/projectswg/holocore/resources/services/TestConfig.java +++ b/src/test/java/com/projectswg/holocore/resources/services/TestConfig.java @@ -36,7 +36,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import com.projectswg.common.data.info.Config; -import com.projectswg.common.debug.Log; +import me.joshlarson.jlcommon.log.Log; @RunWith(JUnit4.class) public class TestConfig { diff --git a/src/test/java/com/projectswg/holocore/runners/TestRunnerNoIntents.java b/src/test/java/com/projectswg/holocore/runners/TestRunnerNoIntents.java index 5caeaf141..b735d13d3 100644 --- a/src/test/java/com/projectswg/holocore/runners/TestRunnerNoIntents.java +++ b/src/test/java/com/projectswg/holocore/runners/TestRunnerNoIntents.java @@ -27,7 +27,7 @@ package com.projectswg.holocore.runners; -import com.projectswg.common.control.IntentManager; +import me.joshlarson.jlcommon.control.IntentManager; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; diff --git a/src/test/java/com/projectswg/holocore/services/TestServices.java b/src/test/java/com/projectswg/holocore/services/TestServices.java index 346fd3be4..a0752ea11 100644 --- a/src/test/java/com/projectswg/holocore/services/TestServices.java +++ b/src/test/java/com/projectswg/holocore/services/TestServices.java @@ -34,7 +34,7 @@ import org.junit.runners.Suite.SuiteClasses; import com.projectswg.holocore.services.crafting.TestCrafting; import com.projectswg.holocore.services.galaxy.TestGalaxy; -import com.projectswg.holocore.services.loot.TestRareLootService; +import com.projectswg.holocore.services.combat.loot.TestRareLootService; import com.projectswg.holocore.services.player.TestPlayer; @RunWith(Suite.class) diff --git a/src/test/java/com/projectswg/holocore/services/loot/TestRareLootService.java b/src/test/java/com/projectswg/holocore/services/combat/loot/TestRareLootService.java similarity index 98% rename from src/test/java/com/projectswg/holocore/services/loot/TestRareLootService.java rename to src/test/java/com/projectswg/holocore/services/combat/loot/TestRareLootService.java index 49ff1c2f2..e96251474 100644 --- a/src/test/java/com/projectswg/holocore/services/loot/TestRareLootService.java +++ b/src/test/java/com/projectswg/holocore/services/combat/loot/TestRareLootService.java @@ -25,7 +25,7 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package com.projectswg.holocore.services.loot; +package com.projectswg.holocore.services.combat.loot; import com.projectswg.holocore.resources.objects.creature.CreatureDifficulty; import com.projectswg.holocore.runners.TestRunnerNoIntents; diff --git a/src/test/java/com/projectswg/holocore/services/faction/TestCivilWarService.java b/src/test/java/com/projectswg/holocore/services/faction/TestCivilWarService.java index c4f64c787..441cb22a9 100644 --- a/src/test/java/com/projectswg/holocore/services/faction/TestCivilWarService.java +++ b/src/test/java/com/projectswg/holocore/services/faction/TestCivilWarService.java @@ -76,7 +76,7 @@ public class TestCivilWarService extends TestRunnerNoIntents { } private int epochTime(LocalDate date) { - return (int) date.toEpochSecond(LocalTime.MIDNIGHT, OffsetDateTime.now().getOffset()); + return (int) date.atStartOfDay(OffsetDateTime.now().getOffset()).toEpochSecond(); } @Test