├── .github ├── BK.md ├── README.md └── workflows │ └── release.yml ├── .gitignore ├── LICENSE ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src └── main ├── java └── ink │ └── ptms │ └── chemdah │ ├── library │ └── redlib │ │ ├── BlockDataListener.java │ │ ├── BlockDataManager.java │ │ ├── BlockPosition.java │ │ ├── ChunkPosition.java │ │ ├── DataBlock.java │ │ ├── EventListener.java │ │ ├── Locations.java │ │ ├── Path.java │ │ ├── Task.java │ │ ├── backend │ │ ├── BlockDataBackend.java │ │ ├── PDCBackend.java │ │ └── SQLiteBackend.java │ │ ├── event │ │ ├── DataBlockDestroyEvent.java │ │ └── DataBlockMoveEvent.java │ │ └── sql │ │ ├── SQLCache.java │ │ ├── SQLCacheEntry.java │ │ └── SQLHelper.java │ └── util │ ├── Function2.java │ ├── Function3.java │ └── StringNumber.java ├── kotlin └── ink │ └── ptms │ └── chemdah │ ├── AdyeshachChecker.kt │ ├── Chemdah.kt │ ├── api │ ├── ChemdahAPI.kt │ ├── ChemdahEventFactory.kt │ └── event │ │ ├── InferEntityHookEvent.kt │ │ ├── InferItemHookEvent.kt │ │ ├── PartyHookEvent.kt │ │ ├── collect │ │ ├── ConversationEvents.kt │ │ ├── ObjectiveEvents.kt │ │ ├── PlayerEvents.kt │ │ ├── PluginReloadEvent.kt │ │ ├── QuestEvents.kt │ │ └── TemplateEvents.kt │ │ └── plugin │ │ ├── CollectEvent.kt │ │ └── ObjectiveCallEvent.kt │ ├── core │ ├── Data.kt │ ├── DataContainer.kt │ ├── PlayerProfile.kt │ ├── bukkit │ │ ├── NMS.kt │ │ └── NMSImpl.kt │ ├── conversation │ │ ├── Agent.kt │ │ ├── AgentType.kt │ │ ├── Conversation.kt │ │ ├── ConversationLoader.kt │ │ ├── ConversationManager.kt │ │ ├── ConversationSwitch.kt │ │ ├── ConversationTransfer.kt │ │ ├── LineFormat.kt │ │ ├── Option.kt │ │ ├── PlayerReply.kt │ │ ├── PlayerSide.kt │ │ ├── Session.kt │ │ ├── Source.kt │ │ ├── Trigger.kt │ │ ├── theme │ │ │ ├── Theme.kt │ │ │ ├── ThemeChat.kt │ │ │ ├── ThemeChatSettings.kt │ │ │ ├── ThemeChest.kt │ │ │ ├── ThemeChestSetting.kt │ │ │ └── ThemeSettings.kt │ │ └── trigger │ │ │ ├── TriggerAdyeshach.kt │ │ │ ├── TriggerCitizens.kt │ │ │ ├── TriggerMythicMobs.kt │ │ │ └── TriggerVanilla.kt │ ├── database │ │ ├── Database.kt │ │ ├── DatabaseError.kt │ │ ├── DatabaseSQL.kt │ │ ├── DatabaseSQLite.kt │ │ ├── Type.kt │ │ └── UserIndex.kt │ └── quest │ │ ├── AcceptResult.kt │ │ ├── Agent.kt │ │ ├── AgentType.kt │ │ ├── Id.kt │ │ ├── Option.kt │ │ ├── Quest.kt │ │ ├── QuestChecker.kt │ │ ├── QuestContainer.kt │ │ ├── QuestDataOperator.kt │ │ ├── QuestDevelopment.kt │ │ ├── QuestLoader.kt │ │ ├── Task.kt │ │ ├── Template.kt │ │ ├── TemplateGroup.kt │ │ ├── addon │ │ ├── Addon.kt │ │ ├── AddonAutomation.kt │ │ ├── AddonControl.kt │ │ ├── AddonDepend.kt │ │ ├── AddonOptional.kt │ │ ├── AddonParty.kt │ │ ├── AddonResetDataOnAccepted.kt │ │ ├── AddonRestart.kt │ │ ├── AddonStats.kt │ │ ├── AddonTimeout.kt │ │ ├── AddonTrack.kt │ │ ├── AddonTrackEvents.kt │ │ ├── AddonUI.kt │ │ └── data │ │ │ ├── Automation.kt │ │ │ ├── Control.kt │ │ │ └── Track.kt │ │ ├── meta │ │ ├── Meta.kt │ │ ├── MetaName.kt │ │ └── MetaType.kt │ │ ├── objective │ │ ├── Abstract.kt │ │ ├── Dependency.kt │ │ ├── Objective.kt │ │ ├── ObjectiveCountableF.kt │ │ ├── ObjectiveCountableI.kt │ │ ├── Progress.kt │ │ ├── adyeshach │ │ │ ├── ANPCDamage.kt │ │ │ └── ANPCInteract.kt │ │ ├── brewery │ │ │ ├── BBarrelAccess.kt │ │ │ ├── BBarrelCreate.kt │ │ │ ├── BBarrelDestroy.kt │ │ │ ├── BBrewDrink.kt │ │ │ ├── BPuke.kt │ │ │ └── BPush.kt │ │ ├── bukkit │ │ │ ├── AEntityDamage.kt │ │ │ ├── AEntityDeath.kt │ │ │ ├── APlayerBucket.kt │ │ │ ├── IBlockBreak.kt │ │ │ ├── IBlockFarm.kt │ │ │ ├── IBlockHarvest.kt │ │ │ ├── IBlockIgnite.kt │ │ │ ├── IBlockInteract.kt │ │ │ ├── IBlockPlace.kt │ │ │ ├── IEntityCombust.kt │ │ │ ├── IEntityInteract.kt │ │ │ ├── IEntityTame.kt │ │ │ ├── IItemAnvil.kt │ │ │ ├── IItemBreak.kt │ │ │ ├── IItemConsume.kt │ │ │ ├── IItemCraft.kt │ │ │ ├── IItemDrop.kt │ │ │ ├── IItemEnchant.kt │ │ │ ├── IItemFurnace.kt │ │ │ ├── IItemInteract.kt │ │ │ ├── IItemMend.kt │ │ │ ├── IItemPick.kt │ │ │ ├── IItemPickArrow.kt │ │ │ ├── IItemPickExp.kt │ │ │ ├── IPlayerAdvancement.kt │ │ │ ├── IPlayerAnimation.kt │ │ │ ├── IPlayerAttack.kt │ │ │ ├── IPlayerBedEnter.kt │ │ │ ├── IPlayerBedLeave.kt │ │ │ ├── IPlayerBook.kt │ │ │ ├── IPlayerBreed.kt │ │ │ ├── IPlayerBucketEmpty.kt │ │ │ ├── IPlayerBucketFill.kt │ │ │ ├── IPlayerChangeWorld.kt │ │ │ ├── IPlayerChat.kt │ │ │ ├── IPlayerCommand.kt │ │ │ ├── IPlayerDamage.kt │ │ │ ├── IPlayerDamageByBlock.kt │ │ │ ├── IPlayerDamageByEntity.kt │ │ │ ├── IPlayerDeath.kt │ │ │ ├── IPlayerDismount.kt │ │ │ ├── IPlayerExpChange.kt │ │ │ ├── IPlayerFish.kt │ │ │ ├── IPlayerFoodChange.kt │ │ │ ├── IPlayerItemHeld.kt │ │ │ ├── IPlayerJump.kt │ │ │ ├── IPlayerJumpHorse.kt │ │ │ ├── IPlayerKill.kt │ │ │ ├── IPlayerLevelChange.kt │ │ │ ├── IPlayerMount.kt │ │ │ ├── IPlayerMove.kt │ │ │ ├── IPlayerPortalEnter.kt │ │ │ ├── IPlayerPortalExit.kt │ │ │ ├── IPlayerPressurePlate.kt │ │ │ ├── IPlayerRealMove.kt │ │ │ ├── IPlayerRecipeDiscover.kt │ │ │ ├── IPlayerRegain.kt │ │ │ ├── IPlayerRespawn.kt │ │ │ ├── IPlayerResurrect.kt │ │ │ ├── IPlayerRiptide.kt │ │ │ ├── IPlayerShear.kt │ │ │ ├── IPlayerShootBow.kt │ │ │ ├── IPlayerStatistic.kt │ │ │ ├── IPlayerTeleport.kt │ │ │ ├── Units.kt │ │ │ └── paper │ │ │ │ ├── IPlayerCriterionGrant.kt │ │ │ │ ├── IPlayerElytraBoost.kt │ │ │ │ └── IPlayerShoot.kt │ │ ├── chatreaction │ │ │ └── CChatReactionWin.kt │ │ ├── citizens │ │ │ ├── CNPCDamage.kt │ │ │ └── CNPCInteract.kt │ │ ├── crazycrates │ │ │ └── CCratesOpen.kt │ │ ├── lands │ │ │ ├── LLandsClaim.kt │ │ │ ├── LLandsCreate.kt │ │ │ ├── LLandsDisband.kt │ │ │ ├── LLandsJoin.kt │ │ │ ├── LLandsLeave.kt │ │ │ └── LlandsInvite.kt │ │ ├── marriagemaster │ │ │ ├── MMarriageGift.kt │ │ │ ├── MMarriageHug.kt │ │ │ ├── MMarriageKiss.kt │ │ │ └── MMarriageMarried.kt │ │ ├── mythicmobs │ │ │ └── MMobDeath.kt │ │ ├── other │ │ │ ├── APlayerData.kt │ │ │ ├── IAlways.kt │ │ │ ├── ICustomLevel.kt │ │ │ ├── INever.kt │ │ │ ├── IPlayerData.kt │ │ │ ├── IPlayerInventory.kt │ │ │ ├── IPlayerPermission.kt │ │ │ └── ITrigger.kt │ │ ├── placeholderapi │ │ │ └── PPlaceholderAPI.kt │ │ ├── quickshop │ │ │ ├── QShopCreate.kt │ │ │ ├── QShopDelete.kt │ │ │ └── QShopPurchase.kt │ │ ├── sandalphon │ │ │ ├── SBlockBreak.kt │ │ │ └── SChestOpen.kt │ │ ├── self │ │ │ ├── CConversationRefused.kt │ │ │ └── CConversationReply.kt │ │ ├── skillapi │ │ │ ├── SCastSkill.kt │ │ │ ├── SClassChange.kt │ │ │ ├── SCombo.kt │ │ │ ├── SLevelUp.kt │ │ │ ├── SSkillDamage.kt │ │ │ ├── SSkillDowngrade.kt │ │ │ ├── SSkillUnlock.kt │ │ │ ├── SSkillUpgrade.kt │ │ │ └── SUpAttribute.kt │ │ └── votifier │ │ │ └── VVotifierVote.kt │ │ └── selector │ │ ├── DataMatch.kt │ │ ├── Flags.kt │ │ ├── InferArea.kt │ │ ├── InferBlock.kt │ │ ├── InferEntity.kt │ │ ├── InferItem.kt │ │ └── InferItemHooks.kt │ ├── library │ └── redlib │ │ └── BlockDataContainer.kt │ ├── module │ ├── Metrics.kt │ ├── Module.kt │ ├── PlaceholderHook.kt │ ├── command │ │ ├── CommandChemdah.kt │ │ ├── CommandChemdahAPI.kt │ │ ├── CommandChemdahPlayerData.kt │ │ ├── CommandChemdahPlayerLevel.kt │ │ ├── CommandChemdahQuest.kt │ │ ├── CommandChemdahScript.kt │ │ ├── CommandChemdahVariables.kt │ │ └── CommandHelper.kt │ ├── generator │ │ └── NameGenerator.kt │ ├── kether │ │ ├── ActionInventory.kt │ │ ├── ActionLocation.kt │ │ ├── ActionMath.kt │ │ ├── ActionParticle.kt │ │ ├── ActionPosition.kt │ │ ├── ActionProfile.kt │ │ ├── ActionQuest.kt │ │ ├── ActionQuestGroup.kt │ │ ├── ActionRealms.kt │ │ ├── ActionScenes.kt │ │ ├── ActionScript.kt │ │ ├── ActionTrigger.kt │ │ ├── ActionVariables.kt │ │ ├── ActionWizard.kt │ │ ├── ActionWorkflows.kt │ │ ├── KetherHook.kt │ │ ├── compat │ │ │ ├── ActionCore.kt │ │ │ ├── ActionMythic.kt │ │ │ ├── ActionSchematic.kt │ │ │ ├── ActionSkillAPI.kt │ │ │ └── ActionSkript.kt │ │ ├── conversation │ │ │ ├── ConversationAgent.kt │ │ │ ├── ConversationCancel.kt │ │ │ ├── ConversationClose.kt │ │ │ ├── ConversationCreate.kt │ │ │ ├── ConversationGoto.kt │ │ │ ├── ConversationOpen.kt │ │ │ ├── ConversationOrigin.kt │ │ │ ├── ConversationRelease.kt │ │ │ ├── ConversationRename.kt │ │ │ ├── ConversationTalkNPC.kt │ │ │ └── ConversationTalkPlayer.kt │ │ ├── quest │ │ │ ├── QuestCancel.kt │ │ │ └── QuestThis.kt │ │ └── ui │ │ │ └── UI.kt │ ├── level │ │ ├── Level.kt │ │ ├── LevelOption.kt │ │ ├── LevelReward.kt │ │ ├── LevelSystem.kt │ │ └── PlayerLevel.kt │ ├── party │ │ ├── Party.kt │ │ ├── PartyHook.kt │ │ └── PartySystem.kt │ ├── realms │ │ ├── Realms.kt │ │ └── RealmsSystem.kt │ ├── scenes │ │ ├── BlockList.kt │ │ ├── BlockListArea.kt │ │ ├── BlockListSingle.kt │ │ ├── ScenesBlockData.kt │ │ ├── ScenesFile.kt │ │ ├── ScenesState.kt │ │ └── ScenesSystem.kt │ ├── synchronous │ │ ├── SynchronizedVault.kt │ │ └── Synchronous.kt │ ├── ui │ │ ├── Include.kt │ │ ├── Item.kt │ │ ├── ItemFilter.kt │ │ ├── ItemQuest.kt │ │ ├── ItemQuestNoIcon.kt │ │ ├── ItemType.kt │ │ ├── UI.kt │ │ ├── UIMenu.kt │ │ ├── UIMenuFilter.kt │ │ ├── UISystem.kt │ │ └── UITemplate.kt │ └── wizard │ │ ├── WizardAction.kt │ │ ├── WizardInfo.kt │ │ └── WizardSystem.kt │ └── util │ ├── Couple.kt │ ├── Effect.kt │ ├── Effects.kt │ ├── Futures.kt │ ├── Utils.kt │ ├── UtilsForAdy.kt │ └── UtilsForKether.kt └── resources ├── config.yml ├── core ├── conversation.yml ├── conversation │ └── example.yml ├── group.yml └── quest │ └── example.yml ├── lang ├── en_US.yml └── zh_CN.yml └── module ├── generator ├── city.ks ├── dragon_1.ks ├── dragon_2.ks ├── dragon_3.ks ├── dwarf_1.ks ├── dwarf_2.ks ├── elf_1.ks ├── elf_2.ks ├── elf_3.ks ├── human.ks ├── item.ks ├── kingdom.ks └── town.ks ├── level.yml ├── party.yml ├── realms.yml ├── scenes.yml ├── synchronous.yml ├── ui.yml └── wizard └── example.yml /.github/BK.md: -------------------------------------------------------------------------------- 1 | ![](https://i.loli.net/2021/02/03/FBrgWYhtn8VwNlc.png) 2 | 3 | # Chemdah 对比 其他插件 4 | > 数据来源: BetonQuest 5 | 6 | | Feature | Chemdah | BetonQuest | Quests | BeautyQuests | QuestCreator | MangoQuest | 7 | | --- | --- | --- | --- | --- | --- | --- | 8 | | 免费使用 | ✅ (¥198) | ✅ | ✅ | ✅ | ❌ (¥131.25) | ✅ 9 | | 开源 | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ 10 | | API | ✅ | ✅ | ✅ | ✅ | ❌ (闭源) | ✅ 11 | | 版本支持 | 1.9-1.16.5 | 1.13.2-1.16.5 | 1.7-1.16.5 | 1.11-1.16.5 | 1.7-1.16.5 | 1.13-1.16.5 12 | | 数据库支持 | SQLite & MySQL & MongoDB | SQLite & MySQL | ❌ | MySQL | MySQL | MySQL & MongoDB 13 | | 多人任务 | ✅ | ❌ | ❌ | ❌ | ❓ | ❌ 14 | | 多分支对话 | ✅ | ✅ | ❓ | ❓| ✅ | ❓ 15 | | 客户端 NPC | ✅ (Adyeshach) | ✅ | ❓ | ❓| ✅ | ❓ 16 | | 有组织的文件结构 | ✅ | ✅ | ❌ | ❓ | ✅ | ✅ 17 | | 基于可编程的脚本 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ 18 | | 自动化任务分发 | ✅ 自动化组件 (Automation Addon) | ❌ 全局事件 (Static Events) | ✅ 计划任务 (Planner) | ❌ | ✅ 任务激活器 (Activators) | ❌ 19 | | 沉浸式任务追踪 | ✅ 追踪组件 (Track Addon) | ❌ 任务手册 (Journal) | ❌ | ❌ | ❌ | ❌ 20 | | 自定义通知系统 | ✅ 脚本代理 (Kether) | ✅ Notify IO | ❌ | ❌ | ❌ | ❌ -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # By Super_chen520 2 | # Date 2023-8-30 3 | 4 | name: Chemdah Release 5 | 6 | on: 7 | push: 8 | branches: [ "rebirth" ] 9 | pull_request: 10 | branches: [ "rebirth" ] 11 | 12 | jobs: 13 | releaseJar: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: set up JDK 17 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: '17' 21 | distribution: 'temurin' 22 | cache: gradle 23 | 24 | - name: Grant execute permission for gradlew 25 | run: chmod +x gradlew 26 | # - name: Build with Gradle 27 | # run: ./gradlew build 28 | 29 | # First build 30 | - name: build 31 | id: build_1 32 | run: ./gradlew build 33 | # Second build 34 | - name: build (retry 1) 35 | id: build_2 36 | if: steps.build_1.outcome == 'failure' 37 | run: ./gradlew build 38 | # Third build 39 | - name: build (retry 2) 40 | id: build_3 41 | if: steps.build_2.outcome == 'failure' 42 | run: ./gradlew build 43 | # Fourth build 44 | - name: build (retry 3) 45 | id: build_4 46 | if: steps.build_3.outcome == 'failure' 47 | run: ./gradlew build 48 | 49 | # output jar 50 | - name: Upload Artifacts 51 | uses: actions/upload-artifact@v3.1.2 52 | with: 53 | name: Chemdah Release 54 | path: build/libs/*.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | build 4 | About Chemdah 5 | bin 6 | *.txt 7 | *.zip 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 坏黑 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=ink.ptms.chemdah 2 | version=0.3.32 3 | kotlin.incremental=true 4 | kotlin.incremental.java=true 5 | kotlin.caching.enabled=true 6 | kotlin.parallel.tasks.in.project=true 7 | kotlin.incremental.useClasspathSnapshot=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuiqing2046/Chemdah/84245af7e5563545ef60159f8176527a5d7fba9b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Mar 08 11:48:15 CST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "Chemdah" -------------------------------------------------------------------------------- /src/main/java/ink/ptms/chemdah/library/redlib/BlockPosition.java: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.library.redlib; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.block.Block; 5 | 6 | import java.util.Objects; 7 | 8 | class BlockPosition { 9 | 10 | private final int x; 11 | private final int y; 12 | private final int z; 13 | 14 | public BlockPosition(int x, int y, int z) { 15 | this.x = x; 16 | this.y = y; 17 | this.z = z; 18 | } 19 | 20 | public BlockPosition(Block block) { 21 | this(block.getX(), block.getY(), block.getZ()); 22 | } 23 | 24 | public int getX() { 25 | return x; 26 | } 27 | 28 | public int getY() { 29 | return y; 30 | } 31 | 32 | public int getZ() { 33 | return z; 34 | } 35 | 36 | public Block getBlock(World world) { 37 | return world.getBlockAt(x, y, z); 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return Objects.hash(x, y, z); 43 | } 44 | 45 | @Override 46 | public boolean equals(Object o) { 47 | if (!(o instanceof BlockPosition)) { 48 | return false; 49 | } 50 | BlockPosition pos = (BlockPosition) o; 51 | return pos.x == x && pos.y == y && pos.z == z; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return x + " " + y + " " + z; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/ink/ptms/chemdah/library/redlib/sql/SQLCacheEntry.java: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.library.redlib.sql; 2 | 3 | import java.util.Arrays; 4 | import java.util.Objects; 5 | 6 | class SQLCacheEntry { 7 | 8 | private final Object[] params; 9 | 10 | public SQLCacheEntry(Object[] params) { 11 | this.params = params; 12 | } 13 | 14 | public Object[] getParams() { 15 | return params; 16 | } 17 | 18 | @Override 19 | public int hashCode() { 20 | return Objects.hash(params); 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (!(o instanceof SQLCacheEntry)) { 26 | return false; 27 | } 28 | return Arrays.equals(params, ((SQLCacheEntry) o).params); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/ink/ptms/chemdah/util/Function2.java: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.util; 2 | 3 | public interface Function2 { 4 | 5 | R invoke(T1 var1, T2 var2); 6 | } -------------------------------------------------------------------------------- /src/main/java/ink/ptms/chemdah/util/Function3.java: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.util; 2 | 3 | public interface Function3 { 4 | 5 | R invoke(T1 var1, T2 var2, T3 var3); 6 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/AdyeshachChecker.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah 2 | 3 | import ink.ptms.adyeshach.core.Adyeshach 4 | import taboolib.common.util.unsafeLazy 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.AdyeshachChecker 9 | * 10 | * @author 坏黑 11 | * @since 2023/1/5 17:14 12 | */ 13 | object AdyeshachChecker { 14 | 15 | /** 16 | * 是否为 v2 版本 17 | */ 18 | val isNewVersion by unsafeLazy { kotlin.runCatching { Adyeshach.api() }.isSuccess } 19 | 20 | /** 21 | * 是否为 v1 版本 22 | */ 23 | val isLegacyVersion by unsafeLazy { !isNewVersion } 24 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/Chemdah.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah 2 | 3 | import taboolib.common.platform.Plugin 4 | import taboolib.common.platform.function.console 5 | import taboolib.common.platform.function.disablePlugin 6 | import taboolib.module.configuration.Config 7 | import taboolib.module.configuration.Configuration 8 | import taboolib.module.lang.sendLang 9 | import taboolib.module.nms.MinecraftVersion 10 | import taboolib.platform.BukkitPlugin 11 | 12 | object Chemdah : Plugin() { 13 | 14 | @Config 15 | lateinit var conf: Configuration 16 | private set 17 | 18 | val plugin by lazy { 19 | BukkitPlugin.getInstance() 20 | } 21 | 22 | override fun onLoad() { 23 | if (MinecraftVersion.majorLegacy < 10900 || !MinecraftVersion.isSupported) { 24 | console().sendLang("not-support") 25 | disablePlugin() 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/ChemdahEventFactory.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api 2 | 3 | import ink.ptms.chemdah.api.event.plugin.CollectEvent 4 | import ink.ptms.chemdah.api.event.plugin.ObjectiveCallEvent 5 | import ink.ptms.chemdah.core.PlayerProfile 6 | import ink.ptms.chemdah.core.quest.Quest 7 | import ink.ptms.chemdah.core.quest.objective.Objective 8 | 9 | /** 10 | * Chemdah 11 | * ink.ptms.chemdah.api.ChemdahEventFactory 12 | * 13 | * @author 坏黑 14 | * @since 2022/7/20 16:43 15 | */ 16 | open class ChemdahEventFactory { 17 | 18 | protected val questCollectCallback = arrayListOf() 19 | protected val objectiveCallCallback = arrayListOf() 20 | 21 | open fun prepareObjectiveCall(consumer: ObjectiveCallEvent) { 22 | objectiveCallCallback.add(consumer) 23 | } 24 | 25 | open fun prepareQuestCollect(consumer: CollectEvent) { 26 | questCollectCallback.add(consumer) 27 | } 28 | 29 | open fun callQuestCollect(playerProfile: PlayerProfile, quests: List): List { 30 | val list = quests.toMutableList() 31 | questCollectCallback.forEach { it(playerProfile, list) } 32 | return list 33 | } 34 | 35 | open fun callObjectiveCall(objective: Objective<*>, event: Any): Boolean { 36 | objectiveCallCallback.forEach { it(objective, event) } 37 | return true 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/InferEntityHookEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event 2 | 3 | import ink.ptms.chemdah.core.quest.selector.InferEntity 4 | import taboolib.platform.type.BukkitProxyEvent 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.api.event.InferEntityHookEvent 9 | * 10 | * @author sky 11 | * @since 2021/4/17 2:41 下午 12 | */ 13 | class InferEntityHookEvent(val id: String, var itemClass: Class) : BukkitProxyEvent() { 14 | 15 | override val allowCancelled: Boolean 16 | get() = false 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/InferItemHookEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event 2 | 3 | import ink.ptms.chemdah.core.quest.selector.InferItem 4 | import taboolib.platform.type.BukkitProxyEvent 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.api.event.InferItemHookEvent 9 | * 10 | * @author sky 11 | * @since 2021/4/17 2:41 下午 12 | */ 13 | class InferItemHookEvent(val id: String, var itemClass: Class) : BukkitProxyEvent() { 14 | 15 | override val allowCancelled: Boolean 16 | get() = false 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/PartyHookEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event 2 | 3 | import ink.ptms.chemdah.module.party.Party 4 | import taboolib.platform.type.BukkitProxyEvent 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.api.event.PartyHookEvent 9 | * 10 | * @author sky 11 | * @since 2021/4/24 5:36 下午 12 | */ 13 | class PartyHookEvent(val plugin: String, var party: Party? = null) : BukkitProxyEvent() { 14 | 15 | override val allowCancelled: Boolean 16 | get() = false 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/collect/PluginReloadEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event.collect 2 | 3 | import taboolib.platform.type.BukkitProxyEvent 4 | 5 | /** 6 | * Chemdah 7 | * ink.ptms.chemdah.api.event.collect.PluginReloadEvent 8 | * 9 | * @author sky 10 | * @since 2021/4/24 5:36 下午 11 | */ 12 | class PluginReloadEvent { 13 | 14 | /** 任务重载 */ 15 | class Quest : BukkitProxyEvent() { 16 | 17 | override val allowCancelled: Boolean 18 | get() = false 19 | } 20 | 21 | /** 模块重载 */ 22 | class Module : BukkitProxyEvent() { 23 | 24 | override val allowCancelled: Boolean 25 | get() = false 26 | } 27 | 28 | /** 对话重载 */ 29 | class Conversation : BukkitProxyEvent() { 30 | 31 | override val allowCancelled: Boolean 32 | get() = false 33 | } 34 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/collect/TemplateEvents.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event.collect 2 | 3 | import ink.ptms.chemdah.core.quest.Template 4 | import ink.ptms.chemdah.core.quest.addon.data.Control 5 | import taboolib.library.configuration.ConfigurationSection 6 | import taboolib.platform.type.BukkitProxyEvent 7 | import java.io.File 8 | 9 | /** 10 | * Chemdah 11 | * ink.ptms.chemdah.api.event.collect.TemplateEvents 12 | * 13 | * @author sky 14 | * @since 2021/5/7 12:13 上午 15 | */ 16 | class TemplateEvents { 17 | 18 | /** 19 | * 当模板被加载时 20 | */ 21 | class Load(val file: File?, val id: String, val root: ConfigurationSection): BukkitProxyEvent() 22 | 23 | /** 24 | * 控制器挂钩事件 25 | */ 26 | class ControlHook(val template: Template, val type: String, val map: Map) : BukkitProxyEvent() { 27 | 28 | override val allowCancelled: Boolean 29 | get() = false 30 | 31 | var control: Control? = null 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/plugin/CollectEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event.plugin 2 | 3 | import ink.ptms.chemdah.core.PlayerProfile 4 | import ink.ptms.chemdah.core.quest.Quest 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.api.event.plugin.CollectEvent 9 | * 10 | * @author 坏黑 11 | * @since 2022/7/20 16:47 12 | */ 13 | interface CollectEvent { 14 | 15 | operator fun invoke(playerProfile: PlayerProfile, quests: MutableList) 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/api/event/plugin/ObjectiveCallEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.api.event.plugin 2 | 3 | import ink.ptms.chemdah.core.quest.objective.Objective 4 | 5 | /** 6 | * Chemdah 7 | * ink.ptms.chemdah.api.event.plugin.ObjectiveCallEvent 8 | * 9 | * @author 坏黑 10 | * @since 2022/7/20 16:47 11 | */ 12 | interface ObjectiveCallEvent { 13 | 14 | operator fun invoke(objective: Objective<*>, event: Any) 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/bukkit/NMS.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.bukkit 2 | 3 | import org.bukkit.block.Block 4 | import taboolib.module.nms.nmsProxy 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.core.bukkit.NMS 9 | * 10 | * @author 坏黑 11 | * @since 2022/7/18 13:40 12 | */ 13 | abstract class NMS { 14 | 15 | abstract fun getBlocKData(block: Block): Map 16 | 17 | companion object { 18 | 19 | @JvmStatic 20 | val INSTANCE = nmsProxy() 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/Agent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | /** 4 | * Chemdah 5 | * ink.ptms.chemdah.core.conversation.Agent 6 | * 7 | * @author sky 8 | * @since 2021/2/9 6:29 下午 9 | */ 10 | data class Agent(var type: AgentType, var action: List, var restrict: String? = "self") -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/AgentType.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | enum class AgentType(val namespace: String) { 4 | 5 | /** 6 | * 对话即将开始 7 | */ 8 | BEGIN("npc"), 9 | 10 | /** 11 | * 对话已经开始 12 | */ 13 | START("npc"), 14 | 15 | /** 16 | * 对话放弃 17 | */ 18 | REFUSE("player"), 19 | 20 | /** 21 | * 对话结束 22 | */ 23 | END("player"), 24 | 25 | /** 26 | * 无 27 | */ 28 | NONE(""); 29 | 30 | /** 31 | * 获取所有 Kether 命名空间 32 | */ 33 | fun namespaceAll() = listOf( 34 | "chemdah", 35 | "chemdah-conversation", 36 | "chemdah-conversation-${namespace}", 37 | "adyeshach" 38 | ) 39 | 40 | companion object { 41 | 42 | fun String.toAgent(): AgentType { 43 | return try { 44 | valueOf(uppercase()) 45 | } catch (ignored: Exception) { 46 | NONE 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/ConversationTransfer.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | import taboolib.library.configuration.ConfigurationSection 4 | 5 | /** 6 | * Chemdah 7 | * ink.ptms.chemdah.core.conversation.ConversationTransfer 8 | * 9 | * @author 坏黑 10 | * @since 2021/12/11 3:32 AM 11 | */ 12 | open class ConversationTransfer(val root: ConfigurationSection) { 13 | 14 | /** 15 | * 转移到目标 16 | */ 17 | val id = root.getString("id") 18 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/LineFormat.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | import taboolib.library.configuration.ConfigurationSection 4 | import taboolib.module.chat.colored 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.core.conversation.LineFormat 9 | * 10 | * @author 坏黑 11 | * @since 2022/11/19 22:49 12 | */ 13 | class LineFormat(val root: ConfigurationSection) { 14 | 15 | /** 单行格式 **/ 16 | val single = root.getString("single")?.colored() 17 | 18 | /** 顶行格式 **/ 19 | val top = root.getString("top")?.colored() 20 | 21 | /** 间行格式 **/ 22 | val body = root.getString("body")?.colored() 23 | 24 | /** 底行格式 **/ 25 | val bottom = root.getString("bottom")?.colored() 26 | 27 | /** 28 | * 对消息进行格式化 29 | */ 30 | fun format(message: String, idx: Int, size: Int): String { 31 | if (single == null || top == null || body == null || bottom == null) { 32 | return message 33 | } 34 | return when { 35 | size == 1 -> single 36 | idx == 0 -> top 37 | idx + 1 < size -> body 38 | else -> bottom 39 | }.replace("{text}", message) 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/Option.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | import ink.ptms.chemdah.api.ChemdahAPI 4 | import ink.ptms.chemdah.core.conversation.theme.Theme 5 | import taboolib.library.configuration.ConfigurationSection 6 | import taboolib.module.chat.colored 7 | import taboolib.module.configuration.Configuration 8 | 9 | /** 10 | * Chemdah 11 | * ink.ptms.chemdah.core.conversation.Option 12 | * 13 | * @author sky 14 | * @since 2021/2/10 10:22 上午 15 | */ 16 | data class Option( 17 | val root: ConfigurationSection, 18 | val theme: String = root.getString("theme", "chat")!!, 19 | val title: String = root.getString("title", "NPC")!!.colored() 20 | ) { 21 | 22 | val instanceTheme: Theme<*> 23 | get() = ChemdahAPI.getConversationTheme(theme) ?: error("theme $theme not supported.") 24 | 25 | /** 全局标签 */ 26 | val globalFlags = root.getStringList("global-flags") 27 | 28 | companion object { 29 | 30 | val default = Option(Configuration.empty().createSection("__option__")) 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/PlayerSide.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | import java.util.concurrent.CompletableFuture 4 | 5 | /** 6 | * Chemdah 7 | * ink.ptms.chemdah.core.conversation.PlayerSIde 8 | * 9 | * @author sky 10 | * @since 2021/2/9 6:23 下午 11 | */ 12 | data class PlayerSide(val reply: MutableList = arrayListOf()) { 13 | 14 | fun checked(session: Session): CompletableFuture> { 15 | val future = CompletableFuture>() 16 | val r = arrayListOf() 17 | fun process(cur: Int) { 18 | if (cur < reply.size) { 19 | val reply = reply[cur] 20 | reply.check(session).thenApply { 21 | if (it) { 22 | r.add(reply) 23 | } 24 | process(cur + 1) 25 | } 26 | } else { 27 | future.complete(r) 28 | } 29 | } 30 | process(0) 31 | return future 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/Source.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | import org.bukkit.Location 4 | import org.bukkit.entity.Player 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.core.conversation.Source 9 | * 10 | * @author 坏黑 11 | * @since 2021/12/11 2:28 AM 12 | */ 13 | abstract class Source(var name: String, var entity: T) { 14 | 15 | abstract fun transfer(player: Player, newId: String): Boolean 16 | 17 | abstract fun getOriginLocation(entity: T): Location 18 | 19 | fun update(name: String, entity: T) { 20 | this.name = name 21 | this.entity = entity 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/Trigger.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation 2 | 3 | /** 4 | * Chemdah 5 | * ink.ptms.chemdah.core.NpcId 6 | * 7 | * @author sky 8 | * @since 2021/2/9 6:19 下午 9 | */ 10 | data class Trigger(val id: List = emptyList()) { 11 | 12 | data class Id(val namespace: String, val value: String) { 13 | 14 | fun isNPC(namespace: String, value: String): Boolean { 15 | return namespace.equals(this.namespace, true) && value.equals(this.value, true) 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/conversation/theme/ThemeSettings.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.conversation.theme 2 | 3 | import ink.ptms.chemdah.core.conversation.Session 4 | import taboolib.library.configuration.ConfigurationSection 5 | import taboolib.library.xseries.XSound 6 | 7 | /** 8 | * Chemdah 9 | * ink.ptms.chemdah.core.conversation.theme.ThemeSettings 10 | * 11 | * @author sky 12 | * @since 2021/4/15 3:36 下午 13 | */ 14 | @Suppress("CanBeParameter") 15 | abstract class ThemeSettings(val root: ConfigurationSection) { 16 | 17 | val sound: XSound? = XSound.matchXSound(root.getString("sound.name").toString()).orElse(null) 18 | val soundPitch = root.getDouble("sound.p").toFloat() 19 | val soundVolume = root.getDouble("sound.v").toFloat() 20 | 21 | fun playSound(session: Session) { 22 | if (!session.conversation.hasFlag("NO_EFFECT:SOUND")) { 23 | sound?.play(session.player, soundPitch, soundVolume) 24 | } 25 | } 26 | 27 | override fun toString(): String { 28 | return "ThemeSettings(root=$root, sound=$sound, soundPitch=$soundPitch, soundVolume=$soundVolume)" 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/database/DatabaseError.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.database 2 | 3 | import ink.ptms.chemdah.core.PlayerProfile 4 | import ink.ptms.chemdah.core.quest.Quest 5 | import org.bukkit.entity.Player 6 | 7 | /** 8 | * Chemdah 9 | * ink.ptms.chemdah.database.DatabaseSQL 10 | * 11 | * @author sky 12 | * @since 2021/3/5 3:51 下午 13 | */ 14 | class DatabaseError(val cause: Throwable) : Database() { 15 | 16 | override fun select(player: Player): PlayerProfile { 17 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 18 | } 19 | 20 | override fun update(player: Player, playerProfile: PlayerProfile) { 21 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 22 | } 23 | 24 | override fun releaseQuest(player: Player, playerProfile: PlayerProfile, quest: Quest) { 25 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 26 | } 27 | 28 | override fun selectVariable0(key: String): String? { 29 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 30 | } 31 | 32 | override fun updateVariable0(key: String, value: String) { 33 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 34 | } 35 | 36 | override fun releaseVariable0(key: String) { 37 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 38 | } 39 | 40 | override fun variables(): List { 41 | throw IllegalAccessError("Database initialization failed: ${cause.localizedMessage}") 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/database/Type.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.database 2 | 3 | import ink.ptms.chemdah.Chemdah 4 | 5 | /** 6 | * Chemdah 7 | * ink.ptms.chemdah.database.Type 8 | * 9 | * @author sky 10 | * @since 2021/3/5 3:51 下午 11 | */ 12 | enum class Type { 13 | 14 | LOCAL, SQL, MONGODB; 15 | 16 | companion object { 17 | 18 | val INSTANCE: Type by lazy { 19 | try { 20 | valueOf(Chemdah.conf.getString("database.use", "")!!.uppercase()) 21 | } catch (ignored: Throwable) { 22 | LOCAL 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/database/UserIndex.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.database 2 | 3 | import ink.ptms.chemdah.Chemdah 4 | 5 | /** 6 | * Chemdah 7 | * ink.ptms.chemdah.core.database.UserIndex 8 | * 9 | * @author sky 10 | * @since 2021/9/18 10:56 下午 11 | */ 12 | enum class UserIndex { 13 | 14 | NAME, UUID; 15 | 16 | companion object { 17 | 18 | val INSTANCE: UserIndex by lazy { 19 | try { 20 | valueOf(Chemdah.conf.getString("database.user-index", "")!!.uppercase()) 21 | } catch (ignored: Throwable) { 22 | UUID 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/AcceptResult.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | /** 4 | * Chemdah 5 | * ink.ptms.chemdah.core.quest.AcceptResult 6 | * 7 | * @author sky 8 | * @since 2021/3/4 11:52 下午 9 | */ 10 | data class AcceptResult(val type: Type, val reason: String? = null) { 11 | 12 | enum class Type { 13 | 14 | /** 15 | * 已存在 16 | */ 17 | ALREADY_EXISTS, 18 | 19 | /** 20 | * 取消 21 | */ 22 | CANCELLED, 23 | 24 | /** 25 | * 取消(通过控制组件) 26 | */ 27 | CANCELLED_BY_CONTROL, 28 | 29 | /** 30 | * 取消(通过脚本代理) 31 | */ 32 | CANCELLED_BY_AGENT, 33 | 34 | /** 35 | * 取消(通过事件) 36 | */ 37 | CANCELLED_BY_EVENT, 38 | 39 | /** 40 | * 成功 41 | */ 42 | SUCCESSFUL, 43 | 44 | /** 45 | * 失败 46 | */ 47 | FAILED 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/Agent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | /** 4 | * Chemdah 5 | * ink.ptms.chemdah.core.conversation.Agent 6 | * 7 | * @author sky 8 | * @since 2021/2/9 6:29 下午 9 | */ 10 | data class Agent(var type: AgentType, var action: List, var restrict: String? = "self") -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/Id.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | /** 4 | * Chemdah 5 | * ink.ptms.chemdah.core.quest.Id 6 | * 7 | * @author sky 8 | * @since 2021/3/2 12:00 上午 9 | */ 10 | annotation class Id(val id: String) 11 | -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/Option.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | import taboolib.common.platform.function.warning 4 | import taboolib.library.configuration.ConfigurationSection 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.core.quest.MetaType 9 | * 10 | * @author sky 11 | * @since 2021/3/4 12:45 上午 12 | */ 13 | annotation class Option(val type: Type) { 14 | 15 | enum class Type { 16 | 17 | LIST, MAP_LIST, SECTION, TEXT, NUMBER, BOOLEAN, ANY; 18 | 19 | operator fun get(config: ConfigurationSection, node: String): Any? { 20 | try { 21 | return when (this) { 22 | LIST -> config.getList(node) 23 | MAP_LIST -> config.getMapList(node) 24 | SECTION -> config.getConfigurationSection(node) 25 | TEXT -> config.getString(node) 26 | NUMBER -> config.getDouble(node) 27 | BOOLEAN -> config.getBoolean(node) 28 | ANY -> config[node] 29 | } 30 | } catch (e: Throwable) { 31 | warning("${config[node]} (${config[node]?.javaClass?.simpleName}) cannot cast to $this ($node)") 32 | } 33 | return null 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/QuestDataOperator.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | import ink.ptms.chemdah.core.DataContainer.Companion.unsafeData 4 | import ink.ptms.chemdah.core.PlayerProfile 5 | 6 | /** 7 | * Chemdah 8 | * ink.ptms.chemdah.core.quest.QuestMetaOperator 9 | * 10 | * @author sky 11 | * @since 2021/3/2 1:13 上午 12 | */ 13 | class QuestDataOperator(val profile: PlayerProfile, val task: Task) { 14 | 15 | val container = profile.getQuests(openAPI = true).firstOrNull { it.id == task.template.id }?.persistentDataContainer 16 | 17 | fun containsKey(node: String) = container?.containsKey("${task.id}.$node") 18 | 19 | fun get(node: String) = container?.get("${task.id}.$node") 20 | 21 | fun get(node: String, def: Any) = container?.get("${task.id}.$node") ?: def.unsafeData() 22 | 23 | fun put(node: String, value: Any) = container?.set("${task.id}.$node", value) 24 | 25 | fun remove(node: String) = container?.remove("${task.id}.$node") 26 | 27 | fun clear() { 28 | container?.run { removeIf { it.key.startsWith(task.id) } } 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/Task.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | import ink.ptms.chemdah.api.ChemdahAPI 4 | import ink.ptms.chemdah.core.DataContainer 5 | import ink.ptms.chemdah.core.PlayerProfile 6 | import ink.ptms.chemdah.core.quest.objective.other.IAlways 7 | import ink.ptms.chemdah.core.quest.objective.other.INever 8 | import taboolib.library.configuration.ConfigurationSection 9 | 10 | /** 11 | * Chemdah 12 | * ink.ptms.chemdah.core.quest.Task 13 | * 14 | * @author sky 15 | * @since 2021/3/1 11:51 下午 16 | */ 17 | class Task(id: String, config: ConfigurationSection, val template: Template) : QuestContainer(id, config) { 18 | 19 | val objective = if (config.contains("objective")) ChemdahAPI.getQuestObjective(config.getString("objective")!!) ?: INever else IAlways 20 | val condition = DataContainer() 21 | val goal = DataContainer() 22 | 23 | init { 24 | config.getConfigurationSection("condition")?.toMap()?.forEach { (k, v) -> 25 | // 适配 Chemdah Lab 26 | if (v is String && v.contains(';')) { 27 | condition[k] = v.split(';').map { it.trim() } 28 | } else { 29 | condition[k] = v!! 30 | } 31 | } 32 | config.getConfigurationSection("goal")?.toMap()?.forEach { (k, v) -> 33 | // 适配 Chemdah Lab 34 | if (v is String && v.contains(';')) { 35 | goal[k] = v.split(';').map { it.trim() } 36 | } else { 37 | goal[k] = v!! 38 | } 39 | } 40 | } 41 | 42 | fun isCompleted(profile: PlayerProfile) = objective.hasCompletedSignature(profile, this) 43 | } -------------------------------------------------------------------------------- /src/main/kotlin/ink/ptms/chemdah/core/quest/TemplateGroup.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.chemdah.core.quest 2 | 3 | /** 4 | * Chemdah 5 | * ink.ptms.chemdah.core.quest.TemplateGroup 6 | * 7 | * @author mac 8 | * @since 2021/11/2 4:45 下午 9 | */ 10 | data class TemplateGroup(val id: String, val quests: Set