From 720538d0f878fe65390d81a410ce91abd6f69505 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sun, 1 Oct 2023 10:53:50 -0400 Subject: [PATCH] Quests 5 (#2146) * Begin refactoring, update license. Bump version * Update locale library * More refactoring * Still more refactoring * Even more refactoring * Cut missing quest requirement, fixes #2131 * Yet more refactoring * Refactoring intensifies * Wreaks of refactoring * Add debug warning for #2138 * Refactoring too stronk * Such refactoring wow * Do not assume click index, fixes #2143 * Bump version * Update headers --- LICENSE.txt | 29 +- api/pom.xml | 188 +- .../java/me/blackvein/quests/QuestsAPI.java | 98 - .../quests/actions/ActionFactory.java | 60 - .../me/blackvein/quests/actions/IAction.java | 121 - .../quests/conditions/ConditionFactory.java | 37 - .../actions/ActionsEditorNumericPrompt.java | 60 - .../actions/ActionsEditorStringPrompt.java | 53 - .../ConditionsEditorNumericPrompt.java | 60 - .../ConditionsEditorStringPrompt.java | 53 - .../quests/QuestsEditorNumericPrompt.java | 60 - .../quests/QuestsEditorStringPrompt.java | 53 - .../quests/dependencies/IDependencies.java | 87 - .../me/blackvein/quests/entity/QuestMob.java | 57 - .../blackvein/quests/events/QuestsEvent.java | 37 - .../quests/events/quest/QuestEvent.java | 54 - .../quests/events/quest/QuestQuitEvent.java | 62 - .../quests/events/quest/QuestTakeEvent.java | 62 - .../me/blackvein/quests/player/IQuester.java | 268 - .../me/blackvein/quests/quests/IQuest.java | 101 - .../me/blackvein/quests/quests/IStage.java | 335 -- .../me/blackvein/quests/quests/Objective.java | 30 - .../me/blackvein/quests/quests/Planner.java | 47 - .../blackvein/quests/quests/QuestFactory.java | 66 - .../main/java/me/pikamug/quests/Quests.java | 100 + .../me/pikamug/quests/actions/Action.java | 81 + .../pikamug/quests/actions/ActionFactory.java | 36 + .../quests/conditions/Condition.java} | 33 +- .../quests/conditions/ConditionFactory.java | 35 + .../quests/config/ConfigSettings.java} | 18 +- .../quests/convo/QuestsNumericPrompt.java | 23 +- .../quests/convo/QuestsStringPrompt.java | 23 +- .../actions/ActionsEditorNumericPrompt.java | 52 + .../actions/ActionsEditorStringPrompt.java | 45 + .../ConditionsEditorNumericPrompt.java | 52 + .../ConditionsEditorStringPrompt.java | 45 + .../quests/QuestsEditorNumericPrompt.java | 52 + .../quests/QuestsEditorStringPrompt.java | 45 + .../quests/dependencies/Dependencies.java | 18 + .../me/pikamug/quests/entity/QuestMob.java | 27 + .../quests/enums/ObjectiveType.java | 16 +- .../me/pikamug/quests/enums/StorageType.java | 58 + .../me/pikamug/quests/events/QuestsEvent.java | 35 + .../editor/actions/ActionsEditorEvent.java | 26 +- ...tionsEditorPostOpenNumericPromptEvent.java | 18 +- ...ctionsEditorPostOpenStringPromptEvent.java | 18 +- .../conditions/ConditionsEditorEvent.java | 26 +- ...tionsEditorPostOpenNumericPromptEvent.java | 18 +- ...itionsEditorPostOpenStringPromptEvent.java | 18 +- .../editor/quests/QuestsEditorEvent.java | 26 +- ...uestsEditorPostOpenNumericPromptEvent.java | 18 +- ...QuestsEditorPostOpenStringPromptEvent.java | 18 +- .../quests/events/misc/MiscEditorEvent.java | 18 +- .../misc/MiscPostNpcOfferQuestEvent.java | 16 +- .../misc/MiscPostQuestAbandonEvent.java | 16 +- .../events/misc/MiscPostQuestAcceptEvent.java | 16 +- .../quests/events/quest/QuestEvent.java | 52 + .../quests/events/quest/QuestQuitEvent.java | 60 + .../quests/events/quest/QuestTakeEvent.java | 60 + .../events/quest/QuestUpdateCompassEvent.java | 26 +- .../exceptions/ActionFormatException.java | 16 +- .../exceptions/ConditionFormatException.java | 16 +- .../exceptions/QuestFormatException.java | 16 +- .../exceptions/StageFormatException.java | 24 +- .../quests/interfaces/ReloadCallback.java | 15 + .../quests/module/CustomObjective.java} | 41 +- .../quests/module/CustomRequirement.java | 62 + .../pikamug/quests/module/CustomReward.java | 61 + .../pikamug/quests/player/QuestProgress.java | 93 + .../me/pikamug/quests/player/Quester.java | 256 + .../java/me/pikamug/quests/quests/Quest.java | 93 + .../pikamug/quests/quests/QuestFactory.java | 51 + .../quests/quests/components/Objective.java | 28 + .../quests/quests/components}/Options.java | 16 +- .../quests/quests/components/Planner.java | 45 + .../quests/components}/Requirements.java | 22 +- .../quests/quests/components}/Rewards.java | 22 +- .../quests/quests/components/Stage.java | 220 + .../quests/storage/QuesterStorage.java | 42 +- .../implementation/ActionStorageImpl.java | 27 + .../implementation/ConditionStorageImpl.java | 27 + .../implementation/ModuleStorageImpl.java | 17 + .../implementation/QuestStorageImpl.java | 27 + .../implementation/QuesterStorageImpl.java | 37 + .../custom/CustomStorageProvider.java | 18 + .../custom/CustomStorageProviders.java | 29 + .../sql/connection/ConnectionFactory.java | 35 + .../hikari/HikariConnectionFactory.java | 36 +- .../hikari/MySqlConnectionFactory.java | 23 +- .../storage/misc/StorageCredentials.java | 16 +- .../main/java/me/pikamug/quests/util/Key.java | 78 +- .../me/pikamug/quests/util/RomanNumeral.java | 42 + core/pom.xml | 43 +- .../main/java/me/blackvein/quests/Quests.java | 4815 ----------------- .../quests/actions/BukkitActionFactory.java | 480 -- .../questadmin/QuestadminCommandHandler.java | 191 - .../subcommands/QuestadminReloadCommand.java | 79 - .../commands/quests/QuestsCommandHandler.java | 131 - .../subcommands/QuestsActionsCommand.java | 75 - .../subcommands/QuestsConditionsCommand.java | 74 - .../subcommands/QuestsEditorCommand.java | 88 - .../quests/subcommands/QuestsInfoCommand.java | 68 - .../subcommands/QuestsJournalCommand.java | 115 - .../quests/subcommands/QuestsListCommand.java | 110 - .../quests/subcommands/QuestsQuitCommand.java | 124 - .../subcommands/QuestsStatsCommand.java | 110 - .../quests/subcommands/QuestsTakeCommand.java | 112 - .../conditions/BukkitConditionFactory.java | 293 - .../quests/convo/misc/MiscNumericPrompt.java | 44 - .../quests/convo/misc/MiscStringPrompt.java | 39 - .../quests/stages/QuestStageMenuPrompt.java | 292 - .../quests/dependencies/DenizenTrigger.java | 46 - .../blackvein/quests/entity/CountableMob.java | 42 - .../events/command/QuestsCommandEvent.java | 53 - .../QuestsCommandPreQuestsEditorEvent.java | 56 - .../QuestsCommandPreQuestsJournalEvent.java | 49 - .../QuestsCommandPreQuestsListEvent.java | 55 - .../quests/events/quester/QuesterEvent.java | 54 - .../quester/QuesterPostChangeStageEvent.java | 62 - .../QuesterPostCompleteQuestEvent.java | 49 - .../quester/QuesterPostFailQuestEvent.java | 49 - .../quester/QuesterPostStartQuestEvent.java | 49 - .../QuesterPostUpdateObjectiveEvent.java | 73 - .../quester/QuesterPreChangeStageEvent.java | 74 - .../quester/QuesterPreCompleteQuestEvent.java | 66 - .../quester/QuesterPreFailQuestEvent.java | 61 - .../quester/QuesterPreStartQuestEvent.java | 61 - .../QuesterPreUpdateObjectiveEvent.java | 73 - .../quests/interfaces/ReloadCallback.java | 17 - .../quests/listeners/CommandManager.java | 75 - .../quests/listeners/ConvoListener.java | 23 - .../quests/listeners/PartiesListener.java | 58 - .../quests/nms/ActionBarProvider.java | 51 - .../quests/nms/ActionBarProvider_Bukkit.java | 25 - .../quests/nms/ParticleProvider_Bukkit.java | 51 - .../blackvein/quests/nms/TitleProvider.java | 53 - .../quests/nms/TitleProvider_Bukkit.java | 12 - .../quests/quests/BukkitObjective.java | 130 - .../quests/quests/BukkitQuestFactory.java | 932 ---- .../blackvein/quests/storage/StorageType.java | 57 - .../implementation/StorageImplementation.java | 39 - .../custom/CustomStorageProvider.java | 20 - .../custom/CustomStorageProviders.java | 31 - .../sql/connection/ConnectionFactory.java | 37 - .../blackvein/quests/tasks/ActionTimer.java | 46 - .../quests/tasks/PlayerMoveThread.java | 39 - .../me/blackvein/quests/tasks/StageTimer.java | 63 - .../blackvein/quests/util/RomanNumeral.java | 44 - .../blackvein/quests/util/UpdateChecker.java | 48 - .../me/pikamug/quests/BukkitQuestsPlugin.java | 860 +++ .../quests/actions/BukkitAction.java} | 74 +- .../quests/actions/BukkitActionFactory.java | 472 ++ .../commands/BukkitQuestsSubCommand.java} | 22 +- .../quest/BukkitQuestCommandHandler.java} | 126 +- .../BukkitQuestadminCommandHandler.java | 189 + .../BukkitQuestadminFinishCommand.java} | 62 +- .../BukkitQuestadminGiveCommand.java} | 58 +- .../BukkitQuestadminGivepointsCommand.java} | 46 +- .../BukkitQuestadminNextstageCommand.java} | 62 +- .../BukkitQuestadminPointsCommand.java} | 46 +- .../BukkitQuestadminPointsallCommand.java} | 56 +- .../BukkitQuestadminQuitCommand.java} | 62 +- .../BukkitQuestadminReloadCommand.java | 77 + .../BukkitQuestadminRemoveCommand.java} | 56 +- .../BukkitQuestadminResetCommand.java} | 54 +- .../BukkitQuestadminSetstageCommand.java} | 69 +- .../BukkitQuestadminStatsCommand.java} | 66 +- .../BukkitQuestadminTakepointsCommand.java} | 46 +- .../quests/BukkitQuestsCommandHandler.java | 129 + .../BukkitQuestsActionsCommand.java | 73 + .../BukkitQuestsChoiceCommand.java} | 16 +- .../BukkitQuestsConditionsCommand.java | 72 + .../BukkitQuestsEditorCommand.java | 86 + .../subcommands/BukkitQuestsInfoCommand.java | 64 + .../BukkitQuestsJournalCommand.java | 113 + .../subcommands/BukkitQuestsListCommand.java | 108 + .../subcommands/BukkitQuestsQuitCommand.java | 122 + .../subcommands/BukkitQuestsStatsCommand.java | 108 + .../subcommands/BukkitQuestsTakeCommand.java | 110 + .../subcommands/BukkitQuestsTopCommand.java} | 44 +- .../quests/conditions/BukkitCondition.java} | 56 +- .../conditions/BukkitConditionFactory.java | 292 + .../quests/config/BukkitConfigSettings.java} | 30 +- .../convo/actions/main/ActionMainPrompt.java | 357 +- .../convo/actions/menu/ActionMenuPrompt.java | 152 +- .../actions/tasks/ActionEffectPrompt.java | 162 +- .../actions/tasks/ActionPlayerPrompt.java | 338 +- .../actions/tasks/ActionTimerPrompt.java | 82 +- .../actions/tasks/ActionWeatherPrompt.java | 208 +- .../conditions/main/ConditionMainPrompt.java | 192 +- .../conditions/menu/ConditionMenuPrompt.java | 142 +- .../tasks/ConditionEntityPrompt.java | 100 +- .../tasks/ConditionPlayerPrompt.java | 142 +- .../tasks/ConditionWorldPrompt.java | 180 +- .../quests/convo/generic/ItemStackPrompt.java | 170 +- .../quests/convo/generic/OverridePrompt.java | 30 +- .../quests/convo/misc/MiscNumericPrompt.java | 42 + .../quests/convo/misc/MiscStringPrompt.java | 37 + .../convo/misc/NpcOfferQuestPrompt.java | 100 +- .../quests/convo/misc/QuestAbandonPrompt.java | 65 +- .../quests/convo/misc/QuestAcceptPrompt.java | 138 + .../convo/quests/main/QuestMainPrompt.java | 296 +- .../convo/quests/menu/QuestMenuPrompt.java | 132 +- .../quests/objectives/QuestBlocksPrompt.java | 420 +- .../quests/objectives/QuestItemsPrompt.java | 244 +- .../quests/objectives/QuestMobsPrompt.java | 414 +- .../quests/objectives/QuestNpcsPrompt.java | 270 +- .../quests/options/QuestOptionsPrompt.java | 262 +- .../quests/planner/QuestDateTimePrompt.java | 130 +- .../quests/planner/QuestPlannerPrompt.java | 170 +- .../requirements/QuestRequirementsPrompt.java | 606 ++- .../quests/rewards/QuestRewardsPrompt.java | 602 +-- .../quests/stages/QuestStageMainPrompt.java | 1126 ++-- .../quests/stages/QuestStageMenuPrompt.java | 290 + .../dependencies/BukkitDenizenTrigger.java | 44 + .../dependencies/BukkitDependencies.java} | 122 +- .../reflect/denizen/DenizenAPI.java | 16 +- .../reflect/denizen/DenizenAPI_1_0_9.java | 20 +- .../reflect/denizen/DenizenAPI_1_1_0.java | 20 +- .../reflect/denizen/DenizenAPI_1_1_1.java | 20 +- .../reflect/denizen/DenizenAPI_1_2_2.java | 16 +- .../reflect/worldguard/WorldGuardAPI.java | 16 +- .../worldguard/WorldGuardAPI_7_0_0.java | 16 +- .../quests/entity/BukkitCountableMob.java | 40 + .../quests/entity/BukkitQuestMob.java | 73 +- .../quests/enums/BukkitPreBuiltParticle.java} | 26 +- .../command/BukkitQuestsCommandEvent.java | 51 + .../BukkitQuestsCommandPreEditorEvent.java | 54 + .../BukkitQuestsCommandPreJournalEvent.java | 47 + .../BukkitQuestsCommandPreListEvent.java | 53 + .../events/quester/BukkitQuesterEvent.java | 52 + .../BukkitQuesterPostChangeStageEvent.java | 60 + .../BukkitQuesterPostCompleteQuestEvent.java | 47 + .../BukkitQuesterPostFailQuestEvent.java | 47 + .../BukkitQuesterPostStartQuestEvent.java | 47 + ...BukkitQuesterPostUpdateObjectiveEvent.java | 71 + .../BukkitQuesterPostViewEffectEvent.java} | 22 +- .../BukkitQuesterPreChangeStageEvent.java | 72 + .../BukkitQuesterPreCompleteQuestEvent.java | 64 + .../BukkitQuesterPreFailQuestEvent.java | 59 + .../BukkitQuesterPreOpenGUIEvent.java} | 28 +- .../BukkitQuesterPreStartQuestEvent.java | 59 + .../BukkitQuesterPreUpdateObjectiveEvent.java | 71 + .../quests/item/BukkitQuestJournal.java} | 68 +- .../listeners/BukkitBlockListener.java} | 179 +- .../listeners/BukkitCitizensListener.java} | 150 +- .../listeners/BukkitCommandManager.java | 73 + .../quests/listeners/BukkitConvoListener.java | 33 + .../quests/listeners/BukkitItemListener.java} | 70 +- .../listeners/BukkitPartiesListener.java | 56 + .../listeners/BukkitPlayerListener.java} | 313 +- .../listeners/BukkitUniteListener.java} | 44 +- .../listeners/BukkitZnpcsListener.java} | 133 +- .../logging/BukkitQuestsLog4JFilter.java} | 18 +- .../quests/module/BukkitCustomObjective.java} | 132 +- .../module/BukkitCustomRequirement.java | 70 +- .../quests/module/BukkitCustomReward.java | 49 +- .../quests/nms/BukkitActionBarProvider.java | 50 + .../nms/BukkitActionBarProvider_Modern.java | 23 + .../quests/nms/BukkitParticleProvider.java} | 36 +- .../nms/BukkitParticleProvider_Modern.java | 50 + .../quests/nms/BukkitTitleProvider.java | 52 + .../nms/BukkitTitleProvider_Modern.java | 22 + .../quests/player/BukkitQuestProgress.java | 80 +- .../quests/player/BukkitQuester.java} | 1854 ++++--- .../quests/quests/BukkitQuest.java} | 370 +- .../quests/quests/BukkitQuestFactory.java | 938 ++++ .../quests/components/BukkitObjective.java | 104 + .../quests/components}/BukkitOptions.java | 18 +- .../quests/components}/BukkitPlanner.java | 16 +- .../components}/BukkitRequirements.java | 16 +- .../quests/components}/BukkitRewards.java | 16 +- .../quests/components/BukkitStage.java} | 119 +- .../quests/statistics/BukkitMetrics.java} | 23 +- .../quests/storage/BukkitStorageFactory.java} | 51 +- .../file/BukkitActionYamlStorage.java | 452 ++ .../file/BukkitConditionYamlStorage.java | 286 + .../file/BukkitQuestYamlStorage.java | 1858 +++++++ .../file/BukkitQuesterYamlStorage.java} | 208 +- .../jar/BukkitModuleJarStorage.java | 343 ++ .../sql/BukkitQuesterSqlStorage.java} | 185 +- .../quests/tasks/BukkitActionTimer.java | 44 + .../quests/tasks/BukkitNpcEffectThread.java} | 57 +- .../quests/tasks/BukkitPlayerMoveThread.java | 37 + .../quests/tasks/BukkitStageTimer.java | 61 + .../quests/util/BukkitConfigUtil.java} | 63 +- .../quests/util/BukkitFakeConversable.java} | 18 +- .../quests/util/BukkitInventoryUtil.java} | 24 +- .../quests/util/BukkitItemUtil.java} | 92 +- .../me/pikamug/quests/util/BukkitLang.java | 110 +- .../quests/util/BukkitMiscUtil.java} | 56 +- .../quests/util/BukkitUpdateChecker.java | 46 + core/src/main/resources/actions.yml | 3 +- core/src/main/resources/plugin.yml | 2 +- core/src/main/resources/quests.yml | 9 +- core/src/main/resources/strings.yml | 4 +- dist/pom.xml | 12 +- pom.xml | 4 +- v1_8_R1/pom.xml | 4 +- .../quests/nms/ActionBarProvider_v1_8_R1.java | 30 - .../quests/nms/ParticleProvider_v1_8_R1.java | 56 - .../nms/BukkitActionBarProvider_v1_8_R1.java | 28 + .../nms/BukkitParticleProvider_v1_8_R1.java | 55 + .../nms/BukkitTitleProvider_v1_8_R1.java} | 18 +- v1_8_R2/pom.xml | 4 +- .../quests/nms/ActionBarProvider_v1_8_R2.java | 30 - .../quests/nms/ParticleProvider_v1_8_R2.java | 56 - .../nms/BukkitActionBarProvider_v1_8_R2.java | 28 + .../nms/BukkitParticleProvider_v1_8_R2.java | 55 + .../nms/BukkitTitleProvider_v1_8_R2.java} | 18 +- v1_8_R3/pom.xml | 4 +- .../quests/nms/ActionBarProvider_v1_8_R3.java | 30 - .../quests/nms/ParticleProvider_v1_8_R3.java | 56 - .../nms/BukkitActionBarProvider_v1_8_R3.java | 28 + .../nms/BukkitParticleProvider_v1_8_R3.java | 55 + .../nms/BukkitTitleProvider_v1_8_R3.java} | 18 +- 316 files changed, 18113 insertions(+), 19497 deletions(-) delete mode 100644 api/src/main/java/me/blackvein/quests/QuestsAPI.java delete mode 100644 api/src/main/java/me/blackvein/quests/actions/ActionFactory.java delete mode 100644 api/src/main/java/me/blackvein/quests/actions/IAction.java delete mode 100644 api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java delete mode 100644 api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java delete mode 100644 api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java delete mode 100644 api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java delete mode 100644 api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java delete mode 100644 api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java delete mode 100644 api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java delete mode 100644 api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java delete mode 100644 api/src/main/java/me/blackvein/quests/entity/QuestMob.java delete mode 100644 api/src/main/java/me/blackvein/quests/events/QuestsEvent.java delete mode 100644 api/src/main/java/me/blackvein/quests/events/quest/QuestEvent.java delete mode 100644 api/src/main/java/me/blackvein/quests/events/quest/QuestQuitEvent.java delete mode 100644 api/src/main/java/me/blackvein/quests/events/quest/QuestTakeEvent.java delete mode 100644 api/src/main/java/me/blackvein/quests/player/IQuester.java delete mode 100644 api/src/main/java/me/blackvein/quests/quests/IQuest.java delete mode 100644 api/src/main/java/me/blackvein/quests/quests/IStage.java delete mode 100644 api/src/main/java/me/blackvein/quests/quests/Objective.java delete mode 100644 api/src/main/java/me/blackvein/quests/quests/Planner.java delete mode 100644 api/src/main/java/me/blackvein/quests/quests/QuestFactory.java create mode 100644 api/src/main/java/me/pikamug/quests/Quests.java create mode 100644 api/src/main/java/me/pikamug/quests/actions/Action.java create mode 100644 api/src/main/java/me/pikamug/quests/actions/ActionFactory.java rename api/src/main/java/me/{blackvein/quests/conditions/ICondition.java => pikamug/quests/conditions/Condition.java} (52%) create mode 100644 api/src/main/java/me/pikamug/quests/conditions/ConditionFactory.java rename api/src/main/java/me/{blackvein/quests/config/ISettings.java => pikamug/quests/config/ConfigSettings.java} (75%) rename api/src/main/java/me/{blackvein => pikamug}/quests/convo/QuestsNumericPrompt.java (72%) rename api/src/main/java/me/{blackvein => pikamug}/quests/convo/QuestsStringPrompt.java (72%) create mode 100644 api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorNumericPrompt.java create mode 100644 api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorStringPrompt.java create mode 100644 api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorNumericPrompt.java create mode 100644 api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorStringPrompt.java create mode 100644 api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorNumericPrompt.java create mode 100644 api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorStringPrompt.java create mode 100644 api/src/main/java/me/pikamug/quests/dependencies/Dependencies.java create mode 100644 api/src/main/java/me/pikamug/quests/entity/QuestMob.java rename api/src/main/java/me/{blackvein => pikamug}/quests/enums/ObjectiveType.java (71%) create mode 100644 api/src/main/java/me/pikamug/quests/enums/StorageType.java create mode 100644 api/src/main/java/me/pikamug/quests/events/QuestsEvent.java rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/actions/ActionsEditorEvent.java (59%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java (52%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java (51%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/conditions/ConditionsEditorEvent.java (59%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java (52%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java (52%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/quests/QuestsEditorEvent.java (58%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java (52%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java (51%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/misc/MiscEditorEvent.java (60%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/misc/MiscPostNpcOfferQuestEvent.java (57%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/misc/MiscPostQuestAbandonEvent.java (57%) rename api/src/main/java/me/{blackvein => pikamug}/quests/events/misc/MiscPostQuestAcceptEvent.java (57%) create mode 100644 api/src/main/java/me/pikamug/quests/events/quest/QuestEvent.java create mode 100644 api/src/main/java/me/pikamug/quests/events/quest/QuestQuitEvent.java create mode 100644 api/src/main/java/me/pikamug/quests/events/quest/QuestTakeEvent.java rename api/src/main/java/me/{blackvein => pikamug}/quests/events/quest/QuestUpdateCompassEvent.java (53%) rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/exceptions/ActionFormatException.java (50%) rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/exceptions/ConditionFormatException.java (51%) rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/exceptions/QuestFormatException.java (50%) rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/exceptions/StageFormatException.java (50%) create mode 100644 api/src/main/java/me/pikamug/quests/interfaces/ReloadCallback.java rename api/src/main/java/me/{blackvein/quests/module/ICustomObjective.java => pikamug/quests/module/CustomObjective.java} (51%) create mode 100644 api/src/main/java/me/pikamug/quests/module/CustomRequirement.java create mode 100644 api/src/main/java/me/pikamug/quests/module/CustomReward.java create mode 100644 api/src/main/java/me/pikamug/quests/player/QuestProgress.java create mode 100644 api/src/main/java/me/pikamug/quests/player/Quester.java create mode 100644 api/src/main/java/me/pikamug/quests/quests/Quest.java create mode 100644 api/src/main/java/me/pikamug/quests/quests/QuestFactory.java create mode 100644 api/src/main/java/me/pikamug/quests/quests/components/Objective.java rename api/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/Options.java (55%) create mode 100644 api/src/main/java/me/pikamug/quests/quests/components/Planner.java rename api/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/Requirements.java (60%) rename api/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/Rewards.java (63%) create mode 100644 api/src/main/java/me/pikamug/quests/quests/components/Stage.java rename core/src/main/java/me/blackvein/quests/storage/Storage.java => api/src/main/java/me/pikamug/quests/storage/QuesterStorage.java (61%) create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/ActionStorageImpl.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/ConditionStorageImpl.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/ModuleStorageImpl.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/QuestStorageImpl.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/QuesterStorageImpl.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProvider.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProviders.java create mode 100644 api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/ConnectionFactory.java rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java (77%) rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java (69%) rename {core/src/main/java/me/blackvein => api/src/main/java/me/pikamug}/quests/storage/misc/StorageCredentials.java (71%) rename core/src/main/java/me/blackvein/quests/util/CK.java => api/src/main/java/me/pikamug/quests/util/Key.java (79%) create mode 100644 api/src/main/java/me/pikamug/quests/util/RomanNumeral.java delete mode 100644 core/src/main/java/me/blackvein/quests/Quests.java delete mode 100644 core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminReloadCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsJournalCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java delete mode 100644 core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java delete mode 100644 core/src/main/java/me/blackvein/quests/convo/misc/MiscNumericPrompt.java delete mode 100644 core/src/main/java/me/blackvein/quests/convo/misc/MiscStringPrompt.java delete mode 100644 core/src/main/java/me/blackvein/quests/convo/quests/stages/QuestStageMenuPrompt.java delete mode 100644 core/src/main/java/me/blackvein/quests/dependencies/DenizenTrigger.java delete mode 100644 core/src/main/java/me/blackvein/quests/entity/CountableMob.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsListEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPostCompleteQuestEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPostFailQuestEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPostStartQuestEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPostUpdateObjectiveEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPreCompleteQuestEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPreFailQuestEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPreStartQuestEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/events/quester/QuesterPreUpdateObjectiveEvent.java delete mode 100644 core/src/main/java/me/blackvein/quests/interfaces/ReloadCallback.java delete mode 100644 core/src/main/java/me/blackvein/quests/listeners/CommandManager.java delete mode 100644 core/src/main/java/me/blackvein/quests/listeners/ConvoListener.java delete mode 100644 core/src/main/java/me/blackvein/quests/listeners/PartiesListener.java delete mode 100644 core/src/main/java/me/blackvein/quests/nms/ActionBarProvider.java delete mode 100644 core/src/main/java/me/blackvein/quests/nms/ActionBarProvider_Bukkit.java delete mode 100644 core/src/main/java/me/blackvein/quests/nms/ParticleProvider_Bukkit.java delete mode 100644 core/src/main/java/me/blackvein/quests/nms/TitleProvider.java delete mode 100644 core/src/main/java/me/blackvein/quests/nms/TitleProvider_Bukkit.java delete mode 100644 core/src/main/java/me/blackvein/quests/quests/BukkitObjective.java delete mode 100644 core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java delete mode 100644 core/src/main/java/me/blackvein/quests/storage/StorageType.java delete mode 100644 core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java delete mode 100644 core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProvider.java delete mode 100644 core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProviders.java delete mode 100644 core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/ConnectionFactory.java delete mode 100644 core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java delete mode 100644 core/src/main/java/me/blackvein/quests/tasks/PlayerMoveThread.java delete mode 100644 core/src/main/java/me/blackvein/quests/tasks/StageTimer.java delete mode 100644 core/src/main/java/me/blackvein/quests/util/RomanNumeral.java delete mode 100644 core/src/main/java/me/blackvein/quests/util/UpdateChecker.java create mode 100644 core/src/main/java/me/pikamug/quests/BukkitQuestsPlugin.java rename core/src/main/java/me/{blackvein/quests/actions/Action.java => pikamug/quests/actions/BukkitAction.java} (82%) create mode 100644 core/src/main/java/me/pikamug/quests/actions/BukkitActionFactory.java rename core/src/main/java/me/{blackvein/quests/commands/QuestsSubCommand.java => pikamug/quests/commands/BukkitQuestsSubCommand.java} (81%) rename core/src/main/java/me/{blackvein/quests/commands/quest/QuestCommandHandler.java => pikamug/quests/commands/quest/BukkitQuestCommandHandler.java} (68%) create mode 100644 core/src/main/java/me/pikamug/quests/commands/questadmin/BukkitQuestadminCommandHandler.java rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminFinishCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminFinishCommand.java} (59%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminGiveCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminGiveCommand.java} (65%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminGivepointsCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminGivepointsCommand.java} (58%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminNextstageCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminNextstageCommand.java} (59%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminPointsCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminPointsCommand.java} (57%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminPointsallCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminPointsallCommand.java} (60%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminQuitCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminQuitCommand.java} (57%) create mode 100644 core/src/main/java/me/pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminReloadCommand.java rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminRemoveCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminRemoveCommand.java} (59%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminResetCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminResetCommand.java} (57%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminSetstageCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminSetstageCommand.java} (63%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminStatsCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminStatsCommand.java} (50%) rename core/src/main/java/me/{blackvein/quests/commands/questadmin/subcommands/QuestadminTakepointsCommand.java => pikamug/quests/commands/questadmin/subcommands/BukkitQuestadminTakepointsCommand.java} (58%) create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/BukkitQuestsCommandHandler.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsActionsCommand.java rename core/src/main/java/me/{blackvein/quests/commands/quests/subcommands/QuestsChoiceCommand.java => pikamug/quests/commands/quests/subcommands/BukkitQuestsChoiceCommand.java} (68%) create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsConditionsCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsEditorCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsInfoCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsJournalCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsListCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsQuitCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsStatsCommand.java create mode 100644 core/src/main/java/me/pikamug/quests/commands/quests/subcommands/BukkitQuestsTakeCommand.java rename core/src/main/java/me/{blackvein/quests/commands/quests/subcommands/QuestsTopCommand.java => pikamug/quests/commands/quests/subcommands/BukkitQuestsTopCommand.java} (66%) rename core/src/main/java/me/{blackvein/quests/conditions/Condition.java => pikamug/quests/conditions/BukkitCondition.java} (85%) create mode 100644 core/src/main/java/me/pikamug/quests/conditions/BukkitConditionFactory.java rename core/src/main/java/me/{blackvein/quests/Settings.java => pikamug/quests/config/BukkitConfigSettings.java} (90%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/actions/main/ActionMainPrompt.java (77%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/actions/menu/ActionMenuPrompt.java (72%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/actions/tasks/ActionEffectPrompt.java (77%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/actions/tasks/ActionPlayerPrompt.java (74%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/actions/tasks/ActionTimerPrompt.java (61%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/actions/tasks/ActionWeatherPrompt.java (75%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/conditions/main/ConditionMainPrompt.java (76%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/conditions/menu/ConditionMenuPrompt.java (74%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/conditions/tasks/ConditionEntityPrompt.java (74%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/conditions/tasks/ConditionPlayerPrompt.java (75%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/conditions/tasks/ConditionWorldPrompt.java (75%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/generic/ItemStackPrompt.java (84%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/generic/OverridePrompt.java (66%) create mode 100644 core/src/main/java/me/pikamug/quests/convo/misc/MiscNumericPrompt.java create mode 100644 core/src/main/java/me/pikamug/quests/convo/misc/MiscStringPrompt.java rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/misc/NpcOfferQuestPrompt.java (67%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/misc/QuestAbandonPrompt.java (68%) create mode 100644 core/src/main/java/me/pikamug/quests/convo/misc/QuestAcceptPrompt.java rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/main/QuestMainPrompt.java (76%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/menu/QuestMenuPrompt.java (74%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/objectives/QuestBlocksPrompt.java (80%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/objectives/QuestItemsPrompt.java (76%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/objectives/QuestMobsPrompt.java (78%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/objectives/QuestNpcsPrompt.java (77%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/options/QuestOptionsPrompt.java (72%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/planner/QuestDateTimePrompt.java (87%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/planner/QuestPlannerPrompt.java (66%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/requirements/QuestRequirementsPrompt.java (74%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/rewards/QuestRewardsPrompt.java (77%) rename core/src/main/java/me/{blackvein => pikamug}/quests/convo/quests/stages/QuestStageMainPrompt.java (69%) create mode 100644 core/src/main/java/me/pikamug/quests/convo/quests/stages/QuestStageMenuPrompt.java create mode 100644 core/src/main/java/me/pikamug/quests/dependencies/BukkitDenizenTrigger.java rename core/src/main/java/me/{blackvein/quests/Dependencies.java => pikamug/quests/dependencies/BukkitDependencies.java} (77%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/denizen/DenizenAPI.java (91%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/denizen/DenizenAPI_1_0_9.java (82%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/denizen/DenizenAPI_1_1_0.java (76%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/denizen/DenizenAPI_1_1_1.java (75%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/denizen/DenizenAPI_1_2_2.java (70%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/worldguard/WorldGuardAPI.java (87%) rename {api/src/main/java/me/blackvein/quests => core/src/main/java/me/pikamug/quests/dependencies}/reflect/worldguard/WorldGuardAPI_7_0_0.java (60%) create mode 100644 core/src/main/java/me/pikamug/quests/entity/BukkitCountableMob.java rename core/src/main/java/me/{blackvein => pikamug}/quests/entity/BukkitQuestMob.java (69%) rename core/src/main/java/me/{blackvein/quests/nms/PreBuiltParticle.java => pikamug/quests/enums/BukkitPreBuiltParticle.java} (62%) create mode 100644 core/src/main/java/me/pikamug/quests/events/command/BukkitQuestsCommandEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/command/BukkitQuestsCommandPreEditorEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/command/BukkitQuestsCommandPreJournalEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/command/BukkitQuestsCommandPreListEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPostChangeStageEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPostCompleteQuestEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPostFailQuestEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPostStartQuestEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPostUpdateObjectiveEvent.java rename core/src/main/java/me/{blackvein/quests/events/quester/QuesterPostViewEffectEvent.java => pikamug/quests/events/quester/BukkitQuesterPostViewEffectEvent.java} (52%) create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPreChangeStageEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPreCompleteQuestEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPreFailQuestEvent.java rename core/src/main/java/me/{blackvein/quests/events/quester/QuesterPreOpenGUIEvent.java => pikamug/quests/events/quester/BukkitQuesterPreOpenGUIEvent.java} (50%) create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPreStartQuestEvent.java create mode 100644 core/src/main/java/me/pikamug/quests/events/quester/BukkitQuesterPreUpdateObjectiveEvent.java rename core/src/main/java/me/{blackvein/quests/item/QuestJournal.java => pikamug/quests/item/BukkitQuestJournal.java} (63%) rename core/src/main/java/me/{blackvein/quests/listeners/BlockListener.java => pikamug/quests/listeners/BukkitBlockListener.java} (66%) rename core/src/main/java/me/{blackvein/quests/listeners/CitizensListener.java => pikamug/quests/listeners/BukkitCitizensListener.java} (72%) create mode 100644 core/src/main/java/me/pikamug/quests/listeners/BukkitCommandManager.java create mode 100644 core/src/main/java/me/pikamug/quests/listeners/BukkitConvoListener.java rename core/src/main/java/me/{blackvein/quests/listeners/ItemListener.java => pikamug/quests/listeners/BukkitItemListener.java} (79%) create mode 100644 core/src/main/java/me/pikamug/quests/listeners/BukkitPartiesListener.java rename core/src/main/java/me/{blackvein/quests/listeners/PlayerListener.java => pikamug/quests/listeners/BukkitPlayerListener.java} (76%) rename core/src/main/java/me/{blackvein/quests/listeners/UniteListener.java => pikamug/quests/listeners/BukkitUniteListener.java} (50%) rename core/src/main/java/me/{blackvein/quests/listeners/ZnpcsListener.java => pikamug/quests/listeners/BukkitZnpcsListener.java} (70%) rename core/src/main/java/me/{blackvein/quests/logging/QuestsLog4JFilter.java => pikamug/quests/logging/BukkitQuestsLog4JFilter.java} (71%) rename core/src/main/java/me/{blackvein/quests/CustomObjective.java => pikamug/quests/module/BukkitCustomObjective.java} (53%) rename api/src/main/java/me/blackvein/quests/CustomReward.java => core/src/main/java/me/pikamug/quests/module/BukkitCustomRequirement.java (58%) rename api/src/main/java/me/blackvein/quests/CustomRequirement.java => core/src/main/java/me/pikamug/quests/module/BukkitCustomReward.java (64%) create mode 100644 core/src/main/java/me/pikamug/quests/nms/BukkitActionBarProvider.java create mode 100644 core/src/main/java/me/pikamug/quests/nms/BukkitActionBarProvider_Modern.java rename core/src/main/java/me/{blackvein/quests/nms/ParticleProvider.java => pikamug/quests/nms/BukkitParticleProvider.java} (75%) create mode 100644 core/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider_Modern.java create mode 100644 core/src/main/java/me/pikamug/quests/nms/BukkitTitleProvider.java create mode 100644 core/src/main/java/me/pikamug/quests/nms/BukkitTitleProvider_Modern.java rename api/src/main/java/me/blackvein/quests/QuestData.java => core/src/main/java/me/pikamug/quests/player/BukkitQuestProgress.java (96%) rename core/src/main/java/me/{blackvein/quests/Quester.java => pikamug/quests/player/BukkitQuester.java} (73%) rename core/src/main/java/me/{blackvein/quests/Quest.java => pikamug/quests/quests/BukkitQuest.java} (78%) create mode 100644 core/src/main/java/me/pikamug/quests/quests/BukkitQuestFactory.java create mode 100644 core/src/main/java/me/pikamug/quests/quests/components/BukkitObjective.java rename core/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/BukkitOptions.java (76%) rename core/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/BukkitPlanner.java (73%) rename core/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/BukkitRequirements.java (83%) rename core/src/main/java/me/{blackvein/quests/quests => pikamug/quests/quests/components}/BukkitRewards.java (85%) rename core/src/main/java/me/{blackvein/quests/Stage.java => pikamug/quests/quests/components/BukkitStage.java} (88%) rename core/src/main/java/me/{blackvein/quests/statistics/Metrics.java => pikamug/quests/statistics/BukkitMetrics.java} (96%) rename core/src/main/java/me/{blackvein/quests/storage/StorageFactory.java => pikamug/quests/storage/BukkitStorageFactory.java} (55%) create mode 100644 core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitActionYamlStorage.java create mode 100644 core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitConditionYamlStorage.java create mode 100644 core/src/main/java/me/pikamug/quests/storage/implementation/file/BukkitQuestYamlStorage.java rename core/src/main/java/me/{blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java => pikamug/quests/storage/implementation/file/BukkitQuesterYamlStorage.java} (62%) create mode 100644 core/src/main/java/me/pikamug/quests/storage/implementation/jar/BukkitModuleJarStorage.java rename core/src/main/java/me/{blackvein/quests/storage/implementation/sql/SqlStorage.java => pikamug/quests/storage/implementation/sql/BukkitQuesterSqlStorage.java} (78%) create mode 100644 core/src/main/java/me/pikamug/quests/tasks/BukkitActionTimer.java rename core/src/main/java/me/{blackvein/quests/tasks/NpcEffectThread.java => pikamug/quests/tasks/BukkitNpcEffectThread.java} (64%) create mode 100644 core/src/main/java/me/pikamug/quests/tasks/BukkitPlayerMoveThread.java create mode 100644 core/src/main/java/me/pikamug/quests/tasks/BukkitStageTimer.java rename core/src/main/java/me/{blackvein/quests/util/ConfigUtil.java => pikamug/quests/util/BukkitConfigUtil.java} (78%) rename core/src/main/java/me/{blackvein/quests/util/FakeConversable.java => pikamug/quests/util/BukkitFakeConversable.java} (76%) rename core/src/main/java/me/{blackvein/quests/util/InventoryUtil.java => pikamug/quests/util/BukkitInventoryUtil.java} (83%) rename core/src/main/java/me/{blackvein/quests/util/ItemUtil.java => pikamug/quests/util/BukkitItemUtil.java} (89%) rename api/src/main/java/me/blackvein/quests/util/Lang.java => core/src/main/java/me/pikamug/quests/util/BukkitLang.java (80%) rename core/src/main/java/me/{blackvein/quests/util/MiscUtil.java => pikamug/quests/util/BukkitMiscUtil.java} (81%) create mode 100644 core/src/main/java/me/pikamug/quests/util/BukkitUpdateChecker.java delete mode 100644 v1_8_R1/src/main/java/me/blackvein/quests/nms/ActionBarProvider_v1_8_R1.java delete mode 100644 v1_8_R1/src/main/java/me/blackvein/quests/nms/ParticleProvider_v1_8_R1.java create mode 100644 v1_8_R1/src/main/java/me/pikamug/quests/nms/BukkitActionBarProvider_v1_8_R1.java create mode 100644 v1_8_R1/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider_v1_8_R1.java rename v1_8_R1/src/main/java/me/{blackvein/quests/nms/TitleProvider_v1_8_R1.java => pikamug/quests/nms/BukkitTitleProvider_v1_8_R1.java} (59%) delete mode 100644 v1_8_R2/src/main/java/me/blackvein/quests/nms/ActionBarProvider_v1_8_R2.java delete mode 100644 v1_8_R2/src/main/java/me/blackvein/quests/nms/ParticleProvider_v1_8_R2.java create mode 100644 v1_8_R2/src/main/java/me/pikamug/quests/nms/BukkitActionBarProvider_v1_8_R2.java create mode 100644 v1_8_R2/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider_v1_8_R2.java rename v1_8_R2/src/main/java/me/{blackvein/quests/nms/TitleProvider_v1_8_R2.java => pikamug/quests/nms/BukkitTitleProvider_v1_8_R2.java} (59%) delete mode 100644 v1_8_R3/src/main/java/me/blackvein/quests/nms/ActionBarProvider_v1_8_R3.java delete mode 100644 v1_8_R3/src/main/java/me/blackvein/quests/nms/ParticleProvider_v1_8_R3.java create mode 100644 v1_8_R3/src/main/java/me/pikamug/quests/nms/BukkitActionBarProvider_v1_8_R3.java create mode 100644 v1_8_R3/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider_v1_8_R3.java rename v1_8_R3/src/main/java/me/{blackvein/quests/nms/TitleProvider_v1_8_R3.java => pikamug/quests/nms/BukkitTitleProvider_v1_8_R3.java} (59%) diff --git a/LICENSE.txt b/LICENSE.txt index a7aa70c11..049ede5bc 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,9 +1,22 @@ -Copyright (c) 2014 PikaMug and contributors. All rights reserved. +MIT License -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) PikaMug +Copyright (c) contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/api/pom.xml b/api/pom.xml index 2e5c2271a..e8629409c 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -4,7 +4,7 @@ 4.0.0 - me.blackvein.quests + me.pikamug.quests quests-parent ${revision} @@ -15,50 +15,10 @@ - - - jitpack.io - https://jitpack.io - spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - citizens-repo - https://repo.citizensnpcs.co/ - - - - enginehub-repo - https://maven.enginehub.org/repo/ - - - - alessiodp-repo - https://repo.alessiodp.com/releases/ - - - - papi-repo - https://repo.extendedclip.com/content/repositories/placeholderapi/ - - - - hc-repo - https://nexus.hc.to/content/repositories/pub_releases/ - - - - repsy-release - https://repo.repsy.io/mvn/niconeko/release - - - - codemc-snapshots - https://repo.codemc.io/repository/maven-snapshots/ - @@ -69,88 +29,32 @@ provided - net.citizensnpcs - citizensapi - 2.0.30-SNAPSHOT - provided + org.jetbrains + annotations + 24.0.1 - com.denizenscript - denizen - 1.2.5-SNAPSHOT - provided + mysql + mysql-connector-java + 8.0.28 + + + com.google.protobuf + protobuf-java + + - net.milkbowl.vault - Vault - 1.7.1 - provided - - - com.github.mcMMO-Dev - mcMMO-Classic - master-82f97cbe04-1 - provided - - - com.herocraftonline.heroes - Heroes - 1.9.26-RELEASE - provided - - - com.sk89q.worldedit - worldedit-bukkit - 7.2.8 - provided - - - com.sk89q.worldguard - worldguard-bukkit - 7.0.5-SNAPSHOT - provided - - - me.clip - placeholderapi - 2.11.2 - provided - - - ro.niconeko - astralbooks-api - 3.0.1 - provided - - - com.github.RednedEpic - PhatLoots - e55d0ba1f6 - provided - - - com.alessiodp.parties - parties-api - 3.2.9 - provided - - - com.github.retrooper.packetevents - spigot - 2.0.0-SNAPSHOT - provided - - - com.github.Pyrbu - ZNPCsPlus - 271b087586 - provided - - - com.github.PikaMug - Unite - 1.1.7 - provided + com.zaxxer + HikariCP + + 4.0.3 + + + slf4j-api + org.slf4j + + @@ -174,6 +78,52 @@ maven-jar-plugin 3.2.0 + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + false + + + + + + + + me.* + com.zaxxer:HikariCP + mysql + + + + + *:* + + META-INF/*.MF + + + + + + com.zaxxer.hikari + me.pikamug.quests.libs.hikari + + + com.mysql + me.pikamug.quests.libs.mysql + + + + diff --git a/api/src/main/java/me/blackvein/quests/QuestsAPI.java b/api/src/main/java/me/blackvein/quests/QuestsAPI.java deleted file mode 100644 index 4399921a9..000000000 --- a/api/src/main/java/me/blackvein/quests/QuestsAPI.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests; - -import me.blackvein.quests.actions.ActionFactory; -import me.blackvein.quests.actions.IAction; -import me.blackvein.quests.conditions.ConditionFactory; -import me.blackvein.quests.conditions.ICondition; -import me.blackvein.quests.config.ISettings; -import me.blackvein.quests.dependencies.IDependencies; -import me.blackvein.quests.module.ICustomObjective; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.QuestFactory; - -import java.io.File; -import java.io.InputStream; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.logging.Logger; - -public interface QuestsAPI { - - boolean isLoading(); - - String getDetectedServerSoftwareVersion(); - - File getPluginDataFolder(); - - Logger getPluginLogger(); - - InputStream getPluginResource(String filename); - - IDependencies getDependencies(); - - ISettings getSettings(); - - List getCustomObjectives(); - - List getCustomRewards(); - - List getCustomRequirements(); - - Collection getLoadedQuests(); - - Collection getLoadedActions(); - - Collection getLoadedConditions(); - - IQuester getQuester(final UUID id); - - Collection getOnlineQuesters(); - - Collection getOfflineQuesters(); - - void setOfflineQuesters(final Collection questers); - - QuestFactory getQuestFactory(); - - ActionFactory getActionFactory(); - - ConditionFactory getConditionFactory(); - - /*ConvoListener getConvoListener(); - - BlockListener getBlockListener(); - - ItemListener getItemListener(); - - NpcListener getNpcListener(); - - PlayerListener getPlayerListener(); - - UniteListener getUniteListener(); - - NpcEffectThread getNpcEffectThread(); - - PlayerMoveThread getPlayerMoveThread(); - - PartiesListener getPartiesListener(); - - DenizenTrigger getDenizenTrigger(); - - LocaleManager getLocaleManager(); - - Storage getStorage();*/ -} diff --git a/api/src/main/java/me/blackvein/quests/actions/ActionFactory.java b/api/src/main/java/me/blackvein/quests/actions/ActionFactory.java deleted file mode 100644 index 8a341c8d2..000000000 --- a/api/src/main/java/me/blackvein/quests/actions/ActionFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.actions; - -import org.bukkit.block.Block; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.Prompt; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public interface ActionFactory { - Map getSelectedExplosionLocations(); - - void setSelectedExplosionLocations(final Map selectedExplosionLocations); - - Map getSelectedEffectLocations(); - - void setSelectedEffectLocations(final Map selectedEffectLocations); - - Map getSelectedMobLocations(); - - void setSelectedMobLocations(final Map selectedMobLocations); - - Map getSelectedLightningLocations(); - - void setSelectedLightningLocations(final Map selectedLightningLocations); - - Map getSelectedTeleportLocations(); - - void setSelectedTeleportLocations(final Map selectedTeleportLocations); - - ConversationFactory getConversationFactory(); - - List getNamesOfActionsBeingEdited(); - - void setNamesOfActionsBeingEdited(final List actionNames); - - Prompt returnToMenu(final ConversationContext context); - - void loadData(final IAction event, final ConversationContext context); - - void clearData(final ConversationContext context); - - void deleteAction(final ConversationContext context); - - void saveAction(final ConversationContext context); -} diff --git a/api/src/main/java/me/blackvein/quests/actions/IAction.java b/api/src/main/java/me/blackvein/quests/actions/IAction.java deleted file mode 100644 index 31f7e3f8f..000000000 --- a/api/src/main/java/me/blackvein/quests/actions/IAction.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.actions; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.entity.QuestMob; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; - -import java.util.LinkedList; -import java.util.Map; - -public interface IAction extends Comparable { - String getName(); - - void setName(final String name); - - String getMessage(); - - void setMessage(final String message); - - boolean isClearInv(); - - void setClearInv(final boolean clearInv); - - boolean isFailQuest(); - - void setFailQuest(final boolean failQuest); - - LinkedList getExplosions(); - - void setExplosions(final LinkedList explosions); - - Map getEffects(); - - void setEffects(final Map effects); - - LinkedList getItems(); - - void setItems(final LinkedList items); - - World getStormWorld(); - - void setStormWorld(final World stormWorld); - - int getStormDuration(); - - void setStormDuration(final int stormDuration); - - World getThunderWorld(); - - void setThunderWorld(final World thunderWorld); - - int getThunderDuration(); - - void setThunderDuration(final int thunderDuration); - - int getTimer(); - - void setTimer(final int timer); - - boolean isCancelTimer(); - - void setCancelTimer(final boolean cancelTimer); - - LinkedList getMobSpawns(); - - void setMobSpawns(final LinkedList mobSpawns); - - LinkedList getLightningStrikes(); - - void setLightningStrikes(final LinkedList lightningStrikes); - - LinkedList getCommands(); - - void setCommands(final LinkedList commands); - - LinkedList getPotionEffects(); - - void setPotionEffects(final LinkedList potionEffects); - - int getHunger(); - - void setHunger(final int hunger); - - int getSaturation(); - - void setSaturation(final int saturation); - - float getHealth(); - - void setHealth(final float health); - - Location getTeleport(); - - void setTeleport(final Location teleport); - - String getBook(); - - void setBook(final String book); - - String getDenizenScript(); - - void setDenizenScript(final String scriptName); - - void fire(final IQuester quester, final IQuest quest); -} diff --git a/api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java b/api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java deleted file mode 100644 index 0bc10493b..000000000 --- a/api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.conditions; - -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.Prompt; - -import java.util.List; - -public interface ConditionFactory { - ConversationFactory getConversationFactory(); - - List getNamesOfConditionsBeingEdited(); - - void setNamesOfConditionsBeingEdited(final List conditionNames); - - Prompt returnToMenu(final ConversationContext context); - - void loadData(final ICondition condition, final ConversationContext context); - - void clearData(final ConversationContext context); - - void deleteCondition(final ConversationContext context); - - void saveCondition(final ConversationContext context); -} diff --git a/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java deleted file mode 100644 index dee281759..000000000 --- a/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.actions; - -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.actions.ActionFactory; -import me.blackvein.quests.convo.QuestsNumericPrompt; -import org.bukkit.ChatColor; -import org.bukkit.conversations.ConversationContext; - -public abstract class ActionsEditorNumericPrompt extends QuestsNumericPrompt { - private final ConversationContext context; - private ActionFactory factory; - - public ActionsEditorNumericPrompt(final ConversationContext context) { - this.context = context; - if (context != null && context.getPlugin() != null) { - this.factory = ((QuestsAPI)context.getPlugin()).getActionFactory(); - } - } - - @Deprecated - public ActionsEditorNumericPrompt(final ConversationContext context, final ActionFactory factory) { - this.context = context; - this.factory = factory; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public ActionFactory getActionFactory() { - return factory; - } - - public abstract int getSize(); - - public abstract String getTitle(ConversationContext context); - - public abstract ChatColor getNumberColor(ConversationContext context, int number); - - public abstract String getSelectionText(ConversationContext context, int number); - - public abstract String getAdditionalText(ConversationContext context, int number); -} diff --git a/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java deleted file mode 100644 index 07d7bac38..000000000 --- a/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.actions; - -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.actions.ActionFactory; -import me.blackvein.quests.convo.QuestsStringPrompt; -import org.bukkit.conversations.ConversationContext; - -public abstract class ActionsEditorStringPrompt extends QuestsStringPrompt { - private final ConversationContext context; - private ActionFactory factory; - - public ActionsEditorStringPrompt(final ConversationContext context) { - this.context = context; - if (context != null && context.getPlugin() != null) { - this.factory = ((QuestsAPI)context.getPlugin()).getActionFactory(); - } - } - - @Deprecated - public ActionsEditorStringPrompt(final ConversationContext context, final ActionFactory factory) { - this.context = context; - this.factory = factory; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public ActionFactory getActionFactory() { - return factory; - } - - public abstract String getTitle(ConversationContext context); - - public abstract String getQueryText(ConversationContext context); -} diff --git a/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java deleted file mode 100644 index bda21db68..000000000 --- a/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.conditions; - -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.conditions.ConditionFactory; -import me.blackvein.quests.convo.QuestsNumericPrompt; -import org.bukkit.ChatColor; -import org.bukkit.conversations.ConversationContext; - -public abstract class ConditionsEditorNumericPrompt extends QuestsNumericPrompt { - private final ConversationContext context; - private ConditionFactory factory; - - public ConditionsEditorNumericPrompt(final ConversationContext context) { - this.context = context; - if (context != null && context.getPlugin() != null) { - this.factory = ((QuestsAPI)context.getPlugin()).getConditionFactory(); - } - } - - @Deprecated - public ConditionsEditorNumericPrompt(final ConversationContext context, final ConditionFactory factory) { - this.context = context; - this.factory = factory; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public ConditionFactory getConditionFactory() { - return factory; - } - - public abstract int getSize(); - - public abstract String getTitle(ConversationContext context); - - public abstract ChatColor getNumberColor(ConversationContext context, int number); - - public abstract String getSelectionText(ConversationContext context, int number); - - public abstract String getAdditionalText(ConversationContext context, int number); -} diff --git a/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java deleted file mode 100644 index 3063da619..000000000 --- a/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.conditions; - -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.conditions.ConditionFactory; -import me.blackvein.quests.convo.QuestsStringPrompt; -import org.bukkit.conversations.ConversationContext; - -public abstract class ConditionsEditorStringPrompt extends QuestsStringPrompt { - private final ConversationContext context; - private ConditionFactory factory; - - public ConditionsEditorStringPrompt(final ConversationContext context) { - this.context = context; - if (context != null && context.getPlugin() != null) { - this.factory = ((QuestsAPI)context.getPlugin()).getConditionFactory(); - } - } - - @Deprecated - public ConditionsEditorStringPrompt(final ConversationContext context, final ConditionFactory factory) { - this.context = context; - this.factory = factory; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public ConditionFactory getConditionFactory() { - return factory; - } - - public abstract String getTitle(ConversationContext context); - - public abstract String getQueryText(ConversationContext context); -} diff --git a/api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java deleted file mode 100644 index b8d6658ac..000000000 --- a/api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.quests; - -import me.blackvein.quests.quests.QuestFactory; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.convo.QuestsNumericPrompt; -import org.bukkit.ChatColor; -import org.bukkit.conversations.ConversationContext; - -public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt { - private final ConversationContext context; - private QuestFactory factory; - - public QuestsEditorNumericPrompt(final ConversationContext context) { - this.context = context; - if (context != null && context.getPlugin() != null) { - factory = ((QuestsAPI)context.getPlugin()).getQuestFactory(); - } - } - - @Deprecated - public QuestsEditorNumericPrompt(final ConversationContext context, final QuestFactory factory) { - this.context = context; - this.factory = factory; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public QuestFactory getQuestFactory() { - return factory; - } - - public abstract int getSize(); - - public abstract String getTitle(ConversationContext context); - - public abstract ChatColor getNumberColor(ConversationContext context, int number); - - public abstract String getSelectionText(ConversationContext context, int number); - - public abstract String getAdditionalText(ConversationContext context, int number); -} diff --git a/api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java deleted file mode 100644 index b0a83b124..000000000 --- a/api/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.quests; - -import me.blackvein.quests.quests.QuestFactory; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.convo.QuestsStringPrompt; -import org.bukkit.conversations.ConversationContext; - -public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt { - private final ConversationContext context; - private QuestFactory factory; - - public QuestsEditorStringPrompt(final ConversationContext context) { - this.context = context; - if (context != null && context.getPlugin() != null) { - factory = ((QuestsAPI)context.getPlugin()).getQuestFactory(); - } - } - - @Deprecated - public QuestsEditorStringPrompt(final ConversationContext context, final QuestFactory factory) { - this.context = context; - this.factory = factory; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public QuestFactory getQuestFactory() { - return factory; - } - - public abstract String getTitle(ConversationContext context); - - public abstract String getQueryText(ConversationContext context); -} diff --git a/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java b/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java deleted file mode 100644 index 594d6d465..000000000 --- a/api/src/main/java/me/blackvein/quests/dependencies/IDependencies.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.dependencies; - -import com.alessiodp.parties.api.interfaces.PartiesAPI; -import com.gmail.nossr50.datatypes.skills.SkillType; -import com.gmail.nossr50.mcMMO; -import com.herocraftonline.heroes.Heroes; -import com.herocraftonline.heroes.characters.Hero; -import lol.pyr.znpcsplus.ZNPCsPlus; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.reflect.denizen.DenizenAPI; -import me.blackvein.quests.reflect.worldguard.WorldGuardAPI; -import me.clip.placeholderapi.PlaceholderAPIPlugin; -import me.pikamug.unite.api.objects.PartyProvider; -import net.citizensnpcs.api.CitizensPlugin; -import net.milkbowl.vault.economy.Economy; -import net.milkbowl.vault.permission.Permission; -import org.bukkit.Location; -import ro.niconeko.astralbooks.api.AstralBooksAPI; - -import java.util.Set; -import java.util.UUID; - -public interface IDependencies { - Economy getVaultEconomy(); - - Permission getVaultPermission(); - - PartyProvider getPartyProvider(); - - Set getPartyProviders(); - - WorldGuardAPI getWorldGuardApi(); - - mcMMO getMcmmoClassic(); - - Heroes getHeroes(); - - PlaceholderAPIPlugin getPlaceholderApi(); - - CitizensPlugin getCitizens(); - - void linkCitizens(); - - void unlinkCitizens(); - - DenizenAPI getDenizenApi(); - - AstralBooksAPI getAstralBooksApi(); - - ZNPCsPlus getZnpcsPlus(); - - void linkZnpcsPlus(); - - void unlinkZnpcsPlus(); - - PartiesAPI getPartiesApi(); - - boolean isPluginAvailable(final String pluginName); - - boolean runDenizenScript(final String scriptName, final IQuester quester, final UUID uuid); - - Location getNpcLocation(final UUID uuid); - - String getNpcName(final UUID uuid); - - int getMcmmoSkillLevel(final SkillType st, final String player); - - Hero getHero(final UUID uuid); - - boolean testPrimaryHeroesClass(final String primaryClass, final UUID uuid); - - boolean testSecondaryHeroesClass(final String secondaryClass, final UUID uuid); - - void init(); -} diff --git a/api/src/main/java/me/blackvein/quests/entity/QuestMob.java b/api/src/main/java/me/blackvein/quests/entity/QuestMob.java deleted file mode 100644 index 079bbc7f9..000000000 --- a/api/src/main/java/me/blackvein/quests/entity/QuestMob.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.entity; - -import org.bukkit.Location; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -public interface QuestMob { - String getName(); - - void setName(final String name); - - EntityType getType(); - - void setType(final EntityType entityType); - - Location getSpawnLocation(); - - void setSpawnLocation(final Location spawnLocation); - - Integer getSpawnAmounts(); - - void setSpawnAmounts(final int spawnAmounts); - - ItemStack[] getInventory(); - - void setInventory(final ItemStack[] inventory); - - Float[] getDropChances(); - - void setDropChances(final Float[] dropChances); - - void setHelmet(final ItemStack helmet, final float dropChance); - - void setChest(final ItemStack chest, final float dropChance); - - void setLeggings(final ItemStack leggings, final float dropChance); - - void setBoots(final ItemStack boots, final float dropChance); - - void setHeldItem(final ItemStack heldItem, final float dropChance); - - void spawn(); - - String serialize(); -} diff --git a/api/src/main/java/me/blackvein/quests/events/QuestsEvent.java b/api/src/main/java/me/blackvein/quests/events/QuestsEvent.java deleted file mode 100644 index f3f21f071..000000000 --- a/api/src/main/java/me/blackvein/quests/events/QuestsEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events; - -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -public abstract class QuestsEvent extends Event { - private static final HandlerList HANDLERS = new HandlerList(); - - public QuestsEvent() { - } - - public QuestsEvent(final boolean async) { - super(async); - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/api/src/main/java/me/blackvein/quests/events/quest/QuestEvent.java b/api/src/main/java/me/blackvein/quests/events/quest/QuestEvent.java deleted file mode 100644 index 24a7fddf0..000000000 --- a/api/src/main/java/me/blackvein/quests/events/quest/QuestEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quest; - -import org.bukkit.event.HandlerList; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.events.QuestsEvent; -import org.jetbrains.annotations.NotNull; - -/** - * Represents a quest-related event - */ -public abstract class QuestEvent extends QuestsEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - - public QuestEvent(final IQuest quest) { - this.quest = quest; - } - - public QuestEvent(final IQuest quest, final boolean async) { - super(async); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public final IQuest getQuest() { - return quest; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/api/src/main/java/me/blackvein/quests/events/quest/QuestQuitEvent.java b/api/src/main/java/me/blackvein/quests/events/quest/QuestQuitEvent.java deleted file mode 100644 index 91ee14edb..000000000 --- a/api/src/main/java/me/blackvein/quests/events/quest/QuestQuitEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quest; - -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; -import org.jetbrains.annotations.NotNull; - -/** - * Called when a quest is quit by a quester - */ -public class QuestQuitEvent extends QuestEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuester quester; - private boolean cancel = false; - - public QuestQuitEvent(final IQuest quest, final IQuester who) { - super(quest); - this.quester = who; - } - - /** - * Returns the quester involved in this event - * - * @return Quester who is involved in this event - */ - public IQuester getQuester() { - return quester; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/api/src/main/java/me/blackvein/quests/events/quest/QuestTakeEvent.java b/api/src/main/java/me/blackvein/quests/events/quest/QuestTakeEvent.java deleted file mode 100644 index 28590208c..000000000 --- a/api/src/main/java/me/blackvein/quests/events/quest/QuestTakeEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quest; - -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; -import org.jetbrains.annotations.NotNull; - -/** - * Called when a quest is taken by a quester - */ -public class QuestTakeEvent extends QuestEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuester quester; - private boolean cancel = false; - - public QuestTakeEvent(final IQuest quest, final IQuester who) { - super(quest); - this.quester = who; - } - - /** - * Returns the quester involved in this event - * - * @return Quester who is involved in this event - */ - public IQuester getQuester() { - return quester; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/api/src/main/java/me/blackvein/quests/player/IQuester.java b/api/src/main/java/me/blackvein/quests/player/IQuester.java deleted file mode 100644 index 731d2da31..000000000 --- a/api/src/main/java/me/blackvein/quests/player/IQuester.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.player; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.IStage; -import me.blackvein.quests.quests.Objective; -import me.blackvein.quests.QuestData; -import me.blackvein.quests.enums.ObjectiveType; -import me.blackvein.quests.module.ICustomObjective; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentSkipListSet; -import java.util.function.BiFunction; -import java.util.function.Function; - -public interface IQuester extends Comparable { - UUID getUUID(); - - void setUUID(final UUID id); - - String getQuestIdToTake(); - - void setQuestIdToTake(final String questIdToTake); - - String getQuestIdToQuit(); - - void setQuestIdToQuit(final String questIdToQuit); - - String getLastKnownName(); - - void setLastKnownName(final String lastKnownName); - - int getQuestPoints(); - - void setQuestPoints(final int questPoints); - - /** - * Get compass target quest. Returns null if not set - * - * @return Quest or null - * @deprecated Do not use - */ - IQuest getCompassTargetTemp(); - - /** - * Set compass target quest. Does not update in-game - * - * @param quest The target quest - */ - void setCompassTarget(final IQuest quest); - - ConcurrentHashMap getTimers(); - - void setTimers(final ConcurrentHashMap timers); - - void removeTimer(final Integer timerId); - - /** - * @deprecated Do not use - */ - ConcurrentHashMap getCurrentQuestsTemp(); - - void setCurrentQuests(final ConcurrentHashMap currentQuests); - - /** - * @deprecated Do not use - */ - ConcurrentSkipListSet getCompletedQuestsTemp(); - - void setCompletedQuests(final ConcurrentSkipListSet completedQuests); - - ConcurrentHashMap getCompletedTimes(); - - void setCompletedTimes(final ConcurrentHashMap completedTimes); - - ConcurrentHashMap getAmountsCompleted(); - - void setAmountsCompleted(final ConcurrentHashMap amountsCompleted); - - ConcurrentHashMap getQuestData(); - - void setQuestData(final ConcurrentHashMap questData); - - Player getPlayer(); - - OfflinePlayer getOfflinePlayer(); - - void sendMessage(final String message); - - IStage getCurrentStage(final IQuest quest); - - QuestData getQuestData(final IQuest quest); - - boolean hasJournal(); - - ItemStack getJournal(); - - int getJournalIndex(); - - void updateJournal(); - - boolean offerQuest(final IQuest quest, final boolean giveReason); - - boolean canAcceptOffer(final IQuest quest, final boolean giveReason); - - boolean isOnTime(final IQuest quest, final boolean giveReason); - - void takeQuest(final IQuest quest, final boolean ignoreRequirements); - - boolean abandonQuest(final IQuest quest, final String message); - - boolean abandonQuest(final IQuest quest, final String[] messages); - - void quitQuest(final IQuest quest, final String message); - - void quitQuest(final IQuest quest, final String[] messages); - - void listQuests(final IQuester quester, final int page); - - LinkedList getCurrentRequirements(final IQuest quest, final boolean ignoreOverrides); - - LinkedList getCurrentObjectives(final IQuest quest, final boolean ignoreOverrides); - - void showCurrentObjectives(final IQuest quest, final IQuester quester, final boolean ignoreOverrides); - - LinkedList getObjectives(final IQuest quest, final boolean ignoreOverrides); - - boolean containsObjective(final IQuest quest, final String name); - - boolean hasObjective(final IQuest quest, final ObjectiveType type); - - boolean hasCustomObjective(final IQuest quest, final String name); - - void showCurrentConditions(final IQuest quest, final IQuester quester); - - void breakBlock(final IQuest quest, final ItemStack itemStack); - - void damageBlock(final IQuest quest, final ItemStack itemStack); - - void placeBlock(final IQuest quest, final ItemStack itemStack); - - void useBlock(final IQuest quest, final ItemStack itemStack); - - void cutBlock(final IQuest quest, final ItemStack itemStack); - - void craftItem(final IQuest quest, final ItemStack itemStack); - - void smeltItem(final IQuest quest, final ItemStack itemStack); - - void enchantBook(final IQuest quest, final ItemStack itemStack, final Map enchantsToAdd); - - void enchantItem(final IQuest quest, final ItemStack itemStack); - - void brewItem(final IQuest quest, final ItemStack itemStack); - - void consumeItem(final IQuest quest, final ItemStack itemStack); - - void deliverToNPC(final IQuest quest, final UUID npc, final ItemStack itemStack); - - void interactWithNPC(final IQuest quest, final UUID npc); - - void killNPC(final IQuest quest, final UUID npc); - - void milkCow(final IQuest quest); - - void catchFish(final IQuest quest); - - void killMob(final IQuest quest, final Location killedLocation, final EntityType entityType); - - void killPlayer(final IQuest quest, final Player player); - - void reachLocation(final IQuest quest, final Location location); - - void tameMob(final IQuest quest, final EntityType entityType); - - void shearSheep(final IQuest quest, final DyeColor color); - - void sayPassword(final IQuest quest, final AsyncPlayerChatEvent evt); - - void finishObjective(final IQuest quest, final Objective objective, final EntityType mob, - final String extra, final UUID npc, final Location location, final DyeColor color, - final String pass, final ICustomObjective co); - - boolean testComplete(final IQuest quest); - - void addEmptiesFor(final IQuest quest, final int stage); - - boolean saveData(); - - long getCompletionDifference(final IQuest quest); - - long getRemainingCooldown(final IQuest quest); - - FileConfiguration getBaseData(); - - boolean hasData(); - - boolean hasBaseData(); - - void startStageTimer(final IQuest quest); - - void stopStageTimer(final IQuest quest); - - long getStageTime(final IQuest quest); - - void checkQuest(final IQuest quest); - - void showGUIDisplay(final UUID npc, final LinkedList quests); - - void hardQuit(final IQuest quest); - - void hardRemove(final IQuest quest); - - void hardClear(); - - void hardStagePut(final IQuest key, final Integer val); - - void hardDataPut(final IQuest key, final QuestData val); - - boolean canUseCompass(); - - void resetCompass(); - - void findCompassTarget(); - - void findNextCompassTarget(final boolean notify); - - boolean hasItem(final ItemStack is); - - Set dispatchMultiplayerEverything(final IQuest quest, final ObjectiveType type, - final BiFunction fun); - - Set dispatchMultiplayerObjectives(final IQuest quest, final IStage currentStage, - final Function fun); - - List getMultiplayerQuesters(final IQuest quest); - - boolean meetsCondition(final IQuest quest, final boolean giveReason); - - boolean isSelectingBlock(); - - boolean isInRegion(final String regionID); -} diff --git a/api/src/main/java/me/blackvein/quests/quests/IQuest.java b/api/src/main/java/me/blackvein/quests/quests/IQuest.java deleted file mode 100644 index 24219549f..000000000 --- a/api/src/main/java/me/blackvein/quests/quests/IQuest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -import me.blackvein.quests.actions.IAction; -import me.blackvein.quests.player.IQuester; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; - -import java.util.LinkedList; -import java.util.UUID; - -public interface IQuest extends Comparable { - Plugin getPlugin(); - - void setPlugin(Plugin plugin); - - String getId(); - - void setId(String id); - - String getName(); - - void setName(final String name); - - String getDescription(); - - void setDescription(final String description); - - String getFinished(); - - void setFinished(final String finished); - - String getRegionStart(); - - void setRegionStart(final String regionStart); - - ItemStack getGUIDisplay(); - - void setGUIDisplay(final ItemStack guiDisplay); - - IStage getStage(final int index); - - LinkedList getStages(); - - UUID getNpcStart(); - - void setNpcStart(final UUID npcStart); - - String getNpcStartName(); - - Location getBlockStart(); - - void setBlockStart(final Location blockStart); - - IAction getInitialAction(); - - void setInitialAction(final IAction initialAction); - - Requirements getRequirements(); - - Planner getPlanner(); - - Rewards getRewards(); - - Options getOptions(); - - void nextStage(final IQuester quester, final boolean allowSharedProgress); - - void setStage(final IQuester quester, final int stage); - - boolean updateCompass(final IQuester quester, final IStage stage); - - boolean testRequirements(final IQuester quester); - - boolean testRequirements(final OfflinePlayer player); - - void completeQuest(final IQuester quester); - - void completeQuest(final IQuester quester, final boolean allowMultiplayer); - - void failQuest(final IQuester quester); - - void failQuest(final IQuester quester, final boolean ignoreFailAction); - - boolean isInRegion(final IQuester quester); - - boolean isInRegionStart(final IQuester quester); -} diff --git a/api/src/main/java/me/blackvein/quests/quests/IStage.java b/api/src/main/java/me/blackvein/quests/quests/IStage.java deleted file mode 100644 index f17e858a9..000000000 --- a/api/src/main/java/me/blackvein/quests/quests/IStage.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -import me.blackvein.quests.actions.IAction; -import me.blackvein.quests.conditions.ICondition; -import me.blackvein.quests.enums.ObjectiveType; -import me.blackvein.quests.module.ICustomObjective; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -import java.util.LinkedList; -import java.util.Map; -import java.util.UUID; - -public interface IStage { - LinkedList getBlocksToBreak(); - - boolean addBlockToBreak(ItemStack blockToBreak); - - void setBlocksToBreak(final LinkedList blocksToBreak); - - LinkedList getBlocksToDamage(); - - boolean addBlockToDamage(ItemStack blockToDamage); - - void setBlocksToDamage(final LinkedList blocksToDamage); - - LinkedList getBlocksToPlace(); - - boolean addBlockToPlace(ItemStack blockToPlace); - - void setBlocksToPlace(final LinkedList blocksToPlace); - - LinkedList getBlocksToUse(); - - boolean addBlockToUse(ItemStack blockToUse); - - void setBlocksToUse(final LinkedList blocksToUse); - - LinkedList getBlocksToCut(); - - boolean addBlockToCut(ItemStack blockToCut); - - void setBlocksToCut(final LinkedList blocksToCut); - - LinkedList getItemsToCraft(); - - boolean addItemToCraft(ItemStack itemToCraft); - - void setItemsToCraft(final LinkedList itemsToCraft); - - LinkedList getItemsToSmelt(); - - boolean addItemToSmelt(ItemStack itemToSmelt); - - void setItemsToSmelt(final LinkedList itemsToSmelt); - - LinkedList getItemsToEnchant(); - - boolean addItemToEnchant(ItemStack itemToEnchant); - - void setItemsToEnchant(final LinkedList itemsToEnchant); - - LinkedList getItemsToBrew(); - - boolean addItemsToBrew(ItemStack itemToBrew); - - void setItemsToBrew(final LinkedList itemsToBrew); - - LinkedList getItemsToConsume(); - - boolean addItemToConsume(ItemStack itemToConsume); - - void setItemsToConsume(final LinkedList itemsToConsume); - - LinkedList getItemsToDeliver(); - - boolean addItemToDeliver(ItemStack itemToDeliver); - - void setItemsToDeliver(final LinkedList itemsToDeliver); - - LinkedList getItemDeliveryTargets(); - - boolean addItemDeliveryTarget(UUID itemDeliveryTarget); - - void setItemDeliveryTargets(final LinkedList itemDeliveryTargets); - - LinkedList getDeliverMessages(); - - boolean addDeliverMessage(String deliverMessage); - - void setDeliverMessages(final LinkedList deliverMessages); - - LinkedList getNpcsToInteract(); - - boolean addNpcToInteract(UUID npcToInteract); - - void setNpcsToInteract(final LinkedList npcsToInteract); - - LinkedList getNpcsToKill(); - - boolean addNpcToKill(UUID citizenToKill); - - void setNpcsToKill(final LinkedList npcsToKill); - - LinkedList getNpcNumToKill(); - - boolean addNpcNumToKill(Integer npcNumToKill); - - void setNpcNumToKill(final LinkedList npcNumToKill); - - LinkedList getMobsToKill(); - - boolean addMobToKill(EntityType mobToKill); - - void setMobsToKill(final LinkedList mobsToKill); - - LinkedList getMobNumToKill(); - - boolean addMobNumToKill(Integer mobNumToKill); - - void setMobNumToKill(final LinkedList mobNumToKill); - - LinkedList getLocationsToKillWithin(); - - boolean addLocationToKillWithin(Location locationToKillWithin); - - void setLocationsToKillWithin(final LinkedList locationsToKillWithin); - - LinkedList getRadiiToKillWithin(); - - boolean addRadiusToKillWithin(Integer radiusToKillWithin); - - void setRadiiToKillWithin(final LinkedList radiiToKillWithin); - - LinkedList getKillNames(); - - boolean addKillName(String killName); - - void setKillNames(final LinkedList killNames); - - LinkedList getLocationsToReach(); - - boolean addLocationToReach(Location locationToReach); - - void setLocationsToReach(final LinkedList locationsToReach); - - LinkedList getRadiiToReachWithin(); - - boolean addRadiusToReachWithin(Integer radiusToReachWithin); - - void setRadiiToReachWithin(final LinkedList radiiToReachWithin); - - LinkedList getWorldsToReachWithin(); - - boolean addWorldToReachWithin(World worldToReachWithin); - - void setWorldsToReachWithin(final LinkedList worldsToReachWithin); - - LinkedList getLocationNames(); - - boolean addLocationName(String locationName); - - void setLocationNames(final LinkedList locationNames); - - LinkedList getMobsToTame(); - - boolean addMobToTame(EntityType mobToTame); - - void setMobsToTame(final LinkedList mobsToTame); - - LinkedList getMobNumToTame(); - - boolean addMobNumToTame(Integer mobNumToTame); - - void setMobNumToTame(final LinkedList mobNumToTame); - - Integer getFishToCatch(); - - void setFishToCatch(final Integer fishToCatch); - - Integer getCowsToMilk(); - - void setCowsToMilk(final Integer cowsToMilk); - - Integer getPlayersToKill(); - - void setPlayersToKill(final Integer playersToKill); - - LinkedList getSheepToShear(); - - boolean addSheepToShear(DyeColor sheepToShear); - - void setSheepToShear(final LinkedList sheepToShear); - - LinkedList getSheepNumToShear(); - - boolean addSheepNumToShear(Integer sheepNumToShear); - - void setSheepNumToShear(final LinkedList sheepNumToShear); - - LinkedList getPasswordDisplays(); - - boolean addPasswordDisplay(String passwordDisplay); - - void setPasswordDisplays(final LinkedList passwordDisplays); - - LinkedList getPasswordPhrases(); - - boolean addPasswordPhrase(String passwordPhrase); - - void setPasswordPhrases(final LinkedList passwordPhrases); - - String getScript(); - - void setScript(final String script); - - IAction getStartAction(); - - void setStartAction(final IAction startAction); - - IAction getFinishAction(); - - void setFinishAction(final IAction finishAction); - - IAction getFailAction(); - - void setFailAction(final IAction failAction); - - IAction getDeathAction(); - - void setDeathAction(final IAction deathAction); - - Map getChatActions(); - - void addChatAction(Map.Entry chatAction); - - void setChatActions(final Map chatActions); - - Map getCommandActions(); - - void addCommandAction(Map.Entry commandAction); - - void setCommandActions(final Map commandActions); - - IAction getDisconnectAction(); - - void setDisconnectAction(final IAction disconnectAction); - - ICondition getCondition(); - - void setCondition(final ICondition condition); - - long getDelay(); - - void setDelay(final long delay); - - String getDelayMessage(); - - void setDelayMessage(final String delayMessage); - - String getCompleteMessage(); - - void setCompleteMessage(final String completeMessage); - - String getStartMessage(); - - void setStartMessage(final String startMessage); - - LinkedList getObjectiveOverrides(); - - boolean addObjectiveOverride(String objectiveOverride); - - void setObjectiveOverrides(final LinkedList objectiveOverrides); - - LinkedList getCustomObjectives(); - - boolean addCustomObjectives(final ICustomObjective customObjective); - - void clearCustomObjectives(); - - LinkedList getCustomObjectiveCounts(); - - boolean addCustomObjectiveCounts(final Integer customObjectiveCount); - - void clearCustomObjectiveCounts(); - - LinkedList getCustomObjectiveDisplays(); - - void clearCustomObjectiveDisplays(); - - LinkedList> getCustomObjectiveData(); - - boolean addCustomObjectiveData(final Map.Entry customObjectiveDatum); - - void clearCustomObjectiveData(); - - /** - * Check if stage has at least one objective

- * - * Excludes start/complete message, delay, and objective-override - * - * @return true if stage contains an objective - */ - boolean hasObjective(); - - /** - * Check if stage has at least one objective of which the target can be located easily

- * - * @return true if stage contains a locatable objective - */ - boolean hasLocatableObjective(); - - /** - * Check if stage has the specified type of objective

- * - * @param type The type of objective to check for - * @return true if stage contains specified objective - */ - boolean containsObjective(final ObjectiveType type); -} diff --git a/api/src/main/java/me/blackvein/quests/quests/Objective.java b/api/src/main/java/me/blackvein/quests/quests/Objective.java deleted file mode 100644 index e5001b9ae..000000000 --- a/api/src/main/java/me/blackvein/quests/quests/Objective.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -import me.blackvein.quests.enums.ObjectiveType; -import org.jetbrains.annotations.NotNull; - -public interface Objective { - ObjectiveType getType(); - - String getMessage(); - - int getProgress(); - - int getGoal(); - - @NotNull Object getProgressObject(); - - @NotNull Object getGoalObject(); -} diff --git a/api/src/main/java/me/blackvein/quests/quests/Planner.java b/api/src/main/java/me/blackvein/quests/quests/Planner.java deleted file mode 100644 index fe18ed622..000000000 --- a/api/src/main/java/me/blackvein/quests/quests/Planner.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -public interface Planner { - String getStart(); - - long getStartInMillis(); - - boolean hasStart(); - - void setStart(final String start); - - String getEnd(); - - long getEndInMillis(); - - boolean hasEnd(); - - void setEnd(final String end); - - long getRepeat(); - - boolean hasRepeat(); - - void setRepeat(final long repeat); - - long getCooldown(); - - boolean hasCooldown(); - - void setCooldown(final long cooldown); - - boolean getOverride(); - - void setOverride(final boolean override); -} diff --git a/api/src/main/java/me/blackvein/quests/quests/QuestFactory.java b/api/src/main/java/me/blackvein/quests/quests/QuestFactory.java deleted file mode 100644 index 234767f22..000000000 --- a/api/src/main/java/me/blackvein/quests/quests/QuestFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -import org.bukkit.block.Block; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.Prompt; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -public interface QuestFactory { - Map getSelectedBlockStarts(); - - void setSelectedBlockStarts(final Map selectedBlockStarts); - - Map getSelectedKillLocations(); - - void setSelectedKillLocations(final Map selectedKillLocations); - - Map getSelectedReachLocations(); - - void setSelectedReachLocations(final Map selectedReachLocations); - - Set getSelectingNpcs(); - - void setSelectingNpcs(final Set selectingNpcs); - - List getNamesOfQuestsBeingEdited(); - - void setNamesOfQuestsBeingEdited(final List questNames); - - ConversationFactory getConversationFactory(); - - Prompt returnToMenu(final ConversationContext context); - - void loadQuest(final ConversationContext context, final IQuest q); - - void deleteQuest(final ConversationContext context); - - void saveQuest(final ConversationContext context, final ConfigurationSection section); - - /*void saveRequirements(final ConversationContext context, final ConfigurationSection section); - - void saveStages(final ConversationContext context, final ConfigurationSection section); - - void saveRewards(final ConversationContext context, final ConfigurationSection section); - - void savePlanner(final ConversationContext context, final ConfigurationSection section); - - void saveOptions(final ConversationContext context, final ConfigurationSection section);*/ -} diff --git a/api/src/main/java/me/pikamug/quests/Quests.java b/api/src/main/java/me/pikamug/quests/Quests.java new file mode 100644 index 000000000..67332d4b9 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/Quests.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests; + +import me.pikamug.quests.actions.Action; +import me.pikamug.quests.actions.ActionFactory; +import me.pikamug.quests.conditions.Condition; +import me.pikamug.quests.conditions.ConditionFactory; +import me.pikamug.quests.config.ConfigSettings; +import me.pikamug.quests.dependencies.Dependencies; +import me.pikamug.quests.module.CustomObjective; +import me.pikamug.quests.module.CustomRequirement; +import me.pikamug.quests.module.CustomReward; +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.Quest; +import me.pikamug.quests.quests.QuestFactory; + +import java.io.File; +import java.io.InputStream; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.logging.Logger; + +public interface Quests { + + boolean isLoading(); + + String getDetectedServerSoftwareVersion(); + + File getPluginDataFolder(); + + Logger getPluginLogger(); + + InputStream getPluginResource(String filename); + + Dependencies getDependencies(); + + ConfigSettings getConfigSettings(); + + List getCustomObjectives(); + + List getCustomRewards(); + + List getCustomRequirements(); + + Collection getLoadedQuests(); + + Collection getLoadedActions(); + + Collection getLoadedConditions(); + + Quester getQuester(final UUID id); + + Collection getOnlineQuesters(); + + Collection getOfflineQuesters(); + + void setOfflineQuesters(final Collection questers); + + QuestFactory getQuestFactory(); + + ActionFactory getActionFactory(); + + ConditionFactory getConditionFactory(); + + /*ConvoListener getConvoListener(); + + BlockListener getBlockListener(); + + ItemListener getItemListener(); + + NpcListener getNpcListener(); + + PlayerListener getPlayerListener(); + + UniteListener getUniteListener(); + + NpcEffectThread getNpcEffectThread(); + + PlayerMoveThread getPlayerMoveThread(); + + PartiesListener getPartiesListener(); + + DenizenTrigger getDenizenTrigger(); + + LocaleManager getLocaleManager(); + + QuesterStorage getStorage();*/ + + void saveResourceAs(String resourcePath, final String outputPath, final boolean replace); +} diff --git a/api/src/main/java/me/pikamug/quests/actions/Action.java b/api/src/main/java/me/pikamug/quests/actions/Action.java new file mode 100644 index 000000000..beb8fb856 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/actions/Action.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.actions; + +import me.pikamug.quests.entity.QuestMob; +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.Quest; + +import java.util.LinkedList; + +public interface Action extends Comparable { + String getName(); + + void setName(final String name); + + String getMessage(); + + void setMessage(final String message); + + boolean isClearInv(); + + void setClearInv(final boolean clearInv); + + boolean isFailQuest(); + + void setFailQuest(final boolean failQuest); + + int getStormDuration(); + + void setStormDuration(final int stormDuration); + + int getThunderDuration(); + + void setThunderDuration(final int thunderDuration); + + int getTimer(); + + void setTimer(final int timer); + + boolean isCancelTimer(); + + void setCancelTimer(final boolean cancelTimer); + + LinkedList getMobSpawns(); + + void setMobSpawns(final LinkedList mobSpawns); + + LinkedList getCommands(); + + void setCommands(final LinkedList commands); + + int getHunger(); + + void setHunger(final int hunger); + + int getSaturation(); + + void setSaturation(final int saturation); + + float getHealth(); + + void setHealth(final float health); + + String getBook(); + + void setBook(final String book); + + String getDenizenScript(); + + void setDenizenScript(final String scriptName); + + void fire(final Quester quester, final Quest quest); +} diff --git a/api/src/main/java/me/pikamug/quests/actions/ActionFactory.java b/api/src/main/java/me/pikamug/quests/actions/ActionFactory.java new file mode 100644 index 000000000..b260908a4 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/actions/ActionFactory.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.actions; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; + +import java.util.List; + +public interface ActionFactory { + + ConversationFactory getConversationFactory(); + + List getNamesOfActionsBeingEdited(); + + void setNamesOfActionsBeingEdited(final List actionNames); + + Prompt returnToMenu(final ConversationContext context); + + void loadData(final ConversationContext context, final Action action); + + void clearData(final ConversationContext context); + + void deleteAction(final ConversationContext context); + + void saveAction(final ConversationContext context); +} diff --git a/api/src/main/java/me/blackvein/quests/conditions/ICondition.java b/api/src/main/java/me/pikamug/quests/conditions/Condition.java similarity index 52% rename from api/src/main/java/me/blackvein/quests/conditions/ICondition.java rename to api/src/main/java/me/pikamug/quests/conditions/Condition.java index 5f9491962..d665e1f3b 100644 --- a/api/src/main/java/me/blackvein/quests/conditions/ICondition.java +++ b/api/src/main/java/me/pikamug/quests/conditions/Condition.java @@ -1,25 +1,22 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.conditions; +package me.pikamug.quests.conditions; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.inventory.ItemStack; +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.Quest; import java.util.LinkedList; import java.util.UUID; -public interface ICondition extends Comparable { +public interface Condition extends Comparable { String getName(); void setName(final String name); @@ -40,14 +37,6 @@ public interface ICondition extends Comparable { void setPermissions(final LinkedList permissions); - LinkedList getItemsWhileHoldingMainHand(); - - void setItemsWhileHoldingMainHand(final LinkedList itemsWhileHoldingMainHand); - - LinkedList getItemsWhileWearing(); - - void setItemsWhileWearing(final LinkedList itemsWhileWearing); - LinkedList getWorldsWhileStayingWithin(); void setWorldsWhileStayingWithin(final LinkedList worldsWhileStayingWithin); @@ -76,5 +65,5 @@ public interface ICondition extends Comparable { void setPlaceholdersCheckValue(final LinkedList placeholdersCheckValue); - boolean check(final IQuester quester, final IQuest quest); + boolean check(final Quester quester, final Quest quest); } diff --git a/api/src/main/java/me/pikamug/quests/conditions/ConditionFactory.java b/api/src/main/java/me/pikamug/quests/conditions/ConditionFactory.java new file mode 100644 index 000000000..03fad34f8 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/conditions/ConditionFactory.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.conditions; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; + +import java.util.List; + +public interface ConditionFactory { + ConversationFactory getConversationFactory(); + + List getNamesOfConditionsBeingEdited(); + + void setNamesOfConditionsBeingEdited(final List conditionNames); + + Prompt returnToMenu(final ConversationContext context); + + void loadData(final ConversationContext context, final Condition condition); + + void clearData(final ConversationContext context); + + void deleteCondition(final ConversationContext context); + + void saveCondition(final ConversationContext context); +} diff --git a/api/src/main/java/me/blackvein/quests/config/ISettings.java b/api/src/main/java/me/pikamug/quests/config/ConfigSettings.java similarity index 75% rename from api/src/main/java/me/blackvein/quests/config/ISettings.java rename to api/src/main/java/me/pikamug/quests/config/ConfigSettings.java index 4994bff93..a05f18494 100644 --- a/api/src/main/java/me/blackvein/quests/config/ISettings.java +++ b/api/src/main/java/me/pikamug/quests/config/ConfigSettings.java @@ -1,18 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.config; +package me.pikamug.quests.config; -public interface ISettings { +public interface ConfigSettings { int getAcceptTimeout(); void setAcceptTimeout(final int acceptTimeout); boolean canAllowCommands(); diff --git a/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java b/api/src/main/java/me/pikamug/quests/convo/QuestsNumericPrompt.java similarity index 72% rename from api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java rename to api/src/main/java/me/pikamug/quests/convo/QuestsNumericPrompt.java index 18ec112a5..f7648a230 100644 --- a/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java +++ b/api/src/main/java/me/pikamug/quests/convo/QuestsNumericPrompt.java @@ -1,19 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.convo; +package me.pikamug.quests.convo; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.util.Lang; +import me.pikamug.quests.Quests; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.ChatColor; @@ -64,9 +61,9 @@ public abstract class QuestsNumericPrompt extends NumericPrompt { */ public static String sendClickableSelection(final String input, final ConversationContext context) { if (context.getPlugin() == null) { - return Lang.get("itemCreateCriticalError"); + return "ERROR"; } - if (!(context.getForWhom() instanceof Player) || !((QuestsAPI)context.getPlugin()).getSettings().canClickablePrompts()) { + if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getConfigSettings().canClickablePrompts()) { return input; } final String[] basicText = input.split("\n"); diff --git a/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java b/api/src/main/java/me/pikamug/quests/convo/QuestsStringPrompt.java similarity index 72% rename from api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java rename to api/src/main/java/me/pikamug/quests/convo/QuestsStringPrompt.java index d1bf64d3d..56f8234b5 100644 --- a/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java +++ b/api/src/main/java/me/pikamug/quests/convo/QuestsStringPrompt.java @@ -1,19 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.convo; +package me.pikamug.quests.convo; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.util.Lang; +import me.pikamug.quests.Quests; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.TextComponent; @@ -57,9 +54,9 @@ public abstract class QuestsStringPrompt extends StringPrompt { protected String sendClickableMenu(final String header, final List list, final String footer, final ConversationContext context) { if (context.getPlugin() == null) { - return Lang.get("itemCreateCriticalError"); + return "ERROR"; } - if (!(context.getForWhom() instanceof Player) || !((QuestsAPI)context.getPlugin()).getSettings().canClickablePrompts()) { + if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getConfigSettings().canClickablePrompts()) { return ChatColor.GOLD + header + "\n" + ChatColor.AQUA + String.join(ChatColor.GRAY + ", " + ChatColor.AQUA, list) + "\n" + ChatColor.YELLOW + footer; } final TextComponent component = new TextComponent(header + "\n"); diff --git a/api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorNumericPrompt.java b/api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorNumericPrompt.java new file mode 100644 index 000000000..aea3fd993 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorNumericPrompt.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.convo.actions; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.actions.ActionFactory; +import me.pikamug.quests.convo.QuestsNumericPrompt; +import org.bukkit.ChatColor; +import org.bukkit.conversations.ConversationContext; + +public abstract class ActionsEditorNumericPrompt extends QuestsNumericPrompt { + private final ConversationContext context; + private ActionFactory factory; + + public ActionsEditorNumericPrompt(final ConversationContext context) { + this.context = context; + if (context != null && context.getPlugin() != null) { + this.factory = ((Quests)context.getPlugin()).getActionFactory(); + } + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + public ConversationContext getConversationContext() { + return context; + } + + public ActionFactory getActionFactory() { + return factory; + } + + public abstract int getSize(); + + public abstract String getTitle(ConversationContext context); + + public abstract ChatColor getNumberColor(ConversationContext context, int number); + + public abstract String getSelectionText(ConversationContext context, int number); + + public abstract String getAdditionalText(ConversationContext context, int number); +} diff --git a/api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorStringPrompt.java b/api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorStringPrompt.java new file mode 100644 index 000000000..578ff2f52 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/convo/actions/ActionsEditorStringPrompt.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.convo.actions; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.actions.ActionFactory; +import me.pikamug.quests.convo.QuestsStringPrompt; +import org.bukkit.conversations.ConversationContext; + +public abstract class ActionsEditorStringPrompt extends QuestsStringPrompt { + private final ConversationContext context; + private ActionFactory factory; + + public ActionsEditorStringPrompt(final ConversationContext context) { + this.context = context; + if (context != null && context.getPlugin() != null) { + this.factory = ((Quests)context.getPlugin()).getActionFactory(); + } + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + public ConversationContext getConversationContext() { + return context; + } + + public ActionFactory getActionFactory() { + return factory; + } + + public abstract String getTitle(ConversationContext context); + + public abstract String getQueryText(ConversationContext context); +} diff --git a/api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorNumericPrompt.java b/api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorNumericPrompt.java new file mode 100644 index 000000000..999b37245 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorNumericPrompt.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.convo.conditions; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.conditions.ConditionFactory; +import me.pikamug.quests.convo.QuestsNumericPrompt; +import org.bukkit.ChatColor; +import org.bukkit.conversations.ConversationContext; + +public abstract class ConditionsEditorNumericPrompt extends QuestsNumericPrompt { + private final ConversationContext context; + private ConditionFactory factory; + + public ConditionsEditorNumericPrompt(final ConversationContext context) { + this.context = context; + if (context != null && context.getPlugin() != null) { + this.factory = ((Quests)context.getPlugin()).getConditionFactory(); + } + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + public ConversationContext getConversationContext() { + return context; + } + + public ConditionFactory getConditionFactory() { + return factory; + } + + public abstract int getSize(); + + public abstract String getTitle(ConversationContext context); + + public abstract ChatColor getNumberColor(ConversationContext context, int number); + + public abstract String getSelectionText(ConversationContext context, int number); + + public abstract String getAdditionalText(ConversationContext context, int number); +} diff --git a/api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorStringPrompt.java b/api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorStringPrompt.java new file mode 100644 index 000000000..a85e9a20d --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/convo/conditions/ConditionsEditorStringPrompt.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.convo.conditions; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.conditions.ConditionFactory; +import me.pikamug.quests.convo.QuestsStringPrompt; +import org.bukkit.conversations.ConversationContext; + +public abstract class ConditionsEditorStringPrompt extends QuestsStringPrompt { + private final ConversationContext context; + private ConditionFactory factory; + + public ConditionsEditorStringPrompt(final ConversationContext context) { + this.context = context; + if (context != null && context.getPlugin() != null) { + this.factory = ((Quests)context.getPlugin()).getConditionFactory(); + } + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + public ConversationContext getConversationContext() { + return context; + } + + public ConditionFactory getConditionFactory() { + return factory; + } + + public abstract String getTitle(ConversationContext context); + + public abstract String getQueryText(ConversationContext context); +} diff --git a/api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorNumericPrompt.java b/api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorNumericPrompt.java new file mode 100644 index 000000000..1809c292e --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorNumericPrompt.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.convo.quests; + +import me.pikamug.quests.quests.QuestFactory; +import me.pikamug.quests.Quests; +import me.pikamug.quests.convo.QuestsNumericPrompt; +import org.bukkit.ChatColor; +import org.bukkit.conversations.ConversationContext; + +public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt { + private final ConversationContext context; + private QuestFactory factory; + + public QuestsEditorNumericPrompt(final ConversationContext context) { + this.context = context; + if (context != null && context.getPlugin() != null) { + factory = ((Quests)context.getPlugin()).getQuestFactory(); + } + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + public ConversationContext getConversationContext() { + return context; + } + + public QuestFactory getQuestFactory() { + return factory; + } + + public abstract int getSize(); + + public abstract String getTitle(ConversationContext context); + + public abstract ChatColor getNumberColor(ConversationContext context, int number); + + public abstract String getSelectionText(ConversationContext context, int number); + + public abstract String getAdditionalText(ConversationContext context, int number); +} diff --git a/api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorStringPrompt.java b/api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorStringPrompt.java new file mode 100644 index 000000000..8db72bcf9 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/convo/quests/QuestsEditorStringPrompt.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.convo.quests; + +import me.pikamug.quests.quests.QuestFactory; +import me.pikamug.quests.Quests; +import me.pikamug.quests.convo.QuestsStringPrompt; +import org.bukkit.conversations.ConversationContext; + +public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt { + private final ConversationContext context; + private QuestFactory factory; + + public QuestsEditorStringPrompt(final ConversationContext context) { + this.context = context; + if (context != null && context.getPlugin() != null) { + factory = ((Quests)context.getPlugin()).getQuestFactory(); + } + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + public ConversationContext getConversationContext() { + return context; + } + + public QuestFactory getQuestFactory() { + return factory; + } + + public abstract String getTitle(ConversationContext context); + + public abstract String getQueryText(ConversationContext context); +} diff --git a/api/src/main/java/me/pikamug/quests/dependencies/Dependencies.java b/api/src/main/java/me/pikamug/quests/dependencies/Dependencies.java new file mode 100644 index 000000000..77df8e348 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/dependencies/Dependencies.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.dependencies; + +public interface Dependencies { + + boolean isPluginAvailable(final String pluginName); + + void init(); +} diff --git a/api/src/main/java/me/pikamug/quests/entity/QuestMob.java b/api/src/main/java/me/pikamug/quests/entity/QuestMob.java new file mode 100644 index 000000000..a426e0b7c --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/entity/QuestMob.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.entity; + +public interface QuestMob { + String getName(); + + void setName(final String name); + + Integer getSpawnAmounts(); + + void setSpawnAmounts(final int spawnAmounts); + + Float[] getDropChances(); + + void setDropChances(final Float[] dropChances); + + void spawn(); +} diff --git a/api/src/main/java/me/blackvein/quests/enums/ObjectiveType.java b/api/src/main/java/me/pikamug/quests/enums/ObjectiveType.java similarity index 71% rename from api/src/main/java/me/blackvein/quests/enums/ObjectiveType.java rename to api/src/main/java/me/pikamug/quests/enums/ObjectiveType.java index 8e5777728..004f6425d 100644 --- a/api/src/main/java/me/blackvein/quests/enums/ObjectiveType.java +++ b/api/src/main/java/me/pikamug/quests/enums/ObjectiveType.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.enums; +package me.pikamug.quests.enums; import java.util.HashMap; import java.util.Map; diff --git a/api/src/main/java/me/pikamug/quests/enums/StorageType.java b/api/src/main/java/me/pikamug/quests/enums/StorageType.java new file mode 100644 index 000000000..4fcf586b8 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/enums/StorageType.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.enums; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public enum StorageType { + + // Local text file + YAML("YAML", "yaml", "yml"), + + // Remote database + MYSQL("MySQL", "mysql"), + + // Local archive + JAR("JAR", "jar"), + + // Custom + CUSTOM("Custom", "custom"); + + private final String name; + + private final List identifiers; + + StorageType(final String name, final String... identifiers) { + this.name = name; + this.identifiers = Collections.unmodifiableList(Arrays.asList(identifiers)); + } + + public static StorageType parse(final String name, final StorageType def) { + for (final StorageType t : values()) { + for (final String id : t.getIdentifiers()) { + if (id.equalsIgnoreCase(name)) { + return t; + } + } + } + return def; + } + + public String getName() { + return name; + } + + public List getIdentifiers() { + return identifiers; + } +} diff --git a/api/src/main/java/me/pikamug/quests/events/QuestsEvent.java b/api/src/main/java/me/pikamug/quests/events/QuestsEvent.java new file mode 100644 index 000000000..a4d6396f9 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/events/QuestsEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.events; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +public abstract class QuestsEvent extends Event { + private static final HandlerList HANDLERS = new HandlerList(); + + public QuestsEvent() { + } + + public QuestsEvent(final boolean async) { + super(async); + } + + @Override + public @NotNull HandlerList getHandlers() { + return HANDLERS; + } + + public static HandlerList getHandlerList() { + return HANDLERS; + } +} diff --git a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorEvent.java similarity index 59% rename from api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorEvent.java index 0d497e886..9d78e017f 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorEvent.java @@ -1,20 +1,18 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.actions; +package me.pikamug.quests.events.editor.actions; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.actions.ActionFactory; -import me.blackvein.quests.events.QuestsEvent; +import me.pikamug.quests.Quests; +import me.pikamug.quests.actions.ActionFactory; +import me.pikamug.quests.events.QuestsEvent; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; import org.bukkit.event.HandlerList; @@ -33,14 +31,14 @@ public abstract class ActionsEditorEvent extends QuestsEvent { public ActionsEditorEvent(final ConversationContext context, final Prompt prompt) { this.context = context; - this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getActionFactory(); + this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getActionFactory(); this.prompt = prompt; } public ActionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) { super(async); this.context = context; - this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getActionFactory(); + this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getActionFactory(); this.prompt = prompt; } diff --git a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java similarity index 52% rename from api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java index 356060d1e..2c5717a19 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorPostOpenNumericPromptEvent.java @@ -1,21 +1,19 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.actions; +package me.pikamug.quests.events.editor.actions; +import me.pikamug.quests.convo.actions.ActionsEditorNumericPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; -import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import org.jetbrains.annotations.NotNull; public class ActionsEditorPostOpenNumericPromptEvent extends ActionsEditorEvent { diff --git a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java similarity index 51% rename from api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java index 757cfbe3b..ac1005219 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.actions; +package me.pikamug.quests.events.editor.actions; -import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; +import me.pikamug.quests.convo.actions.ActionsEditorStringPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorEvent.java similarity index 59% rename from api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorEvent.java index 136a99ddc..d894956c4 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorEvent.java @@ -1,20 +1,18 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.conditions; +package me.pikamug.quests.events.editor.conditions; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.conditions.ConditionFactory; -import me.blackvein.quests.events.QuestsEvent; +import me.pikamug.quests.Quests; +import me.pikamug.quests.conditions.ConditionFactory; +import me.pikamug.quests.events.QuestsEvent; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; import org.bukkit.event.HandlerList; @@ -33,14 +31,14 @@ public abstract class ConditionsEditorEvent extends QuestsEvent { public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt) { this.context = context; - this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getConditionFactory(); + this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getConditionFactory(); this.prompt = prompt; } public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) { super(async); this.context = context; - this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getConditionFactory(); + this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getConditionFactory(); this.prompt = prompt; } diff --git a/api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java similarity index 52% rename from api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java index de1e18b51..3335e7981 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java @@ -1,21 +1,19 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.conditions; +package me.pikamug.quests.events.editor.conditions; +import me.pikamug.quests.convo.conditions.ConditionsEditorNumericPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; -import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import org.jetbrains.annotations.NotNull; public class ConditionsEditorPostOpenNumericPromptEvent extends ConditionsEditorEvent { diff --git a/api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java similarity index 52% rename from api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java index e86201847..db44e426d 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java @@ -1,21 +1,19 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.conditions; +package me.pikamug.quests.events.editor.conditions; +import me.pikamug.quests.convo.conditions.ConditionsEditorStringPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; -import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; import org.jetbrains.annotations.NotNull; public class ConditionsEditorPostOpenStringPromptEvent extends ConditionsEditorEvent { diff --git a/api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorEvent.java similarity index 58% rename from api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorEvent.java index a1990bfce..b5ac6202b 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorEvent.java @@ -1,20 +1,18 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.quests; +package me.pikamug.quests.events.editor.quests; -import me.blackvein.quests.quests.QuestFactory; -import me.blackvein.quests.QuestsAPI; -import me.blackvein.quests.events.QuestsEvent; +import me.pikamug.quests.quests.QuestFactory; +import me.pikamug.quests.Quests; +import me.pikamug.quests.events.QuestsEvent; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; import org.bukkit.event.HandlerList; @@ -33,14 +31,14 @@ public abstract class QuestsEditorEvent extends QuestsEvent { public QuestsEditorEvent(final ConversationContext context, final Prompt prompt) { this.context = context; - this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getQuestFactory(); + this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getQuestFactory(); this.prompt = prompt; } public QuestsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) { super(async); this.context = context; - this.factory = ((QuestsAPI) Objects.requireNonNull(context.getPlugin())).getQuestFactory(); + this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getQuestFactory(); this.prompt = prompt; } diff --git a/api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java similarity index 52% rename from api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java index 86d2f752f..0ab30a80b 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorPostOpenNumericPromptEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.quests; +package me.pikamug.quests.events.editor.quests; -import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; +import me.pikamug.quests.convo.quests.QuestsEditorNumericPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java b/api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java similarity index 51% rename from api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java rename to api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java index efd2dc357..12582b28e 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/editor/quests/QuestsEditorPostOpenStringPromptEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.editor.quests; +package me.pikamug.quests.events.editor.quests; -import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt; +import me.pikamug.quests.convo.quests.QuestsEditorStringPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/me/blackvein/quests/events/misc/MiscEditorEvent.java b/api/src/main/java/me/pikamug/quests/events/misc/MiscEditorEvent.java similarity index 60% rename from api/src/main/java/me/blackvein/quests/events/misc/MiscEditorEvent.java rename to api/src/main/java/me/pikamug/quests/events/misc/MiscEditorEvent.java index bfd46010c..788c6a443 100644 --- a/api/src/main/java/me/blackvein/quests/events/misc/MiscEditorEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/misc/MiscEditorEvent.java @@ -1,18 +1,16 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.misc; +package me.pikamug.quests.events.misc; -import me.blackvein.quests.events.QuestsEvent; +import me.pikamug.quests.events.QuestsEvent; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; import org.bukkit.event.HandlerList; diff --git a/api/src/main/java/me/blackvein/quests/events/misc/MiscPostNpcOfferQuestEvent.java b/api/src/main/java/me/pikamug/quests/events/misc/MiscPostNpcOfferQuestEvent.java similarity index 57% rename from api/src/main/java/me/blackvein/quests/events/misc/MiscPostNpcOfferQuestEvent.java rename to api/src/main/java/me/pikamug/quests/events/misc/MiscPostNpcOfferQuestEvent.java index de6a64358..7cc2f3ae0 100644 --- a/api/src/main/java/me/blackvein/quests/events/misc/MiscPostNpcOfferQuestEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/misc/MiscPostNpcOfferQuestEvent.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.misc; +package me.pikamug.quests.events.misc; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; diff --git a/api/src/main/java/me/blackvein/quests/events/misc/MiscPostQuestAbandonEvent.java b/api/src/main/java/me/pikamug/quests/events/misc/MiscPostQuestAbandonEvent.java similarity index 57% rename from api/src/main/java/me/blackvein/quests/events/misc/MiscPostQuestAbandonEvent.java rename to api/src/main/java/me/pikamug/quests/events/misc/MiscPostQuestAbandonEvent.java index 1baf6051d..dbf62b4fb 100644 --- a/api/src/main/java/me/blackvein/quests/events/misc/MiscPostQuestAbandonEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/misc/MiscPostQuestAbandonEvent.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.misc; +package me.pikamug.quests.events.misc; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; diff --git a/api/src/main/java/me/blackvein/quests/events/misc/MiscPostQuestAcceptEvent.java b/api/src/main/java/me/pikamug/quests/events/misc/MiscPostQuestAcceptEvent.java similarity index 57% rename from api/src/main/java/me/blackvein/quests/events/misc/MiscPostQuestAcceptEvent.java rename to api/src/main/java/me/pikamug/quests/events/misc/MiscPostQuestAcceptEvent.java index f43bfbd2a..7c607585f 100644 --- a/api/src/main/java/me/blackvein/quests/events/misc/MiscPostQuestAcceptEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/misc/MiscPostQuestAcceptEvent.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.misc; +package me.pikamug.quests.events.misc; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; diff --git a/api/src/main/java/me/pikamug/quests/events/quest/QuestEvent.java b/api/src/main/java/me/pikamug/quests/events/quest/QuestEvent.java new file mode 100644 index 000000000..6658dd1f9 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/events/quest/QuestEvent.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.events.quest; + +import me.pikamug.quests.events.QuestsEvent; +import me.pikamug.quests.quests.Quest; +import org.bukkit.event.HandlerList; + +import org.jetbrains.annotations.NotNull; + +/** + * Represents a quest-related event + */ +public abstract class QuestEvent extends QuestsEvent { + private static final HandlerList HANDLERS = new HandlerList(); + private final Quest quest; + + public QuestEvent(final Quest quest) { + this.quest = quest; + } + + public QuestEvent(final Quest quest, final boolean async) { + super(async); + this.quest = quest; + } + + /** + * Returns the quest involved in this event + * + * @return Quest which is involved in this event + */ + public final Quest getQuest() { + return quest; + } + + @Override + public @NotNull HandlerList getHandlers() { + return HANDLERS; + } + + public static HandlerList getHandlerList() { + return HANDLERS; + } +} diff --git a/api/src/main/java/me/pikamug/quests/events/quest/QuestQuitEvent.java b/api/src/main/java/me/pikamug/quests/events/quest/QuestQuitEvent.java new file mode 100644 index 000000000..e2f79bd0d --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/events/quest/QuestQuitEvent.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.events.quest; + +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.Quest; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +import org.jetbrains.annotations.NotNull; + +/** + * Called when a quest is quit by a quester + */ +public class QuestQuitEvent extends QuestEvent implements Cancellable { + private static final HandlerList HANDLERS = new HandlerList(); + private final Quester quester; + private boolean cancel = false; + + public QuestQuitEvent(final Quest quest, final Quester who) { + super(quest); + this.quester = who; + } + + /** + * Returns the quester involved in this event + * + * @return Quester who is involved in this event + */ + public Quester getQuester() { + return quester; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(final boolean cancel) { + this.cancel = cancel; + } + + @Override + public @NotNull HandlerList getHandlers() { + return HANDLERS; + } + + public static HandlerList getHandlerList() { + return HANDLERS; + } +} diff --git a/api/src/main/java/me/pikamug/quests/events/quest/QuestTakeEvent.java b/api/src/main/java/me/pikamug/quests/events/quest/QuestTakeEvent.java new file mode 100644 index 000000000..498a88023 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/events/quest/QuestTakeEvent.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.events.quest; + +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.Quest; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +import org.jetbrains.annotations.NotNull; + +/** + * Called when a quest is taken by a quester + */ +public class QuestTakeEvent extends QuestEvent implements Cancellable { + private static final HandlerList HANDLERS = new HandlerList(); + private final Quester quester; + private boolean cancel = false; + + public QuestTakeEvent(final Quest quest, final Quester who) { + super(quest); + this.quester = who; + } + + /** + * Returns the quester involved in this event + * + * @return Quester who is involved in this event + */ + public Quester getQuester() { + return quester; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(final boolean cancel) { + this.cancel = cancel; + } + + @Override + public @NotNull HandlerList getHandlers() { + return HANDLERS; + } + + public static HandlerList getHandlerList() { + return HANDLERS; + } +} diff --git a/api/src/main/java/me/blackvein/quests/events/quest/QuestUpdateCompassEvent.java b/api/src/main/java/me/pikamug/quests/events/quest/QuestUpdateCompassEvent.java similarity index 53% rename from api/src/main/java/me/blackvein/quests/events/quest/QuestUpdateCompassEvent.java rename to api/src/main/java/me/pikamug/quests/events/quest/QuestUpdateCompassEvent.java index 2ed6d94ba..a34c8f35c 100644 --- a/api/src/main/java/me/blackvein/quests/events/quest/QuestUpdateCompassEvent.java +++ b/api/src/main/java/me/pikamug/quests/events/quest/QuestUpdateCompassEvent.java @@ -1,23 +1,21 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.events.quest; +package me.pikamug.quests.events.quest; +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.Quest; import org.bukkit.Location; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; import org.jetbrains.annotations.NotNull; /** @@ -25,11 +23,11 @@ import org.jetbrains.annotations.NotNull; */ public class QuestUpdateCompassEvent extends QuestEvent implements Cancellable { private static final HandlerList HANDLERS = new HandlerList(); - private final IQuester quester; + private final Quester quester; private final Location target; private boolean cancel = false; - public QuestUpdateCompassEvent(final IQuest quest, final IQuester who, final Location target) { + public QuestUpdateCompassEvent(final Quest quest, final Quester who, final Location target) { super(quest); this.quester = who; this.target = target; @@ -40,7 +38,7 @@ public class QuestUpdateCompassEvent extends QuestEvent implements Cancellable { * * @return Quester who is involved in this event */ - public IQuester getQuester() { + public Quester getQuester() { return quester; } diff --git a/core/src/main/java/me/blackvein/quests/exceptions/ActionFormatException.java b/api/src/main/java/me/pikamug/quests/exceptions/ActionFormatException.java similarity index 50% rename from core/src/main/java/me/blackvein/quests/exceptions/ActionFormatException.java rename to api/src/main/java/me/pikamug/quests/exceptions/ActionFormatException.java index aab6545b9..00d5cb6bc 100644 --- a/core/src/main/java/me/blackvein/quests/exceptions/ActionFormatException.java +++ b/api/src/main/java/me/pikamug/quests/exceptions/ActionFormatException.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.exceptions; +package me.pikamug.quests.exceptions; public class ActionFormatException extends Exception { diff --git a/core/src/main/java/me/blackvein/quests/exceptions/ConditionFormatException.java b/api/src/main/java/me/pikamug/quests/exceptions/ConditionFormatException.java similarity index 51% rename from core/src/main/java/me/blackvein/quests/exceptions/ConditionFormatException.java rename to api/src/main/java/me/pikamug/quests/exceptions/ConditionFormatException.java index ed691d8b3..8b8b74362 100644 --- a/core/src/main/java/me/blackvein/quests/exceptions/ConditionFormatException.java +++ b/api/src/main/java/me/pikamug/quests/exceptions/ConditionFormatException.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.exceptions; +package me.pikamug.quests.exceptions; public class ConditionFormatException extends Exception { diff --git a/core/src/main/java/me/blackvein/quests/exceptions/QuestFormatException.java b/api/src/main/java/me/pikamug/quests/exceptions/QuestFormatException.java similarity index 50% rename from core/src/main/java/me/blackvein/quests/exceptions/QuestFormatException.java rename to api/src/main/java/me/pikamug/quests/exceptions/QuestFormatException.java index 64a7e562a..65d0c52b2 100644 --- a/core/src/main/java/me/blackvein/quests/exceptions/QuestFormatException.java +++ b/api/src/main/java/me/pikamug/quests/exceptions/QuestFormatException.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.exceptions; +package me.pikamug.quests.exceptions; public class QuestFormatException extends Exception { diff --git a/core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java b/api/src/main/java/me/pikamug/quests/exceptions/StageFormatException.java similarity index 50% rename from core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java rename to api/src/main/java/me/pikamug/quests/exceptions/StageFormatException.java index 621fe05a1..5cbfaa0d5 100644 --- a/core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java +++ b/api/src/main/java/me/pikamug/quests/exceptions/StageFormatException.java @@ -1,28 +1,26 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.exceptions; +package me.pikamug.quests.exceptions; -import me.blackvein.quests.quests.IQuest; +import me.pikamug.quests.quests.Quest; public class StageFormatException extends Exception { private static final long serialVersionUID = -8217391053042612896L; private final String message; - private final IQuest quest; + private final Quest quest; private final int stage; - public StageFormatException(final String message, final IQuest quest, final int stage) { + public StageFormatException(final String message, final Quest quest, final int stage) { super(message + ", see quest " + quest.getName() + " stage " + stage); this.message = message + ", see quest " + quest.getName() + " stage " + stage; this.quest = quest; @@ -44,7 +42,7 @@ public class StageFormatException extends Exception { * * @return The quest that an invalid stage id was set within. */ - public IQuest getQuest() { + public Quest getQuest() { return quest; } diff --git a/api/src/main/java/me/pikamug/quests/interfaces/ReloadCallback.java b/api/src/main/java/me/pikamug/quests/interfaces/ReloadCallback.java new file mode 100644 index 000000000..a81234a5a --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/interfaces/ReloadCallback.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.interfaces; + +public interface ReloadCallback { + void execute(T response); +} diff --git a/api/src/main/java/me/blackvein/quests/module/ICustomObjective.java b/api/src/main/java/me/pikamug/quests/module/CustomObjective.java similarity index 51% rename from api/src/main/java/me/blackvein/quests/module/ICustomObjective.java rename to api/src/main/java/me/pikamug/quests/module/CustomObjective.java index 433466ea8..ccfe10548 100644 --- a/api/src/main/java/me/blackvein/quests/module/ICustomObjective.java +++ b/api/src/main/java/me/pikamug/quests/module/CustomObjective.java @@ -1,27 +1,26 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.module; +package me.pikamug.quests.module; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.entity.Player; +import me.pikamug.quests.quests.Quest; import java.util.LinkedList; import java.util.Map; +import java.util.UUID; -public interface ICustomObjective { +public interface CustomObjective { String getModuleName(); + @SuppressWarnings("unused") Map.Entry getModuleItem(); String getName(); @@ -78,12 +77,20 @@ public interface ICustomObjective { /** * Get custom objective data for applicable player * - * @param player Player attempting this objective + * @param uuid UUID of player attempting this objective * @param customObj The objective being attempted - * @param quest Current me.blackvein.quests.Quest which includes this objective - * @return data + * @param quest Current me.pikamug.quests.Quest which includes this objective + * @return data Map of custom objective data */ - Map getDataForPlayerTemp(final Player player, final ICustomObjective customObj, final IQuest quest); + Map getDataForPlayer(final UUID uuid, final CustomObjective customObj, final Quest quest); - void incrementObjectiveTemp(final Player player, final ICustomObjective obj, final int count, final IQuest quest); + /** + * Increment objective count for applicable player + * + * @param uuid UUID of player attempting this objective + * @param customObj The objective being attempted + * @param quest Current me.pikamug.quests.Quest which includes this objective + * @param count Amount to increase objective count by + */ + void incrementObjective(final UUID uuid, final CustomObjective customObj, final Quest quest, final int count); } diff --git a/api/src/main/java/me/pikamug/quests/module/CustomRequirement.java b/api/src/main/java/me/pikamug/quests/module/CustomRequirement.java new file mode 100644 index 000000000..2fab8a81f --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/module/CustomRequirement.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.module; + +import java.util.Map; +import java.util.UUID; + +public interface CustomRequirement { + + String getModuleName(); + + @SuppressWarnings("unused") + Map.Entry getModuleItem(); + + String getName(); + + void setName(final String name); + + String getAuthor(); + + void setAuthor(final String author); + + String getDisplay(); + + void setDisplay(final String display); + + Map.Entry getItem(); + + void setItem(final String type, final short durability); + + Map getData(); + + Map getDescriptions(); + + /** + * Add a new prompt

+ * + * Note that the "defaultValue" Object will be cast to a String internally + * + * @param title Prompt name + * @param description Description of expected input + * @param defaultValue Value to be used if input is not received + */ + void addStringPrompt(final String title, final String description, final Object defaultValue); + + /** + * Test whether a player has met the requirement + * + * @param uuid UUID of player being tested + * @param data Map of custom requirement data + * @return true if met + */ + boolean testRequirement(UUID uuid, Map data); +} diff --git a/api/src/main/java/me/pikamug/quests/module/CustomReward.java b/api/src/main/java/me/pikamug/quests/module/CustomReward.java new file mode 100644 index 000000000..f88decb15 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/module/CustomReward.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.module; + +import java.util.Map; +import java.util.UUID; + +public interface CustomReward { + + String getModuleName(); + + @SuppressWarnings("unused") + Map.Entry getModuleItem(); + + String getName(); + + void setName(final String name); + + String getAuthor(); + + void setAuthor(final String author); + + String getDisplay(); + + void setDisplay(final String display); + + Map.Entry getItem(); + + void setItem(final String type, final short durability); + + Map getData(); + + Map getDescriptions(); + + /** + * Add a new prompt

+ * + * Note that the "defaultValue" Object will be cast to a String internally + * + * @param title Prompt name + * @param description Description of expected input + * @param defaultValue Value to be used if input is not received + */ + void addStringPrompt(final String title, final String description, final Object defaultValue); + + /** + * Give loot reward to a player + * + * @param uuid UUID of player being tested + * @param data Map of custom reward data + */ + void giveReward(UUID uuid, Map data); +} diff --git a/api/src/main/java/me/pikamug/quests/player/QuestProgress.java b/api/src/main/java/me/pikamug/quests/player/QuestProgress.java new file mode 100644 index 000000000..de5a1f9e4 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/player/QuestProgress.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.player; + +import java.util.LinkedList; + +public interface QuestProgress { + LinkedList getBlocksBroken(); + + LinkedList getBlocksDamaged(); + + LinkedList getBlocksPlaced(); + + LinkedList getBlocksUsed(); + + LinkedList getBlocksCut(); + + LinkedList getItemsCrafted(); + + LinkedList getItemsSmelted(); + + LinkedList getItemsEnchanted(); + + LinkedList getItemsBrewed(); + + LinkedList getItemsConsumed(); + + LinkedList getItemsDelivered(); + + LinkedList getNpcsInteracted(); + + void setNpcsInteracted(final LinkedList npcsInteracted); + + LinkedList getNpcsNumKilled(); + + void setNpcsNumKilled(final LinkedList npcsNumKilled); + + LinkedList getMobNumKilled(); + + void setMobNumKilled(final LinkedList mobNumKilled); + + LinkedList getMobsTamed(); + + void setMobsTamed(final LinkedList mobsTamed); + + int getFishCaught(); + + void setFishCaught(final int fishCaught); + + int getCowsMilked(); + + void setCowsMilked(final int cowsMilked); + + LinkedList getSheepSheared(); + + void setSheepSheared(final LinkedList sheepSheared); + + int getPlayersKilled(); + + void setPlayersKilled(final int playersKilled); + + LinkedList getLocationsReached(); + + void setLocationsReached(final LinkedList locationsReached); + + LinkedList getPasswordsSaid(); + + void setPasswordsSaid(final LinkedList passwordsSaid); + + LinkedList getCustomObjectiveCounts(); + + void setCustomObjectiveCounts(final LinkedList customObjectiveCounts); + + long getDelayStartTime(); + + void setDelayStartTime(final long delayStartTime); + + long getDelayTimeLeft(); + + void setDelayTimeLeft(final long delayTimeLeft); + + boolean canDoJournalUpdate(); + + void setDoJournalUpdate(final boolean b); +} diff --git a/api/src/main/java/me/pikamug/quests/player/Quester.java b/api/src/main/java/me/pikamug/quests/player/Quester.java new file mode 100644 index 000000000..9d380ac32 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/player/Quester.java @@ -0,0 +1,256 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.player; + +import me.pikamug.quests.quests.Quest; +import me.pikamug.quests.quests.components.Stage; +import me.pikamug.quests.quests.components.Objective; +import me.pikamug.quests.enums.ObjectiveType; +import me.pikamug.quests.module.CustomObjective; +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.function.BiFunction; +import java.util.function.Function; + +public interface Quester extends Comparable { + UUID getUUID(); + + void setUUID(final UUID id); + + String getQuestIdToTake(); + + void setQuestIdToTake(final String questIdToTake); + + String getQuestIdToQuit(); + + void setQuestIdToQuit(final String questIdToQuit); + + String getLastKnownName(); + + void setLastKnownName(final String lastKnownName); + + int getQuestPoints(); + + void setQuestPoints(final int questPoints); + + /** + * Get compass target quest. Returns null if not set + * + * @return Quest or null + */ + Quest getCompassTarget(); + + /** + * Set compass target quest. Does not update in-game + * + * @param quest The target quest + */ + void setCompassTarget(final Quest quest); + + ConcurrentHashMap getTimers(); + + void setTimers(final ConcurrentHashMap timers); + + void removeTimer(final Integer timerId); + + ConcurrentHashMap getCurrentQuests(); + + void setCurrentQuests(final ConcurrentHashMap currentQuests); + + ConcurrentSkipListSet getCompletedQuests(); + + void setCompletedQuests(final ConcurrentSkipListSet completedQuests); + + ConcurrentHashMap getCompletedTimes(); + + void setCompletedTimes(final ConcurrentHashMap completedTimes); + + ConcurrentHashMap getAmountsCompleted(); + + void setAmountsCompleted(final ConcurrentHashMap amountsCompleted); + + Player getPlayer(); + + OfflinePlayer getOfflinePlayer(); + + void sendMessage(final String message); + + Stage getCurrentStage(final Quest quest); + + QuestProgress getQuestDataOrDefault(final Quest quest); + + boolean hasJournal(); + + ItemStack getJournal(); + + int getJournalIndex(); + + void updateJournal(); + + boolean offerQuest(final Quest quest, final boolean giveReason); + + boolean canAcceptOffer(final Quest quest, final boolean giveReason); + + boolean isOnTime(final Quest quest, final boolean giveReason); + + void takeQuest(final Quest quest, final boolean ignoreRequirements); + + boolean abandonQuest(final Quest quest, final String message); + + boolean abandonQuest(final Quest quest, final String[] messages); + + void quitQuest(final Quest quest, final String message); + + void quitQuest(final Quest quest, final String[] messages); + + void listQuests(final Quester quester, final int page); + + LinkedList getCurrentRequirements(final Quest quest, final boolean ignoreOverrides); + + LinkedList getCurrentObjectives(final Quest quest, final boolean ignoreOverrides); + + void showCurrentObjectives(final Quest quest, final Quester quester, final boolean ignoreOverrides); + + boolean hasObjective(final Quest quest, final ObjectiveType type); + + boolean hasCustomObjective(final Quest quest, final String name); + + void showCurrentConditions(final Quest quest, final Quester quester); + + void breakBlock(final Quest quest, final ItemStack itemStack); + + void damageBlock(final Quest quest, final ItemStack itemStack); + + void placeBlock(final Quest quest, final ItemStack itemStack); + + void useBlock(final Quest quest, final ItemStack itemStack); + + void cutBlock(final Quest quest, final ItemStack itemStack); + + void craftItem(final Quest quest, final ItemStack itemStack); + + void smeltItem(final Quest quest, final ItemStack itemStack); + + void enchantBook(final Quest quest, final ItemStack itemStack, final Map enchantsToAdd); + + void enchantItem(final Quest quest, final ItemStack itemStack); + + void brewItem(final Quest quest, final ItemStack itemStack); + + void consumeItem(final Quest quest, final ItemStack itemStack); + + void deliverToNPC(final Quest quest, final UUID npc, final ItemStack itemStack); + + void interactWithNPC(final Quest quest, final UUID npc); + + void killNPC(final Quest quest, final UUID npc); + + void milkCow(final Quest quest); + + void catchFish(final Quest quest); + + void killMob(final Quest quest, final Location killedLocation, final EntityType entityType); + + void killPlayer(final Quest quest, final Player player); + + void reachLocation(final Quest quest, final Location location); + + void tameMob(final Quest quest, final EntityType entityType); + + void shearSheep(final Quest quest, final DyeColor color); + + void sayPassword(final Quest quest, final AsyncPlayerChatEvent evt); + + void finishObjective(final Quest quest, final Objective objective, final EntityType mob, + final String extra, final UUID npc, final Location location, final DyeColor color, + final String pass, final CustomObjective co); + + boolean testComplete(final Quest quest); + + void addEmptiesFor(final Quest quest, final int stage); + + boolean saveData(); + + long getCompletionDifference(final Quest quest); + + long getRemainingCooldown(final Quest quest); + + FileConfiguration getBaseData(); + + boolean hasData(); + + boolean hasBaseData(); + + void startStageTimer(final Quest quest); + + void stopStageTimer(final Quest quest); + + long getStageTime(final Quest quest); + + void checkQuest(final Quest quest); + + void showGUIDisplay(final UUID npc, final LinkedList quests); + + void hardQuit(final Quest quest); + + void hardRemove(final Quest quest); + + void hardClear(); + + void hardStagePut(final Quest key, final Integer val); + + void hardDataPut(final Quest key, final QuestProgress val); + + boolean canUseCompass(); + + void resetCompass(); + + void findCompassTarget(); + + void findNextCompassTarget(final boolean notify); + + boolean hasItem(final ItemStack is); + + Set dispatchMultiplayerEverything(final Quest quest, final ObjectiveType type, + final BiFunction fun); + + Set dispatchMultiplayerObjectives(final Quest quest, final Stage currentStage, + final Function fun); + + List getMultiplayerQuesters(final Quest quest); + + boolean meetsCondition(final Quest quest, final boolean giveReason); + + boolean isSelectingBlock(); + + boolean isInRegion(final String regionID); + + boolean canAcceptQuest(final UUID npc); + + boolean canAcceptCompletedQuest(final UUID npc); + + boolean canAcceptCompletedRedoableQuest(final UUID npc); +} diff --git a/api/src/main/java/me/pikamug/quests/quests/Quest.java b/api/src/main/java/me/pikamug/quests/quests/Quest.java new file mode 100644 index 000000000..f4a6bf27a --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/quests/Quest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.quests; + +import me.pikamug.quests.actions.Action; +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.quests.components.Options; +import me.pikamug.quests.quests.components.Planner; +import me.pikamug.quests.quests.components.Requirements; +import me.pikamug.quests.quests.components.Rewards; +import me.pikamug.quests.quests.components.Stage; + +import java.util.LinkedList; +import java.util.UUID; + +public interface Quest extends Comparable { + + String getId(); + + void setId(String id); + + String getName(); + + void setName(final String name); + + String getDescription(); + + void setDescription(final String description); + + String getFinished(); + + void setFinished(final String finished); + + String getRegionStart(); + + void setRegionStart(final String regionStart); + + Stage getStage(final int index); + + LinkedList getStages(); + + UUID getNpcStart(); + + void setNpcStart(final UUID npcStart); + + String getNpcStartName(); + + Action getInitialAction(); + + void setInitialAction(final Action initialAction); + + Requirements getRequirements(); + + void setRequirements(final Requirements requirements); + + Planner getPlanner(); + + void setPlanner(final Planner planner); + + Rewards getRewards(); + + void setRewards(final Rewards rewards); + + Options getOptions(); + + void setOptions(final Options options); + + void nextStage(final Quester quester, final boolean allowSharedProgress); + + void setStage(final Quester quester, final int stage); + + boolean updateCompass(final Quester quester, final Stage stage); + + boolean testRequirements(final Quester quester); + + void completeQuest(final Quester quester); + + void completeQuest(final Quester quester, final boolean allowMultiplayer); + + void failQuest(final Quester quester); + + void failQuest(final Quester quester, final boolean ignoreFailAction); + + boolean isInRegionStart(final Quester quester); +} diff --git a/api/src/main/java/me/pikamug/quests/quests/QuestFactory.java b/api/src/main/java/me/pikamug/quests/quests/QuestFactory.java new file mode 100644 index 000000000..f2f24d533 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/quests/QuestFactory.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.quests; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; + +import java.util.List; +import java.util.Set; +import java.util.UUID; + +public interface QuestFactory { + + Set getSelectingNpcs(); + + void setSelectingNpcs(final Set selectingNpcs); + + List getNamesOfQuestsBeingEdited(); + + void setNamesOfQuestsBeingEdited(final List questNames); + + ConversationFactory getConversationFactory(); + + Prompt returnToMenu(final ConversationContext context); + + void loadQuest(final ConversationContext context, final Quest q); + + void deleteQuest(final ConversationContext context); + + void saveQuest(final ConversationContext context, final ConfigurationSection section); + + /*void saveRequirements(final ConversationContext context, final ConfigurationSection section); + + void saveStages(final ConversationContext context, final ConfigurationSection section); + + void saveRewards(final ConversationContext context, final ConfigurationSection section); + + void savePlanner(final ConversationContext context, final ConfigurationSection section); + + void saveOptions(final ConversationContext context, final ConfigurationSection section);*/ +} diff --git a/api/src/main/java/me/pikamug/quests/quests/components/Objective.java b/api/src/main/java/me/pikamug/quests/quests/components/Objective.java new file mode 100644 index 000000000..35154f080 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/quests/components/Objective.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.quests.components; + +import me.pikamug.quests.enums.ObjectiveType; +import org.jetbrains.annotations.NotNull; + +public interface Objective { + ObjectiveType getType(); + + String getMessage(); + + int getProgress(); + + int getGoal(); + + @NotNull Object getProgressObject(); + + @NotNull Object getGoalObject(); +} diff --git a/api/src/main/java/me/blackvein/quests/quests/Options.java b/api/src/main/java/me/pikamug/quests/quests/components/Options.java similarity index 55% rename from api/src/main/java/me/blackvein/quests/quests/Options.java rename to api/src/main/java/me/pikamug/quests/quests/components/Options.java index 0b0cb1896..6e50b94bc 100644 --- a/api/src/main/java/me/blackvein/quests/quests/Options.java +++ b/api/src/main/java/me/pikamug/quests/quests/components/Options.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.quests; +package me.pikamug.quests.quests.components; public interface Options { boolean canAllowCommands(); diff --git a/api/src/main/java/me/pikamug/quests/quests/components/Planner.java b/api/src/main/java/me/pikamug/quests/quests/components/Planner.java new file mode 100644 index 000000000..b00e43d35 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/quests/components/Planner.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.quests.components; + +public interface Planner { + String getStart(); + + long getStartInMillis(); + + boolean hasStart(); + + void setStart(final String start); + + String getEnd(); + + long getEndInMillis(); + + boolean hasEnd(); + + void setEnd(final String end); + + long getRepeat(); + + boolean hasRepeat(); + + void setRepeat(final long repeat); + + long getCooldown(); + + boolean hasCooldown(); + + void setCooldown(final long cooldown); + + boolean getOverride(); + + void setOverride(final boolean override); +} diff --git a/api/src/main/java/me/blackvein/quests/quests/Requirements.java b/api/src/main/java/me/pikamug/quests/quests/components/Requirements.java similarity index 60% rename from api/src/main/java/me/blackvein/quests/quests/Requirements.java rename to api/src/main/java/me/pikamug/quests/quests/components/Requirements.java index d3076de3b..4c0139510 100644 --- a/api/src/main/java/me/blackvein/quests/quests/Requirements.java +++ b/api/src/main/java/me/pikamug/quests/quests/components/Requirements.java @@ -1,18 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.quests; - -import org.bukkit.inventory.ItemStack; +package me.pikamug.quests.quests.components; import java.util.List; import java.util.Map; @@ -30,9 +26,7 @@ public interface Requirements { void setExp(final int exp); - List getItems(); - - void setItems(final List items); + List getItems(); List getRemoveItems(); diff --git a/api/src/main/java/me/blackvein/quests/quests/Rewards.java b/api/src/main/java/me/pikamug/quests/quests/components/Rewards.java similarity index 63% rename from api/src/main/java/me/blackvein/quests/quests/Rewards.java rename to api/src/main/java/me/pikamug/quests/quests/components/Rewards.java index cb45cfca0..7a6662de4 100644 --- a/api/src/main/java/me/blackvein/quests/quests/Rewards.java +++ b/api/src/main/java/me/pikamug/quests/quests/components/Rewards.java @@ -1,18 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.quests; - -import org.bukkit.inventory.ItemStack; +package me.pikamug.quests.quests.components; import java.util.List; import java.util.Map; @@ -46,9 +42,7 @@ public interface Rewards { void setPermissionWorlds(final List worldNames); - List getItems(); - - void setItems(final List items); + List getItems(); List getMcmmoSkills(); diff --git a/api/src/main/java/me/pikamug/quests/quests/components/Stage.java b/api/src/main/java/me/pikamug/quests/quests/components/Stage.java new file mode 100644 index 000000000..1eb9f659e --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/quests/components/Stage.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.quests.components; + +import me.pikamug.quests.actions.Action; +import me.pikamug.quests.conditions.Condition; +import me.pikamug.quests.enums.ObjectiveType; +import me.pikamug.quests.module.CustomObjective; + +import java.util.LinkedList; +import java.util.Map; +import java.util.UUID; + +public interface Stage { + LinkedList getBlocksToBreak(); + + LinkedList getBlocksToDamage(); + + LinkedList getBlocksToPlace(); + + LinkedList getBlocksToUse(); + + LinkedList getBlocksToCut(); + + LinkedList getItemsToCraft(); + + LinkedList getItemsToSmelt(); + + LinkedList getItemsToEnchant(); + + LinkedList getItemsToBrew(); + + LinkedList getItemsToConsume(); + + LinkedList getItemsToDeliver(); + + LinkedList getItemDeliveryTargets(); + + void setItemDeliveryTargets(final LinkedList itemDeliveryTargets); + + LinkedList getDeliverMessages(); + + void setDeliverMessages(final LinkedList deliverMessages); + + LinkedList getNpcsToInteract(); + + void setNpcsToInteract(final LinkedList npcsToInteract); + + LinkedList getNpcsToKill(); + + void setNpcsToKill(final LinkedList npcsToKill); + + LinkedList getNpcNumToKill(); + + void setNpcNumToKill(final LinkedList npcNumToKill); + + LinkedList getMobsToKill(); + + LinkedList getMobNumToKill(); + + void setMobNumToKill(final LinkedList mobNumToKill); + + LinkedList getLocationsToKillWithin(); + + LinkedList getRadiiToKillWithin(); + + void setRadiiToKillWithin(final LinkedList radiiToKillWithin); + + LinkedList getKillNames(); + + void setKillNames(final LinkedList killNames); + + LinkedList getLocationsToReach(); + + LinkedList getRadiiToReachWithin(); + + void setRadiiToReachWithin(final LinkedList radiiToReachWithin); + + LinkedList getWorldsToReachWithin(); + + LinkedList getLocationNames(); + + void setLocationNames(final LinkedList locationNames); + + LinkedList getMobsToTame(); + + LinkedList getMobNumToTame(); + + void setMobNumToTame(final LinkedList mobNumToTame); + + Integer getFishToCatch(); + + void setFishToCatch(final Integer fishToCatch); + + Integer getCowsToMilk(); + + void setCowsToMilk(final Integer cowsToMilk); + + Integer getPlayersToKill(); + + void setPlayersToKill(final Integer playersToKill); + + LinkedList getSheepToShear(); + + LinkedList getSheepNumToShear(); + + void setSheepNumToShear(final LinkedList sheepNumToShear); + + LinkedList getPasswordDisplays(); + + void setPasswordDisplays(final LinkedList passwordDisplays); + + LinkedList getPasswordPhrases(); + + void setPasswordPhrases(final LinkedList passwordPhrases); + + String getScript(); + + void setScript(final String script); + + Action getStartAction(); + + void setStartAction(final Action startAction); + + Action getFinishAction(); + + void setFinishAction(final Action finishAction); + + Action getFailAction(); + + void setFailAction(final Action failAction); + + Action getDeathAction(); + + void setDeathAction(final Action deathAction); + + Map getChatActions(); + + void setChatActions(final Map chatActions); + + Map getCommandActions(); + + void setCommandActions(final Map commandActions); + + Action getDisconnectAction(); + + void setDisconnectAction(final Action disconnectAction); + + Condition getCondition(); + + void setCondition(final Condition condition); + + long getDelay(); + + void setDelay(final long delay); + + String getDelayMessage(); + + void setDelayMessage(final String delayMessage); + + String getCompleteMessage(); + + void setCompleteMessage(final String completeMessage); + + String getStartMessage(); + + void setStartMessage(final String startMessage); + + LinkedList getObjectiveOverrides(); + + void setObjectiveOverrides(final LinkedList objectiveOverrides); + + LinkedList getCustomObjectives(); + + void clearCustomObjectives(); + + LinkedList getCustomObjectiveCounts(); + + void clearCustomObjectiveCounts(); + + LinkedList getCustomObjectiveDisplays(); + + void clearCustomObjectiveDisplays(); + + LinkedList> getCustomObjectiveData(); + + void clearCustomObjectiveData(); + + /** + * Check if stage has at least one objective

+ * + * Excludes start/complete message, delay, and objective-override + * + * @return true if stage contains an objective + */ + boolean hasObjective(); + + /** + * Check if stage has at least one objective of which the target can be located easily

+ * + * @return true if stage contains a locatable objective + */ + boolean hasLocatableObjective(); + + /** + * Check if stage has the specified type of objective

+ * + * @param type The type of objective to check for + * @return true if stage contains specified objective + */ + boolean containsObjective(final ObjectiveType type); +} diff --git a/core/src/main/java/me/blackvein/quests/storage/Storage.java b/api/src/main/java/me/pikamug/quests/storage/QuesterStorage.java similarity index 61% rename from core/src/main/java/me/blackvein/quests/storage/Storage.java rename to api/src/main/java/me/pikamug/quests/storage/QuesterStorage.java index 7bc0b9604..6ae851ba1 100644 --- a/core/src/main/java/me/blackvein/quests/storage/Storage.java +++ b/api/src/main/java/me/pikamug/quests/storage/QuesterStorage.java @@ -1,20 +1,18 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.storage; +package me.pikamug.quests.storage; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.Quests; -import me.blackvein.quests.storage.implementation.StorageImplementation; +import me.pikamug.quests.Quests; +import me.pikamug.quests.player.Quester; +import me.pikamug.quests.storage.implementation.QuesterStorageImpl; import java.util.Collection; import java.util.Collections; @@ -23,20 +21,20 @@ import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; -public class Storage { +public class QuesterStorage { private final Quests plugin; - private final StorageImplementation implementation; + private final QuesterStorageImpl implementation; - public Storage(final Quests plugin, final StorageImplementation implementation) { + public QuesterStorage(final Quests plugin, final QuesterStorageImpl implementation) { this.plugin = plugin; this.implementation = implementation; } - public StorageImplementation getImplementation() { + public QuesterStorageImpl getImplementation() { return implementation; } - public Collection getImplementations() { + public Collection getImplementations() { return Collections.singleton(implementation); } @@ -71,7 +69,7 @@ public class Storage { try { implementation.init(); } catch (final Exception e) { - plugin.getLogger().severe("Failed to initialize storage implementation"); + // Failed to initialize storage implementation e.printStackTrace(); } } @@ -80,16 +78,16 @@ public class Storage { try { implementation.close(); } catch (final Exception e) { - plugin.getLogger().severe("Failed to close storage implementation"); + // Failed to close storage implementation e.printStackTrace(); } } - public CompletableFuture loadQuester(final UUID uniqueId) { + public CompletableFuture loadQuester(final UUID uniqueId) { return makeFuture(() -> implementation.loadQuester(uniqueId)); } - public CompletableFuture saveQuester(final IQuester quester) { + public CompletableFuture saveQuester(final Quester quester) { return makeFuture(() -> { try { implementation.saveQuester(quester); @@ -102,7 +100,7 @@ public class Storage { public CompletableFuture saveOfflineQuesters() { return makeFuture(() -> { try { - for (IQuester quester : plugin.getOfflineQuesters()) { + for (Quester quester : plugin.getOfflineQuesters()) { implementation.saveQuester(quester); } } catch (final Exception e) { diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/ActionStorageImpl.java b/api/src/main/java/me/pikamug/quests/storage/implementation/ActionStorageImpl.java new file mode 100644 index 000000000..f320ba30a --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/ActionStorageImpl.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.actions.Action; +import me.pikamug.quests.exceptions.ActionFormatException; + +public interface ActionStorageImpl { + Quests getPlugin(); + + String getImplementationName(); + + void init() throws Exception; + + void close(); + + Action loadAction(final String name) throws ActionFormatException; +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/ConditionStorageImpl.java b/api/src/main/java/me/pikamug/quests/storage/implementation/ConditionStorageImpl.java new file mode 100644 index 000000000..9c7ecc416 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/ConditionStorageImpl.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.conditions.Condition; +import me.pikamug.quests.exceptions.ConditionFormatException; + +public interface ConditionStorageImpl { + Quests getPlugin(); + + String getImplementationName(); + + void init() throws Exception; + + void close(); + + Condition loadCondition(final String name) throws ConditionFormatException; +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/ModuleStorageImpl.java b/api/src/main/java/me/pikamug/quests/storage/implementation/ModuleStorageImpl.java new file mode 100644 index 000000000..3ae002a1a --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/ModuleStorageImpl.java @@ -0,0 +1,17 @@ +package me.pikamug.quests.storage.implementation; + +import me.pikamug.quests.Quests; + +import java.io.File; + +public interface ModuleStorageImpl { + Quests getPlugin(); + + String getImplementationName(); + + void init(); + + void close(); + + void loadModule(final File jar); +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/QuestStorageImpl.java b/api/src/main/java/me/pikamug/quests/storage/implementation/QuestStorageImpl.java new file mode 100644 index 000000000..04f817d1a --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/QuestStorageImpl.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.exceptions.QuestFormatException; +import me.pikamug.quests.quests.Quest; + +public interface QuestStorageImpl { + Quests getPlugin(); + + String getImplementationName(); + + void init() throws Exception; + + void close(); + + Quest loadQuest(final String name) throws QuestFormatException; +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/QuesterStorageImpl.java b/api/src/main/java/me/pikamug/quests/storage/implementation/QuesterStorageImpl.java new file mode 100644 index 000000000..99238442f --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/QuesterStorageImpl.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.player.Quester; + +import java.util.Collection; +import java.util.UUID; + +public interface QuesterStorageImpl { + Quests getPlugin(); + + String getImplementationName(); + + void init() throws Exception; + + void close(); + + Quester loadQuester(final UUID uniqueId) throws Exception; + + void saveQuester(final Quester quester) throws Exception; + + void deleteQuester(final UUID uniqueId) throws Exception; + + String getQuesterLastKnownName(final UUID uniqueId) throws Exception; + + Collection getSavedUniqueIds() throws Exception; +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProvider.java b/api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProvider.java new file mode 100644 index 000000000..987729a1f --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProvider.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation.custom; + +import me.pikamug.quests.Quests; +import me.pikamug.quests.storage.implementation.QuesterStorageImpl; + +public interface CustomStorageProvider { + QuesterStorageImpl provide(Quests plugin); +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProviders.java b/api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProviders.java new file mode 100644 index 000000000..37905d408 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/custom/CustomStorageProviders.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation.custom; + +public final class CustomStorageProviders { + private CustomStorageProviders() {} + + private static CustomStorageProvider provider = null; + + public static void register(final CustomStorageProvider provider) { + CustomStorageProviders.provider = provider; + } + + public static CustomStorageProvider getProvider() { + if (provider == null) { + throw new IllegalStateException("Provider not found."); + } + + return provider; + } +} diff --git a/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/ConnectionFactory.java b/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/ConnectionFactory.java new file mode 100644 index 000000000..01380931f --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/ConnectionFactory.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.storage.implementation.sql.connection; + +import me.pikamug.quests.Quests; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Collections; +import java.util.Map; +import java.util.function.Function; + +public interface ConnectionFactory { + String getImplementationName(); + + void init(Quests plugin); + + void close() throws Exception; + + default Map getMeta() { + return Collections.emptyMap(); + } + + Function getStatementProcessor(); + + Connection getConnection() throws SQLException; +} diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java b/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java similarity index 77% rename from core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java rename to api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java index 90d8bbbff..448171730 100644 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java @@ -1,33 +1,27 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.storage.implementation.sql.connection.hikari; +package me.pikamug.quests.storage.implementation.sql.connection.hikari; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import me.pikamug.quests.Quests; +import me.pikamug.quests.storage.implementation.sql.connection.ConnectionFactory; +import me.pikamug.quests.storage.misc.StorageCredentials; -import java.lang.reflect.Method; import java.sql.Connection; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -import org.bukkit.plugin.java.JavaPlugin; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.storage.implementation.sql.connection.ConnectionFactory; -import me.blackvein.quests.storage.misc.StorageCredentials; - public abstract class HikariConnectionFactory implements ConnectionFactory { private final StorageCredentials configuration; private HikariDataSource hikari; @@ -128,7 +122,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory { return connection; } - public static String identifyClassLoader(final ClassLoader classLoader) throws ReflectiveOperationException { + /*public static String identifyClassLoader(final ClassLoader classLoader) throws ReflectiveOperationException { final Class pluginClassLoaderClass = Class.forName("org.bukkit.plugin.java.PluginClassLoader"); if (pluginClassLoaderClass.isInstance(classLoader)) { final Method getPluginMethod = pluginClassLoaderClass.getDeclaredMethod("getPlugin"); @@ -138,5 +132,5 @@ public abstract class HikariConnectionFactory implements ConnectionFactory { return plugin.getName(); } return null; - } + }*/ } diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java b/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java similarity index 69% rename from core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java rename to api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java index dd5dff577..aba6e8967 100644 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java +++ b/api/src/main/java/me/pikamug/quests/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java @@ -1,24 +1,21 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.storage.implementation.sql.connection.hikari; +package me.pikamug.quests.storage.implementation.sql.connection.hikari; + +import com.zaxxer.hikari.HikariConfig; +import me.pikamug.quests.storage.misc.StorageCredentials; import java.util.Map; import java.util.function.Function; -import com.zaxxer.hikari.HikariConfig; - -import me.blackvein.quests.storage.misc.StorageCredentials; - public class MySqlConnectionFactory extends HikariConnectionFactory { public MySqlConnectionFactory(final StorageCredentials configuration) { super(configuration); diff --git a/core/src/main/java/me/blackvein/quests/storage/misc/StorageCredentials.java b/api/src/main/java/me/pikamug/quests/storage/misc/StorageCredentials.java similarity index 71% rename from core/src/main/java/me/blackvein/quests/storage/misc/StorageCredentials.java rename to api/src/main/java/me/pikamug/quests/storage/misc/StorageCredentials.java index a3a85fd5c..6638d97be 100644 --- a/core/src/main/java/me/blackvein/quests/storage/misc/StorageCredentials.java +++ b/api/src/main/java/me/pikamug/quests/storage/misc/StorageCredentials.java @@ -1,16 +1,14 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.storage.misc; +package me.pikamug.quests.storage.misc; import java.util.Map; import java.util.Objects; diff --git a/core/src/main/java/me/blackvein/quests/util/CK.java b/api/src/main/java/me/pikamug/quests/util/Key.java similarity index 79% rename from core/src/main/java/me/blackvein/quests/util/CK.java rename to api/src/main/java/me/pikamug/quests/util/Key.java index 3fed47423..7bbccf88b 100644 --- a/core/src/main/java/me/blackvein/quests/util/CK.java +++ b/api/src/main/java/me/pikamug/quests/util/Key.java @@ -1,20 +1,20 @@ /* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. + * Copyright (c) PikaMug and contributors * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package me.blackvein.quests.util; +package me.pikamug.quests.util; + +/** + * Human-readable keys for session data of prompts and factories + */ +public class Key { -public class CK { - - // Temporary data storage for prompts and factories public static final String ED_QUEST_EDIT = "edit"; public static final String ED_QUEST_DELETE = "delQuest"; public static final String ED_EVENT_DELETE = "delEvent"; @@ -152,33 +152,33 @@ public class CK { public static final String OPT_HANDLE_OFFLINE_PLAYERS = "handleOfflinePlayers"; public static final String OPT_IGNORE_BLOCK_REPLACE = "ignoreBlockReplace"; // Actions - public static final String E_OLD_EVENT = "oldEvent"; - public static final String E_NAME = "evtName"; - public static final String E_MESSAGE = "evtMessage"; - public static final String E_CLEAR_INVENTORY = "evtClearInv"; - public static final String E_FAIL_QUEST = "evtFailQuest"; - public static final String E_ITEMS = "evtItems"; - public static final String E_ITEMS_AMOUNTS = "evtItemAmounts"; - public static final String E_EXPLOSIONS = "evtExplosions"; - public static final String E_EFFECTS = "evtEffects"; - public static final String E_EFFECTS_LOCATIONS = "evtEffectLocations"; - public static final String E_WORLD_STORM = "evtStormWorld"; - public static final String E_WORLD_STORM_DURATION = "evtStormDuration"; - public static final String E_WORLD_THUNDER = "evtThunderWorld"; - public static final String E_WORLD_THUNDER_DURATION = "evtThunderDuration"; - public static final String E_MOB_TYPES = "evtMobTypes"; - public static final String E_LIGHTNING = "evtLightningStrikes"; - public static final String E_POTION_TYPES = "evtPotionTypes"; - public static final String E_POTION_DURATIONS = "evtPotionDurations"; - public static final String E_POTION_STRENGTH = "evtPotionMagnitudes"; - public static final String E_HUNGER = "evtHunger"; - public static final String E_SATURATION = "evtSaturation"; - public static final String E_HEALTH = "evtHealth"; - public static final String E_TELEPORT = "evtTeleportLocation"; - public static final String E_COMMANDS = "evtCommands"; - public static final String E_TIMER = "evtTimer"; - public static final String E_CANCEL_TIMER = "evtCancelTimer"; - public static final String E_DENIZEN = "evtDenizen"; + public static final String A_OLD_ACTION = "oldAction"; + public static final String A_NAME = "actName"; + public static final String A_MESSAGE = "actMessage"; + public static final String A_CLEAR_INVENTORY = "actClearInv"; + public static final String A_FAIL_QUEST = "actFailQuest"; + public static final String A_ITEMS = "actItems"; + public static final String A_ITEMS_AMOUNTS = "actItemAmounts"; + public static final String A_EXPLOSIONS = "actExplosions"; + public static final String A_EFFECTS = "actEffects"; + public static final String A_EFFECTS_LOCATIONS = "actEffectLocations"; + public static final String A_WORLD_STORM = "actStormWorld"; + public static final String A_WORLD_STORM_DURATION = "actStormDuration"; + public static final String A_WORLD_THUNDER = "actThunderWorld"; + public static final String A_WORLD_THUNDER_DURATION = "actThunderDuration"; + public static final String A_MOBS = "actMobs"; + public static final String A_LIGHTNING = "actLightningStrikes"; + public static final String A_POTION_TYPES = "actPotionTypes"; + public static final String A_POTION_DURATIONS = "actPotionDurations"; + public static final String A_POTION_STRENGTH = "actPotionMagnitudes"; + public static final String A_HUNGER = "actHunger"; + public static final String A_SATURATION = "actSaturation"; + public static final String A_HEALTH = "actHealth"; + public static final String A_TELEPORT = "actTeleportLocation"; + public static final String A_COMMANDS = "actCommands"; + public static final String A_TIMER = "actTimer"; + public static final String A_CANCEL_TIMER = "actCancelTimer"; + public static final String A_DENIZEN = "actDenizen"; // Conditions public static final String C_OLD_CONDITION = "oldCondition"; public static final String C_NAME = "conName"; diff --git a/api/src/main/java/me/pikamug/quests/util/RomanNumeral.java b/api/src/main/java/me/pikamug/quests/util/RomanNumeral.java new file mode 100644 index 000000000..ba74a3e34 --- /dev/null +++ b/api/src/main/java/me/pikamug/quests/util/RomanNumeral.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) PikaMug and contributors + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package me.pikamug.quests.util; + +import java.util.TreeMap; + +public class RomanNumeral { + + private final static TreeMap map = new TreeMap<>(); + + static { + map.put(1000, "M"); + map.put(900, "CM"); + map.put(500, "D"); + map.put(400, "CD"); + map.put(100, "C"); + map.put(90, "XC"); + map.put(50, "L"); + map.put(40, "XL"); + map.put(10, "X"); + map.put(9, "IX"); + map.put(5, "V"); + map.put(4, "IV"); + map.put(1, "I"); + } + + public static String getNumeral(final int number) { + final int l = map.floorKey(number); + if ( number == l ) { + return map.get(number); + } + return map.get(l) + getNumeral(number-l); + } +} diff --git a/core/pom.xml b/core/pom.xml index 8db4f6b90..8a8fed055 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ 4.0.0 - me.blackvein.quests + me.pikamug.quests quests-parent ${revision} @@ -156,29 +156,6 @@ spigot-book-api 1.6 - - mysql - mysql-connector-java - 8.0.28 - - - com.google.protobuf - protobuf-java - - - - - com.zaxxer - HikariCP - - 4.0.3 - - - slf4j-api - org.slf4j - - - org.slf4j slf4j-simple @@ -190,7 +167,7 @@ 2.17.1 - me.blackvein.quests + me.pikamug.quests quests-api ${project.version} compile @@ -265,8 +242,6 @@ me.* com.github.PikaMug:LocaleLib - com.zaxxer:HikariCP - mysql org.slf4j:slf4j-simple org.slf4j:slf4j-api xyz.upperlevel.spigot.book:spigot-book-api @@ -289,23 +264,15 @@ me.pikamug.localelib - me.blackvein.quests.libs.localelib - - - com.zaxxer.hikari - me.blackvein.quests.libs.hikari - - - com.mysql - me.blackvein.quests.libs.mysql + me.pikamug.quests.libs.localelib org.slf4j - me.blackvein.quests.libs.slf4j + me.pikamug.quests.libs.slf4j xyz.upperlevel.spigot.book - me.blackvein.quests.libs.bookutil + me.pikamug.quests.libs.bookutil diff --git a/core/src/main/java/me/blackvein/quests/Quests.java b/core/src/main/java/me/blackvein/quests/Quests.java deleted file mode 100644 index 770006106..000000000 --- a/core/src/main/java/me/blackvein/quests/Quests.java +++ /dev/null @@ -1,4815 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests; - -import com.gmail.nossr50.datatypes.skills.SkillType; -import com.herocraftonline.heroes.characters.classes.HeroClass; -import me.blackvein.quests.actions.Action; -import me.blackvein.quests.actions.ActionFactory; -import me.blackvein.quests.actions.BukkitActionFactory; -import me.blackvein.quests.actions.IAction; -import me.blackvein.quests.conditions.BukkitConditionFactory; -import me.blackvein.quests.conditions.Condition; -import me.blackvein.quests.conditions.ConditionFactory; -import me.blackvein.quests.conditions.ICondition; -import me.blackvein.quests.config.ISettings; -import me.blackvein.quests.convo.misc.MiscStringPrompt; -import me.blackvein.quests.convo.misc.NpcOfferQuestPrompt; -import me.blackvein.quests.dependencies.DenizenTrigger; -import me.blackvein.quests.dependencies.IDependencies; -import me.blackvein.quests.entity.BukkitQuestMob; -import me.blackvein.quests.entity.QuestMob; -import me.blackvein.quests.events.misc.MiscPostQuestAcceptEvent; -import me.blackvein.quests.exceptions.ActionFormatException; -import me.blackvein.quests.exceptions.ConditionFormatException; -import me.blackvein.quests.exceptions.QuestFormatException; -import me.blackvein.quests.exceptions.StageFormatException; -import me.blackvein.quests.interfaces.ReloadCallback; -import me.blackvein.quests.listeners.BlockListener; -import me.blackvein.quests.listeners.CitizensListener; -import me.blackvein.quests.listeners.CommandManager; -import me.blackvein.quests.listeners.ConvoListener; -import me.blackvein.quests.listeners.ItemListener; -import me.blackvein.quests.listeners.PartiesListener; -import me.blackvein.quests.listeners.PlayerListener; -import me.blackvein.quests.listeners.UniteListener; -import me.blackvein.quests.listeners.ZnpcsListener; -import me.blackvein.quests.logging.QuestsLog4JFilter; -import me.blackvein.quests.module.ICustomObjective; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.BukkitQuestFactory; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.IStage; -import me.blackvein.quests.quests.Options; -import me.blackvein.quests.quests.Planner; -import me.blackvein.quests.quests.QuestFactory; -import me.blackvein.quests.quests.Requirements; -import me.blackvein.quests.quests.Rewards; -import me.blackvein.quests.statistics.Metrics; -import me.blackvein.quests.storage.Storage; -import me.blackvein.quests.storage.StorageFactory; -import me.blackvein.quests.tasks.NpcEffectThread; -import me.blackvein.quests.tasks.PlayerMoveThread; -import me.blackvein.quests.util.ConfigUtil; -import me.blackvein.quests.util.ItemUtil; -import me.blackvein.quests.util.Lang; -import me.blackvein.quests.util.MiscUtil; -import me.blackvein.quests.util.RomanNumeral; -import me.blackvein.quests.util.UpdateChecker; -import me.clip.placeholderapi.PlaceholderAPI; -import me.pikamug.localelib.LocaleManager; -import net.citizensnpcs.api.CitizensAPI; -import net.citizensnpcs.api.npc.NPC; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.TextComponent; -import org.apache.logging.log4j.LogManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.DyeColor; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.TabExecutor; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.Conversable; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.Prompt; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Tameable; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.permissions.Permission; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.lang.reflect.Constructor; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.charset.StandardCharsets; -import java.util.AbstractMap; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentSkipListSet; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class Quests extends JavaPlugin implements QuestsAPI { - - private boolean loading = true; - private String bukkitVersion = "0"; - private IDependencies depends; - private ISettings settings; - private final List customObjectives = new LinkedList<>(); - private final List customRequirements = new LinkedList<>(); - private final List customRewards = new LinkedList<>(); - private Collection questers = new ConcurrentSkipListSet<>(); - private final Collection quests = new ConcurrentSkipListSet<>(); - private Collection actions = new ConcurrentSkipListSet<>(); - private Collection conditions = new ConcurrentSkipListSet<>(); - private Collection questNpcUuids = new ConcurrentSkipListSet<>(); - private TabExecutor cmdExecutor; - private ConversationFactory conversationFactory; - private ConversationFactory npcConversationFactory; - private QuestFactory questFactory; - private ActionFactory actionFactory; - private ConditionFactory conditionFactory; - private ConvoListener convoListener; - private BlockListener blockListener; - private ItemListener itemListener; - private CitizensListener citizensListener; - private ZnpcsListener znpcsListener; - private PlayerListener playerListener; - private NpcEffectThread effectThread; - private PlayerMoveThread moveThread; - private UniteListener uniteListener; - private PartiesListener partiesListener; - private DenizenTrigger trigger; - private LocaleManager localeManager; - private Storage storage; - - @Override - public void onEnable() { - /*----> WARNING: ORDER OF STEPS MATTERS <----*/ - - // 1 - Trigger server to initialize Legacy Material Support - try { - Material.matchMaterial("STONE", true); - } catch (final NoSuchMethodError ignored) { - } - - ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addFilter(new QuestsLog4JFilter()); - - // 2 - Initialize variables - bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0]; - settings = new Settings(this); - try { - Class.forName("me.blackvein.quests.libs.localelib.LocaleManager"); - localeManager = new LocaleManager(); - } catch (final Exception ignored) { - getLogger().warning("LocaleLib not present! Is this a debug environment?"); - } - convoListener = new ConvoListener(); - blockListener = new BlockListener(this); - itemListener = new ItemListener(this); - citizensListener = new CitizensListener(this); - znpcsListener = new ZnpcsListener(this); - playerListener = new PlayerListener(this); - uniteListener = new UniteListener(); - partiesListener = new PartiesListener(); - effectThread = new NpcEffectThread(this); - moveThread = new PlayerMoveThread(this); - questFactory = new BukkitQuestFactory(this); - actionFactory = new BukkitActionFactory(this); - conditionFactory = new BukkitConditionFactory(this); - depends = new Dependencies(this); - trigger = new DenizenTrigger(this); - - // 3 - Load main config - settings.init(); - if (settings.getLanguage().contains("-")) { - final Metrics metrics = new Metrics(this); - metrics.addCustomChart(new Metrics.SimplePie("language", () -> settings.getLanguage())); - } - - // 4 - Setup language files - try { - setupLang(); - } catch (final IOException | URISyntaxException e) { - e.printStackTrace(); - } - - // 5 - Load command executor - cmdExecutor = new CommandManager(this); - - // 6 - Load soft-depends - depends.init(); - - // 7 - Save resources from jar - saveResourceAs("quests.yml", "quests.yml", false); - saveResourceAs("actions.yml", "actions.yml", false); - saveResourceAs("conditions.yml", "conditions.yml", false); - - // 8 - Save config with any new options - getConfig().options().copyDefaults(true); - getConfig().options().header("See https://pikamug.gitbook.io/quests/setup/configuration"); - saveConfig(); - final StorageFactory storageFactory = new StorageFactory(this); - storage = storageFactory.getInstance(); - - // 9 - Setup commands - if (getCommand("quests") != null) { - Objects.requireNonNull(getCommand("quests")).setExecutor(getTabExecutor()); - Objects.requireNonNull(getCommand("quests")).setTabCompleter(getTabExecutor()); - } - if (getCommand("questadmin") != null) { - Objects.requireNonNull(getCommand("questadmin")).setExecutor(getTabExecutor()); - Objects.requireNonNull(getCommand("questadmin")).setTabCompleter(getTabExecutor()); - } - if (getCommand("quest") != null) { - Objects.requireNonNull(getCommand("quest")).setExecutor(getTabExecutor()); - Objects.requireNonNull(getCommand("quest")).setTabCompleter(getTabExecutor()); - } - - // 10 - Build conversation factories - this.conversationFactory = new ConversationFactory(this).withModality(false) - .withPrefix(context -> ChatColor.GRAY.toString()) - .withFirstPrompt(new QuestAcceptPrompt()).withTimeout(settings.getAcceptTimeout()) - .thatExcludesNonPlayersWithMessage("Console may not perform this conversation!") - .addConversationAbandonedListener(convoListener); - this.npcConversationFactory = new ConversationFactory(this).withModality(false) - .withFirstPrompt(new NpcOfferQuestPrompt(this)).withTimeout(settings.getAcceptTimeout()) - .withLocalEcho(false).addConversationAbandonedListener(convoListener); - - // 11 - Register listeners - getServer().getPluginManager().registerEvents(getBlockListener(), this); - getServer().getPluginManager().registerEvents(getItemListener(), this); - depends.linkCitizens(); - if (depends.getZnpcsPlus() != null) { - getServer().getPluginManager().registerEvents(getZnpcsListener(), this); - } - getServer().getPluginManager().registerEvents(getPlayerListener(), this); - if (settings.getStrictPlayerMovement() > 0) { - final long ticks = settings.getStrictPlayerMovement() * 20L; - getServer().getScheduler().scheduleSyncRepeatingTask(this, getPlayerMoveThread(), ticks, ticks); - } - if (depends.getPartyProvider() != null) { - getServer().getPluginManager().registerEvents(getUniteListener(), this); - } else if (depends.getPartiesApi() != null) { - getServer().getPluginManager().registerEvents(getPartiesListener(), this); - } - - // 12 - Attempt to check for updates - new UpdateChecker(this, 3711).getVersion(version -> { - if (!getDescription().getVersion().split("-")[0].equalsIgnoreCase(version)) { - getLogger().info(ChatColor.DARK_GREEN + Lang.get("updateTo").replace("", - version).replace("", ChatColor.AQUA + getDescription().getWebsite())); - } - }); - - // 13 - Delay loading of quests, actions and modules - delayLoadQuestInfo(); - } - - @Override - public void onDisable() { - getLogger().info("Saving Quester data..."); - for (final Player p : getServer().getOnlinePlayers()) { - getQuester(p.getUniqueId()).saveData(); - } - Bukkit.getScheduler().cancelTasks(this); - getLogger().info("Closing storage..."); - if (storage != null) { - storage.close(); - } - } - - public boolean isLoading() { - return loading; - } - - public File getPluginDataFolder() { - return getDataFolder(); - } - - public Logger getPluginLogger() { - return getLogger(); - } - - public InputStream getPluginResource(String filename) { - return getResource(filename); - } - - public String getDetectedServerSoftwareVersion() { - return bukkitVersion; - } - - public Dependencies getDependencies() { - return (Dependencies) depends; - } - - public Settings getSettings() { - return (Settings) settings; - } - - @Override - public List getCustomObjectives() { - return customObjectives; - } - - public Optional getCustomObjective(final String className) { - for (final ICustomObjective co : customObjectives) { - if (co.getClass().getName().equals(className)) { - return Optional.of(co); - } - } - return Optional.empty(); - } - - @Override - public List getCustomRequirements() { - return customRequirements; - } - - public Optional getCustomRequirement(final String className) { - for (final CustomRequirement cr : customRequirements) { - if (cr.getClass().getName().equals(className)) { - return Optional.of(cr); - } - } - return Optional.empty(); - } - - @Override - public List getCustomRewards() { - return customRewards; - } - - public Optional getCustomReward(final String className) { - for (final CustomReward cr : customRewards) { - if (cr.getClass().getName().equals(className)) { - return Optional.of(cr); - } - } - return Optional.empty(); - } - - /** - * Get every Quest loaded in memory - * - * @deprecated Use {@link #getLoadedQuests()} - * @return a list of all Quests - */ - @Deprecated - public LinkedList getQuests() { - final LinkedList list = new LinkedList<>(); - for (IQuest q : quests) { - list.add((Quest) q); - } - return list; - } - - /** - * Get every Quest loaded in memory - * - * @return a collection of all Quests - */ - public Collection getLoadedQuests() { - return quests; - } - - /** - * Get every Action loaded in memory - * - * @deprecated Use {@link #getLoadedActions()} - * @return a list of all Actions - */ - @Deprecated - public LinkedList getActions() { - final LinkedList list = new LinkedList<>(); - for (IAction a : actions) { - list.add((Action) a); - } - return list; - } - - /** - * Get every IAction loaded in memory - * - * @return a collection of all Actions - */ - public Collection getLoadedActions() { - return actions; - } - - /** - * Set every IAction loaded in memory - * - * @deprecated Use {@link #setLoadedActions(Collection)} - */ - @Deprecated - public void setActions(final LinkedList actions) { - this.actions = actions; - } - - /** - * Set every IAction loaded in memory - * - */ - public void setLoadedActions(final Collection actions) { - this.actions = actions; - } - - /** - * Get every Condition loaded in memory - * - * @deprecated Use {@link #getLoadedConditions()} - * @return a list of all Actions - */ - @Deprecated - public LinkedList getConditions() { - final LinkedList list = new LinkedList<>(); - for (ICondition c : conditions) { - list.add((Condition) c); - } - return list; - } - - /** - * Get every ICondition loaded in memory - * - * @return a collection of all Conditions - */ - public Collection getLoadedConditions() { - return conditions; - } - - /** - * Set every ICondition loaded in memory - * - * @deprecated Use {@link #setLoadedConditions(Collection)} - */ - @Deprecated - public void setConditions(final LinkedList conditions) { - this.conditions = conditions; - } - - /** - * Set every ICondition loaded in memory - * - */ - public void setLoadedConditions(final Collection conditions) { - this.conditions = conditions; - } - - /** - * Get Quester from player UUID - * - * @param id Player UUID - * @return new or existing Quester - */ - public Quester getQuester(final @NotNull UUID id) { - final ConcurrentSkipListSet set = (ConcurrentSkipListSet) questers; - for (final IQuester q : set) { - if (q != null && q.getUUID().equals(id)) { - return (Quester) q; - } - } - final Quester quester = new Quester(this, id); - if (depends.getCitizens() != null) { - if (depends.getCitizens().getNPCRegistry().getByUniqueId(id) != null) { - return quester; - } - } - final Quester q = new Quester(this, id); - questers.add(q); - return q; - } - - /** - * Get every online Quester playing on this server - * - * @return a collection of all online Questers - */ - public Collection getOnlineQuesters() { - final Collection questers = new ConcurrentSkipListSet<>(); - for (final IQuester q : getOfflineQuesters()) { - if (q.getOfflinePlayer().isOnline()) { - // Workaround for issues with the compass on fast join - q.findCompassTarget(); - questers.add(q); - } - } - return questers; - } - - /** - * Get every Quester that has ever played on this server - * - * @return a collection of all Questers - */ - public Collection getOfflineQuesters() { - return questers; - } - - /** - * Set every Quester that has ever played on this server - * - * @param questers a collection of Questers - */ - public void setOfflineQuesters(final Collection questers) { - this.questers = new ConcurrentSkipListSet<>(questers); - } - - /** - * Get every NPC UUID which sees use a quest giver, talk target, or kill target - * - * @return a collection of all UUIDs - */ - public Collection getQuestNpcUuids() { - return questNpcUuids; - } - - /** - * Set every NPC UUID which sees use a quest giver, talk target, or kill target - * - * @param questNpcUuids a collection of UUIDs - */ - @SuppressWarnings("unused") - public void setQuestNpcUuids(final Collection questNpcUuids) { - this.questNpcUuids = new ConcurrentSkipListSet<>(questNpcUuids); - } - - @SuppressWarnings("unused") - public CommandExecutor getCommandExecutor() { - return cmdExecutor; - } - - public TabExecutor getTabExecutor() { - return cmdExecutor; - } - - public ConversationFactory getConversationFactory() { - return conversationFactory; - } - - public ConversationFactory getNpcConversationFactory() { - return npcConversationFactory; - } - - public QuestFactory getQuestFactory() { - return questFactory; - } - - public ActionFactory getActionFactory() { - return actionFactory; - } - - public ConditionFactory getConditionFactory() { - return conditionFactory; - } - - public ConvoListener getConvoListener() { - return convoListener; - } - - public BlockListener getBlockListener() { - return blockListener; - } - - public ItemListener getItemListener() { - return itemListener; - } - - public CitizensListener getCitizensListener() { - return citizensListener; - } - - public ZnpcsListener getZnpcsListener() { - return znpcsListener; - } - - public PlayerListener getPlayerListener() { - return playerListener; - } - - public UniteListener getUniteListener() { - return uniteListener; - } - - public NpcEffectThread getNpcEffectThread() { - return effectThread; - } - - public PlayerMoveThread getPlayerMoveThread() { - return moveThread; - } - - public PartiesListener getPartiesListener() { - return partiesListener; - } - - public DenizenTrigger getDenizenTrigger() { - return trigger; - } - - public LocaleManager getLocaleManager() { - return localeManager; - } - - public Storage getStorage() { - return storage; - } - - public class QuestAcceptPrompt extends MiscStringPrompt { - - private ConversationContext context; - - public QuestAcceptPrompt() { - super(null); - } - - public QuestAcceptPrompt(final ConversationContext context) { - super(context); - } - - @Override - public ConversationContext getConversationContext() { - return context; - } - - public int getSize() { - return 2; - } - - public String getTitle(final ConversationContext context) { - return null; - } - - @SuppressWarnings("unused") - public ChatColor getNumberColor(final ConversationContext context, final int number) { - switch (number) { - case 1: - return ChatColor.GREEN; - case 2: - return ChatColor.RED; - default: - return null; - } - } - - @SuppressWarnings("unused") - public String getSelectionText(final ConversationContext context, final int number) { - switch (number) { - case 1: - return ChatColor.GREEN + Lang.get("yesWord"); - case 2: - return ChatColor.RED + Lang.get("noWord"); - default: - return null; - } - } - - public String getQueryText(final ConversationContext context) { - return Lang.get("acceptQuest"); - } - - @Override - public @NotNull String getPromptText(final @NotNull ConversationContext context) { - this.context = context; - - final MiscPostQuestAcceptEvent event = new MiscPostQuestAcceptEvent(context, this); - getServer().getPluginManager().callEvent(event); - - if (!getSettings().canClickablePrompts()) { - return ChatColor.YELLOW + getQueryText(context) + " " + ChatColor.GREEN - + getSelectionText(context, 1) + ChatColor.RESET + " / " + getSelectionText(context, 2); - } - - final TextComponent component = new TextComponent(""); - component.addExtra(ChatColor.YELLOW + getQueryText(context) + " " + ChatColor.GREEN); - final TextComponent yes = new TextComponent(getSelectionText(context, 1)); - yes.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + Lang.get("yesWord"))); - component.addExtra(yes); - component.addExtra(ChatColor.RESET + " / "); - final TextComponent no = new TextComponent(getSelectionText(context, 2)); - no.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + Lang.get("noWord"))); - component.addExtra(no); - - ((Player)context.getForWhom()).spigot().sendMessage(component); - return ""; - } - - @Override - public Prompt acceptInput(final @NotNull ConversationContext context, final String input) { - if (input == null) { - getLogger().severe("Ended conversation because input for " + getName() + "was null"); - return Prompt.END_OF_CONVERSATION; - } - final Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("y") - || input.equalsIgnoreCase(Lang.get("yesWord")) - || input.equalsIgnoreCase(Lang.get(player, "yesWord"))) { - final IQuester quester = getQuester(player.getUniqueId()); - final String questIdToTake = quester.getQuestIdToTake(); - if (getQuestByIdTemp(questIdToTake) == null) { - getLogger().warning(player.getName() + " attempted to take quest ID \"" + questIdToTake - + "\" but something went wrong"); - player.sendMessage(ChatColor.RED - + "Something went wrong! Please report issue to an administrator."); - } else { - quester.takeQuest(getQuestByIdTemp(questIdToTake), false); - } - return Prompt.END_OF_CONVERSATION; - } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("n") - || input.equalsIgnoreCase(Lang.get("noWord")) - || input.equalsIgnoreCase(Lang.get(player, "noWord"))) { - Lang.send(player, ChatColor.YELLOW + Lang.get("cancelled")); - return Prompt.END_OF_CONVERSATION; - } else { - final String msg = Lang.get(player, "questInvalidChoice") - .replace("", Lang.get(player, "yesWord")) - .replace("", Lang.get(player, "noWord")); - Lang.send(player, ChatColor.RED + msg); - return new QuestAcceptPrompt(context); - } - } - } - - /** - * Transfer language files from jar to disk, then initialize default - */ - private void setupLang() throws IOException, URISyntaxException { - final String path = "lang"; - final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()); - if (jarFile.isFile()) { - final JarFile jar = new JarFile(jarFile); - final Enumeration entries = jar.entries(); - final Set results = new HashSet<>(); - while (entries.hasMoreElements()) { - final String name = entries.nextElement().getName(); - if (name.startsWith(path + "/") && name.contains("strings.yml")) { - results.add(name); - } - } - for (final String resourcePath : results) { - saveResourceAs(resourcePath, resourcePath, false); - saveResourceAs(resourcePath, resourcePath.replace(".yml", "_new.yml"), true); - } - jar.close(); - } - try { - Lang.init(this, settings.getLanguage()); - } catch (final InvalidConfigurationException e) { - e.printStackTrace(); - } - } - - /** - * Save a Quests plugin resource to a specific path in the filesystem - * - * @param resourcePath jar file location starting from resource folder, i.e. "lang/el-GR/strings.yml" - * @param outputPath file destination starting from Quests folder, i.e. "lang/el-GR/strings.yml" - * @param replace whether or not to replace the destination file - */ - public void saveResourceAs(String resourcePath, final String outputPath, final boolean replace) { - if (resourcePath == null || resourcePath.equals("")) { - throw new IllegalArgumentException("ResourcePath cannot be null or empty"); - } - - resourcePath = resourcePath.replace('\\', '/'); - final InputStream in = getResource(resourcePath); - if (in == null) { - throw new IllegalArgumentException("The embedded resource '" + resourcePath - + "' cannot be found in Quests jar"); - } - - final String outPath = outputPath.replace('/', File.separatorChar).replace('\\', File.separatorChar); - final File outFile = new File(getDataFolder(), outPath); - final File outDir = new File(outFile.getPath().replace(outFile.getName(), "")); - - if (!outDir.exists()) { - if (!outDir.mkdirs()) { - getLogger().log(Level.SEVERE, "Failed to make directories for " + outFile.getName() + " (canWrite= " - + outDir.canWrite() + ")"); - } - } - - try { - if (!outFile.exists() || replace) { - final OutputStream out = new FileOutputStream(outFile); - final byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - out.close(); - in.close(); - if (!outFile.exists()) { - getLogger().severe("Unable to copy " + outFile.getName() + " (canWrite= " + outFile.canWrite() - + ")"); - } - } - } catch (final IOException ex) { - getLogger().log(Level.SEVERE, "Could not save " + outFile.getName() + " to " + outFile, ex); - } - } - - /** - * Load quests, actions, conditions, and modules - * - * At startup, this lets soft-depends (namely Citizens) fully load first - */ - private void delayLoadQuestInfo() { - getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { - loadQuests(); - loadActions(); - loadConditions(); - getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s), " + actions.size() + " Action(s), " - + conditions.size() + " Condition(s) and " + Lang.size() + " Phrase(s)"); - for (final Player p : getServer().getOnlinePlayers()) { - final IQuester quester = new Quester(Quests.this, p.getUniqueId()); - if (!quester.hasData()) { - quester.saveData(); - } - // Workaround for issues with the compass on fast join - quester.findCompassTarget(); - questers.add(quester); - } - if (depends.getCitizens() != null) { - if (depends.getCitizens().getNPCRegistry() == null) { - getLogger().log(Level.SEVERE, - "Citizens was enabled but NPCRegistry was null. Disabling linkage."); - depends.unlinkCitizens(); - } - } - if (depends.getZnpcsPlus() != null) { - depends.unlinkZnpcsPlus(); - } - loadModules(); - importQuests(); - if (getSettings().canDisableCommandFeedback()) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule sendCommandFeedback false"); - } - loading = false; - }, 5L); - } - - private void importQuests() { - final File f = new File(this.getDataFolder(), "import"); - if (f.exists() && f.isDirectory()) { - final File[] imports = f.listFiles(); - if (imports != null) { - for (final File file : imports) { - if (!file.isDirectory() && file.getName().endsWith(".yml")) { - importQuest(file); - } - } - } - } else if (!f.mkdir()) { - getLogger().warning("Unable to create import directory"); - } - } - - private void importQuest(final File file) { - FileConfiguration config = null; - try { - config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), - StandardCharsets.UTF_8)); - } catch (final IOException e) { - e.printStackTrace(); - } - if (config != null) { - final ConfigurationSection questsSection = config.getConfigurationSection("quests"); - if (questsSection == null) { - getLogger().severe("Missing 'quests' section marker, canceled import of file " + file.getName()); - return; - } - int count = 0; - for (final String questKey : questsSection.getKeys(false)) { - try { - for (final IQuest lq : getLoadedQuests()) { - if (lq.getId().equals(questKey)) { - throw new QuestFormatException("id already exists", questKey); - } - } - final IQuest quest = loadQuest(config, questKey); - if (config.contains("quests." + questKey + ".requirements")) { - loadQuestRequirements(config, questsSection, quest, questKey); - } - if (config.contains("quests." + questKey + ".planner")) { - loadQuestPlanner(config, quest, questKey); - } - if (config.contains("quests." + questKey + ".options")) { - loadQuestOptions(config, quest, questKey); - } - quest.setPlugin(this); - loadQuestStages(quest, config, questKey); - loadQuestRewards(config, quest, questKey); - quests.add(quest); - count++; - } catch (final QuestFormatException | StageFormatException | ActionFormatException - | ConditionFormatException e) { - e.printStackTrace(); - } - } - if (count > 0) { - getLogger().info("Imported " + count + " Quests from " + file.getName()); - } - } else { - getLogger().severe("Unable to import quest file " + file.getName()); - } - } - - /** - * Load modules from file - */ - public void loadModules() { - final File f = new File(this.getDataFolder(), "modules"); - if (f.exists() && f.isDirectory()) { - final File[] modules = f.listFiles(); - if (modules != null) { - for (final File module : modules) { - if (!module.isDirectory() && module.getName().endsWith(".jar")) { - loadModule(module); - } - } - } - } else if (!f.mkdir()) { - getLogger().warning("Unable to create module directory"); - } - FileConfiguration config = null; - final File file = new File(this.getDataFolder(), "quests.yml"); - try { - config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), - StandardCharsets.UTF_8)); - } catch (final IOException e) { - e.printStackTrace(); - } - if (config != null) { - final ConfigurationSection questsSection; - if (config.contains("quests")) { - questsSection = config.getConfigurationSection("quests"); - if (questsSection != null) { - for (final String questKey : questsSection.getKeys(false)) { - try { - if (config.contains("quests." + questKey)) { - loadCustomSections(getQuestByIdTemp(questKey), config, questKey); - } else { - throw new QuestFormatException("Unable to load custom sections", questKey); - } - } catch (final QuestFormatException | StageFormatException ex) { - ex.printStackTrace(); - } - } - } - } - } else { - getLogger().severe("Unable to load module data from quests.yml"); - } - } - - /** - * Load the specified jar as a module - * - * @param jar A custom reward/requirement/objective jar - */ - public void loadModule(final File jar) { - try { - @SuppressWarnings("resource") - final JarFile jarFile = new JarFile(jar); - final Enumeration entry = jarFile.entries(); - final URL[] urls = { new URL("jar:file:" + jar.getPath() + "!/") }; - final ClassLoader cl = URLClassLoader.newInstance(urls, getClassLoader()); - int count = 0; - while (entry.hasMoreElements()) { - final JarEntry je = entry.nextElement(); - if (je.isDirectory() || !je.getName().endsWith(".class")) { - continue; - } - final String className = je.getName().substring(0, je.getName().length() - 6).replace('/', '.'); - Class c = null; - try { - c = Class.forName(className, true, cl); - } catch (final NoClassDefFoundError e) { - getLogger().severe("Module error! Seek help from developer of module:"); - e.printStackTrace(); - } - if (c != null) { - if (CustomRequirement.class.isAssignableFrom(c)) { - final Class requirementClass = c.asSubclass(CustomRequirement.class); - final Constructor constructor = requirementClass.getConstructor(); - final CustomRequirement requirement = constructor.newInstance(); - final Optional oo = getCustomRequirement(requirement.getClass().getName()); - oo.ifPresent(customRequirements::remove); - customRequirements.add(requirement); - final String name = requirement.getName() == null ? "[" + jar.getName() + "]" : requirement.getName(); - final String author = requirement.getAuthor() == null ? "[Unknown]" : requirement.getAuthor(); - count++; - getLogger().info("Loaded \"" + name + "\" by " + author); - } else if (CustomReward.class.isAssignableFrom(c)) { - final Class rewardClass = c.asSubclass(CustomReward.class); - final Constructor constructor = rewardClass.getConstructor(); - final CustomReward reward = constructor.newInstance(); - final Optional oo = getCustomReward(reward.getClass().getName()); - oo.ifPresent(customRewards::remove); - customRewards.add(reward); - final String name = reward.getName() == null ? "[" + jar.getName() + "]" : reward.getName(); - final String author = reward.getAuthor() == null ? "[Unknown]" : reward.getAuthor(); - count++; - getLogger().info("Loaded \"" + name + "\" by " + author); - } else if (ICustomObjective.class.isAssignableFrom(c)) { - final Class objectiveClass = c.asSubclass(CustomObjective.class); - final Constructor constructor = objectiveClass.getConstructor(); - final CustomObjective objective = constructor.newInstance(); - final Optional oo = getCustomObjective(objective.getClass().getName()); - if (oo.isPresent() && oo.get() instanceof CustomObjective) { - HandlerList.unregisterAll((CustomObjective)oo.get()); - customObjectives.remove(oo.get()); - } - customObjectives.add(objective); - final String name = objective.getName() == null ? "[" + jar.getName() + "]" : objective.getName(); - final String author = objective.getAuthor() == null ? "[Unknown]" : objective.getAuthor(); - count++; - getLogger().info("Loaded \"" + name + "\" by " + author); - try { - getServer().getPluginManager().registerEvents(objective, this); - getLogger().info("Registered events for custom objective \"" + name + "\""); - } catch (final Exception ex) { - getLogger().warning("Failed to register events for custom objective \"" + name - + "\". Does the objective class listen for events?"); - ex.printStackTrace(); - } - } - } - } - if (count == 0) { - getLogger().severe("Unable to load module from file " + jar.getName() + " (not a valid module)!"); - } - } catch (final Exception e) { - getLogger().severe("Unable to load module from file " + jar.getName() + " (contact module developer)!"); - e.printStackTrace(); - } - } - - /** - * Show applicable objectives for the current stage of a player's quest.

- * - * Respects PlaceholderAPI and translations, when enabled. - * - * @deprecated Use {@link Quester#showCurrentObjectives(IQuest, IQuester, boolean)} - * @param quest The quest to get current stage objectives of - * @param quester The player to show current stage objectives to - * @param ignoreOverrides Whether to ignore objective-overrides - */ - @SuppressWarnings("deprecation") - public void showObjectives(final IQuest quest, final IQuester quester, final boolean ignoreOverrides) { - if (quest == null) { - getLogger().severe("Quest was null when showing objectives for " + quester.getLastKnownName()); - return; - } - if (quester.getQuestData(quest) == null) { - getLogger().warning("Quest data was null when showing objectives for " + quest.getName()); - return; - } - final IStage stage = quester.getCurrentStage(quest); - if (stage == null) { - getLogger().warning("Current stage was null when showing objectives for " + quest.getName()); - return; - } - if (!ignoreOverrides && !stage.getObjectiveOverrides().isEmpty()) { - for (final String s: stage.getObjectiveOverrides()) { - String message = ChatColor.GREEN + (s.trim().length() > 0 ? "- " : "") + ConfigUtil - .parseString(s, quest, quester.getPlayer()); - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - quester.sendMessage(message); - } - return; - } - final QuestData data = quester.getQuestData(quest); - for (final ItemStack e : stage.getBlocksToBreak()) { - for (final ItemStack e2 : data.blocksBroken) { - if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { - final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "break"); - if (message.contains("")) { - message = message.replace("", "" + color + e2.getAmount() + "/" + e.getAmount()); - } else { - // Legacy - message += " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !e.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(e))); - } - } - } - } - for (final ItemStack e : stage.getBlocksToDamage()) { - for (final ItemStack e2 : data.blocksDamaged) { - if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { - final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "damage"); - if (message.contains("")) { - message = message.replace("", "" + color + e2.getAmount() + "/" + e.getAmount()); - } else { - // Legacy - message += " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !e.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(e))); - } - } - } - } - for (final ItemStack e : stage.getBlocksToPlace()) { - for (final ItemStack e2 : data.blocksPlaced) { - if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { - final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "place"); - if (message.contains("")) { - message = message.replace("", "" + color + e2.getAmount() + "/" + e.getAmount()); - } else { - // Legacy - message += " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !e.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(e))); - } - } - } - } - for (final ItemStack e : stage.getBlocksToUse()) { - for (final ItemStack e2 : data.blocksUsed) { - if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { - final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "use"); - if (message.contains("")) { - message = message.replace("", "" + color + e2.getAmount() + "/" + e.getAmount()); - } else { - // Legacy - message += " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !e.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(e))); - } - } - } - } - for (final ItemStack e : stage.getBlocksToCut()) { - for (final ItemStack e2 : data.blocksCut) { - if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { - final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "cut"); - if (message.contains("")) { - message = message.replace("", "" + color + e2.getAmount() + "/" + e.getAmount()); - } else { - // Legacy - message += " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !e.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(e))); - } - } - } - } - int craftIndex = 0; - for (final ItemStack is : stage.getItemsToCraft()) { - int crafted = 0; - if (data.itemsCrafted.size() > craftIndex) { - crafted = data.itemsCrafted.get(craftIndex).getAmount(); - } - final int amt = is.getAmount(); - final ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - craftIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "craftItem"); - if (message.contains("")) { - message = message.replace("", "" + color + crafted + "/" + is.getAmount()); - } else { - // Legacy - message += color + ": " + crafted + "/" + is.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !is.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments()); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(is))); - } - craftIndex++; - } - int smeltIndex = 0; - for (final ItemStack is : stage.getItemsToSmelt()) { - int smelted = 0; - if (data.itemsSmelted.size() > smeltIndex) { - smelted = data.itemsSmelted.get(smeltIndex).getAmount(); - } - final int amt = is.getAmount(); - final ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - smeltIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "smeltItem"); - if (message.contains("")) { - message = message.replace("", "" + color + smelted + "/" + is.getAmount()); - } else { - // Legacy - message += color + ": " + smelted + "/" + is.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !is.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments()); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(is))); - } - smeltIndex++; - } - int enchantIndex = 0; - for (final ItemStack is : stage.getItemsToEnchant()) { - int enchanted = 0; - if (data.itemsEnchanted.size() > enchantIndex) { - enchanted = data.itemsEnchanted.get(enchantIndex).getAmount(); - } - final int amt = is.getAmount(); - final ChatColor color = enchanted < amt ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - enchantIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "enchItem"); - if (message.contains("")) { - message = message.replace("", "" + color + enchanted + "/" + is.getAmount()); - } else { - // Legacy - message += color + ": " + enchanted + "/" + is.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && is.hasItemMeta()) { - // Bukkit version is 1.9+ - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments(), is.getItemMeta()); - } else if (getSettings().canTranslateNames() && !is.hasItemMeta() - && Material.getMaterial("LINGERING_POTION") == null) { - // Bukkit version is below 1.9 - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments()); - } else { - if (is.getEnchantments().isEmpty()) { - quester.sendMessage(message.replace("", ItemUtil.getName(is)) - .replace("", "") - .replace("", "") - .replaceAll("\\s+", " ")); - } else { - for (final Entry e : is.getEnchantments().entrySet()) { - quester.sendMessage(message.replace("", ItemUtil.getName(is)) - .replace("", ItemUtil.getPrettyEnchantmentName(e.getKey())) - .replace("", RomanNumeral.getNumeral(e.getValue()))); - } - } - } - enchantIndex++; - } - int brewIndex = 0; - for (final ItemStack is : stage.getItemsToBrew()) { - int brewed = 0; - if (data.itemsBrewed.size() > brewIndex) { - brewed = data.itemsBrewed.get(brewIndex).getAmount(); - } - final int amt = is.getAmount(); - final ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - brewIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "brewItem"); - if (message.contains("")) { - message = message.replace("", "" + color + brewed + "/" + is.getAmount()); - } else { - // Legacy - message += color + ": " + brewed + "/" + is.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && is.hasItemMeta()) { - // Bukkit version is 1.9+ - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments(), is.getItemMeta()); - } else if (getSettings().canTranslateNames() && !is.hasItemMeta() - && Material.getMaterial("LINGERING_POTION") == null) { - // Bukkit version is below 1.9 - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments()); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(is))); - } - brewIndex++; - } - int consumeIndex = 0; - for (final ItemStack is : stage.getItemsToConsume()) { - int consumed = 0; - if (data.itemsConsumed.size() > consumeIndex) { - consumed = data.itemsConsumed.get(consumeIndex).getAmount(); - } - final int amt = is.getAmount(); - final ChatColor color = consumed < amt ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - consumeIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "consumeItem"); - if (message.contains("")) { - message = message.replace("", "" + color + consumed + "/" + is.getAmount()); - } else { - // Legacy - message += color + ": " + consumed + "/" + is.getAmount(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && is.hasItemMeta()) { - // Bukkit version is 1.9+ - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments(), is.getItemMeta()); - } else if (getSettings().canTranslateNames() && !is.hasItemMeta() - && Material.getMaterial("LINGERING_POTION") == null) { - // Bukkit version is below 1.9 - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments()); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(is))); - } - consumeIndex++; - } - int deliverIndex = 0; - for (final ItemStack is : stage.getItemsToDeliver()) { - int delivered = 0; - if (data.itemsDelivered.size() > deliverIndex) { - delivered = data.itemsDelivered.get(deliverIndex).getAmount(); - } - final int toDeliver = is.getAmount(); - final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex); - final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - deliverIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "deliver") - .replace("", depends.getNpcName(npc)); - if (message.contains("")) { - message = message.replace("", "" + color + delivered + "/" + toDeliver); - } else { - // Legacy - message += color + ": " + delivered + "/" + toDeliver; - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames() && !is.hasItemMeta()) { - localeManager.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), - is.getEnchantments()); - } else { - quester.sendMessage(message.replace("", ItemUtil.getName(is))); - } - deliverIndex++; - } - int interactIndex = 0; - for (final UUID uuid : stage.getNpcsToInteract()) { - boolean interacted = false; - if (data.npcsInteracted.size() > interactIndex) { - interacted = data.npcsInteracted.get(interactIndex); - } - final ChatColor color = !interacted ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - interactIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "talkTo") - .replace("", depends.getNpcName(uuid)); - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - quester.sendMessage(message); - interactIndex++; - } - int npcKillIndex = 0; - for (final UUID uuid : stage.getNpcsToKill()) { - int npcKilled = 0; - if (data.npcsNumKilled.size() > npcKillIndex) { - npcKilled = data.npcsNumKilled.get(npcKillIndex); - } - final int toNpcKill = stage.getNpcNumToKill().get(npcKillIndex); - final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - npcKillIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "kill"); - if (message.contains("")) { - message = message.replace("", depends.getNpcName(uuid)); - } else { - message += " " + depends.getNpcName(uuid); - } - if (message.contains("")) { - message = message.replace("", "" + color + npcKilled + "/" + toNpcKill); - } else { - // Legacy - message += color + ": " + npcKilled + "/" + toNpcKill; - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - quester.sendMessage(message); - npcKillIndex++; - } - int mobKillIndex = 0; - for (final EntityType e : stage.getMobsToKill()) { - int mobKilled = 0; - if (data.mobNumKilled.size() > mobKillIndex) { - mobKilled = data.mobNumKilled.get(mobKillIndex); - } - final int toMobKill = stage.getMobNumToKill().get(mobKillIndex); - final ChatColor color = mobKilled < toMobKill ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - mobKillIndex++; - continue; - } - String message = color + "- "; - if (stage.getLocationsToKillWithin().isEmpty()) { - message += Lang.get(quester.getPlayer(), "kill"); - if (message.contains("")) { - message = message.replace("", "" + color + mobKilled + "/" + toMobKill); - } else { - // Legacy - message += ChatColor.AQUA + " " + color + ": " + mobKilled + "/" + toMobKill; - } - } else { - message += Lang.get(quester.getPlayer(), "killAtLocation").replace("", - stage.getKillNames().get(stage.getMobsToKill().indexOf(e))); - if (message.contains("")) { - message = message.replace("", "" + color + mobKilled + "/" + toMobKill); - } else { - message += color + ": " + mobKilled + "/" + toMobKill; - } - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - if (getSettings().canTranslateNames()) { - localeManager.sendMessage(quester.getPlayer(), message, e, null); - } else { - quester.sendMessage(message.replace("", MiscUtil.getProperMobName(e))); - } - mobKillIndex++; - } - int tameIndex = 0; - for (final int toTame : stage.getMobNumToTame()) { - int tamed = 0; - if (data.mobsTamed.size() > tameIndex) { - tamed = data.mobsTamed.get(tameIndex); - } - final ChatColor color = tamed < toTame ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - tameIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "tame"); - if (!message.contains("")) { - message += " "; - } - if (message.contains("")) { - message = message.replace("", "" + color + tamed + "/" + toTame); - } else { - // Legacy - message += color + ": " + tamed + "/" + toTame; - } - if (getSettings().canTranslateNames()) { - localeManager.sendMessage(quester.getPlayer(), message, stage.getMobsToTame().get(tameIndex), null); - } else { - quester.sendMessage(message.replace("", - MiscUtil.getProperMobName(stage.getMobsToTame().get(tameIndex)))); - } - tameIndex++; - } - if (stage.getFishToCatch() != null) { - final ChatColor color = data.getFishCaught() < stage.getFishToCatch() ? ChatColor.GREEN : ChatColor.GRAY; - if (settings.canShowCompletedObjs() - || (!settings.canShowCompletedObjs() && color.equals(ChatColor.GREEN))) { - String message = color + "- " + Lang.get(quester.getPlayer(), "catchFish"); - if (message.contains("")) { - message = message.replace("", "" + color + data.getFishCaught() + "/" + stage.getFishToCatch()); - } else { - // Legacy - message += color + ": " + data.getFishCaught() + "/" + stage.getFishToCatch(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - quester.sendMessage(message); - } - } - if (stage.getCowsToMilk() != null) { - final ChatColor color = data.getCowsMilked() < stage.getCowsToMilk() ? ChatColor.GREEN : ChatColor.GRAY; - if (settings.canShowCompletedObjs() - || (!settings.canShowCompletedObjs() && color.equals(ChatColor.GREEN))) { - String message = color + "- " + Lang.get(quester.getPlayer(), "milkCow"); - if (message.contains("")) { - message = message.replace("", "" + color + data.getCowsMilked() + "/" + stage.getCowsToMilk()); - } else { - // Legacy - message += color + ": " + data.getCowsMilked() + "/" + stage.getCowsToMilk(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - quester.sendMessage(message); - } - } - int shearIndex = 0; - for (final int toShear : stage.getSheepNumToShear()) { - int sheared = 0; - if (data.sheepSheared.size() > shearIndex) { - sheared = data.sheepSheared.get(shearIndex); - } - final ChatColor color = sheared < toShear ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - shearIndex++; - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "shearSheep"); - message = message.replace("", MiscUtil.getPrettyDyeColorName(stage.getSheepToShear() - .get(shearIndex))); - if (message.contains("")) { - message = message.replace("", "" + color + sheared + "/" + toShear); - } else { - // Legacy - message += color + ": " + sheared + "/" + toShear; - } - quester.sendMessage(message); - shearIndex++; - } - if (stage.getPlayersToKill() != null) { - final ChatColor color = data.getPlayersKilled() < stage.getPlayersToKill() ? ChatColor.GREEN - : ChatColor.GRAY; - if (settings.canShowCompletedObjs() - || (!settings.canShowCompletedObjs() && color.equals(ChatColor.GREEN))) { - String message = color + "- " + Lang.get(quester.getPlayer(), "killPlayer"); - if (message.contains("")) { - message = message.replace("", "" + color + data.getPlayersKilled() + "/" - + stage.getPlayersToKill()); - } else { - // Legacy - message += color + ": " + data.getPlayersKilled() + "/" + stage.getPlayersToKill(); - } - if (depends.getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); - } - quester.sendMessage(message); - } - } - for (int i = 0 ; i < stage.getLocationsToReach().size(); i++) { - if (i < data.locationsReached.size()) { - final ChatColor color = !data.locationsReached.get(i) ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - continue; - } - String message = color + "- " + Lang.get(quester.getPlayer(), "goTo"); - message = message.replace("", stage.getLocationNames().get(i)); - quester.sendMessage(message); - } - } - int passIndex = 0; - for (final String s : stage.getPasswordDisplays()) { - boolean said = false; - if (data.passwordsSaid.size() > passIndex) { - said = data.passwordsSaid.get(passIndex); - } - final ChatColor color = !said ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - passIndex++; - continue; - } - final String message = color + "- " + s; - quester.sendMessage(message); - passIndex++; - } - int customIndex = 0; - for (final ICustomObjective co : stage.getCustomObjectives()) { - int cleared = 0; - if (data.customObjectiveCounts.size() > customIndex) { - cleared = data.customObjectiveCounts.get(customIndex); - } - final int toClear = stage.getCustomObjectiveCounts().get(customIndex); - final ChatColor color = cleared < toClear ? ChatColor.GREEN : ChatColor.GRAY; - if (!settings.canShowCompletedObjs() && color.equals(ChatColor.GRAY)) { - customIndex++; - continue; - } - String message = color + "- " + co.getDisplay(); - for (final Entry prompt : co.getData()) { - final String replacement = "%" + prompt.getKey() + "%"; - try { - for (final Entry e : stage.getCustomObjectiveData()) { - if (e.getKey().equals(prompt.getKey())) { - if (message.contains(replacement)) { - message = message.replace(replacement, ((String) e.getValue())); - } - } - } - } catch (final NullPointerException ne) { - getLogger().severe("Unable to fetch display for " + co.getName() + " on " - + quest.getName()); - ne.printStackTrace(); - } - } - if (co.canShowCount()) { - message = message.replace("%count%", cleared + "/" + toClear); - } - quester.sendMessage(ConfigUtil.parseString(message)); - customIndex++; - } - } - - /** - * Show all of a player's conditions for the current stage of a quest.

- * - * @deprecated Use {@link Quester#showCurrentConditions(IQuest, IQuester)} - * @param quest The quest to get current stage objectives of - * @param quester The player to show current stage objectives to - */ - public void showConditions(final IQuest quest, final IQuester quester) { - if (quest == null) { - getLogger().severe("Quest was null when getting conditions for " + quester.getLastKnownName()); - return; - } - if (quester.getQuestData(quest) == null) { - getLogger().warning("Quest data was null when showing conditions for " + quest.getName()); - return; - } - final IStage stage = quester.getCurrentStage(quest); - if (stage == null) { - getLogger().warning("Current stage was null when showing conditions for " + quest.getName()); - return; - } - final ICondition c = stage.getCondition(); - if (c != null && stage.getObjectiveOverrides().isEmpty()) { - quester.sendMessage(ChatColor.LIGHT_PURPLE + Lang.get("stageEditorConditions")); - if (!c.getEntitiesWhileRiding().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorRideEntity")); - for (final String e : c.getEntitiesWhileRiding()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(e); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getNpcsWhileRiding().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorRideNPC")); - for (final UUID u : c.getNpcsWhileRiding()) { - if (getDependencies().getCitizens() != null) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(CitizensAPI.getNPCRegistry() - .getByUniqueId(u).getName()); - } else { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(u); - } - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getPermissions().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorPermissions")); - for (final String e : c.getPermissions()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(e); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getItemsWhileHoldingMainHand().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorItemsInMainHand")); - for (final ItemStack is : c.getItemsWhileHoldingMainHand()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(ItemUtil.getPrettyItemName(is - .getType().name())); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getItemsWhileWearing().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorItemsWear")); - for (final ItemStack is : c.getItemsWhileWearing()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(ItemUtil.getPrettyItemName(is - .getType().name())); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getWorldsWhileStayingWithin().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorStayWithinWorld")); - for (final String w : c.getWorldsWhileStayingWithin()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(w); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (c.getTickStartWhileStayingWithin() > -1 && c.getTickEndWhileStayingWithin() > -1) { - final StringBuilder msg = new StringBuilder("- ").append(Lang.get("conditionEditorStayWithinTicks")); - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(c.getTickStartWhileStayingWithin()) - .append(" - ").append(c.getTickEndWhileStayingWithin()); - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getBiomesWhileStayingWithin().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorStayWithinBiome")); - for (final String b : c.getBiomesWhileStayingWithin()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(MiscUtil - .snakeCaseToUpperCamelCase(b)); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getRegionsWhileStayingWithin().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorStayWithinRegion")); - for (final String r : c.getRegionsWhileStayingWithin()) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(r); - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } else if (!c.getPlaceholdersCheckIdentifier().isEmpty()) { - final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorCheckPlaceholder")); - int index = 0; - for (final String r : c.getPlaceholdersCheckIdentifier()) { - if (c.getPlaceholdersCheckValue().size() > index) { - msg.append(ChatColor.AQUA).append("\n \u2515 ").append(r).append(ChatColor.GRAY) - .append(" = ").append(ChatColor.AQUA).append(c.getPlaceholdersCheckValue() - .get(index)); - } - index++; - } - quester.sendMessage(ChatColor.YELLOW + msg.toString()); - } - } - } - - /** - * Show the player a list of their available quests - * - * @deprecated Use {@link Quester#listQuests(IQuester, int)} - * @param quester Quester to show the list - * @param page Page to display, with 7 quests per page - */ - public void listQuests(final IQuester quester, final int page) { - // Although we could copy the quests list to a new object, we instead opt to - // duplicate code to improve efficiency if ignore-locked-quests is set to 'false' - final int rows = 7; - final Player player = quester.getPlayer(); - if (getSettings().canIgnoreLockedQuests()) { - final LinkedList available = new LinkedList<>(); - for (final IQuest q : quests) { - if (!quester.getCompletedQuestsTemp().contains(q)) { - if (q.testRequirements(player)) { - available.add(q); - } - } else if (q.getPlanner().hasCooldown() && quester.getRemainingCooldown(q) < 0) { - if (q.testRequirements(player)) { - available.add(q); - } - } - } - if ((available.size() + rows) <= (page * rows) || available.size() == 0) { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "pageNotExist")); - } else { - Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle")); - int fromOrder = (page - 1) * rows; - final List subQuests; - if (available.size() >= (fromOrder + rows)) { - subQuests = available.subList((fromOrder), (fromOrder + rows)); - } else { - subQuests = available.subList((fromOrder), available.size()); - } - fromOrder++; - for (final IQuest q : subQuests) { - if (quester.canAcceptOffer(q, false)) { - quester.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); - } else { - quester.sendMessage(ChatColor.GRAY + Integer.toString(fromOrder) + ". " + q.getName()); - } - fromOrder++; - } - final int numPages = (int) Math.ceil(((double) available.size()) / ((double) rows)); - String msg = Lang.get(player, "pageFooter"); - msg = msg.replace("", String.valueOf(page)); - msg = msg.replace("", String.valueOf(numPages)); - Lang.send(player, ChatColor.GOLD + msg); - } - } else { - if ((quests.size() + rows) <= (page * rows) || quests.size() == 0) { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "pageNotExist")); - } else { - Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle")); - int fromOrder = (page - 1) * rows; - final List subQuests; - if (quests.size() >= (fromOrder + rows)) { - subQuests = new LinkedList<>(getLoadedQuests()).subList((fromOrder), (fromOrder + rows)); - } else { - subQuests = new LinkedList<>(getLoadedQuests()).subList((fromOrder), quests.size()); - } - fromOrder++; - for (final IQuest q : subQuests) { - if (quester.canAcceptOffer(q, false)) { - Lang.send(player, ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); - } else { - Lang.send(player, ChatColor.GRAY + Integer.toString(fromOrder) + ". " + q.getName()); - } - fromOrder++; - } - final int numPages = (int) Math.ceil(((double) quests.size()) / ((double) rows)); - String msg = Lang.get(player, "pageFooter"); - msg = msg.replace("", String.valueOf(page)); - msg = msg.replace("", String.valueOf(numPages)); - Lang.send(player, ChatColor.GOLD + msg); - } - } - } - - /** - * Reload quests, actions, conditions, config settings, lang, modules, and player data - */ - public void reload(final ReloadCallback callback) { - if (loading) { - getLogger().warning(ChatColor.YELLOW + Lang.get("errorLoading")); - return; - } - loading = true; - reloadConfig(); - Bukkit.getScheduler().runTaskAsynchronously(this, () -> { - try { - getStorage().saveOfflineQuesters().get(); - Lang.clear(); - settings.init(); - Lang.init(Quests.this, settings.getLanguage()); - quests.clear(); - actions.clear(); - conditions.clear(); - loadQuests(); - loadActions(); - loadConditions(); - for (final IQuester quester : questers) { - final IQuester loaded = getStorage().loadQuester(quester.getUUID()).get(); - for (final IQuest quest : loaded.getCurrentQuestsTemp().keySet()) { - loaded.checkQuest(quest); - } - } - loadModules(); - importQuests(); - finishLoading(callback, true, null); - } catch (final Exception e) { - finishLoading(callback, false, e); - } - loading = false; - }); - } - - /** - * Execute finishing task and print provided exception - * - * @param callback Callback to execute - * @param result Result to pass through callback - * @param exception Exception to print, or null - */ - private void finishLoading(final ReloadCallback callback, boolean result, final Exception exception) { - if (exception != null) { - exception.printStackTrace(); - } - if (callback != null) { - Bukkit.getScheduler().runTask(Quests.this, () -> { - loading = false; - callback.execute(result); - }); - } - } - - /** - * Load quests from file - */ - public void loadQuests() { - boolean needsSaving = false; - FileConfiguration config = null; - final File file = new File(this.getDataFolder(), "quests.yml"); - try { - config = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), - StandardCharsets.UTF_8)); - } catch (final IOException e) { - e.printStackTrace(); - } - if (config != null) { - final ConfigurationSection questsSection; - if (config.contains("quests")) { - questsSection = config.getConfigurationSection("quests"); - } else { - questsSection = config.createSection("quests"); - needsSaving = true; - } - if (questsSection == null) { - getLogger().severe("Missing 'quests' section marker within quests.yml, canceled loading"); - return; - } - for (final String questKey : questsSection.getKeys(false)) { - try { - final IQuest quest = loadQuest(config, questKey); - if (config.contains("quests." + questKey + ".requirements")) { - loadQuestRequirements(config, questsSection, quest, questKey); - } - if (config.contains("quests." + questKey + ".planner")) { - loadQuestPlanner(config, quest, questKey); - } - if (config.contains("quests." + questKey + ".options")) { - loadQuestOptions(config, quest, questKey); - } - quest.setPlugin(this); - loadQuestStages(quest, config, questKey); - loadQuestRewards(config, quest, questKey); - quests.add(quest); - if (needsSaving) { - try { - config.save(file); - } catch (final IOException e) { - getLogger().log(Level.SEVERE, "Failed to save Quest \"" + questKey + "\""); - e.printStackTrace(); - } - } - } catch (final QuestFormatException | StageFormatException | ActionFormatException - | ConditionFormatException e) { - e.printStackTrace(); - } - } - } else { - getLogger().severe("Unable to load quests.yml"); - } - } - - @SuppressWarnings("deprecation") - private IQuest loadQuest(final FileConfiguration config, final String questKey) throws QuestFormatException, - ActionFormatException { - final IQuest quest = new Quest(this); - quest.setId(questKey); - if (config.contains("quests." + questKey + ".name")) { - quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest)); - } else { - throw new QuestFormatException("name is missing", questKey); - } - if (config.contains("quests." + questKey + ".ask-message")) { - quest.setDescription(ConfigUtil.parseString(config.getString("quests." + questKey - + ".ask-message"), quest)); - } else { - throw new QuestFormatException("ask-message is missing", questKey); - } - if (config.contains("quests." + questKey + ".finish-message")) { - quest.setFinished(ConfigUtil.parseString(config.getString("quests." + questKey - + ".finish-message"), quest)); - } else { - throw new QuestFormatException("finish-message is missing", questKey); - } - if (config.contains("quests." + questKey + ".npc-giver-uuid")) { - final UUID uuid = UUID.fromString(Objects.requireNonNull(config.getString("quests." + questKey - + ".npc-giver-uuid"))); - quest.setNpcStart(uuid); - questNpcUuids.add(uuid); - } else if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) { - // Legacy - final int id = config.getInt("quests." + questKey + ".npc-giver-id"); - if (CitizensAPI.getNPCRegistry().getById(id) != null) { - final NPC npc = CitizensAPI.getNPCRegistry().getById(id); - quest.setNpcStart(npc.getUniqueId()); - questNpcUuids.add(npc.getUniqueId()); - } else { - throw new QuestFormatException("npc-giver-id has invalid NPC ID " + id, questKey); - } - } - if (config.contains("quests." + questKey + ".block-start")) { - final String blockStart = config.getString("quests." + questKey + ".block-start"); - if (blockStart != null) { - final Location location = ConfigUtil.getLocation(blockStart); - if (location != null) { - quest.setBlockStart(location); - } else { - throw new QuestFormatException("block-start has invalid location", questKey); - } - } else { - throw new QuestFormatException("block-start has invalid location format", questKey); - } - } - if (config.contains("quests." + questKey + ".region") - && getDependencies().getWorldGuardApi() != null) { - final String region = config.getString("quests." + questKey + ".region"); - if (region != null) { - boolean exists = false; - for (final World world : getServer().getWorlds()) { - if (world != null && getDependencies().getWorldGuardApi().getRegionManager(world) != null) { - if (Objects.requireNonNull(getDependencies().getWorldGuardApi().getRegionManager(world)) - .hasRegion(region)) { - quest.setRegionStart(region); - exists = true; - break; - } - } - } - if (!exists) { - throw new QuestFormatException("region has invalid WorldGuard region name", questKey); - } - } else { - throw new QuestFormatException("region has invalid WorldGuard region", questKey); - } - } - if (config.contains("quests." + questKey + ".gui-display")) { - ItemStack stack = config.getItemStack("quests." + questKey + ".gui-display"); - if (stack == null) { - // Legacy - final String item = config.getString("quests." + questKey + ".gui-display"); - try { - stack = ItemUtil.readItemStack(item); - } catch (final Exception e) { - throw new QuestFormatException("items has invalid formatting for " + item, questKey); - } - } - if (stack != null) { - quest.setGUIDisplay(stack); - } else { - throw new QuestFormatException("gui-display has invalid item format", questKey); - } - } - if (config.contains("quests." + questKey + ".redo-delay")) { - // Legacy - if (config.getInt("quests." + questKey + ".redo-delay", -999) != -999) { - quest.getPlanner().setCooldown(config.getInt("quests." + questKey + ".redo-delay") * 1000L); - } else { - throw new QuestFormatException("redo-delay is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".action")) { - final IAction action = loadAction(config.getString("quests." + questKey + ".action")); - if (action != null) { - quest.setInitialAction(action); - } else { - throw new QuestFormatException("action failed to load", questKey); - } - } else if (config.contains("quests." + questKey + ".event")) { - final IAction action = loadAction(config.getString("quests." + questKey + ".event")); - if (action != null) { - quest.setInitialAction(action); - } else { - throw new QuestFormatException("action failed to load", questKey); - } - } - return quest; - } - - @SuppressWarnings({"unchecked", "deprecation"}) - private void loadQuestRewards(final FileConfiguration config, final IQuest quest, final String questKey) - throws QuestFormatException { - final Rewards rewards = quest.getRewards(); - if (config.contains("quests." + questKey + ".rewards.items")) { - final LinkedList temp = new LinkedList<>(); - final List stackList = (List) config.get("quests." + questKey + ".rewards.items"); - if (ConfigUtil.checkList(stackList, ItemStack.class)) { - for (final ItemStack stack : stackList) { - if (stack != null) { - temp.add(stack); - } - } - } else { - // Legacy - if (ConfigUtil.checkList(stackList, String.class)) { - final List items = config.getStringList("quests." + questKey + ".rewards.items"); - for (final String item : items) { - try { - final ItemStack stack = ItemUtil.readItemStack(item); - if (stack != null) { - temp.add(stack); - } - } catch (final Exception e) { - throw new QuestFormatException("Reward items has invalid formatting for " + item, questKey); - } - } - } else { - throw new QuestFormatException("Reward items has invalid formatting", questKey); - } - } - rewards.setItems(temp); - } - if (config.contains("quests." + questKey + ".rewards.money")) { - if (config.getInt("quests." + questKey + ".rewards.money", -999) != -999) { - rewards.setMoney(config.getInt("quests." + questKey + ".rewards.money")); - } else { - throw new QuestFormatException("Reward money is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".rewards.quest-points")) { - if (config.getInt("quests." + questKey + ".rewards.quest-points", -999) != -999) { - rewards.setQuestPoints(config.getInt("quests." + questKey + ".rewards.quest-points")); - } else { - throw new QuestFormatException("Reward quest-points is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".rewards.exp")) { - if (config.getInt("quests." + questKey + ".rewards.exp", -999) != -999) { - rewards.setExp(config.getInt("quests." + questKey + ".rewards.exp")); - } else { - throw new QuestFormatException("Reward exp is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".rewards.commands")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.commands"), String.class)) { - rewards.setCommands(config.getStringList("quests." + questKey + ".rewards.commands")); - } else { - throw new QuestFormatException("Reward commands is not a list of commands", questKey); - } - } - if (config.contains("quests." + questKey + ".rewards.commands-override-display")) { - // Legacy - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.commands-override-display"), - String.class)) { - rewards.setCommandsOverrideDisplay(config.getStringList("quests." + questKey - + ".rewards.commands-override-display")); - } else { - throw new QuestFormatException("Reward commands-override-display is not a list of strings", questKey); - } - } - if (config.contains("quests." + questKey + ".rewards.permissions")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.permissions"), String.class)) { - rewards.setPermissions(config.getStringList("quests." + questKey + ".rewards.permissions")); - } else { - throw new QuestFormatException("Reward permissions is not a list of permissions", questKey); - } - } - if (config.contains("quests." + questKey + ".rewards.permission-worlds")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey - + ".rewards.permission-worlds"), String.class)) { - rewards.setPermissionWorlds(config.getStringList("quests." + questKey + ".rewards.permission-worlds")); - } else { - throw new QuestFormatException("Reward permissions is not a list of worlds", questKey); - } - } - if (depends.isPluginAvailable("mcMMO")) { - if (config.contains("quests." + questKey + ".rewards.mcmmo-skills")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.mcmmo-skills"), - String.class)) { - if (config.contains("quests." + questKey + ".rewards.mcmmo-levels")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.mcmmo-levels"), - Integer.class)) { - for (final String skill : config.getStringList("quests." + questKey - + ".rewards.mcmmo-skills")) { - if (depends.getMcmmoClassic() == null) { - throw new QuestFormatException("Reward mcMMO not found for mcmmo-skills", questKey); - } else if (Quests.getMcMMOSkill(skill) == null) { - throw new QuestFormatException("Reward mcmmo-skills has invalid skill name " - + skill, questKey); - } - } - rewards.setMcmmoSkills(config.getStringList("quests." + questKey - + ".rewards.mcmmo-skills")); - rewards.setMcmmoAmounts(config.getIntegerList("quests." + questKey - + ".rewards.mcmmo-levels")); - } else { - throw new QuestFormatException("Reward mcmmo-levels is not a list of numbers", questKey); - } - } else { - throw new QuestFormatException("Reward mcmmo-levels is missing!", questKey); - } - } else { - throw new QuestFormatException("Reward mcmmo-skills is not a list of mcMMO skill names", questKey); - } - } - } - if (depends.isPluginAvailable("Heroes")) { - if (config.contains("quests." + questKey + ".rewards.heroes-exp-classes")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.heroes-exp-classes"), - String.class)) { - if (config.contains("quests." + questKey + ".rewards.heroes-exp-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.heroes-exp-amounts"), - Double.class)) { - for (final String heroClass : config.getStringList("quests." + questKey - + ".rewards.heroes-exp-classes")) { - if (depends.getHeroes() == null) { - throw new QuestFormatException("Heroes not found for heroes-exp-classes", questKey); - } else if (depends.getHeroes().getClassManager().getClass(heroClass) == null) { - throw new QuestFormatException("Reward heroes-exp-classes has invalid class name " - + heroClass, questKey); - } - } - rewards.setHeroesClasses(config.getStringList("quests." + questKey - + ".rewards.heroes-exp-classes")); - rewards.setHeroesAmounts(config.getDoubleList("quests." + questKey - + ".rewards.heroes-exp-amounts")); - } else { - throw new QuestFormatException("Reward heroes-exp-amounts is not a list of decimal numbers", - questKey); - } - } else { - throw new QuestFormatException("Reward heroes-exp-amounts is missing", questKey); - } - } else { - throw new QuestFormatException("Reward heroes-exp-classes is not a list of Heroes classes", - questKey); - } - } - } - if (depends.isPluginAvailable("Parties")) { - if (config.contains("quests." + questKey + ".rewards.parties-experience")) { - if (config.getInt("quests." + questKey + ".rewards.parties-experience", -999) != -999) { - rewards.setPartiesExperience(config.getInt("quests." + questKey + ".rewards.parties-experience")); - } else { - throw new QuestFormatException("Reward parties-experience is not a number", questKey); - } - } - } - if (config.contains("quests." + questKey + ".rewards.phat-loots")) { - throw new QuestFormatException("PhatLoots support has been removed. Use the module instead!", questKey); - } - if (config.contains("quests." + questKey + ".rewards.details-override")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey - + ".rewards.details-override"), String.class)) { - rewards.setDetailsOverride(config.getStringList("quests." + questKey + ".rewards.details-override")); - } else { - throw new QuestFormatException("Reward details-override is not a list of strings", questKey); - } - } - } - - @SuppressWarnings({ "unchecked", "deprecation" }) - private void loadQuestRequirements(final FileConfiguration config, final ConfigurationSection questsSection, - final IQuest quest, final String questKey) throws QuestFormatException { - final Requirements requires = quest.getRequirements(); - if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) { - final Object o = config.get("quests." + questKey + ".requirements.fail-requirement-message"); - if (o instanceof List) { - requires.setDetailsOverride(config.getStringList("quests." + questKey - + ".requirements.fail-requirement-message")); - } else { - // Legacy - final List override = new LinkedList<>(); - override.add((String) o); - requires.setDetailsOverride(override); - } - } - if (config.contains("quests." + questKey + ".requirements.items")) { - final List temp = new LinkedList<>(); - final List stackList = (List) config.get("quests." + questKey - + ".requirements.items"); - if (ConfigUtil.checkList(stackList, ItemStack.class)) { - for (final ItemStack stack : stackList) { - if (stack != null) { - temp.add(stack); - } - } - } else { - // Legacy - final List items = config.getStringList("quests." + questKey + ".requirements.items"); - if (ConfigUtil.checkList(items, String.class)) { - for (final String item : items) { - try { - final ItemStack stack = ItemUtil.readItemStack(item); - if (stack != null) { - temp.add(stack); - } - } catch (final Exception e) { - throw new QuestFormatException("Requirement items has invalid formatting for " + item, - questKey); - } - } - } else { - throw new QuestFormatException("Requirement items has invalid formatting", questKey); - } - } - requires.setItems(temp); - if (config.contains("quests." + questKey + ".requirements.remove-items")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.remove-items"), - Boolean.class)) { - requires.setRemoveItems(config.getBooleanList("quests." + questKey + ".requirements.remove-items")); - } else { - throw new QuestFormatException("Requirement remove-items is not a list of true/false values", - questKey); - } - } else { - throw new QuestFormatException("Requirement remove-items is missing", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.money")) { - if (config.getInt("quests." + questKey + ".requirements.money", -999) != -999) { - requires.setMoney(config.getInt("quests." + questKey + ".requirements.money")); - } else { - throw new QuestFormatException("Requirement money is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.quest-points")) { - if (config.getInt("quests." + questKey + ".requirements.quest-points", -999) != -999) { - requires.setQuestPoints(config.getInt("quests." + questKey + ".requirements.quest-points")); - } else { - throw new QuestFormatException("Requirement quest-points is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.exp")) { - if (config.getInt("quests." + questKey + ".requirements.exp", -999) != -999) { - requires.setExp(config.getInt("quests." + questKey + ".requirements.exp")); - } else { - throw new QuestFormatException("Requirement exp is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.quest-blocks")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.quest-blocks"), - String.class)) { - final List nodes = config.getStringList("quests." + questKey + ".requirements.quest-blocks"); - boolean failed = false; - String failedQuest = "NULL"; - final List temp = new LinkedList<>(); - for (final String node : nodes) { - boolean done = false; - for (final String id : questsSection.getKeys(false)) { - if (id.equals(node)) { - if (getQuestByIdTemp(node) != null) { - temp.add(node); - } else { - throw new QuestFormatException("Requirement quest-blocks has unknown quest ID " - + node + ", manually update it to a valid ID", questKey); - } - done = true; - break; - } - } - if (!done) { - failed = true; - failedQuest = node; - break; - } - } - requires.setBlockQuestIds(temp); - if (failed) { - throw new QuestFormatException("Requirement quest-blocks has invalid quest ID " + failedQuest, - questKey); - } - } else { - throw new QuestFormatException("Requirement quest-blocks is not a list of quest names", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.quests")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.quests"), String.class)) { - final List nodes = config.getStringList("quests." + questKey + ".requirements.quests"); - boolean failed = false; - String failedQuest = "NULL"; - final List temp = new LinkedList<>(); - for (final String node : nodes) { - boolean done = false; - for (final String id : questsSection.getKeys(false)) { - if (id.equals(node)) { - if (getQuestByIdTemp(node) != null) { - temp.add(node); - } else { - throw new QuestFormatException("Requirement quests has unknown quest ID " - + node + ", manually update it to a valid ID", questKey); - } - done = true; - break; - } - } - if (!done) { - failed = true; - failedQuest = node; - break; - } - } - requires.setNeededQuestIds(temp); - if (failed) { - throw new QuestFormatException("Requirement quests has invalid quest ID " - + failedQuest, questKey); - } - } else { - throw new QuestFormatException("Requirement quests is not a list of quest names", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.permissions")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.permissions"), - String.class)) { - requires.setPermissions(config.getStringList("quests." + questKey + ".requirements.permissions")); - } else { - throw new QuestFormatException("Requirement permissions is not a list of permissions", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.mcmmo-skills")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.mcmmo-skills"), - String.class)) { - if (config.contains("quests." + questKey + ".requirements.mcmmo-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".requirements.mcmmo-amounts"), - Integer.class)) { - final List skills = config.getStringList("quests." + questKey - + ".requirements.mcmmo-skills"); - final List amounts = config.getIntegerList("quests." + questKey - + ".requirements.mcmmo-amounts"); - if (skills.size() != amounts.size()) { - throw new QuestFormatException("Requirement mcmmo-skills: and mcmmo-amounts are not the " + - "same size", questKey); - } - requires.setMcmmoSkills(skills); - requires.setMcmmoAmounts(amounts); - } else { - throw new QuestFormatException("Requirement mcmmo-amounts is not a list of numbers", questKey); - } - } else { - throw new QuestFormatException("Requirement mcmmo-amounts is missing", questKey); - } - } else { - throw new QuestFormatException("Requirement mcmmo-skills is not a list of skills", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.heroes-primary-class")) { - final String className = config.getString("quests." + questKey + ".requirements.heroes-primary-class"); - final HeroClass hc = depends.getHeroes().getClassManager().getClass(className); - if (hc != null && hc.isPrimary()) { - requires.setHeroesPrimaryClass(hc.getName()); - } else if (hc != null) { - throw new QuestFormatException("Requirement heroes-primary-class is not a primary Heroes class", - questKey); - } else { - throw new QuestFormatException("Requirement heroes-primary-class has invalid Heroes class", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.heroes-secondary-class")) { - final String className = config.getString("quests." + questKey + ".requirements.heroes-secondary-class"); - final HeroClass hc = depends.getHeroes().getClassManager().getClass(className); - if (hc != null && hc.isSecondary()) { - requires.setHeroesSecondaryClass(hc.getName()); - } else if (hc != null) { - throw new QuestFormatException("Requirement heroes-secondary-class is not a secondary Heroes class", - questKey); - } else { - throw new QuestFormatException("Requirement heroes-secondary-class has invalid Heroes class", questKey); - } - } - if (config.contains("quests." + questKey + ".requirements.details-override")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey - + ".requirements.details-override"), String.class)) { - requires.setDetailsOverride(config.getStringList("quests." + questKey + ".requirements.details-override")); - } else { - throw new QuestFormatException("Requirement details-override is not a list of strings", questKey); - } - } - } - - private void loadQuestPlanner(final FileConfiguration config, final IQuest quest, final String questKey) - throws QuestFormatException { - final Planner pln = quest.getPlanner(); - if (config.contains("quests." + questKey + ".planner.start")) { - pln.setStart(config.getString("quests." + questKey + ".planner.start")); - } - if (config.contains("quests." + questKey + ".planner.end")) { - pln.setEnd(config.getString("quests." + questKey + ".planner.end")); - } - if (config.contains("quests." + questKey + ".planner.repeat")) { - if (config.getInt("quests." + questKey + ".planner.repeat", -999) != -999) { - pln.setRepeat(config.getInt("quests." + questKey + ".planner.repeat") * 1000L); - } else { - throw new QuestFormatException("Requirement repeat is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".planner.cooldown")) { - if (config.getInt("quests." + questKey + ".planner.cooldown", -999) != -999) { - pln.setCooldown(config.getInt("quests." + questKey + ".planner.cooldown") * 1000L); - } else { - throw new QuestFormatException("Requirement cooldown is not a number", questKey); - } - } - if (config.contains("quests." + questKey + ".planner.override")) { - pln.setOverride(config.getBoolean("quests." + questKey + ".planner.override")); - } - } - - private void loadQuestOptions(final FileConfiguration config, final IQuest quest, final String questKey) - throws QuestFormatException { - final Options opts = quest.getOptions(); - if (config.contains("quests." + questKey + ".options.allow-commands")) { - opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands")); - } - if (config.contains("quests." + questKey + ".options.allow-quitting")) { - opts.setAllowQuitting(config.getBoolean("quests." + questKey + ".options.allow-quitting")); - } else if (getConfig().contains("allow-quitting")) { - // Legacy - opts.setAllowQuitting(getConfig().getBoolean("allow-quitting")); - } - if (config.contains("quests." + questKey + ".options.ignore-silk-touch")) { - opts.setIgnoreSilkTouch(config.getBoolean("quests." + questKey + ".options.ignore-silk-touch")); - } - if (config.contains("quests." + questKey + ".options.external-party-plugin")) { - opts.setExternalPartyPlugin(config.getString("quests." + questKey + ".options.external-party-plugin")); - } - if (config.contains("quests." + questKey + ".options.use-parties-plugin")) { - opts.setUsePartiesPlugin(config.getBoolean("quests." + questKey + ".options.use-parties-plugin")); - } - if (config.contains("quests." + questKey + ".options.share-progress-level")) { - opts.setShareProgressLevel(config.getInt("quests." + questKey + ".options.share-progress-level")); - } - if (config.contains("quests." + questKey + ".options.same-quest-only")) { - opts.setShareSameQuestOnly(config.getBoolean("quests." + questKey + ".options.same-quest-only")); - } - if (config.contains("quests." + questKey + ".options.share-distance")) { - opts.setShareDistance(config.getDouble("quests." + questKey + ".options.share-distance")); - } - if (config.contains("quests." + questKey + ".options.handle-offline-players")) { - opts.setHandleOfflinePlayers(config.getBoolean("quests." + questKey + ".options.handle-offline-players")); - } - if (config.contains("quests." + questKey + ".options.ignore-block-replace")) { - opts.setIgnoreBlockReplace(config.getBoolean("quests." + questKey + ".options.ignore-block-replace")); - } - } - - @SuppressWarnings({ "unchecked", "unused", "deprecation" }) - private void loadQuestStages(final IQuest quest, final FileConfiguration config, final String questKey) - throws StageFormatException, ActionFormatException, ConditionFormatException { - final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey - + ".stages.ordered"); - if (questStages == null) { - getLogger().severe(ChatColor.RED + questKey + " must have at least one stage!"); - return; - } - for (final String stage : questStages.getKeys(false)) { - final int stageNum; - try { - stageNum = Integer.parseInt(stage); - } catch (final NumberFormatException e) { - getLogger().severe("IStage key " + stage + "must be a number!"); - continue; - } - final Stage oStage = new Stage(); - List breakNames = new LinkedList<>(); - List breakAmounts = new LinkedList<>(); - List breakDurability = new LinkedList<>(); - List damageNames = new LinkedList<>(); - List damageAmounts = new LinkedList<>(); - List damageDurability = new LinkedList<>(); - List placeNames = new LinkedList<>(); - List placeAmounts = new LinkedList<>(); - List placeDurability = new LinkedList<>(); - List useNames = new LinkedList<>(); - List useAmounts = new LinkedList<>(); - List useDurability = new LinkedList<>(); - List cutNames = new LinkedList<>(); - List cutAmounts = new LinkedList<>(); - List cutDurability = new LinkedList<>(); - final List mobsToKill = new LinkedList<>(); - final List mobNumsToKill = new LinkedList<>(); - final List locationsToKillWithin = new LinkedList<>(); - final List radiiToKillWithin = new LinkedList<>(); - final List areaNames = new LinkedList<>(); - final List itemsToCraft; - final List itemsToSmelt; - final List itemsToEnchant; - final List itemsToBrew; - final List itemsToConsume; - final List npcUuidsToTalkTo; - final List npcIdsToTalkTo; - final List itemsToDeliver; - final List itemDeliveryTargetUuids; - final List itemDeliveryTargetIds; - final List deliveryMessages; - final List npcUuidsToKill; - final List npcIdsToKill; - final List npcAmountsToKill; - // Legacy Denizen script load - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run")) { - if (getDependencies().getDenizenApi().containsScript(config.getString("quests." + questKey - + ".stages.ordered." + stageNum + ".script-to-run"))) { - oStage.setScript(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".script-to-run")); - } else { - throw new StageFormatException("script-to-run is not a valid Denizen script", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".break-block-names"), String.class)) { - breakNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".break-block-names"); - } else { - throw new StageFormatException("break-block-names is not a list of strings", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".break-block-amounts"), Integer.class)) { - breakAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".break-block-amounts"); - } else { - throw new StageFormatException("break-block-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("break-block-amounts is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-durability")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".break-block-durability"), Integer.class)) { - breakDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum - + ".break-block-durability"); - } else { - throw new StageFormatException("break-block-durability is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("break-block-durability is missing", quest, stageNum); - } - } - int breakIndex = 0; - for (final String s : breakNames) { - final ItemStack is; - if (breakIndex < breakDurability.size() && breakDurability.get(breakIndex) != -1) { - is = ItemUtil.processItemStack(s, breakAmounts.get(breakIndex), breakDurability.get(breakIndex)); - } else { - // Legacy - is = ItemUtil.processItemStack(s, breakAmounts.get(breakIndex), (short) 0); - } - if (Material.matchMaterial(s) != null) { - oStage.addBlockToBreak(is); - } else { - throw new StageFormatException("break-block-names has invalid item name " + s, quest, stageNum); - } - breakIndex++; - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-names"), String.class)) { - damageNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-names"); - } else { - throw new StageFormatException("damage-block-names is not a list of strings", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-amounts"), Integer.class)) { - damageAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-amounts"); - } else { - throw new StageFormatException("damage-block-amounts is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("damage-block-amounts is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-durability")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-durability"), Integer.class)) { - damageDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum - + ".damage-block-durability"); - } else { - throw new StageFormatException("damage-block-durability is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("damage-block-durability is missing", quest, stageNum); - } - } - int damageIndex = 0; - for (final String s : damageNames) { - final ItemStack is; - if (damageIndex < damageDurability.size() && damageDurability.get(damageIndex) != -1) { - is = ItemUtil.processItemStack(s, damageAmounts.get(damageIndex), - damageDurability.get(damageIndex)); - } else { - // Legacy - is = ItemUtil.processItemStack(s, damageAmounts.get(damageIndex), (short) 0); - } - if (Material.matchMaterial(s) != null) { - oStage.addBlockToDamage(is); - } else { - throw new StageFormatException("damage-block-names has invalid item name " + s, quest, stageNum); - } - damageIndex++; - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".place-block-names"), String.class)) { - placeNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".place-block-names"); - } else { - throw new StageFormatException("place-block-names is not a list of strings", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".place-block-amounts"), Integer.class)) { - placeAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".place-block-amounts"); - } else { - throw new StageFormatException("place-block-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("place-block-amounts is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-durability")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".place-block-durability"), Integer.class)) { - placeDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum - + ".place-block-durability"); - } else { - throw new StageFormatException("place-block-durability is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("place-block-durability is missing", quest, stageNum); - } - } - int placeIndex = 0; - for (final String s : placeNames) { - final ItemStack is; - if (placeIndex < placeDurability.size() && placeDurability.get(placeIndex) != -1) { - is = ItemUtil.processItemStack(s, placeAmounts.get(placeIndex), placeDurability.get(placeIndex)); - } else { - // Legacy - is = ItemUtil.processItemStack(s, placeAmounts.get(placeIndex), (short) 0); - } - if (Material.matchMaterial(s) != null) { - oStage.addBlockToPlace(is); - } else { - throw new StageFormatException("place-block-names has invalid item name " + s, quest, stageNum); - } - placeIndex++; - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".use-block-names"), String.class)) { - useNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".use-block-names"); - } else { - throw new StageFormatException("use-block-names is not a list of strings", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".use-block-amounts"),Integer.class)) { - useAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".use-block-amounts"); - } else { - throw new StageFormatException("use-block-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("use-block-amounts is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-durability")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".use-block-durability"), Integer.class)) { - useDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum - + ".use-block-durability"); - } else { - throw new StageFormatException("use-block-durability is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("use-block-durability is missing", quest, stageNum); - } - } - int useIndex = 0; - for (final String s : useNames) { - final ItemStack is; - if (useIndex < useDurability.size() && useDurability.get(useIndex) != -1) { - is = ItemUtil.processItemStack(s, useAmounts.get(useIndex), useDurability.get(useIndex)); - } else { - // Legacy - is = ItemUtil.processItemStack(s, useAmounts.get(useIndex), (short) 0); - } - if (Material.matchMaterial(s) != null) { - oStage.addBlockToUse(is); - } else { - throw new StageFormatException("use-block-names has invalid item name " + s, quest, stageNum); - } - useIndex++; - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".cut-block-names"), String.class)) { - cutNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".cut-block-names"); - } else { - throw new StageFormatException("cut-block-names is not a list of strings", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".cut-block-amounts"), Integer.class)) { - cutAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".cut-block-amounts"); - } else { - throw new StageFormatException("cut-block-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("cut-block-amounts is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-durability")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".cut-block-durability"), Integer.class)) { - cutDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum - + ".cut-block-durability"); - } else { - throw new StageFormatException("cut-block-durability is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("cut-block-durability is missing", quest, stageNum); - } - } - int cutIndex = 0; - for (final String s : cutNames) { - final ItemStack is; - if (cutIndex < cutDurability.size() && cutDurability.get(cutIndex) != -1) { - is = ItemUtil.processItemStack(s, cutAmounts.get(cutIndex), cutDurability.get(cutIndex)); - } else { - // Legacy - is = ItemUtil.processItemStack(s, cutAmounts.get(cutIndex), (short) 0); - } - if (Material.matchMaterial(s) != null) { - oStage.addBlockToCut(is); - } else { - throw new StageFormatException("cut-block-names has invalid item name " + s, quest, stageNum); - } - cutIndex++; - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-craft")) { - itemsToCraft = (List) config.get("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-craft"); - if (ConfigUtil.checkList(itemsToCraft, ItemStack.class)) { - for (final ItemStack stack : itemsToCraft) { - if (stack != null) { - oStage.addItemToCraft(stack); - } else { - throw new StageFormatException("items-to-craft has invalid formatting", quest, stageNum); - } - } - } else { - // Legacy - final List items = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-craft"); - if (ConfigUtil.checkList(items, String.class)) { - for (final String item : items) { - final ItemStack is = ItemUtil.readItemStack("" + item); - if (is != null) { - oStage.addItemToCraft(is); - } else { - throw new StageFormatException("Legacy items-to-craft has invalid formatting " - + item, quest, stageNum); - } - } - } else { - throw new StageFormatException("items-to-craft is not formatted properly", quest, stageNum); - } - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-smelt")) { - itemsToSmelt = (List) config.get("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-smelt"); - if (ConfigUtil.checkList(itemsToSmelt, ItemStack.class)) { - for (final ItemStack stack : itemsToSmelt) { - if (stack != null) { - oStage.addItemToSmelt(stack); - } else { - throw new StageFormatException("items-to-smelt has invalid formatting", quest, stageNum); - } - } - } else { - // Legacy - final List items = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-smelt"); - if (ConfigUtil.checkList(items, String.class)) { - for (final String item : items) { - final ItemStack is = ItemUtil.readItemStack("" + item); - if (is != null) { - oStage.addItemToSmelt(is); - } else { - throw new StageFormatException("Legacy items-to-smelt has invalid formatting " - + item, quest, stageNum); - } - } - } else { - throw new StageFormatException("items-to-smelt is not formatted properly", quest, stageNum); - } - } - } - - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-enchant")) { - itemsToEnchant = (List) config.get("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-enchant"); - if (ConfigUtil.checkList(itemsToEnchant, ItemStack.class)) { - for (final ItemStack stack : itemsToEnchant) { - if (stack != null) { - oStage.addItemToEnchant(stack); - } else { - throw new StageFormatException("items-to-enchant has invalid formatting", quest, stageNum); - } - } - } else { - // Legacy - final LinkedList types = new LinkedList<>(); - final LinkedList enchs = new LinkedList<>(); - final LinkedList amts; - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantments")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".enchantments"), String.class)) { - for (final String enchant : config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".enchantments")) { - final Enchantment e = ItemUtil.getEnchantmentFromProperName(enchant); - if (e != null) { - enchs.add(e); - } else { - throw new StageFormatException("enchantments has invalid enchantment " - + enchant, quest, stageNum); - } - } - } else { - throw new StageFormatException("enchantments is not a list of enchantment names", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-item-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".enchantment-item-names"), String.class)) { - for (final String item : config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".enchantment-item-names")) { - if (Material.matchMaterial(item) != null) { - types.add(Material.matchMaterial(item)); - } else { - throw new StageFormatException("enchantment-item-names has invalid item name " - + item, quest, stageNum); - } - } - } else { - throw new StageFormatException("enchantment-item-names has invalid item name", quest, stageNum); - } - } else { - throw new StageFormatException("enchantment-item-names is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".enchantment-amounts"), Integer.class)) { - amts = new LinkedList<>(config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".enchantment-amounts")); - } else { - throw new StageFormatException("enchantment-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("enchantment-amounts is missing", quest, stageNum); - } - if (!enchs.isEmpty() && !types.isEmpty() && !amts.isEmpty()) { - for (int i = 0; i < enchs.size(); i++) { - final ItemStack stack = new ItemStack(types.get(i), amts.get(i)); - stack.addEnchantment(enchs.get(0), 1); - oStage.addItemToEnchant(stack); - } - } - } - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-brew")) { - itemsToBrew = (List) config.get("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-brew"); - if (ConfigUtil.checkList(itemsToBrew, ItemStack.class)) { - for (final ItemStack stack : itemsToBrew) { - if (stack != null) { - oStage.addItemsToBrew(stack); - } else { - throw new StageFormatException("items-to-brew has invalid formatting", quest, stageNum); - } - } - } else { - // Legacy - final List items = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-brew"); - if (ConfigUtil.checkList(items, String.class)) { - for (final String item : items) { - final ItemStack is = ItemUtil.readItemStack("" + item); - if (is != null) { - oStage.addItemsToBrew(is); - } else { - throw new StageFormatException("Legacy items-to-brew has invalid formatting", quest, - stageNum); - } - } - } else { - throw new StageFormatException("items-to-brew has invalid formatting", quest, stageNum); - } - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-consume")) { - itemsToConsume = (List) config.get("quests." + questKey + ".stages.ordered." + stageNum - + ".items-to-consume"); - if (ConfigUtil.checkList(itemsToConsume, ItemStack.class)) { - for (final ItemStack stack : itemsToConsume) { - if (stack != null) { - oStage.addItemToConsume(stack); - } else { - throw new StageFormatException("items-to-consume has invalid formatting", quest, stageNum); - } - } - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk")) { - if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk", -999) - != -999) { - oStage.setCowsToMilk(config.getInt("quests." + questKey + ".stages.ordered." + stageNum - + ".cows-to-milk")); - } else { - throw new StageFormatException("cows-to-milk is not a number", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch")) { - if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch", -999) - != -999) { - oStage.setFishToCatch(config.getInt("quests." + questKey + ".stages.ordered." + stageNum - + ".fish-to-catch")); - } else { - throw new StageFormatException("fish-to-catch is not a number", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill")) { - if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill", -999) - != -999) { - oStage.setPlayersToKill(config.getInt("quests." + questKey + ".stages.ordered." + stageNum - + ".players-to-kill")); - } else { - throw new StageFormatException("players-to-kill is not a number", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-talk-to")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-uuids-to-talk-to"), String.class)) { - npcUuidsToTalkTo = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-uuids-to-talk-to"); - for (final String s : npcUuidsToTalkTo) { - final UUID uuid = UUID.fromString(s); - oStage.addNpcToInteract(uuid); - questNpcUuids.add(uuid); - } - } else { - throw new StageFormatException("npc-uuids-to-talk-to is not a list of numbers", quest, stageNum); - } - } else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-talk-to")) { - // Legacy - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-ids-to-talk-to"), Integer.class)) { - npcIdsToTalkTo = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-ids-to-talk-to"); - for (final int i : npcIdsToTalkTo) { - if (getDependencies().getCitizens() != null) { - final NPC npc = CitizensAPI.getNPCRegistry().getById(i); - if (npc != null) { - final UUID npcUuid = npc.getUniqueId(); - oStage.addNpcToInteract(npcUuid); - questNpcUuids.add(npcUuid); - } else { - throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest, - stageNum); - } - } else { - throw new StageFormatException("Citizens not found for npc-ids-to-talk-to", quest, - stageNum); - } - } - } else { - throw new StageFormatException("npc-ids-to-talk-to is not a list of numbers", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-deliver")) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-uuids")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-delivery-uuids"), String.class)) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum - + ".delivery-messages")) { - itemsToDeliver = (List) config.get("quests." + questKey + ".stages.ordered." - + stageNum + ".items-to-deliver"); - itemDeliveryTargetUuids = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".npc-delivery-uuids"); - deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".delivery-messages"); - int index = 0; - if (ConfigUtil.checkList(itemsToDeliver, ItemStack.class)) { - for (final ItemStack stack : itemsToDeliver) { - if (stack != null) { - final UUID npcUuid = UUID.fromString(itemDeliveryTargetUuids.get(index)); - final String msg = deliveryMessages.size() > index - ? deliveryMessages.get(index) - : deliveryMessages.get(deliveryMessages.size() - 1); - index++; - oStage.addItemToDeliver(stack); - oStage.addItemDeliveryTarget(npcUuid); - oStage.addDeliverMessage(msg); - } - } - } else { - throw new StageFormatException("items-to-deliver has invalid formatting", quest, - stageNum); - } - } - } else { - throw new StageFormatException("npc-delivery-uuids is not a list of numbers", quest, stageNum); - } - } else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-delivery-ids")) { - // Legacy - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-delivery-ids"), Integer.class)) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum - + ".delivery-messages")) { - itemsToDeliver = (List) config.get("quests." + questKey + ".stages.ordered." - + stageNum + ".items-to-deliver"); - itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".npc-delivery-ids"); - deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".delivery-messages"); - int index = 0; - if (ConfigUtil.checkList(itemsToDeliver, ItemStack.class)) { - for (final ItemStack stack : itemsToDeliver) { - if (stack != null) { - final int npcId = itemDeliveryTargetIds.get(index); - final String msg = deliveryMessages.size() > index - ? deliveryMessages.get(index) - : deliveryMessages.get(deliveryMessages.size() - 1); - index++; - if (getDependencies().getCitizens() != null) { - final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId); - if (npc != null) { - oStage.addItemToDeliver(stack); - oStage.addItemDeliveryTarget(npc.getUniqueId()); - oStage.addDeliverMessage(msg); - } else { - throw new StageFormatException("npc-delivery-ids has invalid NPC " + - "ID of " + npcId, quest, stageNum); - } - } else { - throw new StageFormatException( - "Citizens not found for npc-delivery-ids", quest, stageNum); - } - } - } - } else { - throw new StageFormatException("items-to-deliver has invalid formatting", quest, - stageNum); - } - } - } else { - throw new StageFormatException("npc-delivery-ids is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("npc-delivery-uuid is missing", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-uuids-to-kill")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-uuids-to-kill"), String.class)) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-kill-amounts"), Integer.class)) { - npcUuidsToKill = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-uuids-to-kill"); - npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".npc-kill-amounts"); - for (final String s : npcUuidsToKill) { - final UUID npcUuid = UUID.fromString(s); - if (npcAmountsToKill.get(npcUuidsToKill.indexOf(s)) > 0) { - oStage.addNpcToKill(npcUuid); - oStage.addNpcNumToKill(npcAmountsToKill.get(npcUuidsToKill.indexOf(s))); - questNpcUuids.add(npcUuid); - } else { - throw new StageFormatException("npc-kill-amounts is not a positive number", - quest, stageNum); - } - } - } else { - throw new StageFormatException("npc-kill-amounts is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("npc-kill-amounts is missing", quest, stageNum); - } - } - } else if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-kill")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-ids-to-kill"), Integer.class)) { - // Legacy - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-kill-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-kill-amounts"), Integer.class)) { - npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".npc-ids-to-kill"); - npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".npc-kill-amounts"); - for (final int i : npcIdsToKill) { - if (getDependencies().getCitizens() != null) { - final NPC npc = CitizensAPI.getNPCRegistry().getById(i); - if (npc != null) { - if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) { - final UUID npcUuid = npc.getUniqueId(); - oStage.addNpcToKill(npcUuid); - oStage.addNpcNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i))); - questNpcUuids.add(npcUuid); - } else { - throw new StageFormatException("npc-kill-amounts is not a positive number", - quest, stageNum); - } - } else { - throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest, - stageNum); - } - } else { - throw new StageFormatException( - "Citizens not found for npc-ids-to-kill", quest, stageNum); - } - } - } else { - throw new StageFormatException("npc-kill-amounts is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("npc-kill-amounts is missing", quest, stageNum); - } - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-kill")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".mobs-to-kill"), String.class)) { - final List mobNames = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".mobs-to-kill"); - for (final String mob : mobNames) { - final EntityType type = MiscUtil.getProperMobType(mob); - if (type != null) { - mobsToKill.add(type); - } else { - throw new StageFormatException("mobs-to-kill has invalid mob name " + mob, quest, stageNum); - } - } - } else { - throw new StageFormatException("mobs-to-kill is not a list of mob names", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".mob-amounts"), Integer.class)) { - mobNumsToKill.addAll(config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum - + ".mob-amounts")); - } else { - throw new StageFormatException("mob-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("mob-amounts is missing", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-kill")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".locations-to-kill"), String.class)) { - final List locations = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".locations-to-kill"); - for (final String loc : locations) { - if (ConfigUtil.getLocation(loc) != null) { - locationsToKillWithin.add(ConfigUtil.getLocation(loc)); - } else { - throw new StageFormatException("locations-to-kill has invalid formatting " + loc, quest, - stageNum); - } - } - } else { - throw new StageFormatException("locations-to-kill is not a list of locations", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-radii")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".kill-location-radii"), Integer.class)) { - final List radii = config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".kill-location-radii"); - radiiToKillWithin.addAll(radii); - } else { - throw new StageFormatException("kill-location-radii is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("kill-location-radii is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".kill-location-names"), String.class)) { - final List locationNames = config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".kill-location-names"); - areaNames.addAll(locationNames); - } else { - throw new StageFormatException("kill-location-names is not a list of names", quest, stageNum); - } - } else { - throw new StageFormatException("kill-location-names is missing", quest, stageNum); - } - } - for (EntityType mobToKill : mobsToKill) { - oStage.addMobToKill(mobToKill); - } - for (Integer mobNumToKill : mobNumsToKill) { - oStage.addMobNumToKill(mobNumToKill); - } - for (Location locationToKillWithin : locationsToKillWithin) { - oStage.addLocationToKillWithin(locationToKillWithin); - } - for (Integer radiusToKillWithin : radiiToKillWithin) { - oStage.addRadiusToKillWithin(radiusToKillWithin); - } - for (String killName : areaNames) { - oStage.addKillName(killName); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-reach")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".locations-to-reach"), String.class)) { - final List locations = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".locations-to-reach"); - for (final String loc : locations) { - if (ConfigUtil.getLocation(loc) != null) { - oStage.addLocationToReach(ConfigUtil.getLocation(loc)); - } else { - throw new StageFormatException("locations-to-reach has invalid formatting" + loc, quest, - stageNum); - } - } - } else { - throw new StageFormatException("locations-to-reach is not a list of locations", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-radii")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".reach-location-radii"), Integer.class)) { - final List radii = config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".reach-location-radii"); - for (Integer radius : radii) { - oStage.addRadiusToReachWithin(radius); - } - } else { - throw new StageFormatException("reach-location-radii is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("reach-location-radii is missing", quest, stageNum); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-names")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".reach-location-names"), String.class)) { - final List locationNames = config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".reach-location-names"); - for (String locationName : locationNames) { - oStage.addLocationName(locationName); - } - } else { - throw new StageFormatException("reach-location-names is not a list of names", quest, stageNum); - } - } else { - throw new StageFormatException("reach-location-names is missing", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-tame")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".mobs-to-tame"), String.class)) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-tame-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".mob-tame-amounts"), Integer.class)) { - final List mobs = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".mobs-to-tame"); - final List mobAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." - + stageNum + ".mob-tame-amounts"); - for (final String mob : mobs) { - final EntityType type = MiscUtil.getProperMobType(mob); - if (type != null) { - final Class ec = type.getEntityClass(); - if (ec != null && Tameable.class.isAssignableFrom(ec)) { - oStage.addMobToTame(type); - oStage.addMobNumToTame(mobAmounts.get(mobs.indexOf(mob))); - } else { - throw new StageFormatException("mobs-to-tame has invalid tameable mob " + mob, - quest, stageNum); - } - } else { - throw new StageFormatException("mobs-to-tame has invalid mob name " + mob, quest, stageNum); - } - } - } else { - throw new StageFormatException("mob-tame-amounts is not a list of numbers", quest, - stageNum); - } - } else { - throw new StageFormatException("mob-tame-amounts is missing", quest, stageNum); - } - } else { - throw new StageFormatException("mobs-to-tame is not a list of mob names", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-to-shear")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".sheep-to-shear"), String.class)) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-amounts")) { - if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum - + ".sheep-amounts"), Integer.class)) { - final List sheep = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".sheep-to-shear"); - final List shearAmounts = config.getIntegerList("quests." + questKey - + ".stages.ordered." + stageNum + ".sheep-amounts"); - for (String sheepColor : sheep) { - final String originalColor = sheepColor; - DyeColor dc = null; - if (sheepColor.equalsIgnoreCase("NULL")) { - dc = DyeColor.WHITE; - } - sheepColor = sheepColor.replace(" ", "_"); - try { - if (dc == null) { - for (final DyeColor val : DyeColor.values()) { - if (val.name().replace("_", "").equalsIgnoreCase(sheepColor - .replace("_", ""))) { - dc = val; - break; - } - } - } - } catch (final IllegalArgumentException e) { - // Fail silently - } - if (dc != null) { - oStage.addSheepToShear(dc); - // Legacy start --> - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_BLACK"))) { - oStage.addSheepToShear(DyeColor.BLACK); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_BLUE"))) { - oStage.addSheepToShear(DyeColor.BLUE); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_BROWN"))) { - oStage.addSheepToShear(DyeColor.BROWN); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_CYAN"))) { - oStage.addSheepToShear(DyeColor.CYAN); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_GRAY"))) { - oStage.addSheepToShear(DyeColor.GRAY); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_GREEN"))) { - oStage.addSheepToShear(DyeColor.GREEN); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_LIGHT_BLUE"))) { - oStage.addSheepToShear(DyeColor.LIGHT_BLUE); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_LIME"))) { - oStage.addSheepToShear(DyeColor.LIME); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_MAGENTA"))) { - oStage.addSheepToShear(DyeColor.MAGENTA); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_ORANGE"))) { - oStage.addSheepToShear(DyeColor.ORANGE); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_PINK"))) { - oStage.addSheepToShear(DyeColor.PINK); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_PURPLE"))) { - oStage.addSheepToShear(DyeColor.PURPLE); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_RED"))) { - oStage.addSheepToShear(DyeColor.RED); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_SILVER"))) { - // 1.13 changed DyeColor.SILVER -> DyeColor.LIGHT_GRAY - oStage.addSheepToShear(DyeColor.getByColor(Color.SILVER)); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_WHITE"))) { - oStage.addSheepToShear(DyeColor.WHITE); - } else if (sheepColor.equalsIgnoreCase(Lang.get("COLOR_YELLOW"))) { - oStage.addSheepToShear(DyeColor.YELLOW); - // <-- Legacy end - } else { - throw new StageFormatException("sheep-to-shear has invalid color " + sheepColor, - quest, stageNum); - } - oStage.addSheepNumToShear(shearAmounts.get(sheep.indexOf(originalColor))); - } - } else { - throw new StageFormatException("sheep-amounts is not a list of numbers", quest, stageNum); - } - } else { - throw new StageFormatException("sheep-amounts is missing", quest, stageNum); - } - } else { - throw new StageFormatException("sheep-to-shear is not a list of colors", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-displays")) { - final List displays = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum - + ".password-displays"); - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-phrases")) { - final List phrases = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".password-phrases"); - if (displays.size() == phrases.size()) { - for (int passIndex = 0; passIndex < displays.size(); passIndex++) { - oStage.addPasswordDisplay(displays.get(passIndex)); - oStage.addPasswordPhrase(phrases.get(passIndex)); - } - } else { - throw new StageFormatException("password-displays and password-phrases are not the same size", - quest, stageNum); - } - } else { - throw new StageFormatException("password-phrases is missing", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override")) { - final Object o = config.get("quests." + questKey + ".stages.ordered." + stageNum - + ".objective-override"); - if (o instanceof List) { - for (String objectiveOverride : config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".objective-override")) { - oStage.addObjectiveOverride(objectiveOverride); - } - } else { - // Legacy - final String s = config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".objective-override"); - oStage.addObjectiveOverride(s); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) { - final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".start-event")); - if (action != null) { - oStage.setStartAction(action); - } else { - throw new StageFormatException("start-event failed to load", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")) { - final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".finish-event")); - if (action != null) { - oStage.setFinishAction(action); - } else { - throw new StageFormatException("finish-event failed to load", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fail-event")) { - final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".fail-event")); - if (action != null) { - oStage.setFailAction(action); - } else { - throw new StageFormatException("fail-event failed to load", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")) { - final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".death-event")); - if (action != null) { - oStage.setDeathAction(action); - } else { - throw new StageFormatException("death-event failed to load", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")) { - final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".disconnect-event")); - if (action != null) { - oStage.setDisconnectAction(action); - } else { - throw new StageFormatException("disconnect-event failed to load", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) { - if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum - + ".chat-event-triggers")) { - if (config.isList("quests." + questKey + ".stages.ordered." + stageNum - + ".chat-event-triggers")) { - final List chatEvents = config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".chat-events"); - final List chatEventTriggers = config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".chat-event-triggers"); - for (int i = 0; i < chatEvents.size(); i++) { - final Action action = loadAction(chatEvents.get(i)); - if (action != null) { - if (i < chatEventTriggers.size()) { - oStage.addChatAction(new AbstractMap.SimpleEntry<>(chatEventTriggers.get(i), - action)); - } else { - throw new StageFormatException("chat-event-triggers list is too small", - quest, stageNum); - } - } else { - throw new StageFormatException("chat-events failed to load " + chatEvents.get(i), - quest, stageNum); - } - } - } else { - throw new StageFormatException("chat-event-triggers is not in list format", quest, - stageNum); - } - } else { - throw new StageFormatException("chat-event-triggers is missing", quest, stageNum); - } - } else { - throw new StageFormatException("chat-events is not in list format", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) { - if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) { - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum - + ".command-event-triggers")) { - if (config.isList("quests." + questKey + ".stages.ordered." + stageNum - + ".command-event-triggers")) { - final List commandEvents = config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".command-events"); - final List commandEventTriggers = config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".command-event-triggers"); - for (int i = 0; i < commandEvents.size(); i++) { - final Action action = loadAction(commandEvents.get(i)); - if (action != null) { - if (i < commandEventTriggers.size()) { - oStage.addCommandAction(new AbstractMap.SimpleEntry<>(commandEventTriggers - .get(i), action)); - } else { - throw new StageFormatException("command-event-triggers list is too small", - quest, stageNum); - } - } else { - throw new StageFormatException("command-events failed to load " - + commandEvents.get(i), quest, stageNum); - } - } - } else { - throw new StageFormatException("command-event-triggers is not in list format", quest, - stageNum); - } - } else { - throw new StageFormatException("command-event-triggers is missing", quest, stageNum); - } - } else { - throw new StageFormatException("command-events is not in list format", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".condition")) { - final Condition condition = loadCondition(config.getString("quests." + questKey + ".stages.ordered." - + stageNum + ".condition")); - if (condition != null) { - oStage.setCondition(condition); - } else { - throw new StageFormatException("condition failed to load", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) { - final int delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999); - if (delay > 0) { - oStage.setDelay(delay * 1000L); - } else if (delay != -999) { - throw new StageFormatException("delay is not a positive number", quest, stageNum); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay-message")) { - oStage.setDelayMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".delay-message")); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-message")) { - oStage.setStartMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".start-message")); - } - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".complete-message")) { - oStage.setCompleteMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".complete-message")); - } - quest.getStages().add(oStage); - } - } - - @SuppressWarnings({ "unchecked", "deprecation" }) - protected Action loadAction(final String name) throws ActionFormatException { - if (name == null) { - return null; - } - final File legacy = new File(getDataFolder(), "events.yml"); - final File actions = new File(getDataFolder(), "actions.yml"); - final FileConfiguration data = new YamlConfiguration(); - try { - if (actions.isFile()) { - data.load(actions); - } else { - data.load(legacy); - } - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - final String legacyName = "events." + name; - String actionKey = "actions." + name + "."; - if (data.contains(legacyName)) { - actionKey = legacyName + "."; - } - final Action action = new Action(this); - action.setName(name); - if (data.contains(actionKey + "message")) { - action.setMessage(ConfigUtil.parseString(data.getString(actionKey + "message"))); - } - if (data.contains(actionKey + "open-book")) { - action.setBook(data.getString(actionKey + "open-book")); - } - if (data.contains(actionKey + "clear-inventory")) { - if (data.isBoolean(actionKey + "clear-inventory")) { - action.setClearInv(data.getBoolean(actionKey + "clear-inventory")); - } else { - throw new ActionFormatException("clear-inventory is not a true/false value", actionKey); - } - } - if (data.contains(actionKey + "fail-quest")) { - if (data.isBoolean(actionKey + "fail-quest")) { - action.setFailQuest(data.getBoolean(actionKey + "fail-quest")); - } else { - throw new ActionFormatException("fail-quest is not a true/false value", actionKey); - } - } - if (data.contains(actionKey + "explosions")) { - if (ConfigUtil.checkList(data.getList(actionKey + "explosions"), String.class)) { - final LinkedList explosions = new LinkedList<>(); - for (final String s : data.getStringList(actionKey + "explosions")) { - final Location loc = ConfigUtil.getLocation(s); - if (loc == null) { - throw new ActionFormatException("explosions is not in proper \"WorldName x y z\" format", - actionKey); - } - explosions.add(loc); - } - action.setExplosions(explosions); - } else { - throw new ActionFormatException("explosions is not a list of locations", actionKey); - } - } - if (data.contains(actionKey + "effects")) { - if (ConfigUtil.checkList(data.getList(actionKey + "effects"), String.class)) { - if (data.contains(actionKey + "effect-locations")) { - if (ConfigUtil.checkList(data.getList(actionKey + "effect-locations"), String.class)) { - final List effectList = data.getStringList(actionKey + "effects"); - final List effectLocs = data.getStringList(actionKey + "effect-locations"); - final Map effects = new HashMap<>(); - for (final String s : effectList) { - final Effect effect; - try { - effect = Effect.valueOf(s.toUpperCase()); - } catch (final IllegalArgumentException e) { - throw new ActionFormatException(s + " is not a valid effect name", - actionKey); - } - final Location l = ConfigUtil.getLocation(effectLocs.get(effectList.indexOf(s))); - if (l == null) { - throw new ActionFormatException("effect-locations is not in proper \"WorldName x y z\"" - + "format", actionKey); - } - effects.put(l, effect); - } - action.setEffects(effects); - } else { - throw new ActionFormatException("effect-locations is not a list of locations", actionKey); - } - } else { - throw new ActionFormatException("effect-locations is missing", actionKey); - } - } else { - throw new ActionFormatException("effects is not a list of effects", actionKey); - } - } - if (data.contains(actionKey + "items")) { - final LinkedList temp = new LinkedList<>(); - final List stackList = (List) data.get(actionKey + "items"); - if (ConfigUtil.checkList(stackList, ItemStack.class)) { - for (final ItemStack stack : stackList) { - if (stack != null) { - temp.add(stack); - } - } - } else { - // Legacy - if (ConfigUtil.checkList(stackList, String.class)) { - final List items = data.getStringList(actionKey + "items"); - for (final String item : items) { - try { - final ItemStack stack = ItemUtil.readItemStack(item); - if (stack != null) { - temp.add(stack); - } - } catch (final Exception e) { - throw new ActionFormatException("items is not formatted properly", actionKey); - } - } - } else { - throw new ActionFormatException("items is not a list of items", actionKey); - } - } - action.setItems(temp); - } - if (data.contains(actionKey + "storm-world")) { - final String world = data.getString(actionKey + "storm-world"); - if (world != null) { - final World stormWorld = getServer().getWorld(world); - if (stormWorld == null) { - throw new ActionFormatException("storm-world is not a valid world name", actionKey); - } - if (data.contains(actionKey + "storm-duration")) { - if (data.getInt(actionKey + "storm-duration", -999) != -999) { - action.setStormDuration(data.getInt(actionKey + "storm-duration") * 1000); - } else { - throw new ActionFormatException("storm-duration is not a number", actionKey); - } - action.setStormWorld(stormWorld); - } else { - throw new ActionFormatException("storm-duration is missing", actionKey); - } - } else { - throw new ActionFormatException("storm-world is not a valid world", actionKey); - } - } - if (data.contains(actionKey + "thunder-world")) { - final String world = data.getString(actionKey + "thunder-world"); - if (world != null) { - final World thunderWorld = getServer().getWorld(world); - if (thunderWorld == null) { - throw new ActionFormatException("thunder-world is not a valid world name", actionKey); - } - if (data.contains(actionKey + "thunder-duration")) { - if (data.getInt(actionKey + "thunder-duration", -999) != -999) { - action.setThunderDuration(data.getInt(actionKey + "thunder-duration")); - } else { - throw new ActionFormatException("thunder-duration is not a number", actionKey); - } - action.setThunderWorld(thunderWorld); - } else { - throw new ActionFormatException("thunder-duration is missing", actionKey); - } - } else { - throw new ActionFormatException("thunder-world is not a valid world", actionKey); - } - } - if (data.contains(actionKey + "mob-spawns")) { - final ConfigurationSection section = data.getConfigurationSection(actionKey + "mob-spawns"); - if (section != null) { - final LinkedList mobSpawns = new LinkedList<>(); - for (final String s : section.getKeys(false)) { - final String mobName = section.getString(s + ".name"); - final String location = section.getString(s + ".spawn-location"); - if (location != null) { - final Location spawnLocation = ConfigUtil.getLocation(location); - final EntityType type = MiscUtil.getProperMobType(section.getString(s + ".mob-type")); - final int mobAmount = section.getInt(s + ".spawn-amounts"); - if (spawnLocation == null) { - throw new ActionFormatException("mob-spawn-locations is not in proper \"WorldName x y z\" format", - actionKey); - } - if (type == null) { - throw new ActionFormatException("mob-spawn-types is not a list of mob types", actionKey); - } - final ItemStack[] inventory = new ItemStack[5]; - final Float[] dropChances = new Float[5]; - inventory[0] = ItemUtil.readItemStack(section.getString(s + ".held-item")); - dropChances[0] = (float) section.getDouble(s + ".held-item-drop-chance"); - inventory[1] = ItemUtil.readItemStack(section.getString(s + ".boots")); - dropChances[1] = (float) section.getDouble(s + ".boots-drop-chance"); - inventory[2] = ItemUtil.readItemStack(section.getString(s + ".leggings")); - dropChances[2] = (float) section.getDouble(s + ".leggings-drop-chance"); - inventory[3] = ItemUtil.readItemStack(section.getString(s + ".chest-plate")); - dropChances[3] = (float) section.getDouble(s + ".chest-plate-drop-chance"); - inventory[4] = ItemUtil.readItemStack(section.getString(s + ".helmet")); - dropChances[4] = (float) section.getDouble(s + ".helmet-drop-chance"); - final QuestMob questMob = new BukkitQuestMob(type, spawnLocation, mobAmount); - questMob.setInventory(inventory); - questMob.setDropChances(dropChances); - questMob.setName(mobName); - mobSpawns.add(questMob); - } else { - throw new ActionFormatException("mob-spawn-locations contains an invalid location", actionKey); - } - } - action.setMobSpawns(mobSpawns); - } - } - if (data.contains(actionKey + "lightning-strikes")) { - if (ConfigUtil.checkList(data.getList(actionKey + "lightning-strikes"), String.class)) { - final LinkedList lightningStrikes = new LinkedList<>(); - for (final String s : data.getStringList(actionKey + "lightning-strikes")) { - final Location loc = ConfigUtil.getLocation(s); - if (loc == null) { - throw new ActionFormatException("lightning-strikes is not in proper \"WorldName x y z\" format", - actionKey); - } - lightningStrikes.add(loc); - } - action.setLightningStrikes(lightningStrikes); - } else { - throw new ActionFormatException("lightning-strikes is not a list of locations", actionKey); - } - } - if (data.contains(actionKey + "commands")) { - if (ConfigUtil.checkList(data.getList(actionKey + "commands"), String.class)) { - final LinkedList commands = new LinkedList<>(); - for (String s : data.getStringList(actionKey + "commands")) { - if (s.startsWith("/")) { - s = s.replaceFirst("/", ""); - } - commands.add(s); - } - action.setCommands(commands); - } else { - throw new ActionFormatException("commands is not a list of commands", actionKey); - } - } - if (data.contains(actionKey + "potion-effect-types")) { - if (ConfigUtil.checkList(data.getList(actionKey + "potion-effect-types"), String.class)) { - if (data.contains(actionKey + "potion-effect-durations")) { - if (ConfigUtil.checkList(data.getList(actionKey + "potion-effect-durations"), Integer.class)) { - if (data.contains(actionKey + "potion-effect-amplifiers")) { - if (ConfigUtil.checkList(data.getList(actionKey + "potion-effect-amplifiers"), - Integer.class)) { - final List types = data.getStringList(actionKey + "potion-effect-types"); - final List durations = data.getIntegerList(actionKey + "potion-effect-durations"); - final List amplifiers = data.getIntegerList(actionKey + "potion-effect-amplifiers"); - final LinkedList potionEffects = new LinkedList<>(); - for (final String s : types) { - final PotionEffectType type = PotionEffectType.getByName(s); - if (type == null) { - throw new ActionFormatException("potion-effect-types is not a list of potion " - + "effect types", actionKey); - } - final PotionEffect effect = new PotionEffect(type, durations - .get(types.indexOf(s)), amplifiers.get(types.indexOf(s))); - potionEffects.add(effect); - } - action.setPotionEffects(potionEffects); - } else { - throw new ActionFormatException("potion-effect-amplifiers is not a list of numbers", - actionKey); - } - } else { - throw new ActionFormatException("potion-effect-amplifiers is missing", actionKey); - } - } else { - throw new ActionFormatException("potion-effect-durations is not a list of numbers", actionKey); - } - } else { - throw new ActionFormatException("potion-effect-durations is missing", actionKey); - } - } else { - throw new ActionFormatException("potion-effect-types is not a list of potion effects", actionKey); - } - } - if (data.contains(actionKey + "hunger")) { - if (data.getInt(actionKey + "hunger", -999) != -999) { - action.setHunger(data.getInt(actionKey + "hunger")); - } else { - throw new ActionFormatException("hunger is not a number", actionKey); - } - } - if (data.contains(actionKey + "saturation")) { - if (data.getInt(actionKey + "saturation", -999) != -999) { - action.setSaturation(data.getInt(actionKey + "saturation")); - } else { - throw new ActionFormatException("saturation is not a number", actionKey); - } - } - if (data.contains(actionKey + "health")) { - if (data.getInt(actionKey + "health", -999) != -999) { - action.setHealth(data.getInt(actionKey + "health")); - } else { - throw new ActionFormatException("health is not a number", actionKey); - } - } - if (data.contains(actionKey + "teleport-location")) { - if (data.isString(actionKey + "teleport-location")) { - final String location = data.getString(actionKey + "teleport-location"); - if (location != null) { - final Location teleport = ConfigUtil.getLocation(location); - if (teleport == null) { - throw new ActionFormatException("teleport-location is not in proper \"WorldName x y z\" format", - actionKey); - } - action.setTeleport(teleport); - } else { - throw new ActionFormatException("teleport-location has invalid location", actionKey); - } - } else { - throw new ActionFormatException("teleport-location is not a location", actionKey); - } - } - if (data.contains(actionKey + "timer")) { - if (data.isInt(actionKey + "timer")) { - action.setTimer(data.getInt(actionKey + "timer")); - } else { - throw new ActionFormatException("timer is not a number", actionKey); - } - } - if (data.contains(actionKey + "cancel-timer")) { - if (data.isBoolean(actionKey + "cancel-timer")) { - action.setCancelTimer(data.getBoolean(actionKey + "cancel-timer")); - } else { - throw new ActionFormatException("cancel-timer is not a true/false value", actionKey); - } - } - if (data.contains(actionKey + "denizen-script")) { - action.setDenizenScript(data.getString(actionKey + "denizen-script")); - } - return action; - } - - protected Condition loadCondition(final String name) throws ConditionFormatException { - if (name == null) { - return null; - } - final File conditions = new File(getDataFolder(), "conditions.yml"); - final FileConfiguration data = new YamlConfiguration(); - try { - if (conditions.isFile()) { - data.load(conditions); - } - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - final String conditionKey = "conditions." + name + "."; - final Condition condition = new Condition(this); - condition.setName(name); - if (data.contains(conditionKey + "fail-quest")) { - if (data.isBoolean(conditionKey + "fail-quest")) { - condition.setFailQuest(data.getBoolean(conditionKey + "fail-quest")); - } else { - throw new ConditionFormatException("fail-quest is not a true/false value", conditionKey); - } - } - if (data.contains(conditionKey + "ride-entity")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "ride-entity"), String.class)) { - final LinkedList entities = new LinkedList<>(); - for (final String s : data.getStringList(conditionKey + "ride-entity")) { - final EntityType e = MiscUtil.getProperMobType(s); - if (e == null) { - throw new ConditionFormatException("ride-entity is not a valid entity type", - conditionKey); - } - entities.add(s); - } - condition.setEntitiesWhileRiding(entities); - } else { - throw new ConditionFormatException("ride-entity is not a list of entity types", conditionKey); - } - } - if (data.contains(conditionKey + "ride-npc-uuid")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "ride-npc-uuid"), String.class)) { - final LinkedList npcList = new LinkedList<>(); - for (final String s : data.getStringList(conditionKey + "ride-npc-uuid")) { - final UUID u = UUID.fromString(s); - npcList.add(u); - } - condition.setNpcsWhileRiding(npcList); - } - } else if (data.contains(conditionKey + "ride-npc")) { - // Legacy - if (ConfigUtil.checkList(data.getList(conditionKey + "ride-npc"), Integer.class)) { - final LinkedList npcList = new LinkedList<>(); - if (getDependencies().getCitizens() != null) { - for (final int i : data.getIntegerList(conditionKey + "ride-npc")) { - final NPC npc = CitizensAPI.getNPCRegistry().getById(i); - if (npc != null) { - npcList.add(npc.getUniqueId()); - } else { - throw new ConditionFormatException("ride-npc is not a valid NPC ID", - conditionKey); - } - } - condition.setNpcsWhileRiding(npcList); - } else { - throw new ConditionFormatException("Citizens not found for ride-npc", conditionKey); - } - } else { - throw new ConditionFormatException("ride-npc is not a list of NPC IDs", conditionKey); - } - } - if (data.contains(conditionKey + "permission")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "permission"), String.class)) { - final LinkedList permissions - = new LinkedList<>(data.getStringList(conditionKey + "permission")); - condition.setPermissions(permissions); - } else { - throw new ConditionFormatException("permission is not a list of permissions", conditionKey); - } - } - if (data.contains(conditionKey + "hold-main-hand")) { - final LinkedList temp = new LinkedList<>(); - @SuppressWarnings("unchecked") - final List stackList = (List) data.get(conditionKey + "hold-main-hand"); - if (ConfigUtil.checkList(stackList, ItemStack.class)) { - for (final ItemStack stack : stackList) { - if (stack != null) { - temp.add(stack); - } - } - } - condition.setItemsWhileHoldingMainHand(temp); - } - if (data.contains(conditionKey + "wear")) { - final LinkedList temp = new LinkedList<>(); - @SuppressWarnings("unchecked") - final List stackList = (List) data.get(conditionKey + "wear"); - if (ConfigUtil.checkList(stackList, ItemStack.class)) { - for (final ItemStack stack : stackList) { - if (stack != null) { - temp.add(stack); - } - } - } - condition.setItemsWhileWearing(temp); - } - if (data.contains(conditionKey + "stay-within-world")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "stay-within-world"), String.class)) { - final LinkedList worlds = new LinkedList<>(); - for (final String s : data.getStringList(conditionKey + "stay-within-world")) { - final World w = getServer().getWorld(s); - if (w == null) { - throw new ConditionFormatException("stay-within-world is not a valid world", - conditionKey); - } - worlds.add(s); - } - condition.setWorldsWhileStayingWithin(worlds); - } else { - throw new ConditionFormatException("stay-within-world is not a list of worlds", conditionKey); - } - } - if (data.contains(conditionKey + "stay-within-ticks")) { - if (data.isInt(conditionKey + "stay-within-ticks.start")) { - condition.setTickStartWhileStayingWithin(data.getInt(conditionKey + "stay-within-ticks.start")); - } else { - throw new ConditionFormatException("start tick is not a number", conditionKey); - } - if (data.isInt(conditionKey + "stay-within-ticks.end")) { - condition.setTickEndWhileStayingWithin(data.getInt(conditionKey + "stay-within-ticks.end")); - } else { - throw new ConditionFormatException("end tick is not a number", conditionKey); - } - } - if (data.contains(conditionKey + "stay-within-biome")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "stay-within-biome"), String.class)) { - final LinkedList biomes = new LinkedList<>(); - for (final String s : data.getStringList(conditionKey + "stay-within-biome")) { - final Biome b = MiscUtil.getProperBiome(s); - if (b == null) { - throw new ConditionFormatException("stay-within-biome is not a valid biome", - conditionKey); - } - biomes.add(s); - } - condition.setBiomesWhileStayingWithin(biomes); - } else { - throw new ConditionFormatException("stay-within-biome is not a list of biomes", conditionKey); - } - } - if (data.contains(conditionKey + "stay-within-region")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "stay-within-region"), String.class)) { - final LinkedList regions = new LinkedList<>(); - for (final String region : data.getStringList(conditionKey + "stay-within-region")) { - if (region != null) { - boolean exists = false; - for (final World world : getServer().getWorlds()) { - if (world != null && getDependencies().getWorldGuardApi().getRegionManager(world) != null) { - if (Objects.requireNonNull(getDependencies().getWorldGuardApi().getRegionManager(world)) - .hasRegion(region)) { - regions.add(region); - exists = true; - break; - } - } - } - if (!exists) { - throw new ConditionFormatException("region has invalid WorldGuard region name", conditionKey); - } - } else { - throw new ConditionFormatException("region has invalid WorldGuard region", conditionKey); - } - } - condition.setRegionsWhileStayingWithin(regions); - } else { - throw new ConditionFormatException("stay-within-region is not a list of regions", conditionKey); - } - } - if (data.contains(conditionKey + "check-placeholder-id")) { - if (ConfigUtil.checkList(data.getList(conditionKey + "check-placeholder-id"), String.class)) { - final LinkedList id = new LinkedList<>(data.getStringList(conditionKey - + "check-placeholder-id")); - condition.setPlaceholdersCheckIdentifier(id); - } else { - throw new ConditionFormatException("check-placeholder-id is not a list of identifiers", conditionKey); - } - if (ConfigUtil.checkList(data.getList(conditionKey + "check-placeholder-value"), String.class)) { - final LinkedList val = new LinkedList<>(data.getStringList(conditionKey - + "check-placeholder-value")); - condition.setPlaceholdersCheckValue(val); - } else { - throw new ConditionFormatException("check-placeholder-value is not a list of values", conditionKey); - } - } - return condition; - } - - private void loadCustomSections(final IQuest quest, final FileConfiguration config, final String questKey) - throws StageFormatException, QuestFormatException { - final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey - + ".stages.ordered"); - if (questStages != null) { - for (final String stageNum : questStages.getKeys(false)) { - if (quest == null) { - getLogger().warning("Unable to consider custom objectives because quest for " + questKey - + " was null"); - return; - } - if (quest.getStage(Integer.parseInt(stageNum) - 1) == null) { - getLogger().severe("Unable to load custom objectives because stage" + (Integer.parseInt(stageNum) - - 1) + " for " + quest.getName() + " was null"); - return; - } - final IStage oStage = quest.getStage(Integer.parseInt(stageNum) - 1); - oStage.clearCustomObjectives(); - oStage.clearCustomObjectiveCounts(); - oStage.clearCustomObjectiveData(); - oStage.clearCustomObjectiveDisplays(); - if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".custom-objectives")) { - final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey - + ".stages.ordered." + stageNum + ".custom-objectives"); - if (sec != null) { - for (final String path : sec.getKeys(false)) { - final String name = sec.getString(path + ".name"); - final int count = sec.getInt(path + ".count"); - Optional found = Optional.empty(); - for (final ICustomObjective cr : customObjectives) { - if (cr.getName().equalsIgnoreCase(name)) { - found = Optional.of(cr); - break; - } - } - if (found.isPresent()) { - oStage.addCustomObjectives(found.get()); - oStage.addCustomObjectiveCounts(Math.max(count, 0)); - final ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data"); - for (final Entry prompt : found.get().getData()) { - final Entry data = populateCustoms(sec2, prompt); - oStage.addCustomObjectiveData(data); - } - } else { - throw new QuestFormatException(name + " custom objective not found for IStage " - + stageNum, questKey); - } - } - } - } - } - final Rewards rews = quest.getRewards(); - if (config.contains("quests." + questKey + ".rewards.custom-rewards")) { - final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey - + ".rewards.custom-rewards"); - final Map> temp = new HashMap<>(); - if (sec != null) { - for (final String path : sec.getKeys(false)) { - final String name = sec.getString(path + ".name"); - Optional found = Optional.empty(); - for (final CustomReward cr : customRewards) { - if (cr.getName().equalsIgnoreCase(name)) { - found = Optional.of(cr); - break; - } - } - if (found.isPresent()) { - final ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data"); - final Map data = populateCustoms(sec2, found.get().getData()); - temp.put(name, data); - } else { - throw new QuestFormatException(name + " custom reward not found", questKey); - } - } - } - rews.setCustomRewards(temp); - } - final Requirements reqs = quest.getRequirements(); - if (config.contains("quests." + questKey + ".requirements.custom-requirements")) { - final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey - + ".requirements.custom-requirements"); - final Map> temp = new HashMap<>(); - if (sec != null) { - for (final String path : sec.getKeys(false)) { - final String name = sec.getString(path + ".name"); - Optional found = Optional.empty(); - for (final CustomRequirement cr : customRequirements) { - if (cr.getName().equalsIgnoreCase(name)) { - found = Optional.of(cr); - break; - } - } - if (found.isPresent()) { - final ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data"); - final Map data = populateCustoms(sec2, found.get().getData()); - temp.put(name, data); - } else { - throw new QuestFormatException(name + " custom requirement not found", questKey); - } - } - } - reqs.setCustomRequirements(temp); - } - } - } - - /** - * Permits use of fallbacks for customs maps

- * - * Avoid null objects in datamap by initializing the entry value with empty string if no fallback present. - * - * @param section The section of configuration to check - * @param dataMap The map to process - * @return Populated map - */ - private static Map populateCustoms(final ConfigurationSection section, - final Map dataMap) { - final Map data = new HashMap<>(); - if (section != null) { - for (final String key : dataMap.keySet()) { - data.put(key, section.contains(key) ? section.get(key) : dataMap.get(key) != null - ? dataMap.get(key) : ""); - } - } - return data; - } - - /** - * Permits use of fallbacks for customs entries

- * - * Avoid null objects in datamap by initializing the entry value with empty string if no fallback present. - * - * @param section The section of configuration to check - * @param dataMap The entry to process - * @return Populated entry, or null - */ - private static Entry populateCustoms(final ConfigurationSection section, - final Entry dataMap) { - Entry data = null; - if (section != null) { - final String key = dataMap.getKey(); - final Object value = dataMap.getValue(); - data = new AbstractMap.SimpleEntry<>(key, section.contains(key) ? section.get(key) : value != null - ? value : ""); - } - return data; - } - - /** - * Load actions from file - */ - public void loadActions() { - final YamlConfiguration config = new YamlConfiguration(); - final File legacyFile = new File(this.getDataFolder(), "events.yml"); - final File actionsFile = new File(this.getDataFolder(), "actions.yml"); - // Using #isFile because #exists and #renameTo can return false positives - if (legacyFile.isFile()) { - try { - if (legacyFile.renameTo(actionsFile)) { - getLogger().log(Level.INFO, "Renamed legacy events.yml to actions.yml"); - } - if (actionsFile.isFile()) { - getLogger().log(Level.INFO, "Successfully deleted legacy events.yml"); - if (legacyFile.delete()) { - getLogger().log(Level.INFO, "Done!"); - } - } - } catch (final Exception e) { - getLogger().log(Level.WARNING, "Unable to convert events.yml to actions.yml"); - e.printStackTrace(); - } - } - if (actionsFile.length() != 0) { - try { - if (actionsFile.isFile()) { - config.load(actionsFile); - } else { - config.load(legacyFile); - } - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - ConfigurationSection sec = config.getConfigurationSection("actions"); - if (sec == null) { - getLogger().log(Level.INFO, - "Could not find section \"actions\" from actions.yml. Trying legacy \"events\"..."); - sec = config.getConfigurationSection("events"); - } - if (sec != null) { - for (final String s : sec.getKeys(false)) { - Action action = null; - try { - action = loadAction(s); - } catch (final ActionFormatException e) { - e.printStackTrace(); - } - if (action != null) { - actions.add(action); - } else { - getLogger().log(Level.SEVERE, "Failed to load IAction \"" + s + "\". Skipping."); - } - } - } else { - getLogger().log(Level.SEVERE, "Could not find beginning section from actions.yml. Skipping."); - } - } else { - getLogger().log(Level.WARNING, "Empty file actions.yml was not loaded."); - } - } - - /** - * Load conditions from file - */ - public void loadConditions() { - final YamlConfiguration config = new YamlConfiguration(); - final File conditionsFile = new File(this.getDataFolder(), "conditions.yml"); - // Using #isFile because #exists and #renameTo can return false positives - if (conditionsFile.length() != 0) { - try { - if (conditionsFile.isFile()) { - config.load(conditionsFile); - } - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - final ConfigurationSection sec = config.getConfigurationSection("conditions"); - if (sec != null) { - for (final String s : sec.getKeys(false)) { - Condition condition = null; - try { - condition = loadCondition(s); - } catch (final ConditionFormatException e) { - e.printStackTrace(); - } - if (condition != null) { - conditions.add(condition); - } else { - getLogger().log(Level.SEVERE, "Failed to load ICondition \"" + s + "\". Skipping."); - } - } - } else { - getLogger().log(Level.SEVERE, "Could not find beginning section from conditions.yml. Skipping."); - } - } else { - getLogger().log(Level.WARNING, "Empty file conditions.yml was not loaded."); - } - } - - public static SkillType getMcMMOSkill(final String s) { - return SkillType.getSkill(s); - } - - /** - * Checks if player can use Quests - * - * @param uuid the entity UUID to be checked - * @return {@code true} if entity is a Player that has permission - */ - public boolean canUseQuests(final UUID uuid) { - final Player p = Bukkit.getPlayer(uuid); - if (p != null) { - for (final Permission perm : getDescription().getPermissions()) { - if (p.hasPermission(perm.getName())) { - return true; - } - } - } - return false; - } - - /** - * Checks if conversable is non-op, non-* player in Trial Mode - * - * @param conversable the editor user to be checked - * @return {@code true} if user is a Player with quests.mode.trial permission - */ - public boolean hasLimitedAccess(final Conversable conversable) { - if (!(conversable instanceof Player)) { - return false; - } - final Player player = ((Player)conversable); - if (player.isOp() || player.hasPermission("*")) { - return false; - } - return player.hasPermission("quests.mode.trial"); - } - - /** - * Get a Quest by ID - * - * @param id ID of the quest - * @return Exact match or null if not found - * @since 3.8.6 - */ - public Quest getQuestById(final String id) { - if (id == null) { - return null; - } - for (final IQuest iq : quests) { - final Quest q = (Quest) iq; - if (q.getId().equals(id)) { - return q; - } - } - return null; - } - - /** - * Get a Quest by ID - * - * @param id ID of the quest - * @return Exact match or null if not found - * @since 3.8.6 - * @deprecated Do not use - */ - public IQuest getQuestByIdTemp(final String id) { - if (id == null) { - return null; - } - for (final IQuest q : quests) { - if (q.getId().equals(id)) { - return q; - } - } - return null; - } - - /** - * Get a Quest by name - * - * @param name Name of the quest - * @return Closest match or null if not found - */ - public Quest getQuest(final String name) { - if (name == null) { - return null; - } - for (final IQuest iq : quests) { - final Quest q = (Quest) iq; - if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { - return q; - } - } - for (final IQuest iq : quests) { - final Quest q = (Quest) iq; - if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return q; - } - } - for (final IQuest iq : quests) { - final Quest q = (Quest) iq; - if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return q; - } - } - for (final IQuest iq : quests) { - // For tab completion - final Quest q = (Quest) iq; - if (ChatColor.stripColor(q.getName()).equals(ChatColor.stripColor(ChatColor - .translateAlternateColorCodes('&', name)))) { - return q; - } - } - return null; - } - - /** - * Get a Quest by name - * - * @param name Name of the quest - * @return Closest match or null if not found - */ - public IQuest getQuestTemp(final String name) { - if (name == null) { - return null; - } - for (final IQuest q : quests) { - if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { - return q; - } - } - for (final IQuest q : quests) { - if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return q; - } - } - for (final IQuest q : quests) { - if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return q; - } - } - for (final IQuest q : quests) { - // For tab completion - if (ChatColor.stripColor(q.getName()).equals(ChatColor.stripColor(ChatColor - .translateAlternateColorCodes('&', name)))) { - return q; - } - } - return null; - } - - /** - * Get an IAction by name - * - * @param name Name of the action - * @return Closest match or null if not found - */ - public IAction getAction(final String name) { - if (name == null) { - return null; - } - for (final IAction a : actions) { - if (a.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { - return a; - } - } - for (final IAction a : actions) { - if (a.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return a; - } - } - for (final IAction a : actions) { - if (a.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return a; - } - } - for (final IAction a : actions) { - // For tab completion - if (ChatColor.stripColor(a.getName()).equals(ChatColor.stripColor(ChatColor. - translateAlternateColorCodes('&', name)))) { - return a; - } - } - return null; - } - - /** - * Get a ICondition by name - * - * @param name Name of the condition - * @return Closest match or null if not found - */ - public ICondition getCondition(final String name) { - if (name == null) { - return null; - } - for (final ICondition c : conditions) { - if (c.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { - return c; - } - } - for (final ICondition c : conditions) { - if (c.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return c; - } - } - for (final ICondition c : conditions) { - if (c.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { - return c; - } - } - for (final ICondition c : conditions) { - // For tab completion - if (ChatColor.stripColor(c.getName()).equals(ChatColor.stripColor(ChatColor - .translateAlternateColorCodes('&', name)))) { - return c; - } - } - return null; - } - - /** - * Checks whether an NPC has a quest that the player may accept - * - * @param npc the giver NPC UUID to check - * @param quester The player to check - * @return true if at least one available quest has not yet been completed - */ - public boolean hasQuest(final UUID npc, final IQuester quester) { - for (final IQuest q : quests) { - if (q.getNpcStart() != null && !quester.getCompletedQuestsTemp().contains(q)) { - if (q.getNpcStart().equals(npc)) { - final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); - if (!ignoreLockedQuests || q.testRequirements(quester)) { - return true; - } - } - } - } - return false; - } - - // Unused internally, left for external use - /** - * Checks whether an NPC has a quest that the player has already completed - * - * @param npc The giver NPC UUID to check - * @param quester The player to check - * @return true if at least one available quest has been completed - */ - public boolean hasCompletedQuest(final UUID npc, final IQuester quester) { - for (final IQuest q : quests) { - if (q.getNpcStart() != null && quester.getCompletedQuestsTemp().contains(q)) { - if (q.getNpcStart().equals(npc)) { - final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); - if (!ignoreLockedQuests || q.testRequirements(quester)) { - return true; - } - } - } - } - return false; - } - - /** - * Checks whether an NPC has a repeatable quest that the player has already completed - * - * @param npc The giver NPC UUID to check - * @param quester The player to check - * @return true if at least one available, redoable quest has been completed - */ - public boolean hasCompletedRedoableQuest(final UUID npc, final IQuester quester) { - for (final IQuest q : quests) { - if (q.getNpcStart() != null && quester.getCompletedQuestsTemp().contains(q) - && q.getPlanner().getCooldown() > -1) { - if (q.getNpcStart().equals(npc)) { - final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); - if (!ignoreLockedQuests || q.testRequirements(quester)) { - return true; - } - } - } - } - return false; - } - - /** - * Checks whether an NPC has a quest that the player may accept - * - * @param npc The giver NPC to check - * @param quester The player to check - * @return true if at least one available quest has not yet been completed - * @deprecated Use {@link #hasQuest(UUID, IQuester)} - */ - @Deprecated - public boolean hasQuest(final NPC npc, final IQuester quester) { - return hasQuest(npc.getUniqueId(), quester); - } - - // Unused internally, left for external use - /** - * Checks whether an NPC has a quest that the player has already completed - * - * @param npc The giver NPC to check - * @param quester The player to check - * @return true if at least one available quest has been completed - * @deprecated Use {@link #hasCompletedQuest(UUID, IQuester)} - */ - @Deprecated - public boolean hasCompletedQuest(final NPC npc, final IQuester quester) { - return hasCompletedQuest(npc.getUniqueId(), quester); - } - - /** - * Checks whether an NPC has a repeatable quest that the player has already completed - * - * @param npc The giver NPC to check - * @param quester The player to check - * @return true if at least one available, redoable quest has been completed - * @deprecated Use {@link #hasCompletedRedoableQuest(UUID, IQuester)} - */ - @Deprecated - public boolean hasCompletedRedoableQuest(final NPC npc, final IQuester quester) { - return hasCompletedRedoableQuest(npc.getUniqueId(), quester); - } -} diff --git a/core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java b/core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java deleted file mode 100644 index af06de75f..000000000 --- a/core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.actions; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.Quests; -import me.blackvein.quests.convo.actions.main.ActionMainPrompt; -import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt; -import me.blackvein.quests.entity.BukkitQuestMob; -import me.blackvein.quests.entity.QuestMob; -import me.blackvein.quests.interfaces.ReloadCallback; -import me.blackvein.quests.util.CK; -import me.blackvein.quests.util.ConfigUtil; -import me.blackvein.quests.util.FakeConversable; -import me.blackvein.quests.util.ItemUtil; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.conversations.ConversationAbandonedListener; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.ConversationPrefix; -import org.bukkit.conversations.Prompt; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.UUID; - -public class BukkitActionFactory implements ActionFactory, ConversationAbandonedListener { - - private final Quests plugin; - private final ConversationFactory conversationFactory; - private Map selectedExplosionLocations = new HashMap<>(); - private Map selectedEffectLocations = new HashMap<>(); - private Map selectedMobLocations = new HashMap<>(); - private Map selectedLightningLocations = new HashMap<>(); - private Map selectedTeleportLocations = new HashMap<>(); - private List editingActionNames = new LinkedList<>(); - - public BukkitActionFactory(final Quests plugin) { - this.plugin = plugin; - // Ensure to initialize factory last so that 'this' is fully initialized before it is passed - this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) - .withFirstPrompt(new ActionMenuPrompt(new ConversationContext(plugin, new FakeConversable(), - new HashMap<>()))).withTimeout(3600) - .withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this); - } - - public static class LineBreakPrefix implements ConversationPrefix { - @Override - public @NotNull String getPrefix(final @NotNull ConversationContext context) { - return "\n"; - } - } - - public Map getSelectedExplosionLocations() { - return selectedExplosionLocations; - } - - public void setSelectedExplosionLocations( - final Map selectedExplosionLocations) { - this.selectedExplosionLocations = selectedExplosionLocations; - } - - public Map getSelectedEffectLocations() { - return selectedEffectLocations; - } - - public void setSelectedEffectLocations(final Map selectedEffectLocations) { - this.selectedEffectLocations = selectedEffectLocations; - } - - public Map getSelectedMobLocations() { - return selectedMobLocations; - } - - public void setSelectedMobLocations(final Map selectedMobLocations) { - this.selectedMobLocations = selectedMobLocations; - } - - public Map getSelectedLightningLocations() { - return selectedLightningLocations; - } - - public void setSelectedLightningLocations( - final Map selectedLightningLocations) { - this.selectedLightningLocations = selectedLightningLocations; - } - - public Map getSelectedTeleportLocations() { - return selectedTeleportLocations; - } - - public void setSelectedTeleportLocations( - final Map selectedTeleportLocations) { - this.selectedTeleportLocations = selectedTeleportLocations; - } - - public ConversationFactory getConversationFactory() { - return conversationFactory; - } - - public List getNamesOfActionsBeingEdited() { - return editingActionNames; - } - - public void setNamesOfActionsBeingEdited(final List actionNames) { - this.editingActionNames = actionNames; - } - - @Override - public void conversationAbandoned(final ConversationAbandonedEvent abandonedEvent) { - if (abandonedEvent.getContext().getForWhom() instanceof Player) { - final UUID uuid = ((Player) abandonedEvent.getContext().getForWhom()).getUniqueId(); - selectedExplosionLocations.remove(uuid); - selectedEffectLocations.remove(uuid); - selectedMobLocations.remove(uuid); - selectedLightningLocations.remove(uuid); - selectedTeleportLocations.remove(uuid); - } - } - - public Prompt returnToMenu(final ConversationContext context) { - return new ActionMainPrompt(context); - } - - public void loadData(final IAction event, final ConversationContext context) { - if (event.getMessage() != null) { - context.setSessionData(CK.E_MESSAGE, event.getMessage()); - } - if (event.isClearInv()) { - context.setSessionData(CK.E_CLEAR_INVENTORY, true); - } else { - context.setSessionData(CK.E_CLEAR_INVENTORY, false); - } - if (event.isFailQuest()) { - context.setSessionData(CK.E_FAIL_QUEST, true); - } else { - context.setSessionData(CK.E_FAIL_QUEST, false); - } - if (event.getItems() != null && !event.getItems().isEmpty()) { - final LinkedList items = new LinkedList<>(event.getItems()); - context.setSessionData(CK.E_ITEMS, items); - } - if (event.getExplosions() != null && !event.getExplosions().isEmpty()) { - final LinkedList locs = new LinkedList<>(); - for (final Location loc : event.getExplosions()) { - locs.add(ConfigUtil.getLocationInfo(loc)); - } - context.setSessionData(CK.E_EXPLOSIONS, locs); - } - if (event.getEffects() != null && !event.getEffects().isEmpty()) { - final LinkedList locs = new LinkedList<>(); - final LinkedList effs = new LinkedList<>(); - for (final Entry e : event.getEffects().entrySet()) { - locs.add(ConfigUtil.getLocationInfo(e.getKey())); - effs.add(e.getValue().toString()); - } - context.setSessionData(CK.E_EFFECTS, effs); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); - } - if (event.getStormWorld() != null) { - context.setSessionData(CK.E_WORLD_STORM, event.getStormWorld().getName()); - context.setSessionData(CK.E_WORLD_STORM_DURATION, event.getStormDuration()); - } - if (event.getThunderWorld() != null) { - context.setSessionData(CK.E_WORLD_THUNDER, event.getThunderWorld().getName()); - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, event.getThunderDuration()); - } - if (event.getMobSpawns() != null && !event.getMobSpawns().isEmpty()) { - final LinkedList questMobs = new LinkedList<>(); - for (final QuestMob questMob : event.getMobSpawns()) { - questMobs.add(questMob.serialize()); - } - context.setSessionData(CK.E_MOB_TYPES, questMobs); - } - if (event.getLightningStrikes() != null && !event.getLightningStrikes().isEmpty()) { - final LinkedList locs = new LinkedList<>(); - for (final Location loc : event.getLightningStrikes()) { - locs.add(ConfigUtil.getLocationInfo(loc)); - } - context.setSessionData(CK.E_LIGHTNING, locs); - } - if (event.getPotionEffects() != null && !event.getPotionEffects().isEmpty()) { - final LinkedList types = new LinkedList<>(); - final LinkedList durations = new LinkedList<>(); - final LinkedList mags = new LinkedList<>(); - for (final PotionEffect pe : event.getPotionEffects()) { - types.add(pe.getType().getName()); - durations.add((long) pe.getDuration()); - mags.add(pe.getAmplifier()); - } - context.setSessionData(CK.E_POTION_TYPES, types); - context.setSessionData(CK.E_POTION_DURATIONS, durations); - context.setSessionData(CK.E_POTION_STRENGTH, mags); - } - if (event.getHunger() > -1) { - context.setSessionData(CK.E_HUNGER, event.getHunger()); - } - if (event.getSaturation() > -1) { - context.setSessionData(CK.E_SATURATION, event.getSaturation()); - } - if (event.getHealth() > -1) { - context.setSessionData(CK.E_HEALTH, event.getHealth()); - } - if (event.getTeleport() != null) { - context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(event.getTeleport())); - } - if (event.getCommands() != null) { - context.setSessionData(CK.E_COMMANDS, event.getCommands()); - } - if (event.getTimer() > 0) { - context.setSessionData(CK.E_TIMER, event.getTimer()); - } - if (event.isCancelTimer()) { - context.setSessionData(CK.E_CANCEL_TIMER, true); - } - } - - public void clearData(final ConversationContext context) { - context.setSessionData(CK.E_OLD_EVENT, null); - context.setSessionData(CK.E_NAME, null); - context.setSessionData(CK.E_MESSAGE, null); - context.setSessionData(CK.E_CLEAR_INVENTORY, null); - context.setSessionData(CK.E_FAIL_QUEST, null); - context.setSessionData(CK.E_ITEMS, null); - context.setSessionData(CK.E_ITEMS_AMOUNTS, null); - context.setSessionData(CK.E_EXPLOSIONS, null); - context.setSessionData(CK.E_EFFECTS, null); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); - context.setSessionData(CK.E_WORLD_STORM, null); - context.setSessionData(CK.E_WORLD_STORM_DURATION, null); - context.setSessionData(CK.E_WORLD_THUNDER, null); - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null); - context.setSessionData(CK.E_MOB_TYPES, null); - context.setSessionData(CK.E_LIGHTNING, null); - context.setSessionData(CK.E_POTION_TYPES, null); - context.setSessionData(CK.E_POTION_DURATIONS, null); - context.setSessionData(CK.E_POTION_STRENGTH, null); - context.setSessionData(CK.E_HUNGER, null); - context.setSessionData(CK.E_SATURATION, null); - context.setSessionData(CK.E_HEALTH, null); - context.setSessionData(CK.E_TELEPORT, null); - context.setSessionData(CK.E_COMMANDS, null); - context.setSessionData(CK.E_TIMER, null); - context.setSessionData(CK.E_CANCEL_TIMER, null); - } - - public void deleteAction(final ConversationContext context) { - final YamlConfiguration data = new YamlConfiguration(); - final File actionsFile = new File(plugin.getDataFolder(), "actions.yml"); - try { - data.load(actionsFile); - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile") - .replace("", actionsFile.getName())); - return; - } - final String action = (String) context.getSessionData(CK.ED_EVENT_DELETE); - String key = "actions"; - ConfigurationSection sec = data.getConfigurationSection(key); - if (sec == null) { - key = "events"; - sec = data.getConfigurationSection(key); - } - if (sec != null && action != null) { - sec.set(action, null); - } - try { - data.save(actionsFile); - } catch (final IOException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError")); - return; - } - final ReloadCallback callback = response -> { - if (!response) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError")); - } - }; - plugin.reload(callback); - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorDeleted")); - if (plugin.getSettings().getConsoleLogging() > 0) { - final String identifier = context.getForWhom() instanceof Player ? - "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; - plugin.getLogger().info(identifier + " deleted action " + action); - } - for (final IQuester q : plugin.getOfflineQuesters()) { - for (final IQuest quest : q.getCurrentQuestsTemp().keySet()) { - q.checkQuest(quest); - } - } - clearData(context); - } - - @SuppressWarnings("unchecked") - public void saveAction(final ConversationContext context) { - final YamlConfiguration data = new YamlConfiguration(); - final File actionsFile = new File(plugin.getDataFolder(), "actions.yml"); - try { - data.load(actionsFile); - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile") - .replace("", actionsFile.getName())); - return; - } - String key = "actions"; - if (data.getConfigurationSection(key) == null) { - key = "events"; - } - if (context.getSessionData(CK.E_OLD_EVENT) != null - && !((String) Objects.requireNonNull(context.getSessionData(CK.E_OLD_EVENT))).isEmpty()) { - data.set(key + "." + context.getSessionData(CK.E_OLD_EVENT), null); - final Collection temp = plugin.getLoadedActions(); - temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT))); - plugin.setLoadedActions(temp); - } - final ConfigurationSection section = data.createSection(key + "." + context.getSessionData(CK.E_NAME)); - editingActionNames.remove((String) context.getSessionData(CK.E_NAME)); - if (context.getSessionData(CK.E_MESSAGE) != null) { - section.set("message", context.getSessionData(CK.E_MESSAGE)); - } - if (context.getSessionData(CK.E_CLEAR_INVENTORY) != null) { - final Boolean b = (Boolean) context.getSessionData(CK.E_CLEAR_INVENTORY); - if (b != null) { - section.set("clear-inventory", b); - } - } - if (context.getSessionData(CK.E_FAIL_QUEST) != null) { - final Boolean b = (Boolean) context.getSessionData(CK.E_FAIL_QUEST); - if (b != null) { - section.set("fail-quest", b); - } - } - if (context.getSessionData(CK.E_ITEMS) != null) { - section.set("items", context.getSessionData(CK.E_ITEMS)); - } - if (context.getSessionData(CK.E_EXPLOSIONS) != null) { - section.set("explosions", context.getSessionData(CK.E_EXPLOSIONS)); - } - if (context.getSessionData(CK.E_EFFECTS) != null) { - section.set("effects", context.getSessionData(CK.E_EFFECTS)); - section.set("effect-locations", context.getSessionData(CK.E_EFFECTS_LOCATIONS)); - } - if (context.getSessionData(CK.E_WORLD_STORM) != null) { - section.set("storm-world", context.getSessionData(CK.E_WORLD_STORM)); - section.set("storm-duration", context.getSessionData(CK.E_WORLD_STORM_DURATION)); - } - if (context.getSessionData(CK.E_WORLD_THUNDER) != null) { - section.set("thunder-world", context.getSessionData(CK.E_WORLD_THUNDER)); - section.set("thunder-duration", context.getSessionData(CK.E_WORLD_THUNDER_DURATION)); - } - try { - if (context.getSessionData(CK.E_MOB_TYPES) != null) { - int count = 0; - for (final String s : (LinkedList) Objects.requireNonNull(context - .getSessionData(CK.E_MOB_TYPES))) { - ConfigurationSection ss = section.getConfigurationSection("mob-spawns." + count); - if (ss == null) { - ss = section.createSection("mob-spawns." + count); - } - final QuestMob questMob = BukkitQuestMob.fromString(s); - if (questMob.getName() != null) { - ss.set("name", questMob.getName()); - } - ss.set("spawn-location", ConfigUtil.getLocationInfo(questMob.getSpawnLocation())); - ss.set("mob-type", questMob.getType().name()); - ss.set("spawn-amounts", questMob.getSpawnAmounts()); - ss.set("held-item", ItemUtil.serializeItemStack(questMob.getInventory()[0])); - ss.set("held-item-drop-chance", questMob.getDropChances()[0]); - ss.set("boots", ItemUtil.serializeItemStack(questMob.getInventory()[1])); - ss.set("boots-drop-chance", questMob.getDropChances()[1]); - ss.set("leggings", ItemUtil.serializeItemStack(questMob.getInventory()[2])); - ss.set("leggings-drop-chance", questMob.getDropChances()[2]); - ss.set("chest-plate", ItemUtil.serializeItemStack(questMob.getInventory()[3])); - ss.set("chest-plate-drop-chance", questMob.getDropChances()[3]); - ss.set("helmet", ItemUtil.serializeItemStack(questMob.getInventory()[4])); - ss.set("helmet-drop-chance", questMob.getDropChances()[4]); - count++; - } - } - } catch (final Exception e) { - e.printStackTrace(); - } - if (context.getSessionData(CK.E_LIGHTNING) != null) { - section.set("lightning-strikes", context.getSessionData(CK.E_LIGHTNING)); - } - if (context.getSessionData(CK.E_COMMANDS) != null) { - final LinkedList commands = (LinkedList) context.getSessionData(CK.E_COMMANDS); - if (commands != null && !commands.isEmpty()) { - section.set("commands", commands); - } - } - if (context.getSessionData(CK.E_POTION_TYPES) != null) { - section.set("potion-effect-types", context.getSessionData(CK.E_POTION_TYPES)); - section.set("potion-effect-durations", context.getSessionData(CK.E_POTION_DURATIONS)); - section.set("potion-effect-amplifiers", context.getSessionData(CK.E_POTION_STRENGTH)); - } - if (context.getSessionData(CK.E_HUNGER) != null) { - section.set("hunger", context.getSessionData(CK.E_HUNGER)); - } - if (context.getSessionData(CK.E_SATURATION) != null) { - section.set("saturation", context.getSessionData(CK.E_SATURATION)); - } - if (context.getSessionData(CK.E_HEALTH) != null) { - section.set("health", context.getSessionData(CK.E_HEALTH)); - } - if (context.getSessionData(CK.E_TELEPORT) != null) { - section.set("teleport-location", context.getSessionData(CK.E_TELEPORT)); - } - if (context.getSessionData(CK.E_TIMER) != null) { - final Integer i = (Integer) context.getSessionData(CK.E_TIMER); - if (i != null && i > 0) { - section.set("timer", context.getSessionData(CK.E_TIMER)); - } - } - if (context.getSessionData(CK.E_CANCEL_TIMER) != null) { - final Boolean b = (Boolean) context.getSessionData(CK.E_CANCEL_TIMER); - if (b != null) { - section.set("cancel-timer", b); - } - } - if (context.getSessionData(CK.E_DENIZEN) != null) { - section.set("denizen-script", context.getSessionData(CK.E_DENIZEN)); - } - try { - data.save(actionsFile); - } catch (final IOException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError")); - return; - } - final ReloadCallback callback = response -> { - if (!response) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError")); - } - }; - plugin.reload(callback); - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorSaved")); - if (plugin.getSettings().getConsoleLogging() > 0) { - final String identifier = context.getForWhom() instanceof Player ? - "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; - plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME)); - } - for (final IQuester q : plugin.getOfflineQuesters()) { - for (final IQuest quest : q.getCurrentQuestsTemp().keySet()) { - q.checkQuest(quest); - } - } - clearData(context); - } -} \ No newline at end of file diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java deleted file mode 100644 index a023ee5ad..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/QuestadminCommandHandler.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.questadmin; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminFinishCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminGiveCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminGivepointsCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminNextstageCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminPointsCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminPointsallCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminQuitCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminReloadCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminRemoveCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminResetCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminSetstageCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminStatsCommand; -import me.blackvein.quests.commands.questadmin.subcommands.QuestadminTakepointsCommand; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class QuestadminCommandHandler { - - private final Quests plugin; - private final Map subCommands; - - public QuestadminCommandHandler(Quests plugin) { - this.plugin = plugin; - subCommands = Stream.of(new QuestadminStatsCommand(plugin), - new QuestadminGiveCommand(plugin), - new QuestadminQuitCommand(plugin), - new QuestadminPointsCommand(plugin), - new QuestadminTakepointsCommand(plugin), - new QuestadminGivepointsCommand(plugin), - new QuestadminPointsallCommand(plugin), - new QuestadminFinishCommand(plugin), - new QuestadminNextstageCommand(plugin), - new QuestadminSetstageCommand(plugin), - new QuestadminResetCommand(plugin), - new QuestadminRemoveCommand(plugin), - new QuestadminReloadCommand(plugin)) - .collect(Collectors.toMap(QuestsSubCommand::getName, Function.identity())); - } - - public boolean check(final CommandSender cs, final String[] args) { - if (args.length == 0) { - printAdminHelp(cs); - return true; - } - for (Map.Entry cmd : subCommands.entrySet()) { - if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { - if (args.length < cmd.getValue().getMaxArguments()) { - cs.sendMessage(getAdminCommandUsage(cs, args[0])); - } - cmd.getValue().execute(cs, args); - return true; - } - } - cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownAdminCommand")); - return true; - } - - public List suggest(final CommandSender cs, final String[] args) { - if (args.length == 1) { - final List results = new ArrayList<>(); - for (Map.Entry cmd : subCommands.entrySet()) { - if (cmd.getKey().startsWith(args[0]) || cmd.getValue().getNameI18N().startsWith(args[0])) { - results.add(cmd.getValue().getNameI18N()); - } - } - return results; - } - for (Map.Entry cmd : subCommands.entrySet()) { - if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { - return cmd.getValue().tabComplete(cs, args); - } - } - return Collections.emptyList(); - } - - private void printAdminHelp(final CommandSender cs) { - if (!(cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin"))) { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); - return; - } - cs.sendMessage(ChatColor.GOLD + Lang.get("questAdminHelpTitle")); - cs.sendMessage(ChatColor.YELLOW + "/questadmin" + ChatColor.RED + " " + Lang.get("COMMAND_QUESTADMIN_HELP")); - final boolean translateSubCommands = plugin.getSettings().canTranslateSubCommands(); - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.stats")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_STATS_HELP") - .replace("", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_STATS") - : "stats") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.give")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_GIVE_HELP") - .replace("", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_GIVE") - : "give") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.quit")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_QUIT_HELP") - .replace("", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_QUIT") - : "quit") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_POINTS_HELP") - .replace("", Lang.get("questPoints")) - .replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_POINTS") : "points") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS_HELP") - .replace("", Lang.get("questPoints")) - .replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS") : "takepoints") - + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS_HELP") - .replace("", Lang.get("questPoints")) - .replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS") : "givepoints") - + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.pointsall")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_POINTSALL_HELP") - .replace("", Lang.get("questPoints")) - .replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_POINTSALL") : "pointsall") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_FINISH_HELP").replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_FINISH") : "finish") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP").replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE") : "nextstage") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP").replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED+ Lang.get("COMMAND_QUESTADMIN_RESET_HELP") - .replace("", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") - : "reset") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.remove")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP").replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_REMOVE") : "remove") + ChatColor.RED)); - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reload")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get("COMMAND_QUESTADMIN_RELOAD_HELP").replace("", ChatColor.GOLD - + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RELOAD") : "reload") + ChatColor.RED)); - } - } - - private String getAdminCommandUsage(final CommandSender cs, final String cmd) { - return ChatColor.RED + Lang.get(cs, "usage") + ": " + ChatColor.YELLOW + "/questadmin " - + Lang.get(cs, Lang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP") - .replace("", cmd.toLowerCase()); - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminReloadCommand.java b/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminReloadCommand.java deleted file mode 100644 index d223b9a6b..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/questadmin/subcommands/QuestadminReloadCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.questadmin.subcommands; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.interfaces.ReloadCallback; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -public class QuestadminReloadCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestadminReloadCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "reload"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_QUESTADMIN_RELOAD"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_QUESTADMIN_RELOAD_HELP"); - } - - @Override - public String getPermission() { - return "quests.admin.reload"; - } - - @Override - public String getSyntax() { - return "/questadmin reload"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reload")) { - final ReloadCallback callback = response -> { - if (response) { - cs.sendMessage(ChatColor.GOLD + Lang.get("questsReloaded")); - String msg = Lang.get("numQuestsLoaded"); - msg = msg.replace("", ChatColor.DARK_PURPLE + String.valueOf(plugin.getLoadedQuests().size()) - + ChatColor.GOLD); - cs.sendMessage(ChatColor.GOLD + msg); - } else { - cs.sendMessage(ChatColor.RED + Lang.get("unknownError")); - } - }; - plugin.reload(callback); - } else { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java b/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java deleted file mode 100644 index 3b29e2bc1..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/QuestsCommandHandler.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.quests.subcommands.QuestsActionsCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsChoiceCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsConditionsCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsEditorCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsInfoCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsJournalCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsListCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsQuitCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsStatsCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsTakeCommand; -import me.blackvein.quests.commands.quests.subcommands.QuestsTopCommand; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class QuestsCommandHandler { - - private final Quests plugin; - private final Map subCommands; - - public QuestsCommandHandler(Quests plugin) { - this.plugin = plugin; - subCommands = Stream.of(new QuestsListCommand(plugin), - new QuestsTakeCommand(plugin), - new QuestsQuitCommand(plugin), - new QuestsStatsCommand(plugin), - new QuestsJournalCommand(plugin), - new QuestsTopCommand(plugin), - new QuestsEditorCommand(plugin), - new QuestsActionsCommand(plugin), - new QuestsConditionsCommand(plugin), - new QuestsInfoCommand(plugin), - new QuestsChoiceCommand()) - .collect(Collectors.toMap(QuestsSubCommand::getName, Function.identity())); - } - - public boolean check(final CommandSender cs, final String[] args) { - if (args.length == 0) { - printHelp(cs); - return true; - } - for (Map.Entry cmd : subCommands.entrySet()) { - if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { - if (args.length < cmd.getValue().getMaxArguments()) { - cs.sendMessage(getCommandUsage(cs, args[0])); - } - cmd.getValue().execute(cs, args); - return true; - } - } - cs.sendMessage(ChatColor.YELLOW + Lang.get(cs, "questsUnknownCommand")); - return true; - } - - public List suggest(final CommandSender cs, final String[] args) { - if (args.length == 1) { - final List results = new ArrayList<>(); - for (Map.Entry cmd : subCommands.entrySet()) { - if (cmd.getKey().startsWith(args[0]) || cmd.getValue().getNameI18N().startsWith(args[0])) { - results.add(cmd.getValue().getNameI18N()); - } - } - return results; - } - for (Map.Entry cmd : subCommands.entrySet()) { - if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) { - return cmd.getValue().tabComplete(cs, args); - } - } - return Collections.emptyList(); - } - - private void printHelp(final CommandSender cs) { - if (!cs.hasPermission("quests.quests")) { - cs.sendMessage(ChatColor.RED + Lang.get("noPermission")); - return; - } - cs.sendMessage(ChatColor.GOLD + Lang.get("questHelpTitle")); - cs.sendMessage(ChatColor.YELLOW + "/quests " + Lang.get("questDisplayHelp")); - for (final QuestsSubCommand cmd : subCommands.values()) { - if (cmd.getName().equals("choice")) { - continue; - } - cs.sendMessage(ChatColor.YELLOW + "/quests " + cmd.getDescription().replace("", ChatColor.GOLD - + (plugin.getSettings().canTranslateSubCommands() ? cmd.getNameI18N() : cmd.getName()) - + ChatColor.YELLOW)); - } - if (cs instanceof Player) { - cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW + Lang.get(cs, "COMMAND_QUEST_HELP")); - if (cs.hasPermission("quests.questinfo")) { - cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW - + Lang.get(cs, "COMMAND_QUESTINFO_HELP")); - } - } - if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) { - cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED - + Lang.get(cs, "COMMAND_QUESTADMIN_HELP")); - } - } - - private String getCommandUsage(final CommandSender cs, final String cmd) { - return ChatColor.RED + Lang.get(cs, "usage") + ": " + ChatColor.YELLOW + "/quests " - + Lang.get(cs, Lang.getKeyFromPrefix("COMMAND_", cmd) + "_HELP") - .replace("", cmd.toLowerCase()); - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java deleted file mode 100644 index cd41a3e5d..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsActionsCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.conversations.Conversable; - -public class QuestsActionsCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsActionsCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "actions"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_EVENTS_EDITOR"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_EVENTS_EDITOR_HELP"); - } - - @Override - public String getPermission() { - return "quests.actions"; - } - - @Override - public String getSyntax() { - return "/quests actions"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (cs.hasPermission("quests.events.*") || cs.hasPermission("quests.actions.*") - || cs.hasPermission("quests.actions.editor") || cs.hasPermission("quests.events.editor") - || cs.hasPermission("quests.mode.trial")) { - final Conversable c = (Conversable) cs; - if (!c.isConversing()) { - plugin.getActionFactory().getConversationFactory().buildConversation(c).begin(); - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "duplicateEditor")); - } - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java deleted file mode 100644 index 3fc8368f9..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsConditionsCommand.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.conversations.Conversable; - -public class QuestsConditionsCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsConditionsCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "conditions"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_CONDITIONS_EDITOR"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_CONDITIONS_EDITOR_HELP"); - } - - @Override - public String getPermission() { - return "quests.conditions"; - } - - @Override - public String getSyntax() { - return "/quests conditions"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (cs.hasPermission("quests.conditions.*") || cs.hasPermission("quests.conditions.editor") - || cs.hasPermission("quests.mode.trial")) { - final Conversable c = (Conversable) cs; - if (!c.isConversing()) { - plugin.getConditionFactory().getConversationFactory().buildConversation(c).begin(); - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "duplicateEditor")); - } - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java deleted file mode 100644 index 5fc251fd5..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsEditorCommand.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.conversations.Conversable; -import org.bukkit.conversations.Conversation; -import org.bukkit.entity.Player; - -public class QuestsEditorCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsEditorCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "editor"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_EDITOR"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_EDITOR_HELP"); - } - - @Override - public String getPermission() { - return "quests.editor"; - } - - @Override - public String getSyntax() { - return "/quests editor"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.editor") - || cs.hasPermission("quests.mode.trial")) { - final Conversable c = (Conversable) cs; - if (!c.isConversing()) { - final Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c); - if (cs instanceof Player) { - final Quester quester = plugin.getQuester(((Player) cs).getUniqueId()); - final QuestsCommandPreQuestsEditorEvent event - = new QuestsCommandPreQuestsEditorEvent(quester, cn.getContext()); - plugin.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; - } - } - cn.begin(); - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "duplicateEditor")); - } - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java deleted file mode 100644 index 6729c72f3..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsInfoCommand.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -public class QuestsInfoCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsInfoCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "info"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_INFO"); - } - - public String getDescription() { - return Lang.get("COMMAND_INFO_HELP"); - } - - @Override - public String getPermission() { - return "quests.info"; - } - - @Override - public String getSyntax() { - return "/quests info"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (cs.hasPermission("quests.info")) { - cs.sendMessage(ChatColor.YELLOW + "Quests " + ChatColor.GOLD + plugin.getDescription().getVersion()); - cs.sendMessage(ChatColor.GOLD + Lang.get(cs, "createdBy") + " " + ChatColor.RED + "Blackvein" - + ChatColor.GOLD + " " + Lang.get(cs, "continuedBy") + " " + ChatColor.RED - + "PikaMug & contributors"); - cs.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.UNDERLINE + "https://github.com/PikaMug/Quests"); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsJournalCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsJournalCommand.java deleted file mode 100644 index ed8e55f11..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsJournalCommand.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent; -import me.blackvein.quests.item.QuestJournal; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import xyz.upperlevel.spigot.book.BookUtil; - -public class QuestsJournalCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsJournalCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "journal"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_JOURNAL"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_JOURNAL_HELP"); - } - - @Override - public String getPermission() { - return "quests.journal"; - } - - @Override - public String getSyntax() { - return "/quests journal"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @SuppressWarnings("deprecation") - @Override - public void execute(CommandSender cs, String[] args) { - if (assertNonPlayer(cs)) { - return; - } - final Player player = (Player) cs; - if (player.hasPermission(getPermission())) { - final Quester quester = plugin.getQuester(player.getUniqueId()); - final QuestsCommandPreQuestsJournalEvent preEvent = new QuestsCommandPreQuestsJournalEvent(quester); - plugin.getServer().getPluginManager().callEvent(preEvent); - if (preEvent.isCancelled()) { - return; - } - - if (!plugin.getSettings().canGiveJournalItem()) { - final QuestJournal journal = new QuestJournal(plugin, quester); - BookUtil.openPlayer(player, journal.toItemStack()); - } else { - final Inventory inv = player.getInventory(); - final int index = quester.getJournalIndex(); - if (index != -1) { - inv.setItem(index, null); - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalPutAway") - .replace("", Lang.get(player, "journalTitle"))); - } else if (player.getItemInHand().getType().equals(Material.AIR)) { - final QuestJournal journal = new QuestJournal(plugin, quester); - player.setItemInHand(journal.toItemStack()); - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken") - .replace("", Lang.get(player, "journalTitle"))); - } else if (inv.firstEmpty() != -1) { - final ItemStack[] arr = inv.getContents(); - for (int i = 0; i < arr.length; i++) { - if (arr[i] == null) { - final QuestJournal journal = new QuestJournal(plugin, quester); - inv.setItem(i, journal.toItemStack()); - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken") - .replace("", Lang.get(player, "journalTitle"))); - break; - } - } - } else { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalNoRoom") - .replace("", Lang.get(player, "journalTitle"))); - } - } - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java deleted file mode 100644 index a995d30b2..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsListCommand.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class QuestsListCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsListCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "list"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_LIST"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_LIST_HELP"); - } - - @Override - public String getPermission() { - return "quests.list"; - } - - @Override - public String getSyntax() { - return "/quests list"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (cs.hasPermission(getPermission())) { - if (!(cs instanceof Player)) { - int num = 1; - cs.sendMessage(ChatColor.GOLD + Lang.get("questListTitle")); - for (final IQuest q : plugin.getLoadedQuests()) { - cs.sendMessage(ChatColor.YELLOW + "" + num + ". " + q.getName()); - num++; - } - return; - } - final Player player = (Player)cs; - if (args.length == 1) { - final Quester quester = plugin.getQuester(player.getUniqueId()); - final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, 1); - plugin.getServer().getPluginManager().callEvent(preEvent); - if (preEvent.isCancelled()) { - return; - } - - plugin.listQuests(quester, 1); - } else if (args.length == 2) { - final int page; - try { - page = Integer.parseInt(args[1]); - if (page < 1) { - cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageSelectionPosNum")); - } else { - final Quester quester = plugin.getQuester(player.getUniqueId()); - final QuestsCommandPreQuestsListEvent preEvent - = new QuestsCommandPreQuestsListEvent(quester, page); - plugin.getServer().getPluginManager().callEvent(preEvent); - if (preEvent.isCancelled()) { - return; - } - - plugin.listQuests(quester, page); - } - } catch (final NumberFormatException e) { - cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageSelectionNum")); - } - } - } else { - cs.sendMessage(ChatColor.RED + Lang.get(cs, "noPermission")); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java deleted file mode 100644 index a88b6f914..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsQuitCommand.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class QuestsQuitCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsQuitCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "quit"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_QUIT"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_QUIT_HELP"); - } - - @Override - public String getPermission() { - return "quests.quit"; - } - - @Override - public String getSyntax() { - return "/quests quit"; - } - - @Override - public int getMaxArguments() { - return 2; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (args.length == 1) { - // Shows command usage - return; - } - if (assertNonPlayer(cs)) { - return; - } - final Player player = (Player) cs; - if (player.hasPermission(getPermission())) { - final IQuester quester = plugin.getQuester(player.getUniqueId()); - if (!quester.getCurrentQuestsTemp().isEmpty()) { - final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' ')); - if (quest != null) { - if (quest.getOptions().canAllowQuitting()) { - final String msg = ChatColor.YELLOW + Lang.get(player, "questQuit").replace("", - ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); - quester.abandonQuest(quest, msg); - } else { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questQuitDisabled")); - } - } else { - Lang.send(player, ChatColor.RED + Lang.get(player, "questNotFound")); - } - } else { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "noActiveQuest")); - } - } else { - Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission")); - } - } - - @Override - public List tabComplete(CommandSender commandSender, String[] args) { - if (args.length == 2) { - final List results = new ArrayList<>(); - if (commandSender instanceof Player) { - final Quester quester = plugin.getQuester(((Player) commandSender).getUniqueId()); - if (quester != null) { - for (final IQuest quest : quester.getCurrentQuests().keySet()) { - if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { - results.add(ChatColor.stripColor(quest.getName())); - } - } - } - } else { - for (final IQuest quest : plugin.getLoadedQuests()) { - if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { - results.add(ChatColor.stripColor(quest.getName())); - } - } - } - return results; - } - return Collections.emptyList(); - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java deleted file mode 100644 index aeca6fa67..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsStatsCommand.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Map; - -public class QuestsStatsCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsStatsCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "stats"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_STATS"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_STATS_HELP"); - } - - @Override - public String getPermission() { - return "quests.stats"; - } - - @Override - public String getSyntax() { - return "/quests stats"; - } - - @Override - public int getMaxArguments() { - return 1; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (assertNonPlayer(cs)) { - return; - } - final Player player = (Player) cs; - if (cs.hasPermission(getPermission())) { - final IQuester quester = plugin.getQuester(player.getUniqueId()); - cs.sendMessage(ChatColor.GOLD + "- " + player.getName() + " -"); - cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "questPoints") + " - " + ChatColor.DARK_PURPLE - + quester.getQuestPoints()); - if (quester.getCurrentQuestsTemp().isEmpty()) { - cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "currentQuest") + " " + ChatColor.DARK_PURPLE - + Lang.get("none")); - } else { - cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "currentQuest")); - for (final Map.Entry set : quester.getCurrentQuestsTemp().entrySet()) { - final IQuest q = set.getKey(); - final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName() - + ChatColor.LIGHT_PURPLE + " (" + Lang.get(player, "stageEditorStage") + " " - + (set.getValue() + 1) + ")"; - cs.sendMessage(msg); - } - } - cs.sendMessage(ChatColor.YELLOW + Lang.get(player, "completedQuest")); - - if (quester.getCompletedQuestsTemp().isEmpty()) { - cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none")); - } else { - final StringBuilder completed = new StringBuilder(" "); - int index = 1; - for (final IQuest q : quester.getCompletedQuestsTemp()) { - completed.append(ChatColor.DARK_PURPLE).append(q.getName()); - if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) { - completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted() - .get(q)).append(")"); - } - if (index < (quester.getCompletedQuestsTemp().size())) { - completed.append(", "); - } - index++; - } - cs.sendMessage(completed.toString()); - } - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java b/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java deleted file mode 100644 index 27a7f20be..000000000 --- a/core/src/main/java/me/blackvein/quests/commands/quests/subcommands/QuestsTakeCommand.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.commands.quests.subcommands; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.QuestsSubCommand; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class QuestsTakeCommand extends QuestsSubCommand { - - private final Quests plugin; - - public QuestsTakeCommand(Quests plugin) { - this.plugin = plugin; - } - - @Override - public String getName() { - return "take"; - } - - @Override - public String getNameI18N() { - return Lang.get("COMMAND_TAKE"); - } - - @Override - public String getDescription() { - return Lang.get("COMMAND_TAKE_HELP"); - } - - @Override - public String getPermission() { - return "quests.take"; - } - - @Override - public String getSyntax() { - return "/quests take"; - } - - @Override - public int getMaxArguments() { - return 2; - } - - @Override - public void execute(CommandSender cs, String[] args) { - if (args.length == 1) { - // Shows command usage - return; - } - if (assertNonPlayer(cs)) { - return; - } - final Player player = (Player) cs; - if (plugin.getSettings().canAllowCommands()) { - if (player.hasPermission(getPermission())) { - final IQuest questToFind = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' ')); - final IQuester quester = plugin.getQuester(player.getUniqueId()); - if (questToFind != null) { - for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) { - if (q.getId().equals(questToFind.getId())) { - Lang.send(player, ChatColor.RED + Lang.get(player, "questAlreadyOn")); - return; - } - } - quester.offerQuest(questToFind, true); - } else { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questNotFound")); - } - } else { - Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission")); - } - } else { - Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questTakeDisabled")); - } - } - - @Override - public List tabComplete(CommandSender commandSender, String[] args) { - if (args.length == 2) { - final List results = new ArrayList<>(); - for (final IQuest quest : plugin.getLoadedQuests()) { - if (quest.getName().toLowerCase().startsWith(args[1].toLowerCase())) { - results.add(ChatColor.stripColor(quest.getName())); - } - } - return results; - } - return Collections.emptyList(); - } -} diff --git a/core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java b/core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java deleted file mode 100644 index 7d98389c8..000000000 --- a/core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.conditions; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt; -import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt; -import me.blackvein.quests.interfaces.ReloadCallback; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.util.CK; -import me.blackvein.quests.util.FakeConversable; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.conversations.ConversationAbandonedListener; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.ConversationPrefix; -import org.bukkit.conversations.Prompt; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.UUID; - -public class BukkitConditionFactory implements ConditionFactory, ConversationAbandonedListener { - - private final Quests plugin; - private final ConversationFactory conversationFactory; - private List editingConditionNames = new LinkedList<>(); - - public BukkitConditionFactory(final Quests plugin) { - this.plugin = plugin; - // Ensure to initialize factory last so that 'this' is fully initialized before it is passed - this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) - .withFirstPrompt(new ConditionMenuPrompt(new ConversationContext(plugin, new FakeConversable(), - new HashMap<>()))).withTimeout(3600) - .withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this); - } - - public static class LineBreakPrefix implements ConversationPrefix { - @Override - public @NotNull String getPrefix(final @NotNull ConversationContext context) { - return "\n"; - } - } - - public ConversationFactory getConversationFactory() { - return conversationFactory; - } - - public List getNamesOfConditionsBeingEdited() { - return editingConditionNames; - } - - public void setNamesOfConditionsBeingEdited(final List conditionNames) { - this.editingConditionNames = conditionNames; - } - - @Override - public void conversationAbandoned(final @NotNull ConversationAbandonedEvent abandonedEvent) { - } - - public Prompt returnToMenu(final ConversationContext context) { - return new ConditionMainPrompt(context); - } - - public void loadData(final ICondition condition, final ConversationContext context) { - if (condition.isFailQuest()) { - context.setSessionData(CK.C_FAIL_QUEST, true); - } else { - context.setSessionData(CK.C_FAIL_QUEST, false); - } - if (condition.getEntitiesWhileRiding() != null && !condition.getEntitiesWhileRiding().isEmpty()) { - final LinkedList entities = new LinkedList<>(condition.getEntitiesWhileRiding()); - context.setSessionData(CK.C_WHILE_RIDING_ENTITY, entities); - } - if (condition.getNpcsWhileRiding() != null && !condition.getNpcsWhileRiding().isEmpty()) { - final LinkedList npcs = new LinkedList<>(condition.getNpcsWhileRiding()); - context.setSessionData(CK.C_WHILE_RIDING_NPC, npcs); - } - if (condition.getPermissions() != null && !condition.getPermissions().isEmpty()) { - final LinkedList permissions = new LinkedList<>(condition.getPermissions()); - context.setSessionData(CK.C_WHILE_PERMISSION, permissions); - } - if (condition.getItemsWhileHoldingMainHand() != null && !condition.getItemsWhileHoldingMainHand().isEmpty()) { - final LinkedList items = new LinkedList<>(condition.getItemsWhileHoldingMainHand()); - context.setSessionData(CK.C_WHILE_HOLDING_MAIN_HAND, items); - } - if (condition.getItemsWhileWearing() != null && !condition.getItemsWhileWearing().isEmpty()) { - final LinkedList items = new LinkedList<>(condition.getItemsWhileWearing()); - context.setSessionData(CK.C_WHILE_WEARING, items); - } - if (condition.getWorldsWhileStayingWithin() != null && !condition.getWorldsWhileStayingWithin().isEmpty()) { - final LinkedList worlds = new LinkedList<>(condition.getBiomesWhileStayingWithin()); - context.setSessionData(CK.C_WHILE_WITHIN_WORLD, worlds); - } - if (condition.getTickStartWhileStayingWithin() > -1) { - final int tick = condition.getTickStartWhileStayingWithin(); - context.setSessionData(CK.C_WHILE_WITHIN_TICKS_START, tick); - } - if (condition.getTickEndWhileStayingWithin() > -1) { - final int tick = condition.getTickEndWhileStayingWithin(); - context.setSessionData(CK.C_WHILE_WITHIN_TICKS_END, tick); - } - if (condition.getBiomesWhileStayingWithin() != null && !condition.getBiomesWhileStayingWithin().isEmpty()) { - final LinkedList biomes = new LinkedList<>(condition.getBiomesWhileStayingWithin()); - context.setSessionData(CK.C_WHILE_WITHIN_BIOME, biomes); - } - if (condition.getRegionsWhileStayingWithin() != null && !condition.getRegionsWhileStayingWithin().isEmpty()) { - final LinkedList regions = new LinkedList<>(condition.getRegionsWhileStayingWithin()); - context.setSessionData(CK.C_WHILE_WITHIN_REGION, regions); - } - if (condition.getPlaceholdersCheckIdentifier() != null - && !condition.getPlaceholdersCheckIdentifier().isEmpty()) { - final LinkedList identifiers = new LinkedList<>(condition.getPlaceholdersCheckIdentifier()); - context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, identifiers); - } - if (condition.getPlaceholdersCheckValue() != null && !condition.getPlaceholdersCheckValue().isEmpty()) { - final LinkedList values = new LinkedList<>(condition.getPlaceholdersCheckValue()); - context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, values); - } - } - - public void clearData(final ConversationContext context) { - context.setSessionData(CK.C_OLD_CONDITION, null); - context.setSessionData(CK.C_NAME, null); - context.setSessionData(CK.C_FAIL_QUEST, null); - context.setSessionData(CK.C_WHILE_RIDING_ENTITY, null); - context.setSessionData(CK.C_WHILE_RIDING_NPC, null); - context.setSessionData(CK.C_WHILE_PERMISSION, null); - context.setSessionData(CK.C_WHILE_HOLDING_MAIN_HAND, null); - context.setSessionData(CK.C_WHILE_WEARING, null); - context.setSessionData(CK.C_WHILE_WITHIN_WORLD, null); - context.setSessionData(CK.C_WHILE_WITHIN_TICKS_START, null); - context.setSessionData(CK.C_WHILE_WITHIN_TICKS_END, null); - context.setSessionData(CK.C_WHILE_WITHIN_BIOME, null); - context.setSessionData(CK.C_WHILE_WITHIN_REGION, null); - context.setSessionData(CK.C_WHILE_PLACEHOLDER_ID, null); - context.setSessionData(CK.C_WHILE_PLACEHOLDER_VAL, null); - } - - public void deleteCondition(final ConversationContext context) { - final YamlConfiguration data = new YamlConfiguration(); - final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml"); - try { - data.load(conditionsFile); - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile") - .replace("", conditionsFile.getName())); - return; - } - final String condition = (String) context.getSessionData(CK.ED_CONDITION_DELETE); - final ConfigurationSection sec = data.getConfigurationSection("conditions"); - if (sec != null && condition != null) { - sec.set(condition, null); - } - try { - data.save(conditionsFile); - } catch (final IOException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError")); - return; - } - final ReloadCallback callback = response -> { - if (!response) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError")); - } - }; - plugin.reload(callback); - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorDeleted")); - if (plugin.getSettings().getConsoleLogging() > 0) { - final String identifier = context.getForWhom() instanceof Player ? - "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; - plugin.getLogger().info(identifier + " deleted condition " + condition); - } - for (final IQuester q : plugin.getOfflineQuesters()) { - for (final IQuest quest : q.getCurrentQuestsTemp().keySet()) { - q.checkQuest(quest); - } - } - clearData(context); - } - - public void saveCondition(final ConversationContext context) { - final YamlConfiguration data = new YamlConfiguration(); - final File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml"); - try { - data.load(conditionsFile); - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile") - .replace("", conditionsFile.getName())); - return; - } - if (context.getSessionData(CK.C_OLD_CONDITION) != null - && !((String) Objects.requireNonNull(context.getSessionData(CK.C_OLD_CONDITION))).isEmpty()) { - data.set("conditions." + context.getSessionData(CK.C_OLD_CONDITION), null); - final Collection temp = plugin.getLoadedConditions(); - temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION))); - plugin.setLoadedConditions(temp); - } - final ConfigurationSection section = data.createSection("conditions." + context.getSessionData(CK.C_NAME)); - editingConditionNames.remove((String) context.getSessionData(CK.C_NAME)); - if (context.getSessionData(CK.C_FAIL_QUEST) != null) { - final Boolean b = (Boolean) context.getSessionData(CK.C_FAIL_QUEST); - if (b != null) { - section.set("fail-quest", b); - } - } - if (context.getSessionData(CK.C_WHILE_RIDING_ENTITY) != null) { - section.set("ride-entity", context.getSessionData(CK.C_WHILE_RIDING_ENTITY)); - } - if (context.getSessionData(CK.C_WHILE_RIDING_NPC) != null) { - section.set("ride-npc-uuid", context.getSessionData(CK.C_WHILE_RIDING_NPC)); - } - if (context.getSessionData(CK.C_WHILE_PERMISSION) != null) { - section.set("permission", context.getSessionData(CK.C_WHILE_PERMISSION)); - } - if (context.getSessionData(CK.C_WHILE_HOLDING_MAIN_HAND) != null) { - section.set("hold-main-hand", context.getSessionData(CK.C_WHILE_HOLDING_MAIN_HAND)); - } - if (context.getSessionData(CK.C_WHILE_WEARING) != null) { - section.set("wear", context.getSessionData(CK.C_WHILE_WEARING)); - } - if (context.getSessionData(CK.C_WHILE_WITHIN_WORLD) != null) { - section.set("stay-within-world", context.getSessionData(CK.C_WHILE_WITHIN_WORLD)); - } - if (context.getSessionData(CK.C_WHILE_WITHIN_TICKS_START) != null) { - section.set("stay-within-ticks.start", context.getSessionData(CK.C_WHILE_WITHIN_TICKS_START)); - } - if (context.getSessionData(CK.C_WHILE_WITHIN_TICKS_END) != null) { - section.set("stay-within-ticks.end", context.getSessionData(CK.C_WHILE_WITHIN_TICKS_END)); - } - if (context.getSessionData(CK.C_WHILE_WITHIN_BIOME) != null) { - section.set("stay-within-biome", context.getSessionData(CK.C_WHILE_WITHIN_BIOME)); - } - if (context.getSessionData(CK.C_WHILE_WITHIN_REGION) != null) { - section.set("stay-within-region", context.getSessionData(CK.C_WHILE_WITHIN_REGION)); - } - if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID) != null) { - section.set("check-placeholder-id", context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID)); - } - if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL) != null) { - section.set("check-placeholder-value", context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL)); - } - try { - data.save(conditionsFile); - } catch (final IOException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError")); - return; - } - final ReloadCallback callback = response -> { - if (!response) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError")); - } - }; - plugin.reload(callback); - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorSaved")); - if (plugin.getSettings().getConsoleLogging() > 0) { - final String identifier = context.getForWhom() instanceof Player ? - "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; - plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME)); - } - for (final IQuester q : plugin.getOfflineQuesters()) { - for (final IQuest quest : q.getCurrentQuestsTemp().keySet()) { - q.checkQuest(quest); - } - } - clearData(context); - } -} \ No newline at end of file diff --git a/core/src/main/java/me/blackvein/quests/convo/misc/MiscNumericPrompt.java b/core/src/main/java/me/blackvein/quests/convo/misc/MiscNumericPrompt.java deleted file mode 100644 index e33ddc287..000000000 --- a/core/src/main/java/me/blackvein/quests/convo/misc/MiscNumericPrompt.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.misc; - -import me.blackvein.quests.convo.QuestsNumericPrompt; -import org.bukkit.ChatColor; -import org.bukkit.conversations.ConversationContext; - -public abstract class MiscNumericPrompt extends QuestsNumericPrompt { - private final ConversationContext context; - - public MiscNumericPrompt(final ConversationContext context) { - this.context = context; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public abstract int getSize(); - - public abstract String getTitle(ConversationContext context); - - public abstract ChatColor getNumberColor(ConversationContext context, int number); - - public abstract String getSelectionText(ConversationContext context, int number); - - public abstract String getAdditionalText(ConversationContext context, int number); -} diff --git a/core/src/main/java/me/blackvein/quests/convo/misc/MiscStringPrompt.java b/core/src/main/java/me/blackvein/quests/convo/misc/MiscStringPrompt.java deleted file mode 100644 index 836d47452..000000000 --- a/core/src/main/java/me/blackvein/quests/convo/misc/MiscStringPrompt.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.misc; - -import me.blackvein.quests.convo.QuestsStringPrompt; -import org.bukkit.conversations.ConversationContext; - -public abstract class MiscStringPrompt extends QuestsStringPrompt { - private final ConversationContext context; - - public MiscStringPrompt(final ConversationContext context) { - this.context = context; - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - public ConversationContext getConversationContext() { - return context; - } - - public abstract int getSize(); - - public abstract String getTitle(ConversationContext context); - - public abstract String getQueryText(ConversationContext context); -} diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/stages/QuestStageMenuPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/stages/QuestStageMenuPrompt.java deleted file mode 100644 index 333d64a3a..000000000 --- a/core/src/main/java/me/blackvein/quests/convo/quests/stages/QuestStageMenuPrompt.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.convo.quests.stages; - -import org.bukkit.ChatColor; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.Prompt; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; -import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent; -import me.blackvein.quests.util.CK; -import me.blackvein.quests.util.Lang; -import org.jetbrains.annotations.NotNull; - -public class QuestStageMenuPrompt extends QuestsEditorNumericPrompt { - - private final Quests plugin; - private final int size = 2; - - public QuestStageMenuPrompt(final ConversationContext context) { - super(context); - this.plugin = (Quests)context.getPlugin(); - } - - @Override - public int getSize() { - return size; - } - - @Override - public String getTitle(final ConversationContext context) { - return Lang.get("stageEditorStages"); - } - - @Override - public ChatColor getNumberColor(final ConversationContext context, final int number) { - final int stages = getStages(context); - if (number > 0) { - if (number < stages + 1) { - return ChatColor.BLUE; - } else if (number == stages + 1) { - return ChatColor.BLUE; - } else if (number == stages + 2) { - return ChatColor.GREEN; - } - } - return null; - } - - @Override - public String getSelectionText(final ConversationContext context, final int number) { - final int stages = getStages(context); - if (number > 0) { - if (number < stages + 1) { - return ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + number; - } else if (number == stages + 1) { - return ChatColor.YELLOW + Lang.get("stageEditorNewStage"); - } else if (number == stages + 2) { - return ChatColor.YELLOW + Lang.get("done"); - } - } - return null; - } - - @Override - public String getAdditionalText(final ConversationContext context, final int number) { - return null; - } - - @Override - public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) { - final QuestsEditorPostOpenNumericPromptEvent event - = new QuestsEditorPostOpenNumericPromptEvent(context, this); - plugin.getServer().getPluginManager().callEvent(event); - - final StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + "- " + getTitle(context) + " -"); - for (int i = 1; i <= (getStages(context) + size); i++) { - text.append("\n").append(getNumberColor(context, i)).append(ChatColor.BOLD).append(i) - .append(ChatColor.RESET).append(" - ").append(getSelectionText(context, i)); - } - return text.toString(); - } - - @Override - protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) { - final int i = input.intValue(); - final int stages = getStages(context); - if (i > 0) { - if (i < (stages + 1)) { - return new QuestStageMainPrompt((i), context); - } else if (i == (stages + 1)) { - return new QuestStageMainPrompt((stages + 1), context); - } else if (i == (stages + 2)) { - return plugin.getQuestFactory().returnToMenu(context); - } - } - return new QuestStageMenuPrompt(context); - } - - public int getStages(final ConversationContext context) { - int num = 1; - while (true) { - if (context.getSessionData("stage" + num) != null) { - num++; - } else { - break; - } - } - return (num - 1); - } - - public void deleteStage(final ConversationContext context, final int stageNum) { - final int stages = getStages(context); - int current = stageNum; - String pref = "stage" + current; - String newPref; - final boolean last = stageNum == stages; - while (true) { - if (!last) { - current++; - if (current > stages) { - break; - } - pref = "stage" + current; - newPref = "stage" + (current - 1); - context.setSessionData(newPref + CK.S_BREAK_NAMES, context.getSessionData(pref + CK.S_BREAK_NAMES)); - context.setSessionData(newPref + CK.S_BREAK_AMOUNTS, context.getSessionData(pref + CK.S_BREAK_AMOUNTS)); - context.setSessionData(newPref + CK.S_BREAK_DURABILITY, context.getSessionData(pref - + CK.S_BREAK_DURABILITY)); - context.setSessionData(newPref + CK.S_DAMAGE_NAMES, context.getSessionData(pref + CK.S_DAMAGE_NAMES)); - context.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, context.getSessionData(pref - + CK.S_DAMAGE_AMOUNTS)); - context.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, context.getSessionData(pref - + CK.S_DAMAGE_DURABILITY)); - context.setSessionData(newPref + CK.S_PLACE_NAMES, context.getSessionData(pref + CK.S_PLACE_NAMES)); - context.setSessionData(newPref + CK.S_PLACE_NAMES, context.getSessionData(pref + CK.S_PLACE_AMOUNTS)); - context.setSessionData(newPref + CK.S_PLACE_DURABILITY, context.getSessionData(pref - + CK.S_PLACE_DURABILITY)); - context.setSessionData(newPref + CK.S_USE_NAMES, context.getSessionData(pref + CK.S_USE_NAMES)); - context.setSessionData(newPref + CK.S_USE_AMOUNTS, context.getSessionData(pref + CK.S_USE_AMOUNTS)); - context.setSessionData(newPref + CK.S_USE_DURABILITY, context.getSessionData(pref - + CK.S_USE_DURABILITY)); - context.setSessionData(newPref + CK.S_CUT_NAMES, context.getSessionData(pref + CK.S_CUT_NAMES)); - context.setSessionData(newPref + CK.S_CUT_AMOUNTS, context.getSessionData(pref + CK.S_CUT_AMOUNTS)); - context.setSessionData(newPref + CK.S_CUT_DURABILITY, context.getSessionData(pref - + CK.S_CUT_DURABILITY)); - context.setSessionData(newPref + CK.S_CRAFT_ITEMS, context.getSessionData(pref + CK.S_CRAFT_ITEMS)); - context.setSessionData(newPref + CK.S_SMELT_ITEMS, context.getSessionData(pref + CK.S_SMELT_ITEMS)); - context.setSessionData(newPref + CK.S_ENCHANT_ITEMS, context.getSessionData(pref + CK.S_ENCHANT_ITEMS)); - context.setSessionData(newPref + CK.S_BREW_ITEMS, context.getSessionData(pref + CK.S_BREW_ITEMS)); - context.setSessionData(newPref + CK.S_FISH, context.getSessionData(pref + CK.S_FISH)); - context.setSessionData(newPref + CK.S_PLAYER_KILL, context.getSessionData(pref + CK.S_PLAYER_KILL)); - context.setSessionData(newPref + CK.S_DELIVERY_ITEMS, context.getSessionData(pref - + CK.S_DELIVERY_ITEMS)); - context.setSessionData(newPref + CK.S_DELIVERY_NPCS, context.getSessionData(pref + CK.S_DELIVERY_NPCS)); - context.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, context.getSessionData(pref - + CK.S_DELIVERY_MESSAGES)); - context.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, context.getSessionData(pref - + CK.S_NPCS_TO_TALK_TO)); - context.setSessionData(newPref + CK.S_NPCS_TO_KILL, context.getSessionData(pref + CK.S_NPCS_TO_KILL)); - context.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, context.getSessionData(pref - + CK.S_NPCS_TO_KILL_AMOUNTS)); - context.setSessionData(newPref + CK.S_MOB_TYPES, context.getSessionData(pref + CK.S_MOB_TYPES)); - context.setSessionData(newPref + CK.S_MOB_AMOUNTS, context.getSessionData(pref + CK.S_MOB_AMOUNTS)); - context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, context.getSessionData(pref - + CK.S_MOB_KILL_LOCATIONS)); - context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, context.getSessionData(pref - + CK.S_MOB_KILL_LOCATIONS_RADIUS)); - context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, context.getSessionData(pref - + CK.S_MOB_KILL_LOCATIONS_NAMES)); - context.setSessionData(newPref + CK.S_REACH_LOCATIONS, context.getSessionData(pref - + CK.S_REACH_LOCATIONS)); - context.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, context.getSessionData(pref - + CK.S_REACH_LOCATIONS_RADIUS)); - context.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, context.getSessionData(pref - + CK.S_REACH_LOCATIONS_NAMES)); - context.setSessionData(newPref + CK.S_TAME_TYPES, context.getSessionData(pref + CK.S_TAME_TYPES)); - context.setSessionData(newPref + CK.S_TAME_AMOUNTS, context.getSessionData(pref + CK.S_TAME_AMOUNTS)); - context.setSessionData(newPref + CK.S_SHEAR_COLORS, context.getSessionData(pref + CK.S_SHEAR_COLORS)); - context.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, context.getSessionData(pref + CK.S_SHEAR_AMOUNTS)); - context.setSessionData(newPref + CK.S_START_EVENT, context.getSessionData(pref + CK.S_START_EVENT)); - context.setSessionData(newPref + CK.S_DISCONNECT_EVENT, context.getSessionData(pref - + CK.S_DISCONNECT_EVENT)); - context.setSessionData(newPref + CK.S_DEATH_EVENT, context.getSessionData(pref + CK.S_DEATH_EVENT)); - context.setSessionData(newPref + CK.S_CHAT_EVENTS, context.getSessionData(pref + CK.S_CHAT_EVENTS)); - context.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, context.getSessionData(pref - + CK.S_CHAT_EVENT_TRIGGERS)); - context.setSessionData(newPref + CK.S_FINISH_EVENT, context.getSessionData(pref + CK.S_FINISH_EVENT)); - context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, context.getSessionData(pref - + CK.S_CUSTOM_OBJECTIVES)); - context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, context.getSessionData(pref - + CK.S_CUSTOM_OBJECTIVES_DATA)); - context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, context.getSessionData(pref - + CK.S_CUSTOM_OBJECTIVES_COUNT)); - context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, context.getSessionData(pref - + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS)); - context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, context.getSessionData(pref - + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP)); - context.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, context.getSessionData(pref - + CK.S_PASSWORD_DISPLAYS)); - context.setSessionData(newPref + CK.S_PASSWORD_PHRASES, context.getSessionData(pref - + CK.S_PASSWORD_PHRASES)); - context.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, context.getSessionData(pref - + CK.S_OVERRIDE_DISPLAY)); - context.setSessionData(newPref + CK.S_DELAY, context.getSessionData(pref + CK.S_DELAY)); - context.setSessionData(newPref + CK.S_DELAY_MESSAGE, context.getSessionData(pref - + CK.S_DELAY_MESSAGE)); - context.setSessionData(newPref + CK.S_DENIZEN, context.getSessionData(pref + CK.S_DENIZEN)); - context.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, context.getSessionData(pref - + CK.S_COMPLETE_MESSAGE)); - context.setSessionData(newPref + CK.S_START_MESSAGE, context.getSessionData(pref + CK.S_START_MESSAGE)); - } - context.setSessionData(pref + CK.S_BREAK_NAMES, null); - context.setSessionData(pref + CK.S_BREAK_AMOUNTS, null); - context.setSessionData(pref + CK.S_BREAK_DURABILITY, null); - context.setSessionData(pref + CK.S_DAMAGE_NAMES, null); - context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null); - context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null); - context.setSessionData(pref + CK.S_PLACE_NAMES, null); - context.setSessionData(pref + CK.S_PLACE_AMOUNTS, null); - context.setSessionData(pref + CK.S_PLACE_DURABILITY, null); - context.setSessionData(pref + CK.S_USE_NAMES, null); - context.setSessionData(pref + CK.S_USE_AMOUNTS, null); - context.setSessionData(pref + CK.S_USE_DURABILITY, null); - context.setSessionData(pref + CK.S_CUT_NAMES, null); - context.setSessionData(pref + CK.S_CUT_AMOUNTS, null); - context.setSessionData(pref + CK.S_CUT_DURABILITY, null); - context.setSessionData(pref + CK.S_CRAFT_ITEMS, null); - context.setSessionData(pref + CK.S_SMELT_ITEMS, null); - context.setSessionData(pref + CK.S_ENCHANT_ITEMS, null); - context.setSessionData(pref + CK.S_BREW_ITEMS, null); - context.setSessionData(pref + CK.S_FISH, null); - context.setSessionData(pref + CK.S_PLAYER_KILL, null); - context.setSessionData(pref + CK.S_DELIVERY_ITEMS, null); - context.setSessionData(pref + CK.S_DELIVERY_NPCS, null); - context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null); - context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null); - context.setSessionData(pref + CK.S_NPCS_TO_KILL, null); - context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null); - context.setSessionData(pref + CK.S_MOB_TYPES, null); - context.setSessionData(pref + CK.S_MOB_AMOUNTS, null); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null); - context.setSessionData(pref + CK.S_REACH_LOCATIONS, null); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null); - context.setSessionData(pref + CK.S_TAME_TYPES, null); - context.setSessionData(pref + CK.S_TAME_AMOUNTS, null); - context.setSessionData(pref + CK.S_SHEAR_COLORS, null); - context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null); - context.setSessionData(pref + CK.S_FINISH_EVENT, null); - context.setSessionData(pref + CK.S_START_EVENT, null); - context.setSessionData(pref + CK.S_DEATH_EVENT, null); - context.setSessionData(pref + CK.S_CHAT_EVENTS, null); - context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null); - context.setSessionData(pref + CK.S_DISCONNECT_EVENT, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); - context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null); - context.setSessionData(pref + CK.S_PASSWORD_PHRASES, null); - context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null); - context.setSessionData(pref + CK.S_DELAY, null); - context.setSessionData(pref + CK.S_DELAY_MESSAGE, null); - context.setSessionData(pref + CK.S_DENIZEN, null); - context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null); - context.setSessionData(pref + CK.S_START_MESSAGE, null); - if (last) { - break; - } - } - if (!last) { - context.setSessionData("stage" + (current - 1), null); - } else { - context.setSessionData("stage" + (current), null); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/dependencies/DenizenTrigger.java b/core/src/main/java/me/blackvein/quests/dependencies/DenizenTrigger.java deleted file mode 100644 index 8d0612fe2..000000000 --- a/core/src/main/java/me/blackvein/quests/dependencies/DenizenTrigger.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.dependencies; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.player.IQuester; -import net.citizensnpcs.api.npc.NPC; - -import java.util.UUID; - -public class DenizenTrigger { - private final Quests plugin; - - public DenizenTrigger(final Quests plugin) { - this.plugin = plugin; - } - - public boolean runDenizenScript(final String scriptName, final IQuester quester, final UUID uuid) { - if (scriptName == null) { - return false; - } - if (plugin.getDependencies().getDenizenApi().containsScript(scriptName)) { - if (plugin.getDependencies().getCitizens() != null) { - if (uuid == null) { - plugin.getLogger().severe("NPC UUID was null for Denizen script named " + scriptName); - return false; - } - final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid); - plugin.getDependencies().getDenizenApi().runTaskScript(scriptName, quester.getPlayer(), npc); - } else { - plugin.getDependencies().getDenizenApi().runTaskScript(scriptName, quester.getPlayer(), null); - } - } - return true; - } -} diff --git a/core/src/main/java/me/blackvein/quests/entity/CountableMob.java b/core/src/main/java/me/blackvein/quests/entity/CountableMob.java deleted file mode 100644 index a0fb19aca..000000000 --- a/core/src/main/java/me/blackvein/quests/entity/CountableMob.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.entity; - -import org.bukkit.entity.EntityType; - -public class CountableMob { - - private EntityType entityType; - private int count; - - public CountableMob(EntityType entityType, int count) { - this.entityType = entityType; - this.count = count; - } - - public EntityType getEntityType() { - return entityType; - } - - public void setEntityType(final EntityType entityType) { - this.entityType = entityType; - } - - public int getCount() { - return count; - } - - public void setCount(final int count) { - this.count = count; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java b/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java deleted file mode 100644 index 4584d824d..000000000 --- a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.command; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.events.QuestsEvent; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Represents a Quests command-related event - */ -public abstract class QuestsCommandEvent extends QuestsEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final Quester quester; - - public QuestsCommandEvent(final Quester quester) { - this.quester = quester; - } - - public QuestsCommandEvent(final Quester quester, final boolean async) { - super(async); - this.quester = quester; - } - - /** - * Returns the quester involved in this event - * - * @return Quester which is involved in this event - */ - public final Quester getQuester() { - return quester; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java b/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java deleted file mode 100644 index 92d469916..000000000 --- a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.command; - -import me.blackvein.quests.Quester; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called when the /quests editor command is run by a player - */ -public class QuestsCommandPreQuestsEditorEvent extends QuestsCommandEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; - private final ConversationContext context; - - public QuestsCommandPreQuestsEditorEvent(final Quester quester, final ConversationContext context) { - super(quester); - this.context = context; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - public ConversationContext getConversationContext() { - return context; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java b/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java deleted file mode 100644 index 07a6bb349..000000000 --- a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.command; - -import me.blackvein.quests.Quester; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called when the /quests journal command is run by a player - */ -public class QuestsCommandPreQuestsJournalEvent extends QuestsCommandEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; - - public QuestsCommandPreQuestsJournalEvent(final Quester quester) { - super(quester); - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsListEvent.java b/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsListEvent.java deleted file mode 100644 index e71e90593..000000000 --- a/core/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsListEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.command; - -import me.blackvein.quests.Quester; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called when the /quests list command is run by a player - */ -public class QuestsCommandPreQuestsListEvent extends QuestsCommandEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final int page; - private boolean cancel = false; - - public QuestsCommandPreQuestsListEvent(final Quester quester, final int page) { - super(quester); - this.page = page; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - - public int getPage() { - return page; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterEvent.java deleted file mode 100644 index d64ac83c1..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.events.QuestsEvent; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Represents a quester-related event - */ -public abstract class QuesterEvent extends QuestsEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final Quester quester; - - public QuesterEvent(final Quester quester) { - this.quester = quester; - } - - public QuesterEvent(final Quester quester, final boolean async) { - super(async); - this.quester = quester; - - } - - /** - * Returns the quester involved in this event - * - * @return Quester which is involved in this event - */ - public final Quester getQuester() { - return quester; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java deleted file mode 100644 index a6906d203..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.IStage; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called after an online quester changes stage - */ -public class QuesterPostChangeStageEvent extends QuesterEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private final IStage current; - private final IStage next; - - public QuesterPostChangeStageEvent(final Quester quester, final IQuest quest, final IStage current, final IStage next) { - super(quester); - this.quest = quest; - this.current = current; - this.next = next; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - public IStage getCurrentStage() { - return current; - } - - public IStage getNextStage() { - return next; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostCompleteQuestEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostCompleteQuestEvent.java deleted file mode 100644 index 05d79a284..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostCompleteQuestEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called after an online quester completes a quest - */ -public class QuesterPostCompleteQuestEvent extends QuesterEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - - public QuesterPostCompleteQuestEvent(final Quester quester, final IQuest quest) { - super(quester); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostFailQuestEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostFailQuestEvent.java deleted file mode 100644 index 2d6f1a133..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostFailQuestEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called after a quester fails a quest - */ -public class QuesterPostFailQuestEvent extends QuesterEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - - public QuesterPostFailQuestEvent(final Quester quester, final IQuest quest) { - super(quester); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostStartQuestEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostStartQuestEvent.java deleted file mode 100644 index 23112b2c0..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostStartQuestEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called after an online quester starts a quest - */ -public class QuesterPostStartQuestEvent extends QuesterEvent { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - - public QuesterPostStartQuestEvent(final Quester quester, final IQuest quest) { - super(quester); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostUpdateObjectiveEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostUpdateObjectiveEvent.java deleted file mode 100644 index 4305ae2d5..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostUpdateObjectiveEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.Objective; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called after a quester progresses an objective - */ -public class QuesterPostUpdateObjectiveEvent extends QuesterEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private final Objective objective; - private boolean cancel = false; - - public QuesterPostUpdateObjectiveEvent(final Quester quester, final IQuest quest, final Objective objective) { - super(quester); - this.quest = quest; - this.objective = objective; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - /** - * Returns the objective involved in this event - * - * @return Objective which is involved in this event - */ - public Objective getObjective() { - return objective; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java deleted file mode 100644 index d54457b36..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.IStage; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called before an online quester changes stage - */ -public class QuesterPreChangeStageEvent extends QuesterEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private final IStage current; - private final IStage next; - private boolean cancel = false;; - - public QuesterPreChangeStageEvent(final Quester quester, final IQuest quest, final IStage current, final IStage next) { - super(quester); - this.quest = quest; - this.current = current; - this.next = next; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - public IStage getCurrentStage() { - return current; - } - - public IStage getNextStage() { - return next; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreCompleteQuestEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreCompleteQuestEvent.java deleted file mode 100644 index fd7657c51..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreCompleteQuestEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called before an online quester completes a quest - */ -public class QuesterPreCompleteQuestEvent extends QuesterEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private boolean cancel = false; - - public QuesterPreCompleteQuestEvent(final Quester quester, final IQuest quest) { - super(quester); - this.quest = quest; - } - - public QuesterPreCompleteQuestEvent(final Quester quester, final IQuest quest, final boolean async) { - super(quester, async); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreFailQuestEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreFailQuestEvent.java deleted file mode 100644 index d544c7b8d..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreFailQuestEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called before a quester fails a quest - */ -public class QuesterPreFailQuestEvent extends QuesterEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private boolean cancel = false; - - public QuesterPreFailQuestEvent(final Quester quester, final IQuest quest) { - super(quester); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreStartQuestEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreStartQuestEvent.java deleted file mode 100644 index b1072383d..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreStartQuestEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called before a quester starts a quest - */ -public class QuesterPreStartQuestEvent extends QuesterEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private boolean cancel = false; - - public QuesterPreStartQuestEvent(final Quester quester, final IQuest quest) { - super(quester); - this.quest = quest; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreUpdateObjectiveEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreUpdateObjectiveEvent.java deleted file mode 100644 index 4e7341432..000000000 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreUpdateObjectiveEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.events.quester; - -import me.blackvein.quests.Quester; -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.Objective; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.jetbrains.annotations.NotNull; - -/** - * Called before a quester progresses an objective - */ -public class QuesterPreUpdateObjectiveEvent extends QuesterEvent implements Cancellable { - private static final HandlerList HANDLERS = new HandlerList(); - private final IQuest quest; - private final Objective objective; - private boolean cancel = false; - - public QuesterPreUpdateObjectiveEvent(final Quester quester, final IQuest quest, final Objective objective) { - super(quester); - this.quest = quest; - this.objective = objective; - } - - /** - * Returns the quest involved in this event - * - * @return Quest which is involved in this event - */ - public IQuest getQuest() { - return quest; - } - - /** - * Returns the objective involved in this event - * - * @return Objective which is involved in this event - */ - public Objective getObjective() { - return objective; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(final boolean cancel) { - this.cancel = cancel; - } - - @Override - public @NotNull HandlerList getHandlers() { - return HANDLERS; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } -} diff --git a/core/src/main/java/me/blackvein/quests/interfaces/ReloadCallback.java b/core/src/main/java/me/blackvein/quests/interfaces/ReloadCallback.java deleted file mode 100644 index 06f2c3289..000000000 --- a/core/src/main/java/me/blackvein/quests/interfaces/ReloadCallback.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.interfaces; - -public interface ReloadCallback { - void execute(T response); -} diff --git a/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java b/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java deleted file mode 100644 index 87fb1a698..000000000 --- a/core/src/main/java/me/blackvein/quests/listeners/CommandManager.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.listeners; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.commands.quest.QuestCommandHandler; -import me.blackvein.quests.commands.questadmin.QuestadminCommandHandler; -import me.blackvein.quests.commands.quests.QuestsCommandHandler; -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabExecutor; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class CommandManager implements TabExecutor { - private final Quests plugin; - - public CommandManager(final Quests plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(final @NotNull CommandSender cs, final @NotNull Command cmd, - final @NotNull String label, final String[] args) { - if (plugin.isLoading()) { - cs.sendMessage(ChatColor.RED + Lang.get("errorLoading")); - return true; - } - if (cs instanceof Player) { - if (!plugin.canUseQuests(((Player) cs).getUniqueId())) { - cs.sendMessage(ChatColor.RED + Lang.get((Player) cs, "noPermission")); - return true; - } - } - if (cmd.getName().equalsIgnoreCase("quest")) { - return new QuestCommandHandler(plugin).check(cs, args); - } else if (cmd.getName().equalsIgnoreCase("quests")) { - return new QuestsCommandHandler(plugin).check(cs, args); - } else if (cmd.getName().equalsIgnoreCase("questadmin") || cmd.getName().equalsIgnoreCase("questsadmin")) { - return new QuestadminCommandHandler(plugin).check(cs, args); - } - return false; - } - - @Nullable - @Override - public List onTabComplete(@NotNull CommandSender cs, @NotNull Command cmd, - @NotNull String label, @NotNull String[] args) { - if (args.length > 0) { - if (cmd.getName().equalsIgnoreCase("quest")) { - return new QuestCommandHandler(plugin).suggest(cs, args); - } else if (cmd.getName().equalsIgnoreCase("quests")) { - return new QuestsCommandHandler(plugin).suggest(cs, args); - } else if (cmd.getName().equalsIgnoreCase("questadmin")) { - return new QuestadminCommandHandler(plugin).suggest(cs, args); - } - } - return null; - } -} diff --git a/core/src/main/java/me/blackvein/quests/listeners/ConvoListener.java b/core/src/main/java/me/blackvein/quests/listeners/ConvoListener.java deleted file mode 100644 index 097408421..000000000 --- a/core/src/main/java/me/blackvein/quests/listeners/ConvoListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package me.blackvein.quests.listeners; - -import me.blackvein.quests.util.Lang; -import org.bukkit.ChatColor; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.conversations.ConversationAbandonedListener; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -public class ConvoListener implements ConversationAbandonedListener { - - @Override - public void conversationAbandoned(@NotNull final ConversationAbandonedEvent abandonedEvent) { - if (!abandonedEvent.gracefulExit()) { - try { - abandonedEvent.getContext().getForWhom().sendRawMessage(ChatColor.YELLOW - + Lang.get((Player) abandonedEvent.getContext().getForWhom(), "questTimeout")); - } catch (final Exception e) { - // Do nothing - } - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/listeners/PartiesListener.java b/core/src/main/java/me/blackvein/quests/listeners/PartiesListener.java deleted file mode 100644 index 4c5acc6db..000000000 --- a/core/src/main/java/me/blackvein/quests/listeners/PartiesListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.listeners; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -import com.alessiodp.parties.api.events.bukkit.party.BukkitPartiesPartyPostCreateEvent; -import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPostJoinEvent; -import com.alessiodp.parties.api.events.bukkit.player.BukkitPartiesPlayerPostLeaveEvent; - -import me.blackvein.quests.util.Lang; - -public class PartiesListener implements Listener { - - @EventHandler - public void onPartyCreate(final BukkitPartiesPartyPostCreateEvent event) { - if (event.getCreator() != null) { - final Player p = Bukkit.getServer().getPlayer(event.getCreator().getPlayerUUID()); - if (p != null) { - if (Lang.get("questPartiesCreate").length() > 0) { - Lang.send(p, ChatColor.YELLOW + Lang.get("questPartiesCreate")); - } - } - } - } - - @EventHandler - public void onPlayerJoinEvent(final BukkitPartiesPlayerPostJoinEvent event) { - final Player p = Bukkit.getServer().getPlayer(event.getPartyPlayer().getPlayerUUID()); - if (p != null && Lang.get("questPartiesLeave").length() > 0) { - Lang.send(p, ChatColor.GREEN + Lang.get(p, "questPartiesJoin")); - event.getParty().broadcastMessage(ChatColor.GREEN + Lang.get("questPartiesJoinBroadcast").replace("", event.getPartyPlayer().getName()), event.getPartyPlayer()); - } - } - - @EventHandler - public void onPlayerLeaveEvent(final BukkitPartiesPlayerPostLeaveEvent event) { - final Player p = Bukkit.getServer().getPlayer(event.getPartyPlayer().getPlayerUUID()); - if (p != null && Lang.get("questPartiesLeave").length() > 0) { - Lang.send(p, ChatColor.RED + Lang.get(p, "questPartiesLeave")); - event.getParty().broadcastMessage(ChatColor.RED + Lang.get("questPartiesLeaveBroadcast").replace("", event.getPartyPlayer().getName()), event.getPartyPlayer()); - } - } -} diff --git a/core/src/main/java/me/blackvein/quests/nms/ActionBarProvider.java b/core/src/main/java/me/blackvein/quests/nms/ActionBarProvider.java deleted file mode 100644 index 2ac57b07e..000000000 --- a/core/src/main/java/me/blackvein/quests/nms/ActionBarProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.nms; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public abstract class ActionBarProvider { - - private static ActionBarProvider loaded; - - static { - final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - try { - final String packageName = ActionBarProvider.class.getPackage().getName(); - if (internalsName.startsWith("v1_8_R")) { - loaded = (ActionBarProvider) Class.forName(packageName + ".ActionBarProvider_" + internalsName) - .newInstance(); - } else { - loaded = new ActionBarProvider_Bukkit(); - } - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException - | ClassCastException exception) { - Bukkit.getLogger().severe("[Quests] No valid action bar implementation for version " + internalsName); - } - } - - abstract void sendActionBarPacket(Player player, String message); - - /** - * Sends the action bar to the player. - * - * @param player - * The player to send the action bar to. - * @param message - * The message, - */ - public static void sendActionBar(final Player player, final String message) { - loaded.sendActionBarPacket(player, message); - } -} diff --git a/core/src/main/java/me/blackvein/quests/nms/ActionBarProvider_Bukkit.java b/core/src/main/java/me/blackvein/quests/nms/ActionBarProvider_Bukkit.java deleted file mode 100644 index c952d3578..000000000 --- a/core/src/main/java/me/blackvein/quests/nms/ActionBarProvider_Bukkit.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.nms; - -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.entity.Player; - -class ActionBarProvider_Bukkit extends ActionBarProvider { - - @Override - void sendActionBarPacket(final Player player, String message) { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); - } -} diff --git a/core/src/main/java/me/blackvein/quests/nms/ParticleProvider_Bukkit.java b/core/src/main/java/me/blackvein/quests/nms/ParticleProvider_Bukkit.java deleted file mode 100644 index 6e0700ce3..000000000 --- a/core/src/main/java/me/blackvein/quests/nms/ParticleProvider_Bukkit.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.nms; - -import org.bukkit.Location; -import org.bukkit.Particle; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.Map; - -class ParticleProvider_Bukkit extends ParticleProvider { - - private static final Map PARTICLES = new HashMap<>(); - - static { - PARTICLES.put(PreBuiltParticle.ENCHANT, Particle.ENCHANTMENT_TABLE); - PARTICLES.put(PreBuiltParticle.CRIT, Particle.CRIT); - PARTICLES.put(PreBuiltParticle.SPELL, Particle.SPELL_INSTANT); - PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, Particle.CRIT_MAGIC); - PARTICLES.put(PreBuiltParticle.MOB_SPELL, Particle.SPELL_MOB); - PARTICLES.put(PreBuiltParticle.NOTE, Particle.NOTE); - PARTICLES.put(PreBuiltParticle.PORTAL, Particle.PORTAL); - PARTICLES.put(PreBuiltParticle.DUST, Particle.REDSTONE); - PARTICLES.put(PreBuiltParticle.WITCH, Particle.SPELL_WITCH); - PARTICLES.put(PreBuiltParticle.SNOWBALL, Particle.SNOWBALL); - PARTICLES.put(PreBuiltParticle.SPLASH, Particle.WATER_SPLASH); - PARTICLES.put(PreBuiltParticle.SMOKE, Particle.TOWN_AURA); - } - - @Override - Map getParticleMap() { - return PARTICLES; - } - - @Override - void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX, final float offsetY, final float offsetZ, - final float speed, final int count, final int[] data) { - player.spawnParticle((Particle) particle, location, count, offsetX, offsetY, offsetZ, speed, data); - } -} diff --git a/core/src/main/java/me/blackvein/quests/nms/TitleProvider.java b/core/src/main/java/me/blackvein/quests/nms/TitleProvider.java deleted file mode 100644 index 4b860ff06..000000000 --- a/core/src/main/java/me/blackvein/quests/nms/TitleProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.nms; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public abstract class TitleProvider { - - private static TitleProvider loaded; - - static { - final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - try { - final String packageName = TitleProvider.class.getPackage().getName(); - if (internalsName.startsWith("v1_8_R")) { - loaded = (TitleProvider) Class.forName(packageName + ".TitleProvider_" + internalsName) - .newInstance(); - } else { - loaded = new TitleProvider_Bukkit(); - } - } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException - | ClassCastException exception) { - Bukkit.getLogger().severe("[Quests] No valid title implementation for version " + internalsName); - } - } - - abstract void sendTitlePacket(Player player, String title, String subtitle); - - /** - * Sends the title to the player. - * - * @param player - * The player to send the title to. - * @param title - * The title. - * @param subtitle - * The subtitle. - */ - public static void sendTitle(final Player player, final String title, final String subtitle) { - loaded.sendTitlePacket(player, title, subtitle); - } -} diff --git a/core/src/main/java/me/blackvein/quests/nms/TitleProvider_Bukkit.java b/core/src/main/java/me/blackvein/quests/nms/TitleProvider_Bukkit.java deleted file mode 100644 index 7f1a6a7e8..000000000 --- a/core/src/main/java/me/blackvein/quests/nms/TitleProvider_Bukkit.java +++ /dev/null @@ -1,12 +0,0 @@ -package me.blackvein.quests.nms; - -import org.bukkit.entity.Player; - -class TitleProvider_Bukkit extends TitleProvider { - - @SuppressWarnings("deprecation") - @Override - void sendTitlePacket(final Player player, final String title, final String subtitle) { - player.sendTitle(title, subtitle); - } -} diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitObjective.java b/core/src/main/java/me/blackvein/quests/quests/BukkitObjective.java deleted file mode 100644 index 057e82928..000000000 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitObjective.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -import me.blackvein.quests.entity.CountableMob; -import me.blackvein.quests.enums.ObjectiveType; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class BukkitObjective implements Objective { - private final ObjectiveType type; - private final String message; - private final int progress; - private final int goal; - private final Object progressObj; - private final Object goalObj; - - /** - * @deprecated Use {@link #BukkitObjective(ObjectiveType, String, int, int)} with null message - */ - public BukkitObjective(final ObjectiveType type, final int progress, final int goal) { - this.type = type; - this.message = null; - this.progress = progress; - this.goal = goal; - this.progressObj = new Object(); - this.goalObj = new Object(); - } - - /** - * @deprecated Use {@link #BukkitObjective(ObjectiveType, String, Object, Object)} with null message - */ - public BukkitObjective(final ObjectiveType type, final ItemStack progress, final ItemStack goal) { - this.type = type; - this.message = null; - this.progress = progress.getAmount(); - this.goal = goal.getAmount(); - this.progressObj = progress; - this.goalObj = goal; - } - - public BukkitObjective(final ObjectiveType type, @Nullable final String message, final int progress, - final int goal) { - this.type = type; - this.message = message; - this.progress = progress; - this.goal = goal; - this.progressObj = new Object(); - this.goalObj = new Object(); - } - - public BukkitObjective(final ObjectiveType type, @Nullable final String message, final @NotNull Object progress, - final @NotNull Object goal) { - this.type = type; - this.message = message; - this.progressObj = progress; - this.goalObj = goal; - if (progressObj instanceof ItemStack) { - this.progress = ((ItemStack) progressObj).getAmount(); - } else if (progressObj instanceof CountableMob) { - this.progress = ((CountableMob) progressObj).getCount(); - } else { - this.progress = 0; - } - if (goalObj instanceof ItemStack) { - this.goal = ((ItemStack) goalObj).getAmount(); - } else if (goalObj instanceof CountableMob) { - this.goal = ((CountableMob) goalObj).getCount(); - } else { - this.goal = 0; - } - } - - @Override - public ObjectiveType getType() { - return type; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public int getProgress() { - return progress; - } - - @Override - public int getGoal() { - return goal; - } - - @Override - public @NotNull Object getProgressObject() { - return progressObj; - } - - @Override - public @NotNull Object getGoalObject() { - return goalObj; - } - - public @Nullable ItemStack getProgressAsItem() { - return progressObj instanceof ItemStack ? (ItemStack) progressObj : null; - } - - public @Nullable ItemStack getGoalAsItem() { - return goalObj instanceof ItemStack ? (ItemStack) goalObj : null; - } - - public @Nullable CountableMob getProgressAsMob() { - return progressObj instanceof CountableMob ? (CountableMob) progressObj : null; - } - - public @Nullable CountableMob getGoalAsMob() { - return goalObj instanceof CountableMob ? (CountableMob) goalObj : null; - } -} diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java deleted file mode 100644 index 187e233c9..000000000 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java +++ /dev/null @@ -1,932 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.quests; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.convo.quests.main.QuestMainPrompt; -import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt; -import me.blackvein.quests.convo.quests.stages.QuestStageMenuPrompt; -import me.blackvein.quests.interfaces.ReloadCallback; -import me.blackvein.quests.module.ICustomObjective; -import me.blackvein.quests.util.CK; -import me.blackvein.quests.util.ConfigUtil; -import me.blackvein.quests.util.FakeConversable; -import me.blackvein.quests.util.Lang; -import me.blackvein.quests.util.MiscUtil; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.conversations.ConversationAbandonedListener; -import org.bukkit.conversations.ConversationContext; -import org.bukkit.conversations.ConversationFactory; -import org.bukkit.conversations.ConversationPrefix; -import org.bukkit.conversations.Prompt; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; - -public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedListener { - - private final Quests plugin; - private final ConversationFactory conversationFactory; - private Map selectedBlockStarts = new HashMap<>(); - private Map selectedKillLocations = new HashMap<>(); - private Map selectedReachLocations = new HashMap<>(); - private Set selectingNpcs = new HashSet<>(); - private List editingQuestNames = new LinkedList<>(); - - public BukkitQuestFactory(final Quests plugin) { - this.plugin = plugin; - // Ensure to initialize factory last so that 'this' is fully initialized before it is passed - this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) - .withFirstPrompt(new QuestMenuPrompt(new ConversationContext(plugin, new FakeConversable(), - new HashMap<>()))).withTimeout(3600) - .withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this); - } - - public static class LineBreakPrefix implements ConversationPrefix { - @Override - public @NotNull String getPrefix(final @NotNull ConversationContext context) { - return "\n"; - } - } - - public Map getSelectedBlockStarts() { - return selectedBlockStarts; - } - - public void setSelectedBlockStarts(final Map selectedBlockStarts) { - this.selectedBlockStarts = selectedBlockStarts; - } - - public Map getSelectedKillLocations() { - return selectedKillLocations; - } - - public void setSelectedKillLocations(final Map selectedKillLocations) { - this.selectedKillLocations = selectedKillLocations; - } - - public Map getSelectedReachLocations() { - return selectedReachLocations; - } - - public void setSelectedReachLocations(final Map selectedReachLocations) { - this.selectedReachLocations = selectedReachLocations; - } - - public Set getSelectingNpcs() { - return selectingNpcs; - } - - public void setSelectingNpcs(final Set selectingNpcs) { - this.selectingNpcs = selectingNpcs; - } - - public List getNamesOfQuestsBeingEdited() { - return editingQuestNames; - } - - public void setNamesOfQuestsBeingEdited(final List questNames) { - this.editingQuestNames = questNames; - } - - public ConversationFactory getConversationFactory() { - return conversationFactory; - } - - @Override - public void conversationAbandoned(final ConversationAbandonedEvent abandonedEvent) { - if (abandonedEvent.getContext().getSessionData(CK.Q_NAME) != null) { - editingQuestNames.remove((String) abandonedEvent.getContext().getSessionData(CK.Q_NAME)); - } - if (abandonedEvent.getContext().getForWhom() instanceof Player) { - final UUID uuid = ((Player) abandonedEvent.getContext().getForWhom()).getUniqueId(); - selectedBlockStarts.remove(uuid); - selectedKillLocations.remove(uuid); - selectedReachLocations.remove(uuid); - } - } - - public Prompt returnToMenu(final ConversationContext context) { - return new QuestMainPrompt(context); - } - - @SuppressWarnings("deprecation") - public void loadQuest(final ConversationContext context, final IQuest q) { - try { - context.setSessionData(CK.ED_QUEST_EDIT, q.getName()); - context.setSessionData(CK.Q_ID, q.getId()); - context.setSessionData(CK.Q_NAME, q.getName()); - context.setSessionData(CK.Q_ASK_MESSAGE, q.getDescription()); - context.setSessionData(CK.Q_FINISH_MESSAGE, q.getFinished()); - if (plugin.getDependencies().getCitizens() != null) { - if (q.getNpcStart() != null) { - context.setSessionData(CK.Q_START_NPC, q.getNpcStart().toString()); - } - } - context.setSessionData(CK.Q_START_BLOCK, q.getBlockStart()); - if (q.getInitialAction() != null) { - context.setSessionData(CK.Q_INITIAL_EVENT, q.getInitialAction().getName()); - } - if (q.getRegionStart() != null) { - context.setSessionData(CK.Q_REGION, q.getRegionStart()); - } - if (q.getGUIDisplay() != null) { - context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay()); - } - final Requirements requirements = q.getRequirements(); - if (requirements.getMoney() != 0) { - context.setSessionData(CK.REQ_MONEY, requirements.getMoney()); - } - if (requirements.getQuestPoints() != 0) { - context.setSessionData(CK.REQ_QUEST_POINTS, requirements.getQuestPoints()); - } - if (requirements.getExp() != 0) { - context.setSessionData(CK.REQ_EXP, requirements.getExp()); - } - if (!requirements.getItems().isEmpty()) { - context.setSessionData(CK.REQ_ITEMS, requirements.getItems()); - context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems()); - } - if (!requirements.getNeededQuestIds().isEmpty()) { - context.setSessionData(CK.REQ_QUEST, requirements.getNeededQuestIds()); - } - if (!requirements.getBlockQuestIds().isEmpty()) { - context.setSessionData(CK.REQ_QUEST_BLOCK, requirements.getBlockQuestIds()); - } - if (!requirements.getMcmmoSkills().isEmpty()) { - context.setSessionData(CK.REQ_MCMMO_SKILLS, requirements.getMcmmoAmounts()); - context.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, requirements.getMcmmoAmounts()); - } - if (!requirements.getPermissions().isEmpty()) { - context.setSessionData(CK.REQ_PERMISSION, requirements.getPermissions()); - } - if (requirements.getHeroesPrimaryClass() != null) { - context.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, requirements.getHeroesPrimaryClass()); - } - if (requirements.getHeroesSecondaryClass() != null) { - context.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, requirements.getHeroesSecondaryClass()); - } - if (!requirements.getCustomRequirements().isEmpty()) { - final LinkedList list = new LinkedList<>(); - final LinkedList> dataMapList = new LinkedList<>(); - for (final Entry> entry : requirements.getCustomRequirements().entrySet()) { - list.add(entry.getKey()); - dataMapList.add(entry.getValue()); - } - context.setSessionData(CK.REQ_CUSTOM, list); - context.setSessionData(CK.REQ_CUSTOM_DATA, dataMapList); - } - if (!requirements.getDetailsOverride().isEmpty()) { - context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride()); - } - final Rewards rewards = q.getRewards(); - if (rewards.getMoney() != 0) { - context.setSessionData(CK.REW_MONEY, rewards.getMoney()); - } - if (rewards.getQuestPoints() != 0) { - context.setSessionData(CK.REW_QUEST_POINTS, rewards.getQuestPoints()); - } - if (rewards.getExp() != 0) { - context.setSessionData(CK.REW_EXP, rewards.getExp()); - } - if (!rewards.getItems().isEmpty()) { - context.setSessionData(CK.REW_ITEMS, rewards.getItems()); - } - if (!rewards.getCommands().isEmpty()) { - context.setSessionData(CK.REW_COMMAND, rewards.getCommands()); - } - if (!rewards.getCommandsOverrideDisplay().isEmpty()) { - context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, rewards.getCommandsOverrideDisplay()); - } - if (!rewards.getPermissions().isEmpty()) { - context.setSessionData(CK.REW_PERMISSION, rewards.getPermissions()); - } - if (!rewards.getPermissions().isEmpty()) { - context.setSessionData(CK.REW_PERMISSION_WORLDS, rewards.getPermissionWorlds()); - } - if (!rewards.getMcmmoSkills().isEmpty()) { - context.setSessionData(CK.REW_MCMMO_SKILLS, rewards.getMcmmoSkills()); - context.setSessionData(CK.REW_MCMMO_AMOUNTS, rewards.getMcmmoAmounts()); - } - if (!rewards.getHeroesClasses().isEmpty()) { - context.setSessionData(CK.REW_HEROES_CLASSES, rewards.getHeroesClasses()); - context.setSessionData(CK.REW_HEROES_AMOUNTS, rewards.getHeroesAmounts()); - } - if (rewards.getPartiesExperience() != 0) { - context.setSessionData(CK.REW_PARTIES_EXPERIENCE, rewards.getPartiesExperience()); - } - if (!rewards.getPhatLoots().isEmpty()) { - context.setSessionData(CK.REW_PHAT_LOOTS, rewards.getPhatLoots()); - } - if (!rewards.getCustomRewards().isEmpty()) { - context.setSessionData(CK.REW_CUSTOM, new LinkedList<>(rewards.getCustomRewards().keySet())); - context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList(rewards.getCustomRewards().values())); - } - if (!rewards.getDetailsOverride().isEmpty()) { - context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride()); - } - final Planner pln = q.getPlanner(); - if (pln.getStart() != null) { - context.setSessionData(CK.PLN_START_DATE, pln.getStart()); - } - if (pln.getEnd() != null) { - context.setSessionData(CK.PLN_END_DATE, pln.getEnd()); - } - if (pln.getRepeat() != -1) { - context.setSessionData(CK.PLN_REPEAT_CYCLE, pln.getRepeat()); - } - if (pln.getCooldown() != -1) { - context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown()); - } - context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride()); - final Options opt = q.getOptions(); - context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands()); - context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting()); - context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch()); - context.setSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN, opt.getExternalPartyPlugin()); - context.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.canUsePartiesPlugin()); - context.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel()); - context.setSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY, opt.canShareSameQuestOnly()); - context.setSessionData(CK.OPT_SHARE_DISTANCE, opt.getShareDistance()); - context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers()); - context.setSessionData(CK.OPT_IGNORE_BLOCK_REPLACE, opt.canIgnoreBlockReplace()); - // Stages (Objectives) - int index = 1; - for (final IStage stage : q.getStages()) { - final String pref = "stage" + index; - index++; - context.setSessionData(pref, Boolean.TRUE); - if (!stage.getBlocksToBreak().isEmpty()) { - final LinkedList names = new LinkedList<>(); - final LinkedList amounts = new LinkedList<>(); - final LinkedList durability = new LinkedList<>(); - for (final ItemStack e : stage.getBlocksToBreak()) { - names.add(e.getType().name()); - amounts.add(e.getAmount()); - durability.add(e.getDurability()); - } - context.setSessionData(pref + CK.S_BREAK_NAMES, names); - context.setSessionData(pref + CK.S_BREAK_AMOUNTS, amounts); - context.setSessionData(pref + CK.S_BREAK_DURABILITY, durability); - } - if (!stage.getBlocksToDamage().isEmpty()) { - final LinkedList names = new LinkedList<>(); - final LinkedList amounts = new LinkedList<>(); - final LinkedList durability = new LinkedList<>(); - for (final ItemStack e : stage.getBlocksToDamage()) { - names.add(e.getType().name()); - amounts.add(e.getAmount()); - durability.add(e.getDurability()); - } - context.setSessionData(pref + CK.S_DAMAGE_NAMES, names); - context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amounts); - context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durability); - } - if (!stage.getBlocksToPlace().isEmpty()) { - final LinkedList names = new LinkedList<>(); - final LinkedList amounts = new LinkedList<>(); - final LinkedList durability = new LinkedList<>(); - for (final ItemStack e : stage.getBlocksToPlace()) { - names.add(e.getType().name()); - amounts.add(e.getAmount()); - durability.add(e.getDurability()); - } - context.setSessionData(pref + CK.S_PLACE_NAMES, names); - context.setSessionData(pref + CK.S_PLACE_AMOUNTS, amounts); - context.setSessionData(pref + CK.S_PLACE_DURABILITY, durability); - } - if (!stage.getBlocksToUse().isEmpty()) { - final LinkedList names = new LinkedList<>(); - final LinkedList amounts = new LinkedList<>(); - final LinkedList durability = new LinkedList<>(); - for (final ItemStack e : stage.getBlocksToUse()) { - names.add(e.getType().name()); - amounts.add(e.getAmount()); - durability.add(e.getDurability()); - } - context.setSessionData(pref + CK.S_USE_NAMES, names); - context.setSessionData(pref + CK.S_USE_AMOUNTS, amounts); - context.setSessionData(pref + CK.S_USE_DURABILITY, durability); - } - if (!stage.getBlocksToCut().isEmpty()) { - final LinkedList names = new LinkedList<>(); - final LinkedList amounts = new LinkedList<>(); - final LinkedList durability = new LinkedList<>(); - for (final ItemStack e : stage.getBlocksToCut()) { - names.add(e.getType().name()); - amounts.add(e.getAmount()); - durability.add(e.getDurability()); - } - context.setSessionData(pref + CK.S_CUT_NAMES, names); - context.setSessionData(pref + CK.S_CUT_AMOUNTS, amounts); - context.setSessionData(pref + CK.S_CUT_DURABILITY, durability); - } - if (!stage.getItemsToCraft().isEmpty()) { - final LinkedList items = new LinkedList<>(stage.getItemsToCraft()); - context.setSessionData(pref + CK.S_CRAFT_ITEMS, items); - } - if (!stage.getItemsToSmelt().isEmpty()) { - final LinkedList items = new LinkedList<>(stage.getItemsToSmelt()); - context.setSessionData(pref + CK.S_SMELT_ITEMS, items); - } - if (!stage.getItemsToEnchant().isEmpty()) { - final LinkedList items = new LinkedList<>(stage.getItemsToEnchant()); - context.setSessionData(pref + CK.S_ENCHANT_ITEMS, items); - } - if (!stage.getItemsToBrew().isEmpty()) { - final LinkedList items = new LinkedList<>(stage.getItemsToBrew()); - context.setSessionData(pref + CK.S_BREW_ITEMS, items); - } - if (!stage.getItemsToConsume().isEmpty()) { - final LinkedList items = new LinkedList<>(stage.getItemsToConsume()); - context.setSessionData(pref + CK.S_CONSUME_ITEMS, items); - } - if (stage.getCowsToMilk() != null) { - context.setSessionData(pref + CK.S_COW_MILK, stage.getCowsToMilk()); - } - if (stage.getFishToCatch() != null) { - context.setSessionData(pref + CK.S_FISH, stage.getFishToCatch()); - } - if (stage.getPlayersToKill() != null) { - context.setSessionData(pref + CK.S_PLAYER_KILL, stage.getPlayersToKill()); - } - if (!stage.getItemsToDeliver().isEmpty()) { - final LinkedList items = new LinkedList<>(stage.getItemsToDeliver()); - final LinkedList npcs = new LinkedList<>(); - for (UUID uuid : stage.getItemDeliveryTargets()) { - npcs.add(uuid.toString()); - } - context.setSessionData(pref + CK.S_DELIVERY_ITEMS, items); - context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs); - context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, stage.getDeliverMessages()); - } - if (!stage.getNpcsToInteract().isEmpty()) { - final LinkedList npcs = new LinkedList<>(); - for (UUID uuid : stage.getNpcsToInteract()) { - npcs.add(uuid.toString()); - } - context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs); - } - if (!stage.getNpcsToKill().isEmpty()) { - final LinkedList npcs = new LinkedList<>(); - for (UUID uuid : stage.getNpcsToKill()) { - npcs.add(uuid.toString()); - } - context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs); - context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, stage.getNpcNumToKill()); - } - if (!stage.getMobsToKill().isEmpty()) { - final LinkedList mobs = new LinkedList<>(); - for (final EntityType et : stage.getMobsToKill()) { - mobs.add(MiscUtil.getPrettyMobName(et)); - } - context.setSessionData(pref + CK.S_MOB_TYPES, mobs); - context.setSessionData(pref + CK.S_MOB_AMOUNTS, stage.getMobNumToKill()); - if (!stage.getLocationsToKillWithin().isEmpty()) { - final LinkedList locations = new LinkedList<>(); - for (final Location l : stage.getLocationsToKillWithin()) { - locations.add(ConfigUtil.getLocationInfo(l)); - } - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locations); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, stage.getRadiiToKillWithin()); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, stage.getKillNames()); - } - } - if (!stage.getLocationsToReach().isEmpty()) { - final LinkedList locations = new LinkedList<>(); - for (final Location l : stage.getLocationsToReach()) { - locations.add(ConfigUtil.getLocationInfo(l)); - } - context.setSessionData(pref + CK.S_REACH_LOCATIONS, locations); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, stage.getRadiiToReachWithin()); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, stage.getLocationNames()); - } - if (!stage.getMobsToTame().isEmpty()) { - final LinkedList mobs = new LinkedList<>(); - for (final EntityType e : stage.getMobsToTame()) { - mobs.add(MiscUtil.getPrettyMobName(e)); - } - final LinkedList amounts = new LinkedList<>(stage.getMobNumToTame()); - context.setSessionData(pref + CK.S_TAME_TYPES, mobs); - context.setSessionData(pref + CK.S_TAME_AMOUNTS, amounts); - } - if (!stage.getSheepToShear().isEmpty()) { - final LinkedList colors = new LinkedList<>(); - for (final DyeColor d : stage.getSheepToShear()) { - colors.add(MiscUtil.getPrettyDyeColorName(d)); - - } - final LinkedList amounts = new LinkedList<>(stage.getSheepNumToShear()); - context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); - context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts); - } - if (!stage.getPasswordDisplays().isEmpty()) { - context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, stage.getPasswordDisplays()); - context.setSessionData(pref + CK.S_PASSWORD_PHRASES, stage.getPasswordPhrases()); - } - if (!stage.getCustomObjectives().isEmpty()) { - final LinkedList list = new LinkedList<>(); - final LinkedList countList = new LinkedList<>(); - for (int i = 0; i < stage.getCustomObjectives().size(); i++) { - list.add(stage.getCustomObjectives().get(i).getName()); - countList.add(stage.getCustomObjectiveCounts().get(i)); - } - final LinkedList> dataMapList = new LinkedList<>(stage.getCustomObjectiveData()); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, dataMapList); - } - if (stage.getStartAction() != null) { - context.setSessionData(pref + CK.S_START_EVENT, stage.getStartAction().getName()); - } - if (stage.getFinishAction() != null) { - context.setSessionData(pref + CK.S_FINISH_EVENT, stage.getFinishAction().getName()); - } - if (stage.getFailAction() != null) { - context.setSessionData(pref + CK.S_FAIL_EVENT, stage.getFailAction().getName()); - } - if (stage.getDeathAction() != null) { - context.setSessionData(pref + CK.S_DEATH_EVENT, stage.getDeathAction().getName()); - } - if (stage.getDisconnectAction() != null) { - context.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.getDisconnectAction().getName()); - } - if (!stage.getChatActions().isEmpty()) { - final LinkedList chatEvents = new LinkedList<>(); - final LinkedList chatEventTriggers = new LinkedList<>(); - for (final String s : stage.getChatActions().keySet()) { - chatEventTriggers.add(s); - chatEvents.add(stage.getChatActions().get(s).getName()); - } - context.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents); - context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers); - } - if (!stage.getCommandActions().isEmpty()) { - final LinkedList commandEvents = new LinkedList<>(); - final LinkedList commandEventTriggers = new LinkedList<>(); - for (final String s : stage.getCommandActions().keySet()) { - commandEventTriggers.add(s); - commandEvents.add(stage.getCommandActions().get(s).getName()); - } - context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents); - context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers); - } - if (stage.getCondition() != null) { - context.setSessionData(pref + CK.S_CONDITION, stage.getCondition().getName()); - } - if (stage.getDelay() != -1) { - context.setSessionData(pref + CK.S_DELAY, stage.getDelay()); - if (stage.getDelayMessage() != null) { - context.setSessionData(pref + CK.S_DELAY_MESSAGE, stage.getDelayMessage()); - } - } - if (stage.getScript() != null) { - context.setSessionData(pref + CK.S_DENIZEN, stage.getScript()); - } - if (stage.getCompleteMessage() != null) { - context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.getCompleteMessage()); - } - if (stage.getStartMessage() != null) { - context.setSessionData(pref + CK.S_START_MESSAGE, stage.getStartMessage()); - } - if (!stage.getObjectiveOverrides().isEmpty()) { - context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.getObjectiveOverrides()); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void deleteQuest(final ConversationContext context) { - final FileConfiguration data = new YamlConfiguration(); - final File questsFile = new File(plugin.getDataFolder(), "quests.yml"); - try { - data.load(questsFile); - } catch (final IOException | InvalidConfigurationException e) { - e.printStackTrace(); - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questErrorReadingFile") - .replace("", questsFile.getName())); - return; - } - final String quest = (String) context.getSessionData(CK.ED_QUEST_DELETE); - final ConfigurationSection sec = data.getConfigurationSection("quests"); - if (sec != null) { - for (final String key : sec.getKeys(false)) { - if (sec.getString(key + ".name") != null - && Objects.requireNonNull(sec.getString(key + ".name")).equalsIgnoreCase(quest)) { - sec.set(key, null); - break; - } - } - } - try { - data.save(questsFile); - } catch (final IOException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questSaveError")); - return; - } - final ReloadCallback callback = response -> { - if (!response) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError")); - } - }; - plugin.reload(callback); - context.getForWhom().sendRawMessage(ChatColor.GREEN + Lang.get("questDeleted")); - if (plugin.getSettings().getConsoleLogging() > 0) { - final String identifier = context.getForWhom() instanceof Player ? - "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; - plugin.getLogger().info(identifier + " deleted quest " + quest); - } - } - - public void saveQuest(final ConversationContext context, final ConfigurationSection section) { - String edit = null; - if (context.getSessionData(CK.ED_QUEST_EDIT) != null) { - edit = (String) context.getSessionData(CK.ED_QUEST_EDIT); - } - if (edit != null) { - final ConfigurationSection questList = section.getParent(); - if (questList != null) { - for (final String key : questList.getKeys(false)) { - final String name = questList.getString(key + ".name"); - if (name != null) { - if (name.equalsIgnoreCase(edit)) { - questList.set(key, null); - break; - } - } - } - } - } - section.set("name", context.getSessionData(CK.Q_NAME) != null - ? context.getSessionData(CK.Q_NAME) : null); - section.set("ask-message", context.getSessionData(CK.Q_ASK_MESSAGE) != null - ? context.getSessionData(CK.Q_ASK_MESSAGE) : null); - section.set("finish-message", context.getSessionData(CK.Q_FINISH_MESSAGE) != null - ? context.getSessionData(CK.Q_FINISH_MESSAGE) : null); - section.set("npc-giver-uuid", context.getSessionData(CK.Q_START_NPC) != null - ? context.getSessionData(CK.Q_START_NPC) : null); - section.set("block-start", context.getSessionData(CK.Q_START_BLOCK) != null - ? ConfigUtil.getLocationInfo((Location) Objects.requireNonNull(context - .getSessionData(CK.Q_START_BLOCK))) : null); - section.set("event", context.getSessionData(CK.Q_INITIAL_EVENT) != null - ? context.getSessionData(CK.Q_INITIAL_EVENT) : null); - section.set("region", context.getSessionData(CK.Q_REGION) != null - ? context.getSessionData(CK.Q_REGION) : null); - section.set("gui-display", context.getSessionData(CK.Q_GUIDISPLAY) != null - ? context.getSessionData(CK.Q_GUIDISPLAY) : null); - saveRequirements(context, section); - saveStages(context, section); - saveRewards(context, section); - savePlanner(context, section); - saveOptions(context, section); - if (plugin.getSettings().getConsoleLogging() > 0) { - final String identifier = context.getForWhom() instanceof Player ? - "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; - plugin.getLogger().info(identifier + " saved quest " + context.getSessionData(CK.Q_NAME)); - } - } - - @SuppressWarnings("unchecked") - private void saveRequirements(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection requirements = section.createSection("requirements"); - requirements.set("money", context.getSessionData(CK.REQ_MONEY) != null - ? context.getSessionData(CK.REQ_MONEY) : null); - requirements.set("quest-points", context.getSessionData(CK.REQ_QUEST_POINTS) != null - ? context.getSessionData(CK.REQ_QUEST_POINTS) : null); - requirements.set("exp", context.getSessionData(CK.REQ_EXP) != null - ? context.getSessionData(CK.REQ_EXP) : null); - requirements.set("items", context.getSessionData(CK.REQ_ITEMS) != null - ? context.getSessionData(CK.REQ_ITEMS) : null); - requirements.set("remove-items", context.getSessionData(CK.REQ_ITEMS_REMOVE) != null - ? context.getSessionData(CK.REQ_ITEMS_REMOVE) : null); - requirements.set("permissions", context.getSessionData(CK.REQ_PERMISSION) != null - ? context.getSessionData(CK.REQ_PERMISSION) : null); - requirements.set("quests", context.getSessionData(CK.REQ_QUEST) != null - ? context.getSessionData(CK.REQ_QUEST) : null); - requirements.set("quest-blocks", context.getSessionData(CK.REQ_QUEST_BLOCK) != null - ? context.getSessionData(CK.REQ_QUEST_BLOCK) : null); - requirements.set("mcmmo-skills", context.getSessionData(CK.REQ_MCMMO_SKILLS) != null - ? context.getSessionData(CK.REQ_MCMMO_SKILLS) : null); - requirements.set("mcmmo-amounts", context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) != null - ? context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) : null); - requirements.set("heroes-primary-class", context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null - ? context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) : null); - requirements.set("heroes-secondary-class", context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null - ? context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) : null); - final LinkedList customRequirements = context.getSessionData(CK.REQ_CUSTOM) != null - ? (LinkedList) context.getSessionData(CK.REQ_CUSTOM) : null; - final LinkedList> customRequirementsData = context.getSessionData(CK.REQ_CUSTOM_DATA) != null - ? (LinkedList>) context.getSessionData(CK.REQ_CUSTOM_DATA) : null; - if (customRequirements != null && customRequirementsData != null) { - final ConfigurationSection customRequirementsSec = requirements.createSection("custom-requirements"); - for (int i = 0; i < customRequirements.size(); i++) { - final ConfigurationSection customReqSec = customRequirementsSec.createSection("req" + (i + 1)); - customReqSec.set("name", customRequirements.get(i)); - customReqSec.set("data", customRequirementsData.get(i)); - } - } - requirements.set("fail-requirement-message", context.getSessionData(CK.REQ_FAIL_MESSAGE) != null - ? context.getSessionData(CK.REQ_FAIL_MESSAGE) : null); - if (requirements.getKeys(false).isEmpty()) { - section.set("requirements", null); - } - } - - @SuppressWarnings("unchecked") - private void saveStages(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection stages = section.createSection("stages"); - final ConfigurationSection ordered = stages.createSection("ordered"); - String pref; - for (int i = 1; i <= new QuestStageMenuPrompt(context).getStages(context); i++) { - pref = "stage" + i; - final ConfigurationSection stage = ordered.createSection("" + i); - stage.set("break-block-names", context.getSessionData(pref + CK.S_BREAK_NAMES) != null - ? context.getSessionData(pref + CK.S_BREAK_NAMES) : null); - stage.set("break-block-amounts", context.getSessionData(pref + CK.S_BREAK_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_BREAK_AMOUNTS) : null); - stage.set("break-block-durability", context.getSessionData(pref + CK.S_BREAK_DURABILITY) != null - ? context.getSessionData(pref + CK.S_BREAK_DURABILITY) : null); - stage.set("damage-block-names", context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null - ? context.getSessionData(pref + CK.S_DAMAGE_NAMES) : null); - stage.set("damage-block-amounts", context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) : null); - stage.set("damage-block-durability", context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) != null - ? context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) : null); - stage.set("place-block-names", context.getSessionData(pref + CK.S_PLACE_NAMES) != null - ? context.getSessionData(pref + CK.S_PLACE_NAMES) : null); - stage.set("place-block-amounts", context.getSessionData(pref + CK.S_PLACE_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_PLACE_AMOUNTS) : null); - stage.set("place-block-durability", context.getSessionData(pref + CK.S_PLACE_DURABILITY) != null - ? context.getSessionData(pref + CK.S_PLACE_DURABILITY) : null); - stage.set("use-block-names", context.getSessionData(pref + CK.S_USE_NAMES) != null - ? context.getSessionData(pref + CK.S_USE_NAMES) : null); - stage.set("use-block-amounts", context.getSessionData(pref + CK.S_USE_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_USE_AMOUNTS) : null); - stage.set("use-block-durability", context.getSessionData(pref + CK.S_USE_DURABILITY) != null - ? context.getSessionData(pref + CK.S_USE_DURABILITY) : null); - stage.set("cut-block-names", context.getSessionData(pref + CK.S_CUT_NAMES) != null - ? context.getSessionData(pref + CK.S_CUT_NAMES) : null); - stage.set("cut-block-amounts", context.getSessionData(pref + CK.S_CUT_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_CUT_AMOUNTS) : null); - stage.set("cut-block-durability", context.getSessionData(pref + CK.S_CUT_DURABILITY) != null - ? context.getSessionData(pref + CK.S_CUT_DURABILITY) : null); - stage.set("items-to-craft", context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null - ? context.getSessionData(pref + CK.S_CRAFT_ITEMS) : null); - stage.set("items-to-smelt", context.getSessionData(pref + CK.S_SMELT_ITEMS) != null - ? context.getSessionData(pref + CK.S_SMELT_ITEMS) : null); - stage.set("items-to-enchant", context.getSessionData(pref + CK.S_ENCHANT_ITEMS) != null - ? context.getSessionData(pref + CK.S_ENCHANT_ITEMS) : null); - stage.set("items-to-brew", context.getSessionData(pref + CK.S_BREW_ITEMS) != null - ? context.getSessionData(pref + CK.S_BREW_ITEMS) : null); - stage.set("items-to-consume", context.getSessionData(pref + CK.S_CONSUME_ITEMS) != null - ? context.getSessionData(pref + CK.S_CONSUME_ITEMS) : null); - stage.set("cows-to-milk", context.getSessionData(pref + CK.S_COW_MILK) != null - ? context.getSessionData(pref + CK.S_COW_MILK) : null); - stage.set("fish-to-catch", context.getSessionData(pref + CK.S_FISH) != null - ? context.getSessionData(pref + CK.S_FISH) : null); - stage.set("players-to-kill", context.getSessionData(pref + CK.S_PLAYER_KILL) != null - ? context.getSessionData(pref + CK.S_PLAYER_KILL) : null); - stage.set("items-to-deliver", context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null - ? context.getSessionData(pref + CK.S_DELIVERY_ITEMS) : null); - stage.set("npc-delivery-uuids", context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null - ? context.getSessionData(pref + CK.S_DELIVERY_NPCS) : null); - stage.set("delivery-messages", context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) != null - ? context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) : null); - stage.set("npc-uuids-to-talk-to", context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null - ? context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) : null); - stage.set("npc-uuids-to-kill", context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null - ? context.getSessionData(pref + CK.S_NPCS_TO_KILL) : null); - stage.set("npc-kill-amounts", context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) : null); - stage.set("mobs-to-kill", context.getSessionData(pref + CK.S_MOB_TYPES) != null - ? context.getSessionData(pref + CK.S_MOB_TYPES) : null); - stage.set("mob-amounts", context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_MOB_AMOUNTS) : null); - stage.set("locations-to-kill", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null - ? context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) : null); - stage.set("kill-location-radii", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) != null - ? context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) : null); - stage.set("kill-location-names", context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) != null - ? context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) : null); - stage.set("locations-to-reach", context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null - ? context.getSessionData(pref + CK.S_REACH_LOCATIONS) : null); - stage.set("reach-location-radii", context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) != null - ? context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) : null); - stage.set("reach-location-names", context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) != null - ? context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) : null); - stage.set("mobs-to-tame", context.getSessionData(pref + CK.S_TAME_TYPES) != null - ? context.getSessionData(pref + CK.S_TAME_TYPES) : null); - stage.set("mob-tame-amounts", context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_TAME_AMOUNTS) : null); - stage.set("sheep-to-shear", context.getSessionData(pref + CK.S_SHEAR_COLORS) != null - ? context.getSessionData(pref + CK.S_SHEAR_COLORS) : null); - stage.set("sheep-amounts", context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null - ? context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) : null); - stage.set("password-displays", context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null - ? context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) : null); - stage.set("password-phrases", context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null - ? context.getSessionData(pref + CK.S_PASSWORD_PHRASES) : null); - final LinkedList customObj = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); - final LinkedList customObjCounts - = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT); - final LinkedList> customObjData - = (LinkedList>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); - if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) { - final ConfigurationSection sec = stage.createSection("custom-objectives"); - if (customObj == null || customObjCounts == null || customObjData == null) { - continue; - } - for (int index = 0; index < customObj.size(); index++) { - final ConfigurationSection sec2 = sec.createSection("custom" + (index + 1)); - sec2.set("name", customObj.get(index)); - sec2.set("count", customObjCounts.get(index)); - ICustomObjective found = null; - for (final ICustomObjective co : plugin.getCustomObjectives()) { - if (co.getName().equals(customObj.get(index))) { - found = co; - break; - } - } - if (found == null) { - continue; - } - final ConfigurationSection sec3 = sec2.createSection("data"); - for (final Entry dataMap : found.getData()) { - for (final Entry e : customObjData) { - if (e.getKey().equals(dataMap.getKey())) { - sec3.set(e.getKey(), e.getValue()); // if anything goes wrong it's probably here - } - } - } - } - } - stage.set("script-to-run", context.getSessionData(pref + CK.S_DENIZEN) != null - ? context.getSessionData(pref + CK.S_DENIZEN) : null); - stage.set("start-event", context.getSessionData(pref + CK.S_START_EVENT) != null - ? context.getSessionData(pref + CK.S_START_EVENT) : null); - stage.set("finish-event", context.getSessionData(pref + CK.S_FINISH_EVENT) != null - ? context.getSessionData(pref + CK.S_FINISH_EVENT) : null); - stage.set("fail-event", context.getSessionData(pref + CK.S_FAIL_EVENT) != null - ? context.getSessionData(pref + CK.S_FAIL_EVENT) : null); - stage.set("death-event", context.getSessionData(pref + CK.S_DEATH_EVENT) != null - ? context.getSessionData(pref + CK.S_DEATH_EVENT) : null); - stage.set("disconnect-event", context.getSessionData(pref + CK.S_DISCONNECT_EVENT) != null - ? context.getSessionData(pref + CK.S_DISCONNECT_EVENT) : null); - stage.set("chat-events", context.getSessionData(pref + CK.S_CHAT_EVENTS) != null - ? context.getSessionData(pref + CK.S_CHAT_EVENTS) : null); - stage.set("chat-event-triggers", context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS) != null - ? context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS) : null); - stage.set("command-events", context.getSessionData(pref + CK.S_COMMAND_EVENTS) != null - ? context.getSessionData(pref + CK.S_COMMAND_EVENTS) : null); - stage.set("command-event-triggers", context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS) != null - ? context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS) : null); - stage.set("condition", context.getSessionData(pref + CK.S_CONDITION) != null - ? context.getSessionData(pref + CK.S_CONDITION) : null); - final Long delay = (Long) context.getSessionData(pref + CK.S_DELAY); - if (delay != null) { - stage.set("delay", delay.intValue() / 1000); - } - final String delayMessage = (String) context.getSessionData(pref + CK.S_DELAY_MESSAGE); - if (delayMessage != null) { - stage.set("delay-message", delayMessage.replace("\\n", "\n")); - } - final String startMessage = (String) context.getSessionData(pref + CK.S_START_MESSAGE); - if (startMessage != null) { - stage.set("start-message", startMessage.replace("\\n", "\n")); - } - final String completeMessage = (String) context.getSessionData(pref + CK.S_COMPLETE_MESSAGE); - if (completeMessage != null) { - stage.set("complete-message", completeMessage.replace("\\n", "\n")); - } - stage.set("objective-override", context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) != null - ? context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) : null); - } - } - - @SuppressWarnings("unchecked") - private void saveRewards(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection rewards = section.createSection("rewards"); - rewards.set("items", context.getSessionData(CK.REW_ITEMS) != null - ? context.getSessionData(CK.REW_ITEMS) : null); - rewards.set("money", context.getSessionData(CK.REW_MONEY) != null - ? context.getSessionData(CK.REW_MONEY) : null); - rewards.set("quest-points", context.getSessionData(CK.REW_QUEST_POINTS) != null - ? context.getSessionData(CK.REW_QUEST_POINTS) : null); - rewards.set("exp", context.getSessionData(CK.REW_EXP) != null - ? context.getSessionData(CK.REW_EXP) : null); - rewards.set("commands", context.getSessionData(CK.REW_COMMAND) != null - ? context.getSessionData(CK.REW_COMMAND) : null); - rewards.set("commands-override-display", context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) != null - ? context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) : null); - rewards.set("permissions", context.getSessionData(CK.REW_PERMISSION) != null - ? context.getSessionData(CK.REW_PERMISSION) : null); - rewards.set("permission-worlds", context.getSessionData(CK.REW_PERMISSION_WORLDS) != null - ? context.getSessionData(CK.REW_PERMISSION_WORLDS) : null); - rewards.set("mcmmo-skills", context.getSessionData(CK.REW_MCMMO_SKILLS) != null - ? context.getSessionData(CK.REW_MCMMO_SKILLS) : null); - rewards.set("mcmmo-levels", context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null - ? context.getSessionData(CK.REW_MCMMO_AMOUNTS) : null); - rewards.set("heroes-exp-classes", context.getSessionData(CK.REW_HEROES_CLASSES) != null - ? context.getSessionData(CK.REW_HEROES_CLASSES) : null); - rewards.set("heroes-exp-amounts", context.getSessionData(CK.REW_HEROES_AMOUNTS) != null - ? context.getSessionData(CK.REW_HEROES_AMOUNTS) : null); - rewards.set("parties-experience", context.getSessionData(CK.REW_PARTIES_EXPERIENCE) != null - ? context.getSessionData(CK.REW_PARTIES_EXPERIENCE) : null); - rewards.set("phat-loots", context.getSessionData(CK.REW_PHAT_LOOTS) != null - ? context.getSessionData(CK.REW_PHAT_LOOTS) : null); - final LinkedList customRewards = context.getSessionData(CK.REW_CUSTOM) != null - ? (LinkedList) context.getSessionData(CK.REW_CUSTOM) : null; - final LinkedList> customRewardsData = context.getSessionData(CK.REW_CUSTOM_DATA) != null - ? (LinkedList>) context.getSessionData(CK.REW_CUSTOM_DATA) : null; - if (customRewards != null && customRewardsData != null) { - final ConfigurationSection customRewardsSec = rewards.createSection("custom-rewards"); - for (int i = 0; i < customRewards.size(); i++) { - final ConfigurationSection customRewSec = customRewardsSec.createSection("req" + (i + 1)); - customRewSec.set("name", customRewards.get(i)); - customRewSec.set("data", customRewardsData.get(i)); - } - } - rewards.set("details-override", context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null - ? context.getSessionData(CK.REW_DETAILS_OVERRIDE) : null); - if (rewards.getKeys(false).isEmpty()) { - section.set("rewards", null); - } - } - - private void savePlanner(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection pln = section.createSection("planner"); - pln.set("start", context.getSessionData(CK.PLN_START_DATE) != null - ? context.getSessionData(CK.PLN_START_DATE) : null); - pln.set("end", context.getSessionData(CK.PLN_END_DATE) != null - ? context.getSessionData(CK.PLN_END_DATE) : null); - final Long repeatCycle = (Long) context.getSessionData(CK.PLN_REPEAT_CYCLE); - pln.set("repeat", repeatCycle != null ? (repeatCycle / 1000L) : null); - final Long cooldown = (Long) context.getSessionData(CK.PLN_COOLDOWN); - pln.set("cooldown", cooldown != null ? (cooldown / 1000L) : null); - pln.set("override", context.getSessionData(CK.PLN_OVERRIDE) != null - ? context.getSessionData(CK.PLN_OVERRIDE) : null); - if (pln.getKeys(false).isEmpty()) { - section.set("planner", null); - } - } - - private void saveOptions(final ConversationContext context, final ConfigurationSection section) { - final ConfigurationSection opts = section.createSection("options"); - opts.set("allow-commands", context.getSessionData(CK.OPT_ALLOW_COMMANDS) != null - ? context.getSessionData(CK.OPT_ALLOW_COMMANDS) : null); - opts.set("allow-quitting", context.getSessionData(CK.OPT_ALLOW_QUITTING) != null - ? context.getSessionData(CK.OPT_ALLOW_QUITTING) : null); - opts.set("ignore-silk-touch", context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) != null - ? context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) : null); - opts.set("external-party-plugin", context.getSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN) != null - ? context.getSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN) : null); - opts.set("use-parties-plugin", context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null - ? context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) : null); - opts.set("share-progress-level", context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null - ? context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) : null); - opts.set("same-quest-only", context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY) != null - ? context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY) : null); - opts.set("share-distance", context.getSessionData(CK.OPT_SHARE_DISTANCE) != null - ? context.getSessionData(CK.OPT_SHARE_DISTANCE) : null); - opts.set("handle-offline-players", context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS) != null - ? context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS) : null); - opts.set("ignore-block-replace", context.getSessionData(CK.OPT_IGNORE_BLOCK_REPLACE) != null - ? context.getSessionData(CK.OPT_IGNORE_BLOCK_REPLACE) : null); - if (opts.getKeys(false).isEmpty()) { - section.set("options", null); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/me/blackvein/quests/storage/StorageType.java b/core/src/main/java/me/blackvein/quests/storage/StorageType.java deleted file mode 100644 index dcb13fbe7..000000000 --- a/core/src/main/java/me/blackvein/quests/storage/StorageType.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.storage; - -import java.util.List; - -import com.google.common.collect.ImmutableList; - -public enum StorageType { - - // Local file - YAML("YAML", "yaml", "yml"), - - // Remote database - MYSQL("MySQL", "mysql"), - - // Custom - CUSTOM("Custom", "custom"); - - private final String name; - - private final List identifiers; - - StorageType(final String name, final String... identifiers) { - this.name = name; - this.identifiers = ImmutableList.copyOf(identifiers); - } - - public static StorageType parse(final String name, final StorageType def) { - for (final StorageType t : values()) { - for (final String id : t.getIdentifiers()) { - if (id.equalsIgnoreCase(name)) { - return t; - } - } - } - return def; - } - - public String getName() { - return name; - } - - public List getIdentifiers() { - return identifiers; - } -} diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java b/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java deleted file mode 100644 index d0597c2be..000000000 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.storage.implementation; - -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.Quests; - -import java.util.Collection; -import java.util.UUID; - -public interface StorageImplementation { - Quests getPlugin(); - - String getImplementationName(); - - void init() throws Exception; - - void close(); - - IQuester loadQuester(UUID uniqueId) throws Exception; - - void saveQuester(IQuester quester) throws Exception; - - void deleteQuester(UUID uniqueId) throws Exception; - - String getQuesterLastKnownName(UUID uniqueId) throws Exception; - - Collection getSavedUniqueIds() throws Exception; -} diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProvider.java b/core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProvider.java deleted file mode 100644 index 10343395c..000000000 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.storage.implementation.custom; - -import me.blackvein.quests.Quests; -import me.blackvein.quests.storage.implementation.StorageImplementation; - -public interface CustomStorageProvider { - StorageImplementation provide(Quests plugin); -} diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProviders.java b/core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProviders.java deleted file mode 100644 index 0c1c4c429..000000000 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/custom/CustomStorageProviders.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.storage.implementation.custom; - -public final class CustomStorageProviders { - private CustomStorageProviders() {} - - private static CustomStorageProvider provider = null; - - public static void register(final CustomStorageProvider provider) { - CustomStorageProviders.provider = provider; - } - - public static CustomStorageProvider getProvider() { - if (provider == null) { - throw new IllegalStateException("Provider not found."); - } - - return provider; - } -} diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/ConnectionFactory.java b/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/ConnectionFactory.java deleted file mode 100644 index 775df021d..000000000 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/connection/ConnectionFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.storage.implementation.sql.connection; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Collections; -import java.util.Map; -import java.util.function.Function; - -import me.blackvein.quests.Quests; - -public interface ConnectionFactory { - String getImplementationName(); - - void init(Quests plugin); - - void close() throws Exception; - - default Map getMeta() { - return Collections.emptyMap(); - } - - Function getStatementProcessor(); - - Connection getConnection() throws SQLException; -} diff --git a/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java b/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java deleted file mode 100644 index e20e8572f..000000000 --- a/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 PikaMug and contributors. All rights reserved. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package me.blackvein.quests.tasks; - -import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.player.IQuester; -import me.blackvein.quests.util.Lang; -import me.blackvein.quests.util.MiscUtil; -import org.bukkit.ChatColor; -import org.bukkit.scheduler.BukkitRunnable; - -public class ActionTimer extends BukkitRunnable { - - private final IQuester quester; - private final IQuest quest; - private final int time; - - public ActionTimer(final IQuester quester, final IQuest quest, final int time) { - this.quester = quester; - this.quest = quest; - this.time = time; - } - - @Override - public void run() { - quester.removeTimer(getTaskId()); - if (time < 1) { - quest.failQuest(quester, false); - quester.updateJournal(); - } else { - quester.getPlayer().sendMessage(ChatColor.GREEN + Lang.get(quester.getPlayer(), "timerMessage") - .replace("