├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report-------.md │ └── feature-request-------.md ├── dependabot.yml └── workflows │ ├── deploydocs.yml │ ├── javadoc.yml │ └── unittest.yml ├── .gitignore ├── .idea └── copyright │ ├── astralflow.xml │ └── profiles_settings.xml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── build.gradle ├── docs ├── README.md ├── _navbar.md ├── _sidebar.md ├── getting_started │ ├── README.md │ ├── jeb_wool.md │ └── magica_wand.md ├── guide │ └── contributing.md ├── index.html ├── misc │ ├── README.md │ ├── chunk_storage_spec.md │ ├── event_order.md │ └── memleakcheck.md ├── spec │ ├── crafting.md │ ├── item_categories.md │ ├── item_prototype.md │ ├── machine │ │ ├── interactive.md │ │ ├── machine_factory.md │ │ ├── machine_item.md │ │ ├── machine_lifecycle.md │ │ ├── pushable.md │ │ ├── stateful_and_stateless.md │ │ ├── tickless.md │ │ └── wireless_communication.md │ ├── oredict.md │ ├── recipe_types.md │ └── universal │ │ └── hook.md └── user_guide │ ├── README.md │ ├── configuration.md │ └── maintained_versions.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── src ├── main │ ├── java │ │ └── io │ │ │ └── ib67 │ │ │ ├── astralflow │ │ │ ├── AstralFlow.java │ │ │ ├── Tickable.java │ │ │ ├── api │ │ │ │ ├── AstralFlowAPI.java │ │ │ │ ├── AstralHelper.java │ │ │ │ ├── events │ │ │ │ │ ├── MachineBlockBreakEvent.java │ │ │ │ │ ├── MachineBlockPlaceEvent.java │ │ │ │ │ ├── MachineEvent.java │ │ │ │ │ ├── PlayerInteractMachineEvent.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── external │ │ │ │ │ ├── AstralExtension.java │ │ │ │ │ ├── ExtensionInfo.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── item │ │ │ │ │ ├── BaseCategory.java │ │ │ │ │ ├── ItemBase.java │ │ │ │ │ ├── armor │ │ │ │ │ │ ├── ArmorCategory.java │ │ │ │ │ │ ├── ArmorItem.java │ │ │ │ │ │ ├── ArmorProperty.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── dummy │ │ │ │ │ │ ├── DummyCategory.java │ │ │ │ │ │ ├── DummyItem.java │ │ │ │ │ │ ├── DummyItemProperty.java │ │ │ │ │ │ ├── FetchMethod.java │ │ │ │ │ │ ├── fetch │ │ │ │ │ │ │ ├── BreakBlock.java │ │ │ │ │ │ │ ├── BreakMachine.java │ │ │ │ │ │ │ ├── KillMob.java │ │ │ │ │ │ │ └── package-info.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── machine │ │ │ │ │ │ ├── MachineCategory.java │ │ │ │ │ │ ├── MachineItem.java │ │ │ │ │ │ ├── internal │ │ │ │ │ │ │ └── SimpleMachineItemState.java │ │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── weapon │ │ │ │ │ │ ├── MeleeItem.java │ │ │ │ │ │ ├── RangedItem.java │ │ │ │ │ │ ├── WeaponBase.java │ │ │ │ │ │ ├── WeaponCategory.java │ │ │ │ │ │ ├── WeaponProperty.java │ │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── capability │ │ │ │ ├── ICapabilityService.java │ │ │ │ ├── impl │ │ │ │ │ └── SimpleCapabilityService.java │ │ │ │ ├── package-info.java │ │ │ │ └── wireless │ │ │ │ │ ├── IWirelessPeer.java │ │ │ │ │ ├── SimplePeer.java │ │ │ │ │ ├── impl │ │ │ │ │ └── SimpleWirelessRegistry.java │ │ │ │ │ ├── message │ │ │ │ │ ├── StatelessMessage.java │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── registry │ │ │ │ │ ├── IWirelessRegistry.java │ │ │ │ │ └── package-info.java │ │ │ ├── extension │ │ │ │ ├── IExtensionRegistry.java │ │ │ │ ├── impl │ │ │ │ │ └── ExtensionRegistryImpl.java │ │ │ │ └── package-info.java │ │ │ ├── hook │ │ │ │ ├── HookType.java │ │ │ │ ├── event │ │ │ │ │ ├── HookEvent.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── server │ │ │ │ │ │ ├── SaveDataEvent.java │ │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── internal │ │ │ │ ├── AstralConstants.java │ │ │ │ ├── IChunkTracker.java │ │ │ │ ├── RecipeHelper.java │ │ │ │ ├── Warnings.java │ │ │ │ ├── config │ │ │ │ │ ├── AstralFlowConfiguration.java │ │ │ │ │ ├── ConfigManager.java │ │ │ │ │ ├── ConfigMigrator.java │ │ │ │ │ └── Language.java │ │ │ │ ├── item │ │ │ │ │ └── state │ │ │ │ │ │ └── InternalItemState.java │ │ │ │ ├── listener │ │ │ │ │ ├── BlockListener.java │ │ │ │ │ ├── EntityListener.java │ │ │ │ │ ├── ItemListener.java │ │ │ │ │ ├── MachineListener.java │ │ │ │ │ ├── PlayerListener.java │ │ │ │ │ ├── WorldListener.java │ │ │ │ │ └── crafts │ │ │ │ │ │ └── RecipeListener.java │ │ │ │ ├── package-info.java │ │ │ │ ├── serialization │ │ │ │ │ ├── ItemKeySerializer.java │ │ │ │ │ ├── JsonMachineSerializer.java │ │ │ │ │ ├── MachineStorageHelper.java │ │ │ │ │ ├── StateSerializer.java │ │ │ │ │ └── config │ │ │ │ │ │ └── LanguageSerializer.java │ │ │ │ ├── storage │ │ │ │ │ ├── IMachineStorage.java │ │ │ │ │ ├── KeyedStorage.java │ │ │ │ │ ├── MachineSerializer.java │ │ │ │ │ ├── SimpleChunkTracker.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── MachineStorageType.java │ │ │ │ │ │ └── chunk │ │ │ │ │ │ ├── BufferUtil.java │ │ │ │ │ │ ├── ChunkBasedMachineStorage.java │ │ │ │ │ │ ├── ChunkMachineIndex.java │ │ │ │ │ │ ├── InMemoryChunk.java │ │ │ │ │ │ ├── InMemoryChunkFactory.java │ │ │ │ │ │ ├── MachineCache.java │ │ │ │ │ │ ├── MachineData.java │ │ │ │ │ │ └── tag │ │ │ │ │ │ ├── MachineDataTag.java │ │ │ │ │ │ └── MachineIndexTag.java │ │ │ │ ├── task │ │ │ │ │ └── SaveDataTask.java │ │ │ │ └── update │ │ │ │ │ └── UpdateChecker.java │ │ │ ├── item │ │ │ │ ├── AstralItem.java │ │ │ │ ├── ItemKey.java │ │ │ │ ├── ItemKeys.java │ │ │ │ ├── ItemState.java │ │ │ │ ├── LogicalHolder.java │ │ │ │ ├── StateScope.java │ │ │ │ ├── builder │ │ │ │ │ ├── ItemBuilder.java │ │ │ │ │ ├── ItemCategory.java │ │ │ │ │ ├── ItemPrototype.java │ │ │ │ │ ├── PrototypeDecorator.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── factory │ │ │ │ │ ├── ItemPrototypeFactory.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── internal │ │ │ │ │ ├── NullItemState.java │ │ │ │ │ ├── serialization │ │ │ │ │ │ ├── ItemSerializer.java │ │ │ │ │ │ ├── ItemStorageType.java │ │ │ │ │ │ └── JsonItemSerializer.java │ │ │ │ │ └── tag │ │ │ │ │ │ └── ItemStateTag.java │ │ │ │ ├── oredict │ │ │ │ │ ├── IOreDict.java │ │ │ │ │ ├── internal │ │ │ │ │ │ ├── CompoundOreDict.java │ │ │ │ │ │ ├── SimpleOreDict.java │ │ │ │ │ │ └── VanillaOreDict.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── recipe │ │ │ │ │ ├── AstralRecipe.java │ │ │ │ │ ├── IRecipeRegistry.java │ │ │ │ │ ├── IngredientChoice.java │ │ │ │ │ ├── ItemMatrix.java │ │ │ │ │ ├── RecipeRegistryImpl.java │ │ │ │ │ ├── RecipeType.java │ │ │ │ │ ├── choices │ │ │ │ │ ├── AnyChoice.java │ │ │ │ │ ├── AstralItemChoice.java │ │ │ │ │ ├── ExactItemChoice.java │ │ │ │ │ ├── MaterialChoice.java │ │ │ │ │ ├── OreDictChoice.java │ │ │ │ │ ├── TagChoice.java │ │ │ │ │ └── package-info.java │ │ │ │ │ ├── kind │ │ │ │ │ ├── Brewing.java │ │ │ │ │ ├── Shaped.java │ │ │ │ │ ├── Shapeless.java │ │ │ │ │ ├── Smelting.java │ │ │ │ │ └── package-info.java │ │ │ │ │ └── package-info.java │ │ │ ├── machines │ │ │ │ ├── AbstractMachine.java │ │ │ │ ├── AutoFactory.java │ │ │ │ ├── IMachine.java │ │ │ │ ├── IState.java │ │ │ │ ├── LifeCycle.java │ │ │ │ ├── MachineContext.java │ │ │ │ ├── MachineProperty.java │ │ │ │ ├── Tickless.java │ │ │ │ ├── exception │ │ │ │ │ ├── MachineException.java │ │ │ │ │ ├── MachineNotPushableException.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── factories │ │ │ │ │ ├── IMachineFactory.java │ │ │ │ │ ├── internal │ │ │ │ │ │ └── SimpleMachineFactory.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── internal │ │ │ │ │ └── scheduler │ │ │ │ │ │ └── SimpleCatchingScheduler.java │ │ │ │ ├── package-info.java │ │ │ │ └── trait │ │ │ │ │ ├── Interactive.java │ │ │ │ │ ├── Pushable.java │ │ │ │ │ └── package-info.java │ │ │ ├── manager │ │ │ │ ├── IFactoryManager.java │ │ │ │ ├── IMachineManager.java │ │ │ │ ├── ITickManager.java │ │ │ │ ├── ItemRegistry.java │ │ │ │ ├── impl │ │ │ │ │ ├── FactoryManagerImpl.java │ │ │ │ │ ├── ItemRegistryImpl.java │ │ │ │ │ ├── MachineManagerImpl.java │ │ │ │ │ └── SimpleTickManager.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── scheduler │ │ │ │ ├── AwaitingTickable.java │ │ │ │ ├── Scheduler.java │ │ │ │ ├── TickReceipt.java │ │ │ │ ├── exception │ │ │ │ │ ├── TickTaskException.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── internal │ │ │ │ │ ├── SchedulerAdapter.java │ │ │ │ │ └── SyncScheduler.java │ │ │ │ ├── package-info.java │ │ │ │ └── strategies │ │ │ │ │ ├── PeriodicTicks.java │ │ │ │ │ └── package-info.java │ │ │ ├── security │ │ │ │ ├── ISecurityService.java │ │ │ │ ├── impl │ │ │ │ │ └── SimpleSecurityService.java │ │ │ │ ├── mem │ │ │ │ │ ├── ILeakTracker.java │ │ │ │ │ ├── impl │ │ │ │ │ │ ├── SimpleLeakTracker.java │ │ │ │ │ │ └── TrackedObject.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ ├── texture │ │ │ │ ├── ITextureExporter.java │ │ │ │ ├── ITextureRegistry.java │ │ │ │ ├── Texture.java │ │ │ │ ├── TextureType.java │ │ │ │ ├── package-info.java │ │ │ │ └── util │ │ │ │ │ └── TextureHelper.java │ │ │ └── util │ │ │ │ ├── Blocks.java │ │ │ │ ├── ItemStackBuilder.java │ │ │ │ ├── ItemStacks.java │ │ │ │ ├── LogCategory.java │ │ │ │ └── package-info.java │ │ │ └── internal │ │ │ └── util │ │ │ └── bukkit │ │ │ ├── BukkitGson.java │ │ │ ├── Log.java │ │ │ └── serializer │ │ │ ├── ItemStackSerializer.java │ │ │ └── LocationSerializer.java │ └── resources │ │ ├── buildInfo │ │ └── plugin.yml └── test │ └── java │ └── io │ └── ib67 │ └── astralflow │ ├── ItemSerializerTest.java │ ├── hook │ └── HookTypeTest.java │ ├── internal │ └── RecipeHelperTest.java │ ├── item │ ├── ChoiceTest.java │ ├── ItemRegistryTest.java │ ├── OreDictTest.java │ ├── definitions │ │ ├── DummyStatefulItem.java │ │ └── DummyStatelessItem.java │ ├── itembuilder │ │ ├── ItemBuilderTest.java │ │ ├── Weapon.java │ │ └── weapon │ │ │ ├── Melee.java │ │ │ └── WeaponItems.java │ ├── machine │ │ ├── MachineItemTest.java │ │ └── SimpleStatelessMachine.java │ ├── presets │ │ ├── ArmorItemTest.java │ │ ├── MeleeItemTest.java │ │ └── RangedItemTest.java │ └── recipe │ │ └── RecipeRegistryTest.java │ ├── machine │ ├── AutoFactoryTest.java │ └── MachineManagerTest.java │ ├── security │ └── MemLeakTest.java │ ├── storage │ ├── ChunkBasedMachineStorageTest.java │ ├── DummyStatefulMachine.java │ └── MockItemStorage.java │ ├── test │ └── TestUtil.java │ └── wireless │ └── WirelessTest.java ├── test-plugin ├── build.gradle └── src │ └── main │ ├── java │ └── io │ │ └── ib67 │ │ └── astralflow │ │ ├── TestItems.java │ │ ├── TestModule.java │ │ ├── TestPlugin.java │ │ ├── item │ │ ├── AnotherSimpleState.java │ │ ├── ExCalibur.java │ │ ├── SimpleStatefulCategory.java │ │ ├── SimpleStatelessCategory.java │ │ └── SimpleStatelessUnstackableCategory.java │ │ └── machines │ │ ├── InteractiveBarrel.java │ │ └── JebWool.java │ └── resources │ └── plugin.yml └── translations └── en_US.conf /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [iceBear67] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: ["https://afdian.net/@omgib67"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report-------.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report | 问题反馈 3 | about: Create a report to help us improve 4 | title: "[BUG] XXXX" 5 | labels: bug, help wanted 6 | assignees: iceBear67 7 | 8 | --- 9 | 10 | **我已经认真查阅过了其他人发布的 issue 和常见问题解答且网上搜索没有通用方案** 11 | **I've looked other issues, FAQ and Google** 12 | 13 | 16 | 17 | **Describe the bug / 描述问题 ** 18 | A clear and concise description of what the bug is. 19 | 20 | **To Reproduce / 如何产生这个问题 ** 21 | Steps to reproduce the behavior: 22 | 1. Go to '...' 23 | 2. Click on '....' 24 | 3. Scroll down to '....' 25 | 4. See error 26 | 27 | **Expected behavior / 预期行为 ** 28 | A clear and concise description of what you expected to happen. 29 | 30 | ** Platfrom / 运行平台 ** 31 | 32 | Minecraft: 1.x.x 33 | Using: Paper/Spigot 34 | OS: Linux / Windows 35 | 36 | **Screenshots / 截图 ** 37 | If applicable, add screenshots to help explain your problem. 38 | 39 | **Additional context / 附加内容 ** 40 | Add any other context about the problem here. 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request-------.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request | 特性请求 3 | about: Suggest an idea for this project 4 | title: "[FEAT] XXXX" 5 | labels: enhancement 6 | assignees: iceBear67 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? 你的问题和一个问题相关吗 ** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like 你想要什么样的解决方案** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered 你想过的其他想法 ** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context 附加内容** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | labels: ["dependabot"] 13 | -------------------------------------------------------------------------------- /.github/workflows/deploydocs.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Documentations 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [ published ] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | 14 | - uses: actions/checkout@v2 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v2 17 | with: 18 | java-version: '17' 19 | distribution: 'temurin' 20 | - name: Deploy 21 | uses: JamesIves/github-pages-deploy-action@v4.3.0 22 | with: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | branch: gh-pages 25 | clean: true 26 | folder: docs 27 | target-folder: docs -------------------------------------------------------------------------------- /.github/workflows/javadoc.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 6 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 7 | 8 | name: Publish Javadoc 9 | 10 | on: 11 | workflow_dispatch: 12 | 13 | release: 14 | types: [ published ] 15 | jobs: 16 | build: 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | 21 | - uses: actions/checkout@v2 22 | - name: Set up JDK 17 23 | uses: actions/setup-java@v2 24 | with: 25 | java-version: '17' 26 | distribution: 'temurin' 27 | - name: Build with Gradle 28 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 29 | with: 30 | arguments: javadoc 31 | - name: Deploy 32 | uses: JamesIves/github-pages-deploy-action@v4.3.0 33 | with: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | branch: gh-pages 36 | clean: true 37 | folder: build/docs/javadoc 38 | target-folder: javadoc -------------------------------------------------------------------------------- /.github/workflows/unittest.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 6 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 7 | 8 | name: Tests & Artifact 9 | 10 | on: 11 | push: 12 | branches: [ main ] 13 | pull_request: 14 | branches: [ main ] 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | 22 | - uses: actions/checkout@v2 23 | - name: Set up JDK 17 24 | uses: actions/setup-java@v2 25 | with: 26 | java-version: '17' 27 | distribution: 'temurin' 28 | cache: 'gradle' 29 | - name: Build with Gradle 30 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 31 | with: 32 | arguments: test shadowjar --no-daemon 33 | - name: Upload a Build Artifact 34 | uses: actions/upload-artifact@v3.1.0 35 | with: 36 | # Artifact name 37 | name: "Build Artifact" 38 | # A file, directory or wildcard pattern that describes what to upload 39 | path: build/libs 40 | # The desired behavior if no files are found using the provided path. 41 | -------------------------------------------------------------------------------- /.idea/copyright/astralflow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please go to documentation for detailed contributing guide. 2 | 3 | It is laying on sidebar. -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 0.1.x | :white_check_mark: | 8 | 9 | ## Reporting a Vulnerability 10 | 11 | Submit Here: https://github.com/InlinedLambdas/AstralFlow/security/advisories/new 12 | 13 | Please don't use issue, which leaks the vulnerability to skidders. 14 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Welcome 2 | 3 | 欢迎来到 AstralFlow(也称*星流*) 文档。 4 | 5 | 星流是一个功能强大的 Bukkit 开发框架,它可以帮助您做到很多事情: 6 | 7 | 1. 方便的自定义物品,配方,方块和机器而无需客户端添加 Mod。 8 | 2. 更容易写出值得信赖的代码,避免游戏漏洞和巨大性能开销。 9 | 3. 专注于游戏内容的建设,无需过度考虑实现细节。 10 | 4. 与社区的内容对接,我为人人,人人为我。 11 | 5. ... 还有更多! 12 | 13 | 星流是开源且免费的,您可以点击文档右上角的 `View on GitHub` 快速跳转到项目主页。 14 | 15 | 您也可以通过添加我们的 [Discord 群组](https://discord.com/invite/fSkxjB4z6A) 和订阅 [Telegram 频道](https://t.me/AstralFlows) 来获取最新消息。 16 | 17 | # 开始使用 18 | 19 | 星流意图尽可能使更多人参与社区的建设中,因此我们提供了使用指南以及开发教程。 20 | 21 | ## 对于 开发者 22 | 23 | 对于开发者,我们提供了体验良好的程序接口以便您可以轻松的开发拓展。 24 | 25 | 点击此处查看 [拓展入门](./getting_started/README.md),但我们建议您先阅读 [用户指南](./user_guide/README.md) 26 | 27 | 以及对您有帮助的 [Javadoc](https://inlinedlambdas.codeberg.page/astralflow/javadoc/) 28 | 29 | ## 对于 服主 30 | 31 | 星流仍处于十分原始的状态,但您仍然可以作为一个普通插件安装到服务器中。 32 | 33 | 在未来,我们将会添加更多制作拓展的方式以接纳没有编程基础的用户。 34 | 35 | 点击此处查看 [用户指南](./user_guide/README.md) -------------------------------------------------------------------------------- /docs/_navbar.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kalculos/AstralFlow/ff652aba22f0111e99f3673f7632da5e5bfb036c/docs/_navbar.md -------------------------------------------------------------------------------- /docs/_sidebar.md: -------------------------------------------------------------------------------- 1 | - [用户指南](./user_guide/README.md) 2 | - [配置文件](./user_guide/configuration.md) 3 | - [版本支持情况](./user_guide/maintained_versions.md) 4 | - [拓展入门](./getting_started/README.md) 5 | - [变色羊毛](./getting_started/jeb_wool.md) 6 | - [色色手杖](./getting_started/magica_wand.md) 7 | - 通用组件 8 | - [AstralHelper](https://af.ib67.io/javadoc/io/ib67/astralflow/api/AstralHelper.html) 9 | - [Hook 系统](./spec/universal/hook.md) 10 | - 机器 11 | - [机器工厂](./spec/machine/machine_factory.md) 12 | - [有状态与无状态](./spec/machine/stateful_and_stateless.md) 13 | - [机器物品](./spec/machine/machine_item.md) 14 | - 机器能力与特质 15 | - [能力: 无线通信与发现](./spec/machine/wireless_communication.md) 16 | - [特质: 交互式机器](./spec/machine/interactive.md) 17 | - [特质: 可推动机器](./spec/machine/pushable.md) 18 | - [特质: 取消更新](./spec/machine/tickless.md) 19 | - 物品 20 | - [物品与原型](./spec/item_prototype.md) 21 | - [物品类别](./spec/item_categories.md) 22 | - [矿物辞典](./spec/oredict.md) 23 | - [配方类型](./spec/recipe_types.md) 24 | - [合成系统](./spec/crafting.md) 25 | - [其他](./misc/README.md) 26 | - [区块储存格式](./misc/chunk_storage_spec.md) 27 | - [内存泄漏检测](./misc/memleakcheck.md) 28 | - [事件触发顺序](./misc/event_order.md) 29 | - [贡献星流](./guide/contributing.md) -------------------------------------------------------------------------------- /docs/misc/README.md: -------------------------------------------------------------------------------- 1 | 此分类存放一些和具体实现相关的内容。 -------------------------------------------------------------------------------- /docs/misc/event_order.md: -------------------------------------------------------------------------------- 1 | # 事件触发顺序 2 | 3 | AstralFlow 内置了一些事件监听器以驱动 [Hook 系统](./spec/universal/hook.md) 的运行,它们之间有次序。 4 | 5 | 次序主要是为了与别的插件以及现有内容准备的,如「先广播机器交互,再广播物品接触了机器」 6 | 7 | 具体的次序如下: 8 | 9 | - 与机器方块的交互 -- 最先触发,若此阶段有事件被取消则下游不会触发 10 | - 与物品,方块的交互 -- 同上半条 11 | 12 | 同时,还有一些特殊情况: 13 | 14 | - [手持物品和实体交互](https://af.ib67.io/javadoc/io/ib67/astralflow/hook/HookType.html#PLAYER_INTERACT_ENTITY) 15 | 使用的优先级为 `EventPriority.HIGH`,此优先级低于一般监听器 16 | - 如果你需要绕过被机器方块阻止的事件,可以用带有后缀 `_LOW` 的 Hook, 17 | 例如 [PLAYER_INTERACT_BLOCK_LOW](https://af.ib67.io/javadoc/io/ib67/astralflow/hook/HookType.html#PLAYER_INTERACT_BLOCK_LOW) 18 | ,同时这类 Hook 的优先级通常都高于同类型的其他 Hook. -------------------------------------------------------------------------------- /docs/misc/memleakcheck.md: -------------------------------------------------------------------------------- 1 | 我们引入了 [ILeakTracker](https://af.ib67.io/javadoc/io/ib67/astralflow/security/mem/ILeakTracker.html) 2 | 来帮助我们追踪没有被正确卸载掉的对象,并且把他们在控制台打印出来。 3 | 4 | # 注册内存泄漏检测 5 | 6 | `ILeakTracker` 属于 [SecurityService](https://af.ib67.io/javadoc/io/ib67/astralflow/security/ISecurityService.html) 7 | 的一部分。 8 | 9 | ```java 10 | flow.getSecurityService().getLeakTracker().track(yourObjHere); 11 | ``` 12 | 13 | 类似的还有 `untrack`,不多赘述。 14 | 15 | # 检测原理 16 | 17 | AstralFlow 18 | 采用 [SimpleLeakTracker](https://github.com/InlinedLambdas/AstralFlow/blob/main/src/main/java/io/ib67/astralflow/security/mem/impl/SimpleLeakTracker.java) 19 | 作为实现。 20 | 21 | ```hocon 22 | # 多少个 tick 给潜在的内存泄漏对象记一次周期,有20的倍数个周期的对象会被标记为内存泄露并且在控制台中输出 23 | # 设置为 -1 禁用内存泄漏检测。此项用于寻找潜在的内存泄漏 24 | # 如果你不知道怎么调,就把它设置为 100 25 | leak-check-interval = 100 26 | ``` 27 | 28 | 正如 [配置文件](./user_guide/configuration.md) 说的一样,泄露检查具有周期性,并且周期由配置文件来决定。 29 | 30 | 每过一个周期,SLT 就会给被追踪的对象的计数器自增一次。当 `counter % 20 == 0 ` 时,就会判断为一次内存泄漏,并且播报到控制台中以便尽早发现问题。 -------------------------------------------------------------------------------- /docs/spec/crafting.md: -------------------------------------------------------------------------------- 1 | AstralFlow 有一套自己完全重写的合成系统,并且支持注入原版合成台。 2 | 3 | 关于开启注入原版合成台,请参考 [配置文件](./user_guide/configuration.md) 4 | 5 | # RecipeRegistry 6 | 7 | AstralFlow 8 | 中的合成系统主要由 [IRecipeRegistry](https://af.ib67.io/javadoc/io/ib67/astralflow/item/recipe/IRecipeRegistry.html) 9 | 管理,通过 `AstralFlowAPI` 可以得到一个默认 `RecipeRegistry` 示例。 10 | 11 | ```java 12 | flow.getRecipeRegistry(); 13 | ``` 14 | 15 | 接着你就可以通过它来匹配配方和注册配方,做一个自己的工作台。 16 | 17 | ## ItemMatrix 18 | 19 | 由于各类配方的物品矩阵结构不同,因此向 `matchRecipe` 传入物品的时候需要按照规矩。 20 | 对此,AstralFlow 提供了一个 [ItemMatrix](https://af.ib67.io/javadoc/io/ib67/astralflow/item/recipe/ItemMatrix.html) 21 | 类,可以帮助你构建一个矩阵。 22 | 23 | ```java 24 | ItemMatrix.of(...any...machine...inventory...); 25 | ``` -------------------------------------------------------------------------------- /docs/spec/item_categories.md: -------------------------------------------------------------------------------- 1 | # 物品类别 2 | 3 | [物品类别](https://af.ib67.io/javadoc/io/ib67/astralflow/item/builder/ItemCategory.html) 4 | 用于规定一类物品的行为和定义,它主要为了 `ItemBuilder` 服务,并非核心组件。 5 | 6 | ```java 7 | 8 | /** 9 | * A category of items.
10 | * This class defines how {@link ItemPrototypeFactory}s are created from your custom item types.
11 | * See {@link io.ib67.astralflow.api.item.weapon.WeaponCategory} for an example. 12 | * 13 | * @param The type of item this category is for. 14 | */ 15 | @ApiStatus.AvailableSince("0.1.0") 16 | public interface ItemCategory { 17 | 18 | /** 19 | * Produces an {@link ItemPrototypeFactory} for the given item, which will be registered into {@link io.ib67.astralflow.manager.ItemRegistry} 20 | */ 21 | ItemPrototypeFactory getFactory(I item); 22 | 23 | } 24 | ``` 25 | 26 | 由上定义可知,`ItemCategory` 接受一个类型参数 `I`,用于指定它接收的 *原型* 类型。并且类似一个 `Function` 用于构造 IPF。 27 | 28 | 关于 ItemPrototypeFactory 请参考 [物品与原型](./spec/item_prototype.md) 29 | 30 | * `MachineCategory` 的原型类型是 `MachineItem` 31 | * `WeaponCategory` 的原型类型是 `WeaponBase`,`WeaponBase` 有若干子类.... 32 | 33 | ## 自定义物品类别 34 | 35 | 你可以通过自定义一个物品类别的方式来将你的新物品接入 `ItemBuilder` 中,只需提供单例对象即可。 36 | 在 [io.ib67.astralflow.api.item](https://github.com/InlinedLambdas/AstralFlow/tree/main/src/main/java/io/ib67/astralflow/api/item) 37 | 下有详尽的参考对象。 38 | 39 | > 编写自定义物品的时候经常会需要监听事件(比如交互),这正是你应该用 [Hook](./spec/universal/hook.md) 的时候了。 40 | 41 | 以及,我们通常推荐你的新物品使用 `ItemBase` 作为基类,正如你在 AstralFlow 内置的物品类型内看到的,它可以节省掉一些样版代码。 -------------------------------------------------------------------------------- /docs/spec/machine/interactive.md: -------------------------------------------------------------------------------- 1 | 在 AstralFlow 中,总会有一些机器需要跟玩家打交道,而这是一个机器特质。 2 | 3 | # Interactive 4 | 5 | [Interactive](https://af.ib67.io/javadoc/io/ib67/astralflow/machines/trait/Interactive.html) 代表你的机器能够与玩家交互。 6 | 7 | ```java 8 | /** 9 | * Represents an interactive trait for machines. 10 | */ 11 | @ApiStatus.AvailableSince("0.1.0") 12 | public interface Interactive { 13 | /** 14 | * Called when a player tries to interact with the machine. (clicking) 15 | * 16 | * @param clickType The type of interaction. 17 | * @param player The player that interacted. 18 | * @param itemInHand The item in the player's hand. 19 | */ 20 | void onInteract(Action clickType, Player player, @Nullable ItemStack itemInHand); 21 | } 22 | ``` 23 | 24 | 只需实现 `Interactive`,接下来当你的机器被玩家点击时,AstralFlow 会调用 `onInteract` 方法。 -------------------------------------------------------------------------------- /docs/spec/machine/machine_factory.md: -------------------------------------------------------------------------------- 1 | 在 AstralFlow 2 | 中,你可以注册自己的 [MachineFactory](https://af.ib67.io/javadoc/io/ib67/astralflow/machines/factories/IMachineFactory.html) 3 | 来定义机器的创建方式。 4 | 5 | # 机器工厂 6 | 7 | `MachineFactory` 本质上是一个 `Function`,用于根据机器的信息来构造出对应的机器。 8 | 9 | 需要注意的是,`MachineFactory` 和机器的类型总是一一对应的,并且不支持注册到抽象类型的机器。 10 | 11 | ## 注册 12 | 13 | AstralFlowAPI 提供了对于 FactoryManager 的公开访问,从中可以获取/删除/注册机器工厂。 14 | 15 | ```java 16 | flow.getFactories().register(classOfMachine, factory) 17 | ``` 18 | 19 | ## 自动机器工厂 20 | 21 | 由于机器的创建过程大都相似,我们提供一个注解 `@AutoFactory`,用来标注一个 `IMachine` 的子类是可以通过自动生成的机器工厂来创建的。 22 | 23 | 使用 `@AutoFactory` 需要满足以下条件: 24 | 25 | - 必须有公开的构造器 26 | - 27 | 且构造器参数只能有一个,而且必须是 [MachineProperty](https://af.ib67.io/javadoc/io/ib67/astralflow/machines/MachineProperty.html) 28 | 29 | -------------------------------------------------------------------------------- /docs/spec/machine/machine_item.md: -------------------------------------------------------------------------------- 1 | AstralFlow 提供了 `MachineItem` 用于创建机器的对于物品。 2 | 3 | # 物品与机器 4 | 5 | 熔炉(物品) 能放出 熔炉(方块),而熔炉(方块) 能挖出 熔炉(物品)。 6 | 7 | 因此可以推导 -> 熔炉物品 即为 熔炉方块 的 `MachineItem`。在 [变色羊毛](./getting_started/jeb_wool.md) 中,我们就使用了 `MachineItem`。 8 | 9 | ```java 10 | // 注册 11 | ItemBuilder.of(MachineCategory.INSTANCE) // 声明类别 12 | .prototype(new MachineItem( // 声明原型 13 | itemKey, 14 | itemStack, 15 | JebWool.class // JebWool 的类 16 | )) 17 | .register(); 18 | ``` 19 | 20 | 使用非常简单,不过多赘述,但是有一些特殊的条件需要注意。 21 | 22 | # 限制 23 | 24 | 有状态机器的 State 必须使用 `ItemState`,否则无法储存状态。 25 | 26 | 传入物品原型时不能使用有物理性质的方块,例如 TNT,沙子,沙砾 等。使用这些方块可能会带来意想不到的后果(处于性能考虑,AstralFlow 并没有针对某些方块来处理 BlockPhysicEvent ) 27 | -------------------------------------------------------------------------------- /docs/spec/machine/machine_lifecycle.md: -------------------------------------------------------------------------------- 1 | 在 AstralFlow 中,每个注册的 [IMachine](https://af.ib67.io/javadoc/io/ib67/astralflow/machines/IMachine.html) 2 | 都被严格规定了生命周期,这是为了避免潜在的内存泄漏以及安全问题。 3 | 4 | # 生命周期 5 | 6 | 默认的,在 AstralFlow 中,你的机器应该随着他所在的区块而存在,当区块被卸载的时候也应该随之被卸载卸载。 7 | 8 | 区块加载时 -> 机器加载 -> ... 机器运行 ... 区块运行 ... -> 区块卸载时 -> 机器卸载 -> 区块卸载完毕 9 | 10 | 因此,如果你有必要储存一个 `IMachine` 对象,你应该考虑到他的生命周期问题。典型的做法就是使用 `WeakReference` 那样的弱引用容器来储存,或者是使用 `Flow` 来管理数据的来源从而避免机器对象的直接参与。 11 | 12 | ## 内存泄漏检测 13 | 14 | 当**注册过的机器**被对应的 [IMachineManager](https://af.ib67.io/javadoc/io/ib67/astralflow/manager/IMachineManager.html) 15 | 标注为卸载后,将会被同时纳入内存泄漏检器的目标之内。 16 | 17 | 关于内存泄漏检测,请参考 [内存泄漏检测](./misc/memleakcheck.md) 18 | 19 | -------------------------------------------------------------------------------- /docs/spec/machine/pushable.md: -------------------------------------------------------------------------------- 1 | 在 AstralFlow 中,机器默认是不可推动的,你需要为能够推动的机器专门定义可推动。 2 | 3 | > 注意:Pushable API 处于实验性阶段,未来极有可能发生改变 4 | 5 | # Pushable 6 | 7 | 为了让你的机器方块能够推动,我们需要实现 [Pushable](https://af.ib67.io/javadoc/io/ib67/astralflow/machines/trait/Pushable.html). 8 | 9 | ```java 10 | /** 11 | * Represents a trait that can be moved. 12 | */ 13 | @ApiStatus.AvailableSince("0.1.0") 14 | @ApiStatus.Experimental 15 | public interface Pushable { 16 | void push(Location newLocation, Vector direction); 17 | } 18 | ``` 19 | 20 | `push(Location,Vectory)` 会在推动的时候传入两个参数,一个是新的位置,一个是推动的方向。 21 | 要注意的是,Pushable 暂时还没有事务性( [#155](https://github.com/InlinedLambdas/AstralFlow/issues/155) ),因此一旦被推动,你的机器必须成功,不许失败。 22 | 当然,你不需要担心方块被推到黑曜石里面去的奇怪问题。原版机制不成立的情况下,`push` 是不会被调用的,也就是不会被推动。 23 | 24 | 原版机制适用于 `Pushable`。 -------------------------------------------------------------------------------- /docs/spec/machine/stateful_and_stateless.md: -------------------------------------------------------------------------------- 1 | 根据有无对持久化的需求,我们将机器分为两种类型:`Stateful/有状态` 和 `Stateless/无状态`。 2 | 3 | # 无状态机器 4 | 5 | 无状态机器总是不储存任何数据在内存以外的地方,实例被重复创建后数据也会随之全部丢失。 6 | 如 [变色羊毛](./getting_started/jeb_wool.md) 则是一个无状态机器。他的数据只储存在机器实例中,而不是在 `IState` 里。 7 | 8 | # 有状态机器 9 | 10 | 与无状态机器相反,有状态机器可以持久的保存数据,这是通过 `IState` 实现的。每个机器都有一个 `IState`,不过一般情况下是空的。 11 | 12 | 为了使用 `IState` 存储数据,你需要定义数据类并且实现 `IState` 接口。 13 | 14 | > 需要注意的是,目前 AstralFlow **不支持** 嵌套的 `IState`,也就是一个 `IState` 内不能包含其他的 `IState`,否则会产生问题。 15 | > 对于这种特殊情形,可以考虑使用 @JsonAdapter 并且避免使用 `IState` 作为字段的静态类型。 16 | 17 | 实例: 18 | 19 | ```java 20 | @Getter 21 | class BlockRepository implements IState { 22 | private final List items = new ArrayList(); 23 | } 24 | ``` 25 | 26 | AstralFlow 额外提供了对 `ItemStack`, `Location` 的序列化支持。对于没有被支持到的常用数据类型可以发 Issue 提建议。 27 | 28 | > 需要注意的是: 你永远不应该在 `IState` 里储存 Bukkit 的抽象类型,因为它们的序列化通常无意义。 29 | > 如:Player, Entity, World, etc. 对于此类对象请总是使用 UUID 或其他用于标识他们的方式,并且应该考虑异常的处理,如 `玩家不在线` 30 | 31 | ## MachineItem 32 | 33 | 作为一种特殊情况,当你的机器使用 `MachineItem` 作为和物品联系的桥梁时你需要使用 `ItemState` 而不是 `IState`,好在这两个类型上并没有太大的差异。 34 | 35 | 只需更改 `IState` 到 `ItemState` 即可。 36 | -------------------------------------------------------------------------------- /docs/spec/machine/tickless.md: -------------------------------------------------------------------------------- 1 | 对于一些特殊的机器(比如装饰性方块),他们不做任何事情。因此,AstralFlow 2 | 提供了 [@Tickless](https://af.ib67.io/javadoc/io/ib67/astralflow/machines/Tickless.html) 注解来解决这个问题 3 | 4 | 只需要在任意 `IMachine` 的子类上标注这个注解,AstralFlow 就不会再去更新你的机器了。 5 | -------------------------------------------------------------------------------- /docs/spec/oredict.md: -------------------------------------------------------------------------------- 1 | # 矿物辞典 2 | 3 | AstralFlow 中的矿物辞典类似于 [Tag](https://mcforge.readthedocs.io/en/1.18.x/resources/server/tags/),通过一个 Key 可以匹配到多个物品上。 4 | 5 | 例如:stone -> 各种石头 oreCopper -> 各种扩展的铜矿和原版的铜矿 6 | 7 | 辞典可以注册很多物品进去,包括 AstralFlow 的特殊物品。但是在 `AstralExtension` 的 `init` 阶段过后就会被锁定。 8 | 9 | # 命名规范 10 | 11 | 参chao考xi自 [Forge Documentation](https://mcforge-ko.readthedocs.io/zh/latest/utilities/oredictionary/) 12 | 13 | > 由于辞典名称需要在不同Mod间共享,它们应该是比较统一的。请使用其它拓展可能会使用的名称。 14 | 15 | AstralFlow 并没有规定名称需要有某种特定的格式,但下面这些规则现在已经是比较流行的标准了: 16 | 17 | 整个辞典通常使用驼峰命名法(camelCase,使用小写字母开头,接下来的单词首字母大写的复合词),并且不要使用空格以及下划线。 18 | 19 | 辞典名称的第一个单词应该指明物品的类型。对于那些特殊的物品(比如record,dirt,egg,vine),一个单词就足够了,不用指明物品类型。 20 | 21 | 名称的最后一部分应当指明物品的材料。这将区分开ingotIron与ingotGold。 22 | 23 | 如果两个单词还是不够详细,你也可以加上第三个单词。比如说,花岗岩被注册为blockGranite,而磨制花岗岩被注册为blockGranitePolished。 24 | 25 | 如果想要一份通用前缀以及后缀的列表,见通用名称。 26 | 27 | # 通用名称 28 | 29 | 还是参chao考xi自 [Forge Documentation](https://mcforge-ko.readthedocs.io/zh/latest/utilities/oredictionary/) 30 | 31 | 原版Minecraft物品以及方块的辞典名称可以在下方中找到。 32 | 33 | 已经使用的通用前缀包括 `ore`,`ingot`,`nugget` 34 | 35 | 已经使用的通用后缀包括 Wood,Glass,Iron,Gold,Leaves,和 Brick。 36 | 37 | # 现有 Minecraft 辞典名称 38 | 39 | 我觉得你还是去看 [VanillaOreDict](https://github.com/InlinedLambdas/AstralFlow/blob/main/src/main/java/io/ib67/astralflow/item/oredict/internal/VanillaOreDict.java) 40 | 比较好 41 | 如果你想在配方中运用 Minecraft 自带的 Tag 系统支持,请使用 `TagChoice` -------------------------------------------------------------------------------- /docs/spec/universal/hook.md: -------------------------------------------------------------------------------- 1 | Hook 是 AstralFlow 中主要提供信息通知的组件,你可以通过 Hook 接收到一些来自 Bukkit 的 Event 从而避免繁琐的注册监听器等等过程。 2 | 3 | # HookType 4 | 5 | [io.ib67.astralflow.hook.HookType](https://af.ib67.io/javadoc/io/ib67/astralflow/hook/HookType.html) 是 Hook 6 | 系统里的核心类,你可以通过 HookType 对象来注册你的监听器。 7 | 8 | > 你也可以通过自己创建一个 HookType 用于广播你的自定义信息,这可以简化扩展之间的交互。 9 | 10 | 不过要注意的是,并非所有的 Bukkit 事件都有它对应的 HookType. 如果遇到了没有对应的 HookType 的事件,请自行实现它的转播或者发一个 Issue. 11 | 12 | ## 注册 13 | 14 | 可以使用 `HookType#register(Runnable)` 注册,也可以使用 `HookType#register(Consumer)` 来注册。 15 | 16 | HookType 本身提供了大量已经支持的常量 hook, 如果遇到符合需求的直接使用即可。 17 | 18 | 例如: 19 | 20 | ```java 21 | HookType.CHUNK_LOAD.register(this::initChunk); 22 | HookType.CHUNK_UNLOAD.register(t -> finalizeChunk(t.getChunk())); 23 | HookType.SAVE_DATA.register(this::onSaveData); 24 | ``` 25 | 26 | 要注意的是,有的 HookType 是不会传递任何值的(也就是 null ),但是在 AstralFlow 内,只要 HookType 的类型参数明确(比如`HookType`),就必然有值,否之亦然。 27 | 28 | ## 播报消息 29 | 30 | 可以使用 `AstralFlowAPI#callHooks(HookType,Event)` 播报消息。 31 | 32 | 这个方法返回一个 boolean, 代表传递的 `Event` 是否被 cancell( 如果这个 `Event` 是一个 `Cancellable` ),这样设计主要是为了方便。 33 | 34 | ```java 35 | @EventHandler(ignoreCancelled = true) 36 | public void onBlockPlace(BlockPlaceEvent event) { 37 | event.setCancelled( 38 | flow.callHooks( 39 | HookType.BLOCK_PLACE, 40 | event 41 | ) 42 | ); 43 | } 44 | ``` 45 | 46 | ## 所有已经支持的 HookType 47 | 48 | 请查阅 [Javadoc](https://af.ib67.io/javadoc/io/ib67/astralflow/hook/HookType.html) -------------------------------------------------------------------------------- /docs/user_guide/README.md: -------------------------------------------------------------------------------- 1 | 这一篇指南包含了如何安装插件以及版本类型等注意事项。 2 | 3 | # 下载插件 4 | 5 | 在安装之前,我们首先需要下载到可用的星流。 6 | 一般来说,星流的维护者们会在以下渠道发布更新: 7 | 8 | - [GitHub Releases](https://github.com/InlinedLambdas/AstralFlow/releases) 9 | 10 | 以及插件本身出于安全考虑也会进行自动更新。 11 | > 若要关闭自动更新,请详见 [配置文件](./user_guide/configuration.md) 12 | 13 | 在一般情况下,我们总是推荐您使用最新的 Spigot/Paper 来配合最新的星流使用。若您正好正在使用最新的 Spigot/Paper,那么您可以直接在 Release 上下载最新的星流。 14 | > 在 Github Release 上下载星流时,请选择正式发布版本 ,即标题右边是绿色的 *Release* 15 | 16 | > 若您正巧没有在使用最新的 Spigot/Paper,请参见 [支持的版本列表](./user_guide/maintained_versions.md) 17 | 18 | ## 版本类型 19 | 20 | 星流具有三种版本类型,并且会在版本名字内标出。 21 | 它们分别为: `Milestone / 里程碑`,`Release Candidate / 预览` 和 `Release / 正式发布`。如果您不知道您应该选择哪种,请总是选择 `Release` 版。 22 | 另外,`Release` 版本没有 `-RC` `-M` 作为后缀,请注意这一点。 23 | 24 | > 在开发中,维护着以 -M1 ,-M2 等后缀发布里程碑版本,此类版本标志一系列功能的完成,并且里程碑版本内可能会引入新的 API 变更,并不稳定。 25 | > 在大版本即将发布前,Maintainer 会以 -RC 版本后缀发布最终的预览版本,表示新版本 API 已经确定,离稳定版发布只差最后的一些内部优化或 bug 修复。 26 | > 27 | > -- [版本演进策略 from SaltedFish Club](https://github.com/saltedfishclub/documents/blob/main/Evolution.md) 28 | 29 | ## 安装插件 30 | 31 | 像大多数的 Spigot 插件一样,只需要把星流和需要的拓展拖入插件目录即可。在重启服务器后,插件会自动加载。 32 | 33 | 加载成功后,插件将会在控制台输出构建信息和它的 logo ,以及在插件目录下生成对应的数据文件夹。 34 | 35 | 接下来:[配置插件](./user_guide/configuration.md) -------------------------------------------------------------------------------- /docs/user_guide/maintained_versions.md: -------------------------------------------------------------------------------- 1 | # 支持的版本 2 | 3 | | 星流版本 | Minecraft 版本 | 状态 | 4 | | - | - | - | 5 | | **0.1.X** | **1.18-1.19** | **支持** | 6 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # AstralFlow - The plugin enriches bukkit servers 4 | # Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | 22 | version=0.1.6-build+7 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kalculos/AstralFlow/ff652aba22f0111e99f3673f7632da5e5bfb036c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # AstralFlow - The plugin enriches bukkit servers 4 | # Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | distributionBase=GRADLE_USER_HOME 22 | distributionPath=wrapper/dists 23 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 24 | zipStoreBase=GRADLE_USER_HOME 25 | zipStorePath=wrapper/dists 26 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - Storage utilities for spigot servers. 4 | * Copyright (C) 2022 iceBear67 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | rootProject.name = 'AstralFlow' 23 | include 'test-plugin' 24 | 25 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/Tickable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow; 23 | 24 | import io.ib67.astralflow.scheduler.TickReceipt; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * Represents a tickable object. 29 | * 30 | * @param 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | public interface Tickable> { 34 | /** 35 | * Called at each tick. 36 | * 37 | * @param self 38 | */ 39 | void update(T self); 40 | 41 | @SuppressWarnings("unchecked") 42 | default void update() { 43 | update((T) this); 44 | } 45 | 46 | /** 47 | * Called when the tickable is added to the scheduler. 48 | * 49 | * @param receipt 50 | */ 51 | default void setup(TickReceipt receipt) { 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/events/MachineEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.events; 23 | 24 | import io.ib67.astralflow.machines.IMachine; 25 | import org.bukkit.event.Event; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | /** 29 | * Events that related to machines. 30 | */ 31 | @ApiStatus.AvailableSince("0.1.0") 32 | public abstract class MachineEvent extends Event { 33 | /** 34 | * Get the involved machine. 35 | * 36 | * @return machine 37 | */ 38 | public abstract IMachine getMachine(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/events/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Events from AstralFlow 24 | */ 25 | package io.ib67.astralflow.api.events; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/external/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Something about Extension 24 | */ 25 | package io.ib67.astralflow.api.external; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/BaseCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | /** 30 | * The base class for some item based on {@link ItemBase} 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | public class BaseCategory implements ItemCategory { 34 | public static final BaseCategory INSTANCE = new BaseCategory(); 35 | 36 | private BaseCategory() { 37 | 38 | } 39 | 40 | @Override 41 | public ItemPrototypeFactory getFactory(ItemBase item) { 42 | return ItemPrototype 43 | .builder() 44 | .holder(item) 45 | .id(item.getId()) 46 | .prototype(item.getPrototype()) 47 | .build(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/ItemBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import io.ib67.astralflow.item.LogicalHolder; 26 | import lombok.Getter; 27 | import org.bukkit.inventory.ItemStack; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | import static java.util.Objects.requireNonNull; 31 | 32 | /** 33 | * Subclass this to make your own item!
34 | * This class provides basic functionality for all items. 35 | */ 36 | @ApiStatus.AvailableSince("0.1.0") 37 | public abstract class ItemBase implements LogicalHolder { 38 | protected final ItemKey itemKey; 39 | @Getter 40 | protected final ItemStack prototype; 41 | 42 | protected ItemBase(ItemKey itemKey, ItemStack prototype) { 43 | this.itemKey = requireNonNull(itemKey); 44 | this.prototype = requireNonNull(prototype); 45 | } 46 | 47 | @Override 48 | public ItemKey getId() { 49 | return itemKey; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/armor/ArmorCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.armor; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | /** 30 | * Category for {@link ArmorItem}. {@link io.ib67.astralflow.item.builder.ItemBuilder#of(ItemCategory)} 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | public enum ArmorCategory implements ItemCategory { 34 | INSTANCE; 35 | 36 | @Override 37 | public ItemPrototypeFactory getFactory(ArmorItem item) { 38 | return ItemPrototype.builder() 39 | .prototype(item.getPrototype()) 40 | .id(item.getId()) 41 | .holder(item) 42 | .build(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/armor/ArmorProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.armor; 23 | 24 | import org.bukkit.event.entity.EntityDamageEvent; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | import java.util.Map; 28 | 29 | /** 30 | * Properties for armor. 31 | * 32 | * @param damageReduction The factor of damage reduction. 33 | */ 34 | @ApiStatus.AvailableSince("0.1.0") 35 | public record ArmorProperty( 36 | /** 37 | * The factors of damage reduction. 38 | */ 39 | Map damageReduction, 40 | /** 41 | * The common damage reduction. 42 | */ 43 | float commonReduction 44 | ) { 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/armor/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some preset for creating simple armor items 24 | */ 25 | package io.ib67.astralflow.api.item.armor; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/dummy/DummyCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.dummy; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | @ApiStatus.AvailableSince("0.1.0") 30 | public enum DummyCategory implements ItemCategory { 31 | INSTANCE; 32 | 33 | @Override 34 | public ItemPrototypeFactory getFactory(DummyItem item) { 35 | return ItemPrototype.builder() 36 | .id(item.key()) 37 | .prototype(item.item()) 38 | .holder(null) 39 | .build(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/dummy/DummyItemProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.dummy; 23 | 24 | import lombok.Builder; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Simple dummy item property. 31 | * 32 | * @param fetchMethods how can we get this item 33 | */ 34 | @ApiStatus.AvailableSince("0.1.0") 35 | public record DummyItemProperty( 36 | List fetchMethods 37 | ) { 38 | @Builder 39 | public DummyItemProperty { 40 | if (fetchMethods == null) { 41 | fetchMethods = List.of(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/dummy/FetchMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.dummy; 23 | 24 | import org.bukkit.inventory.ItemStack; 25 | 26 | import java.util.function.Supplier; 27 | 28 | /** 29 | * Way to fetch dummy items.
30 | * see {@link io.ib67.astralflow.api.item.dummy.fetch} 31 | */ 32 | public interface FetchMethod { 33 | void init(Supplier producer); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/dummy/fetch/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Way to fetch dummy items 24 | */ 25 | package io.ib67.astralflow.api.item.dummy.fetch; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/dummy/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some preset for creating dummy items 24 | */ 25 | package io.ib67.astralflow.api.item.dummy; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/machine/MachineCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.machine; 23 | 24 | import io.ib67.astralflow.api.item.machine.internal.SimpleMachineItemState; 25 | import io.ib67.astralflow.item.builder.ItemCategory; 26 | import io.ib67.astralflow.item.builder.ItemPrototype; 27 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | /** 31 | * The machine category. 32 | */ 33 | @ApiStatus.AvailableSince("0.1.0") 34 | public final class MachineCategory implements ItemCategory { 35 | public static final MachineCategory INSTANCE = new MachineCategory(); 36 | 37 | private MachineCategory() { 38 | 39 | } 40 | 41 | @Override 42 | public ItemPrototypeFactory getFactory(MachineItem item) { 43 | return ItemPrototype.builder() 44 | .id(item.getId()) 45 | .prototype(item.getPrototype()) 46 | .holder(item) 47 | .statePrototype(new SimpleMachineItemState(item.getTypeOfMachine().getName())) 48 | .build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/machine/internal/SimpleMachineItemState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.machine.internal; 23 | 24 | import io.ib67.astralflow.item.ItemState; 25 | import lombok.AllArgsConstructor; 26 | import lombok.Data; 27 | import lombok.EqualsAndHashCode; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | @ApiStatus.Internal 31 | @EqualsAndHashCode(callSuper = true) 32 | @AllArgsConstructor 33 | @Data 34 | public final class SimpleMachineItemState extends ItemState { 35 | private String machineType; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/machine/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some presets for machine block item 24 | */ 25 | package io.ib67.astralflow.api.item.machine; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Here are some presets for the Item API. You can use these components to create some common items (such as ingredients) quickly.
24 | *


25 | * A usual case is to create a new item with dummy first, then set states for them in the future (but you will have to do some migration like {@link io.ib67.astralflow.manager.ItemRegistry#saveState(org.bukkit.inventory.ItemStack, io.ib67.astralflow.item.StateScope, io.ib67.astralflow.item.ItemState)}) 26 | */ 27 | package io.ib67.astralflow.api.item; 28 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/weapon/MeleeItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.weapon; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import lombok.Builder; 26 | import org.bukkit.entity.Entity; 27 | import org.bukkit.event.entity.EntityDamageEvent; 28 | import org.bukkit.inventory.ItemStack; 29 | import org.jetbrains.annotations.ApiStatus; 30 | 31 | import java.util.Set; 32 | import java.util.function.Predicate; 33 | 34 | /** 35 | * For items like swords, axes, etc. 36 | */ 37 | @ApiStatus.AvailableSince("0.1.0") 38 | public class MeleeItem extends WeaponBase { 39 | @Builder 40 | protected MeleeItem(ItemKey id, ItemStack prototype, WeaponProperty property, Predicate entitySelector) { 41 | super(id, prototype, property, entitySelector, Set.of( 42 | EntityDamageEvent.DamageCause.ENTITY_ATTACK, 43 | EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK 44 | )); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/weapon/WeaponCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.weapon; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | /** 30 | * The weapon category. {@link io.ib67.astralflow.item.builder.ItemBuilder#of(ItemCategory)} 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | public final class WeaponCategory implements ItemCategory { 34 | public static final WeaponCategory INSTANCE = new WeaponCategory(); 35 | 36 | private WeaponCategory() { 37 | } 38 | 39 | @Override 40 | public ItemPrototypeFactory getFactory(WeaponBase item) { 41 | return ItemPrototype.builder() 42 | .holder(item) 43 | .id(item.getId()) 44 | .prototype(item.getPrototype()) 45 | .build(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/weapon/WeaponProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.api.item.weapon; 23 | 24 | import lombok.Builder; 25 | import lombok.Getter; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | /** 29 | * Properties that defines a weapon. Build it by its builder method {@link WeaponProperty#builder()}. 30 | */ 31 | @ApiStatus.AvailableSince("0.1.0") 32 | @Builder 33 | @Getter 34 | public final class WeaponProperty { 35 | /** 36 | * The direct damage 37 | */ 38 | private final double damage; 39 | /** 40 | * Possibility of critical hit (0~1) 41 | */ 42 | private final double criticalChance; 43 | /** 44 | * The critical damage multiplier 45 | */ 46 | private final double criticalMultiplexer; 47 | /** 48 | * Should we override the original damage? 49 | */ 50 | private final boolean clearOriginalDamage; 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/item/weapon/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some presets for creating simple weapons 24 | */ 25 | package io.ib67.astralflow.api.item.weapon; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/api/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * External APIs for extensions. 24 | */ 25 | package io.ib67.astralflow.api; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/ICapabilityService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.capability; 23 | 24 | import io.ib67.astralflow.capability.wireless.registry.IWirelessRegistry; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * An interface that provides capability services. 29 | */ 30 | @ApiStatus.AvailableSince("0.1.0") 31 | public interface ICapabilityService { 32 | IWirelessRegistry getWirelessRegistry(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/impl/SimpleCapabilityService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.capability.impl; 23 | 24 | import io.ib67.astralflow.capability.ICapabilityService; 25 | import io.ib67.astralflow.capability.wireless.registry.IWirelessRegistry; 26 | import lombok.Getter; 27 | import lombok.RequiredArgsConstructor; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | @RequiredArgsConstructor 31 | @Getter 32 | @ApiStatus.Internal 33 | public final class SimpleCapabilityService implements ICapabilityService { 34 | private final IWirelessRegistry wirelessRegistry; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * These things are related to machine capabilities, Flow and Wireless Discovery API for example. 24 | */ 25 | package io.ib67.astralflow.capability; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/wireless/message/StatelessMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.capability.wireless.message; 23 | 24 | import io.ib67.astralflow.capability.wireless.IWirelessPeer; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * This kind of wireless message doesn't care about {@link io.ib67.astralflow.capability.wireless.IWirelessPeer#negotiate(IWirelessPeer)} 29 | */ 30 | @ApiStatus.AvailableSince("0.1.0") 31 | public interface StatelessMessage { 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/wireless/message/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some universal messages between peers. 24 | */ 25 | package io.ib67.astralflow.capability.wireless.message; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/wireless/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Things about wireless discovery, etc. 24 | */ 25 | package io.ib67.astralflow.capability.wireless; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/capability/wireless/registry/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Things about {@link io.ib67.astralflow.capability.wireless.registry.IWirelessRegistry} 24 | */ 25 | package io.ib67.astralflow.capability.wireless.registry; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/extension/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Extension Registry 24 | */ 25 | package io.ib67.astralflow.extension; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/hook/event/HookEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.hook.event; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | /** 27 | * Events that are fired by the hook system. 28 | */ 29 | @ApiStatus.AvailableSince("0.1.0") 30 | public abstract class HookEvent { 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/hook/event/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Hook events. 24 | */ 25 | package io.ib67.astralflow.hook.event; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/hook/event/server/SaveDataEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.hook.event.server; 23 | 24 | import io.ib67.astralflow.hook.event.HookEvent; 25 | import lombok.Getter; 26 | import lombok.RequiredArgsConstructor; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | /** 30 | * This event is called when we're asking you to save your data. 31 | */ 32 | @RequiredArgsConstructor 33 | @Getter 34 | @ApiStatus.AvailableSince("0.1.0") 35 | public final class SaveDataEvent extends HookEvent { 36 | /** 37 | * If the server is shutting down. Do your finalization 38 | */ 39 | private final boolean isShuttingDown; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/hook/event/server/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Hooks that called when server state change, etc. 24 | */ 25 | package io.ib67.astralflow.hook.event.server; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/hook/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Things about hooks 24 | */ 25 | package io.ib67.astralflow.hook; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/AstralConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal; 23 | 24 | 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | import static io.ib67.kiwi.Kiwi.fromAny; 28 | 29 | @ApiStatus.Internal 30 | public final class AstralConstants { 31 | public static final boolean MOCKING = fromAny(() -> { 32 | try { 33 | Class.forName("io.ib67.astralflow.test.TestUtil"); 34 | return true; 35 | } catch (Throwable t) { 36 | return false; 37 | } 38 | }).orElseThrow(); 39 | public static final boolean DEBUG = Boolean.getBoolean("astralflow.debug"); 40 | public static final String[] LOGO = (" _ _ _ _____ _ \n" + 41 | " / \\ ___| |_ _ __ __ _| | ___| | _____ __\n" + 42 | " / _ \\ / __| __| '__/ _` | | |_ | |/ _ \\ \\ /\\ / /\n" + 43 | " / ___ \\\\__ \\ |_| | | (_| | | _| | | (_) \\ V V / \n" + 44 | "/_/ \\_\\___/\\__|_| \\__,_|_|_| |_|\\___/ \\_/\\_/ \n" + 45 | " \n").split("\n"); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/IChunkTracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal; 23 | 24 | import org.bukkit.Chunk; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | import java.util.Collection; 28 | 29 | /** 30 | * A ChunkTracker represents a class that records chunk load/unloading. 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | public interface IChunkTracker { 34 | boolean isChunkMarked(Chunk chunk); 35 | void markChunk(Chunk chunk); 36 | void unmarkChunk(Chunk chunk); 37 | Collection getMarkedChunks(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/Warnings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal; 23 | 24 | import io.ib67.internal.util.bukkit.Log; 25 | import lombok.experimental.UtilityClass; 26 | 27 | @UtilityClass 28 | public final class Warnings { 29 | public static void warnUnstableServerSoft() { 30 | Log.warn("Is this server just generated new maps or you are running some \"Optimized\" Server Software (e.g Mirai, Pufferfish)? They are known to cause issues and we can't help anymore."); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/config/ConfigManager.java: -------------------------------------------------------------------------------- 1 | package io.ib67.astralflow.internal.config; 2 | 3 | import lombok.SneakyThrows; 4 | import org.spongepowered.configurate.CommentedConfigurationNode; 5 | import org.spongepowered.configurate.ConfigurationOptions; 6 | import org.spongepowered.configurate.hocon.HoconConfigurationLoader; 7 | 8 | import java.nio.file.Path; 9 | import java.util.function.UnaryOperator; 10 | 11 | 12 | public final class ConfigManager { 13 | private CommentedConfigurationNode moduleConfigRoot; 14 | private HoconConfigurationLoader moduleConfigLoader; 15 | private Path confFile; 16 | 17 | @SneakyThrows 18 | public ConfigManager(Path confFile, UnaryOperator op) { 19 | this.confFile = confFile; 20 | this.moduleConfigLoader = HoconConfigurationLoader.builder() 21 | .path(confFile) 22 | .defaultOptions(op) 23 | .build(); 24 | moduleConfigRoot = moduleConfigLoader.load(); 25 | } 26 | 27 | @SneakyThrows 28 | public void save() { 29 | moduleConfigLoader.save(moduleConfigRoot); 30 | } 31 | 32 | @SneakyThrows 33 | public A getConfig(Class configClass) { 34 | return moduleConfigRoot.get(configClass); 35 | } 36 | 37 | @SneakyThrows 38 | public void reload() { 39 | this.moduleConfigLoader = HoconConfigurationLoader.builder() 40 | .path(confFile) 41 | .build(); 42 | moduleConfigRoot = moduleConfigLoader.load(); 43 | } 44 | 45 | @SneakyThrows 46 | public void saveConfig(T config) { 47 | moduleConfigRoot.set(config); 48 | save(); 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/config/ConfigMigrator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.config; 23 | 24 | import com.google.gson.JsonObject; 25 | import lombok.RequiredArgsConstructor; 26 | 27 | @RequiredArgsConstructor 28 | public final class ConfigMigrator { 29 | private final JsonObject targetedConfig; 30 | 31 | public AstralFlowConfiguration migrate(AstralFlowConfiguration currentConfig) { 32 | return currentConfig; // TODO but not now 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/config/Language.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.config; 23 | 24 | import lombok.Getter; 25 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 26 | 27 | @ConfigSerializable 28 | public final class Language { 29 | public final String serverIsInitializing = """ 30 | &c 服务器正在加载中,请稍候再试。 31 | &8&o 这通常不需要太长时间 ( < 3min ) 32 | """; 33 | public final String anyItemName = "&a?? 任何物品 ??"; 34 | @Getter 35 | private final String name = "zh_CN"; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/item/state/InternalItemState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.item.state; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import io.ib67.astralflow.item.ItemState; 26 | import lombok.Getter; 27 | import lombok.RequiredArgsConstructor; 28 | 29 | @RequiredArgsConstructor 30 | @Getter 31 | public final class InternalItemState extends ItemState implements Cloneable { 32 | private final ItemKey prototypeKey; 33 | 34 | @Override 35 | public ItemState clone() { 36 | return super.clone(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/listener/WorldListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.listener; 23 | 24 | import io.ib67.astralflow.AstralFlow; 25 | import io.ib67.astralflow.hook.HookType; 26 | import org.bukkit.event.EventHandler; 27 | import org.bukkit.event.Listener; 28 | import org.bukkit.event.world.ChunkLoadEvent; 29 | import org.bukkit.event.world.ChunkUnloadEvent; 30 | 31 | public final class WorldListener implements Listener { 32 | 33 | @EventHandler(ignoreCancelled = true) 34 | public void onChunkLoad(ChunkLoadEvent event) { 35 | AstralFlow.getInstance().callHooks(HookType.CHUNK_LOAD, event); 36 | } 37 | 38 | @EventHandler(ignoreCancelled = true) 39 | public void onChunkUnload(ChunkUnloadEvent event) { 40 | AstralFlow.getInstance().callHooks(HookType.CHUNK_UNLOAD, event); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Internal utilities for AstralFlow. 24 | * Use at your own risk. Undefined behaviours may occur. 25 | */ 26 | package io.ib67.astralflow.internal; 27 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/serialization/config/LanguageSerializer.java: -------------------------------------------------------------------------------- 1 | package io.ib67.astralflow.internal.serialization.config; 2 | 3 | import io.ib67.astralflow.internal.config.ConfigManager; 4 | import io.ib67.astralflow.internal.config.Language; 5 | import lombok.RequiredArgsConstructor; 6 | import org.checkerframework.checker.nullness.qual.Nullable; 7 | import org.spongepowered.configurate.ConfigurationNode; 8 | import org.spongepowered.configurate.ConfigurationOptions; 9 | import org.spongepowered.configurate.serialize.SerializationException; 10 | import org.spongepowered.configurate.serialize.TypeSerializer; 11 | 12 | import java.lang.reflect.Type; 13 | import java.nio.file.Path; 14 | 15 | @RequiredArgsConstructor 16 | public final class LanguageSerializer implements TypeSerializer { 17 | private final Path localeDir; 18 | 19 | @Override 20 | public Language deserialize(Type type, ConfigurationNode node) throws SerializationException { 21 | var name = node.getString(); 22 | if (name == null) { 23 | throw new SerializationException("Language name is null"); 24 | } 25 | return loadLanguage(name); 26 | } 27 | 28 | private Language loadLanguage(String name) { 29 | var cnf = new ConfigManager<>(localeDir.resolve(name + ".conf"), t -> t); 30 | return cnf.getConfig(Language.class); 31 | } 32 | 33 | @Override 34 | public void serialize(Type type, @Nullable Language obj, ConfigurationNode node) throws SerializationException { 35 | if (obj == null) { 36 | throw new SerializationException("Language is null"); 37 | } 38 | node.set(obj.getName()); 39 | } 40 | 41 | @Override 42 | public @Nullable Language emptyValue(Type specificType, ConfigurationOptions options) { 43 | return new Language(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/storage/IMachineStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.storage; 23 | 24 | import io.ib67.astralflow.machines.IMachine; 25 | import io.ib67.astralflow.manager.IMachineManager; 26 | import org.bukkit.Chunk; 27 | import org.bukkit.Location; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | import java.util.Collection; 31 | import java.util.UUID; 32 | 33 | @ApiStatus.AvailableSince("0.1.0") 34 | public interface IMachineStorage extends KeyedStorage { 35 | void init(IMachineManager manager); 36 | 37 | Location getLocationByUUID(UUID uuid); 38 | 39 | UUID getUUIDByLocation(Location location); 40 | 41 | Collection getMachinesByChunk(Chunk chunk); 42 | 43 | void initChunk(Chunk chunk); 44 | 45 | void finalizeChunk(Chunk chunk, boolean isUnloading); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/storage/KeyedStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.storage; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | import java.util.Collection; 27 | 28 | @ApiStatus.AvailableSince("0.1.0") 29 | public interface KeyedStorage { 30 | boolean has(K uuid); 31 | 32 | V get(K uuid); 33 | 34 | Collection getKeys(); 35 | 36 | void save(K uuid, V state); // flush cache 37 | 38 | void remove(K uuid); 39 | 40 | void flush(); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/storage/MachineSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.storage; 23 | 24 | import io.ib67.astralflow.machines.IMachine; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | @ApiStatus.AvailableSince("0.1.0") 28 | public interface MachineSerializer { 29 | IMachine fromData(byte[] t); 30 | 31 | byte[] toData(IMachine machine); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/storage/impl/chunk/MachineData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.storage.impl.chunk; 23 | 24 | import io.ib67.astralflow.internal.storage.impl.MachineStorageType; 25 | import io.ib67.kiwi.tuple.Pair; 26 | import lombok.Getter; 27 | import lombok.RequiredArgsConstructor; 28 | import org.bukkit.Location; 29 | import org.jetbrains.annotations.ApiStatus; 30 | 31 | import java.util.HashMap; 32 | import java.util.Map; 33 | 34 | @ApiStatus.Internal 35 | @RequiredArgsConstructor 36 | @Getter 37 | public final class MachineData { 38 | private final Map> machineData = new HashMap<>(); 39 | private final int chunkX; 40 | private final int chunkZ; 41 | 42 | public void save(Location loc, MachineStorageType type, byte[] data) { 43 | machineData.put(loc, new Pair<>(type, data)); 44 | } 45 | 46 | public Pair getData(Location loc) { 47 | return machineData.get(loc); 48 | } 49 | 50 | public void remove(Location loc) { 51 | machineData.remove(loc); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/internal/task/SaveDataTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.internal.task; 23 | 24 | import io.ib67.astralflow.AstralFlow; 25 | import io.ib67.astralflow.hook.HookType; 26 | import io.ib67.astralflow.hook.event.server.SaveDataEvent; 27 | import org.bukkit.scheduler.BukkitRunnable; 28 | 29 | public final class SaveDataTask extends BukkitRunnable { 30 | @Override 31 | public void run() { 32 | AstralFlow.getInstance().callHooks(HookType.SAVE_DATA, new SaveDataEvent(false)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/ItemState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import io.ib67.astralflow.machines.IState; 25 | import lombok.experimental.Delegate; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | import java.util.HashMap; 29 | import java.util.Map; 30 | 31 | /** 32 | * State of items. Used for persistence.
33 | * Just subclass this and add your properties, we'll serialize them for you. 34 | */ 35 | @ApiStatus.AvailableSince("0.1.0") 36 | public abstract class ItemState implements IState, Cloneable { 37 | 38 | @Override 39 | public ItemState clone() { 40 | try { 41 | return (ItemState) super.clone(); 42 | } catch (CloneNotSupportedException e) { 43 | throw new AssertionError(); 44 | } 45 | } 46 | 47 | public static class SimpleItemState extends ItemState implements Map { 48 | @Delegate 49 | private final Map theRealData = new HashMap<>(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/LogicalHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | /** 27 | * The class who is holding the item for a {@link ItemKey} 28 | */ 29 | @ApiStatus.AvailableSince("0.1.0") 30 | public interface LogicalHolder { 31 | ItemKey getId(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/StateScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import io.ib67.astralflow.AstralFlow; 25 | import lombok.Getter; 26 | import lombok.RequiredArgsConstructor; 27 | import org.bukkit.NamespacedKey; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | @RequiredArgsConstructor 31 | @Getter 32 | @ApiStatus.Internal 33 | public enum StateScope { 34 | INTERNAL_ITEM(new NamespacedKey(AstralFlow.getInstance().asPlugin(), "internal.item.state")), 35 | USER_ITEM(new NamespacedKey(AstralFlow.getInstance().asPlugin(), "user.item.state")), 36 | SERVICE(new NamespacedKey(AstralFlow.getInstance().asPlugin(), "internal.service.state")), 37 | USER_MACHINE(new NamespacedKey(AstralFlow.getInstance().asPlugin(), "user.machine.state")), 38 | INTERNAL_MACHINE(new NamespacedKey(AstralFlow.getInstance().asPlugin(), "internal.machine.state")); 39 | private final NamespacedKey tagKey; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/builder/ItemCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.builder; 23 | 24 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * A category of items.
29 | * This class defines how {@link ItemPrototypeFactory}s are created from your custom item types.
30 | * See {@link io.ib67.astralflow.api.item.weapon.WeaponCategory} for an example. 31 | * 32 | * @param The type of item this category is for. 33 | */ 34 | @ApiStatus.AvailableSince("0.1.0") 35 | public interface ItemCategory { 36 | 37 | /** 38 | * Produces an {@link ItemPrototypeFactory} for the given item, which will be registered into {@link io.ib67.astralflow.manager.ItemRegistry} 39 | */ 40 | ItemPrototypeFactory getFactory(I item); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/builder/ItemPrototype.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.builder; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import io.ib67.astralflow.item.ItemState; 26 | import io.ib67.astralflow.item.LogicalHolder; 27 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 28 | import lombok.Builder; 29 | import lombok.Getter; 30 | import org.bukkit.inventory.ItemStack; 31 | import org.jetbrains.annotations.ApiStatus; 32 | 33 | /** 34 | * Utility class that builds an {@link ItemPrototypeFactory} without having to subclass. 35 | */ 36 | @ApiStatus.AvailableSince("0.1.0") 37 | @Getter 38 | @Builder 39 | public final class ItemPrototype implements ItemPrototypeFactory { 40 | private final ItemStack prototype; 41 | private final ItemState statePrototype; 42 | private final ItemKey id; 43 | private final LogicalHolder holder; 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/builder/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * High-Level Item Creation API 24 | */ 25 | package io.ib67.astralflow.item.builder; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/factory/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Low level API for item creation 24 | */ 25 | package io.ib67.astralflow.item.factory; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/internal/NullItemState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.internal; 23 | 24 | import io.ib67.astralflow.item.ItemState; 25 | 26 | public final class NullItemState extends ItemState { 27 | public static final NullItemState NULL_ITEM_STATE = new NullItemState(); 28 | 29 | private NullItemState() { 30 | } 31 | 32 | @Override 33 | public ItemState clone() { 34 | return NULL_ITEM_STATE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/internal/serialization/ItemSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.internal.serialization; 23 | 24 | import io.ib67.astralflow.item.ItemState; 25 | 26 | public interface ItemSerializer { 27 | ItemState deserialize(byte[] bytes); 28 | 29 | byte[] serialize(ItemState state); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/internal/serialization/ItemStorageType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.internal.serialization; 23 | 24 | import io.ib67.astralflow.manager.IFactoryManager; 25 | import lombok.Getter; 26 | import lombok.RequiredArgsConstructor; 27 | 28 | import java.util.function.Function; 29 | 30 | @Getter 31 | @RequiredArgsConstructor 32 | public enum ItemStorageType implements Function { 33 | JSON(0, JsonItemSerializer::new); 34 | 35 | private final int typeIndex; 36 | private final Function factory; 37 | 38 | public static ItemStorageType getType(int index) { 39 | return switch (index) { 40 | case 0 -> JSON; 41 | default -> throw new IllegalArgumentException("Invalid type index"); 42 | }; 43 | } 44 | 45 | @Override 46 | public ItemSerializer apply(IFactoryManager factory) { 47 | return this.factory.apply(factory); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/oredict/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Ore Dictionaries 24 | */ 25 | package io.ib67.astralflow.item.oredict; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Things about custom items 24 | */ 25 | package io.ib67.astralflow.item; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/recipe/IRecipeRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.recipe; 23 | 24 | import org.bukkit.NamespacedKey; 25 | import org.bukkit.inventory.ItemStack; 26 | import org.jetbrains.annotations.ApiStatus; 27 | import org.jetbrains.annotations.Contract; 28 | 29 | import java.util.List; 30 | 31 | /** 32 | * This class could registry a recipe. 33 | */ 34 | @ApiStatus.AvailableSince("0.1.0") 35 | public interface IRecipeRegistry { 36 | @Contract(pure = true, value = "_->this") 37 | IRecipeRegistry registerRecipe(AstralRecipe recipe); 38 | 39 | @Contract(pure = true, value = "_->this") 40 | IRecipeRegistry unregisterRecipe(AstralRecipe recipe); 41 | 42 | AstralRecipe getRecipeByKey(NamespacedKey key); 43 | 44 | @Contract(value = " -> new") 45 | List getRecipes(); 46 | 47 | AstralRecipe matchRecipe(ItemMatrix matrix); 48 | 49 | @SuppressWarnings("all") 50 | default AstralRecipe matchRecipe(ItemStack... recipe) { 51 | return matchRecipe(ItemMatrix.createRawMatrix(RecipeType.CRAFTING, recipe)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/recipe/RecipeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.recipe; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | /** 27 | * Kinds of recipes. 28 | */ 29 | @ApiStatus.AvailableSince("0.1.0") 30 | public enum RecipeType { 31 | /** 32 | * This kind of recipe is mainly for CraftingTable and player's inventories.
33 | * Matrix: 3x3 34 | */ 35 | CRAFTING, 36 | /** 37 | * This kind of recipe is mainly for furnace. 38 | */ 39 | SMELTING, 40 | /** 41 | * This kind of recipe is mainly for brewing stand. 42 | */ 43 | BREWING 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/recipe/choices/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some ingredient choices. 24 | */ 25 | package io.ib67.astralflow.item.recipe.choices; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/recipe/kind/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Kinds of recipes 24 | */ 25 | package io.ib67.astralflow.item.recipe.kind; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/item/recipe/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Things about custom recipes 24 | */ 25 | package io.ib67.astralflow.item.recipe; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/AutoFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines; 23 | 24 | import io.ib67.astralflow.machines.factories.IMachineFactory; 25 | import io.ib67.astralflow.machines.factories.internal.SimpleMachineFactory; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | import java.lang.annotation.*; 29 | 30 | /** 31 | * Marks a machine, and auto-registers factory with the value, specified factory must have an empty constructor.
32 | * This may help for many simple machines. 33 | */ 34 | @ApiStatus.AvailableSince("0.1.0") 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target(ElementType.TYPE) 37 | @Documented 38 | public @interface AutoFactory { 39 | /** 40 | * The factory class to be instantiated. Left it default to use the smart one (which finds constructor for machine classes.). 41 | * 42 | * @return 43 | */ 44 | Class value() default SimpleMachineFactory.class; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/IMachine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines; 23 | 24 | import io.ib67.astralflow.Tickable; 25 | import org.bukkit.Location; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | import java.util.UUID; 29 | 30 | /** 31 | * Basic definition of a machine. We don't subclass this as usual, see {@link AbstractMachine} 32 | */ 33 | @ApiStatus.AvailableSince("0.1.0") 34 | public interface IMachine extends Tickable, LifeCycle { 35 | 36 | MachineProperty getProperty(); 37 | 38 | default UUID getId() { 39 | return getProperty().getUuid(); 40 | } 41 | 42 | default Location getLocation() { 43 | return getProperty().getLocation(); 44 | } 45 | 46 | default IState getState() { 47 | return getProperty().getState(); 48 | } 49 | 50 | default void update() { 51 | this.update(this); 52 | } 53 | 54 | default Class getType() { 55 | return this.getClass(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/IState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | /** 27 | * Data of machine, you can use it for persistence.
28 | * Just subclass this and add your properties, we'll load/save/serialize them for you transparently. 29 | */ 30 | @ApiStatus.AvailableSince("0.1.0") 31 | public interface IState { 32 | @SuppressWarnings("unused") 33 | IState EMPTY = new EmptyState(); 34 | default Class getType() { 35 | return this.getClass(); 36 | } 37 | 38 | class EmptyState implements IState { 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/LifeCycle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | /** 27 | * Represents a lifecycle-able object. 28 | */ 29 | @ApiStatus.AvailableSince("0.1.0") 30 | public interface LifeCycle { 31 | /** 32 | * Calls when the chunk is loaded and your machine is ready to initialize. 33 | * You can get {@link io.ib67.astralflow.scheduler.TickReceipt} by calling {@link io.ib67.astralflow.manager.IMachineManager#getReceiptByMachine(IMachine)}. 34 | */ 35 | default void onLoad() { 36 | } 37 | 38 | /** 39 | * Called when chunk is unloading or machine is deactivated. Save your data into state here. 40 | */ 41 | default void onUnload() { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/Tickless.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | import java.lang.annotation.*; 27 | 28 | /** 29 | * An annotation that represents tick-less machines.
30 | *

31 | * Machines with this annotation will not be ticked. 32 | */ 33 | @ApiStatus.AvailableSince("0.1.0") 34 | @Target(ElementType.TYPE) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Documented 37 | public @interface Tickless { 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Exceptions that related to some machines. 24 | */ 25 | package io.ib67.astralflow.machines.exception; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/factories/IMachineFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines.factories; 23 | 24 | import io.ib67.astralflow.machines.IMachine; 25 | import io.ib67.astralflow.machines.MachineProperty; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | /** 29 | * A factory that creates machine by a given {@link MachineProperty}. 30 | * 31 | * @param The type of the machine. 32 | */ 33 | @ApiStatus.AvailableSince("0.1.0") 34 | @FunctionalInterface 35 | public interface IMachineFactory { 36 | 37 | T createMachine(MachineProperty property); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/factories/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * About machine creation. Users can customize their machine initialization by registering a {@link io.ib67.astralflow.machines.factories.IMachineFactory} 24 | * Also see: {@link io.ib67.astralflow.api.AstralFlowAPI#getFactories()} 25 | */ 26 | package io.ib67.astralflow.machines.factories; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Things about machines. 24 | */ 25 | package io.ib67.astralflow.machines; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/trait/Interactive.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines.trait; 23 | 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.event.block.Action; 26 | import org.bukkit.inventory.ItemStack; 27 | import org.jetbrains.annotations.ApiStatus; 28 | import org.jetbrains.annotations.Nullable; 29 | 30 | /** 31 | * Represents an interactive trait for machines. 32 | */ 33 | @ApiStatus.AvailableSince("0.1.0") 34 | public interface Interactive { 35 | /** 36 | * Called when a player tries to interact with the machine. (clicking) 37 | * 38 | * @param clickType The type of interaction. 39 | * @param player The player that interacted. 40 | * @param itemInHand The item in the player's hand. 41 | */ 42 | void onInteract(Action clickType, Player player, @Nullable ItemStack itemInHand); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/trait/Pushable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines.trait; 23 | 24 | import org.bukkit.Location; 25 | import org.bukkit.util.Vector; 26 | import org.jetbrains.annotations.ApiStatus; 27 | 28 | 29 | /** 30 | * Represents a trait that can be moved. 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | @ApiStatus.Experimental 34 | public interface Pushable { 35 | void push(Location newLocation, Vector direction); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/machines/trait/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Machine Features. 24 | */ 25 | package io.ib67.astralflow.machines.trait; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/manager/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Managers for some basic components. 24 | */ 25 | package io.ib67.astralflow.manager; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * The root package.
24 | * Before diving into AstralFlow, You should mention that there're many `Simple` or `XXImpl` classes.
25 | * Generally, these classes are for internal use only and you're not supposed to use them due to not clearly defined behaviours.
26 | * Always use these abstract classes (or interfaces), have fun!
27 | */ 28 | package io.ib67.astralflow; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/scheduler/AwaitingTickable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.scheduler; 23 | 24 | import io.ib67.astralflow.Tickable; 25 | import lombok.RequiredArgsConstructor; 26 | import lombok.SneakyThrows; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | import java.util.concurrent.atomic.AtomicInteger; 30 | 31 | @ApiStatus.Internal 32 | @RequiredArgsConstructor 33 | public final class AwaitingTickable> { 34 | public final Tickable tickable; 35 | public final TickReceipt receipt; 36 | public final AtomicInteger exceptionCounter = new AtomicInteger(); // for SimpleCatchingScheduler. 37 | 38 | @SuppressWarnings("all") 39 | public void tick() throws Throwable { 40 | if (receipt.tick(tickable)) { 41 | tickable.update(); 42 | } 43 | } 44 | 45 | @Deprecated 46 | @SneakyThrows 47 | public boolean tickAlsoClean() { 48 | if (receipt.isDropped()) { 49 | return true; 50 | } 51 | tick(); 52 | return false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/scheduler/Scheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.scheduler; 23 | 24 | import io.ib67.astralflow.Tickable; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * Task Scheduler.
29 | * Calls every element for every tick.
30 | * Also see {@link Tickable} 31 | */ 32 | @ApiStatus.AvailableSince("0.1.0") 33 | public interface Scheduler { 34 | 35 | /** 36 | * tick all things if their receipt allows. 37 | */ 38 | @ApiStatus.Internal 39 | void tick(); 40 | 41 | /** 42 | * Add a ticking target, throws {@link IllegalArgumentException} when you're attempting to add an object which already exists. 43 | * Always invoke tick( itself ) 44 | * 45 | * @param tickable target. 46 | * @param tickType 47 | * @return Receipt. also see {@link TickReceipt} 48 | */ 49 | > TickReceipt add(Tickable tickable); 50 | 51 | /** 52 | * Remove from ticklist. 53 | * 54 | * @param tickable tickable object. 55 | */ 56 | void remove(Tickable tickable); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/scheduler/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Exceptions may throw in tick loop 24 | */ 25 | package io.ib67.astralflow.scheduler.exception; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/scheduler/internal/SchedulerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.scheduler.internal; 23 | 24 | import io.ib67.astralflow.scheduler.Scheduler; 25 | import lombok.Getter; 26 | import lombok.RequiredArgsConstructor; 27 | import org.bukkit.scheduler.BukkitRunnable; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | @RequiredArgsConstructor 31 | @Getter 32 | @ApiStatus.Internal 33 | public final class SchedulerAdapter extends BukkitRunnable { 34 | private final Scheduler delegatedScheduler; 35 | 36 | @Override 37 | public void run() { 38 | delegatedScheduler.tick(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/scheduler/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * The scheduler and TickReceipt 24 | */ 25 | package io.ib67.astralflow.scheduler; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/scheduler/strategies/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Some built-in presets for {@link io.ib67.astralflow.scheduler.TickReceipt#requires(java.util.function.Predicate)} 24 | */ 25 | package io.ib67.astralflow.scheduler.strategies; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/security/ISecurityService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.security; 23 | 24 | import io.ib67.astralflow.security.mem.ILeakTracker; 25 | import org.jetbrains.annotations.ApiStatus; 26 | 27 | /** 28 | * A security service holds things related to security, from gaming one to jvm one. 29 | */ 30 | @ApiStatus.AvailableSince("0.1.0") 31 | public interface ISecurityService { 32 | /** 33 | * Get a tracker for mem leak detection. 34 | * 35 | * @return tracker. 36 | */ 37 | ILeakTracker getLeakTracker(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/security/impl/SimpleSecurityService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.security.impl; 23 | 24 | import io.ib67.astralflow.security.ISecurityService; 25 | import io.ib67.astralflow.security.mem.ILeakTracker; 26 | import lombok.Getter; 27 | import lombok.RequiredArgsConstructor; 28 | import org.jetbrains.annotations.ApiStatus; 29 | 30 | @ApiStatus.Internal 31 | @RequiredArgsConstructor 32 | public final class SimpleSecurityService implements ISecurityService { 33 | @Getter 34 | private final ILeakTracker leakTracker; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/security/mem/ILeakTracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.security.mem; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | /** 27 | * A class that tracks object live time and detects memory leaks. 28 | */ 29 | @ApiStatus.AvailableSince("0.1.0") 30 | public interface ILeakTracker { 31 | /** 32 | * Add an object into the track list. Tracker will alert if the object kept in memory for many rounds. 33 | * 34 | * @param obj 35 | */ 36 | void track(Object obj); 37 | 38 | /** 39 | * Contrary to {@link #track(Object)} 40 | * 41 | * @param obj 42 | */ 43 | void untrack(Object obj); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/security/mem/impl/TrackedObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.security.mem.impl; 23 | 24 | import lombok.AllArgsConstructor; 25 | 26 | import java.lang.ref.WeakReference; 27 | 28 | @AllArgsConstructor 29 | final class TrackedObject { 30 | public WeakReference ref; 31 | public int counter; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/security/mem/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Safety about memory leak 24 | */ 25 | package io.ib67.astralflow.security.mem; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/security/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * These things are related to security management. 24 | */ 25 | package io.ib67.astralflow.security; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/texture/ITextureExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.texture; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | import java.nio.file.Path; 27 | 28 | @ApiStatus.AvailableSince("0.1.0") 29 | public interface ITextureExporter { 30 | void export(Path pathToResult); 31 | 32 | void updateHost(Path resourcePack); 33 | 34 | void flushAndUpdate(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/texture/ITextureRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.texture; 23 | 24 | import org.jetbrains.annotations.ApiStatus; 25 | 26 | import java.util.Optional; 27 | 28 | @ApiStatus.AvailableSince("0.1.0") 29 | public interface ITextureRegistry { 30 | void registerTexture(Texture texture); 31 | 32 | Optional getTexture(String namespace, String id); 33 | 34 | int fetchModelId(Texture texture); 35 | 36 | default Optional getTexture(String namespaceAndID) { 37 | var a = namespaceAndID.split(":"); 38 | if (a.length != 2) { 39 | throw new IllegalArgumentException("Invalid texture namespace and id: " + namespaceAndID); 40 | } 41 | return getTexture(a[0], a[1]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/texture/TextureType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.texture; 23 | 24 | public enum TextureType { 25 | BLOCK, ENTITY, ITEM 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/texture/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Texture related things. (WIP) 24 | */ 25 | package io.ib67.astralflow.texture; -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/texture/util/TextureHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.texture.util; 23 | 24 | public class TextureHelper { 25 | //todo provide some convenience methods of loading resources from classpath etc. 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/util/Blocks.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.util; 23 | 24 | import lombok.experimental.UtilityClass; 25 | import org.bukkit.Material; 26 | 27 | import static java.util.Objects.requireNonNull; 28 | 29 | /** 30 | * Some utility classes that are used for {@link org.bukkit.block.Block}s 31 | */ 32 | @UtilityClass 33 | public class Blocks { 34 | /** 35 | * Check if a block is physical, meaning it can move itself(like gravity) or being broken by state changes (like TNT) 36 | * 37 | * @return 38 | */ 39 | public static boolean isNonPhysical(Material material) { 40 | requireNonNull(material); 41 | if (material.isAir() || !material.isBlock() || !material.isSolid()) { 42 | return false; 43 | } 44 | return switch (material) { 45 | case SAND, GRAVEL: 46 | case ACACIA_LEAVES, BIRCH_LEAVES, DARK_OAK_LEAVES, JUNGLE_LEAVES, OAK_LEAVES, SPRUCE_LEAVES, AZALEA_LEAVES, FLOWERING_AZALEA_LEAVES: 47 | case AZALEA: 48 | case TNT: 49 | yield false; 50 | default: 51 | yield true; 52 | }; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/astralflow/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | /** 23 | * Utilities for developers, which easier your life {@literal <3} 24 | */ 25 | package io.ib67.astralflow.util; -------------------------------------------------------------------------------- /src/main/java/io/ib67/internal/util/bukkit/BukkitGson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.internal.util.bukkit; 23 | 24 | import com.google.gson.Gson; 25 | import com.google.gson.GsonBuilder; 26 | import io.ib67.internal.util.bukkit.serializer.ItemStackSerializer; 27 | import io.ib67.internal.util.bukkit.serializer.LocationSerializer; 28 | import org.bukkit.Location; 29 | import org.bukkit.inventory.ItemStack; 30 | 31 | public class BukkitGson { 32 | public static final GsonBuilder BUILDER = new GsonBuilder() 33 | .registerTypeAdapter(ItemStack.class, new ItemStackSerializer()) 34 | .registerTypeAdapter(Location.class, new LocationSerializer()); 35 | public static final Gson INSTANCE = BUILDER.create(); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/ib67/internal/util/bukkit/serializer/ItemStackSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.internal.util.bukkit.serializer; 23 | 24 | import com.google.gson.*; 25 | import io.leangen.geantyref.TypeToken; 26 | import lombok.SneakyThrows; 27 | import org.bukkit.inventory.ItemStack; 28 | 29 | import java.lang.reflect.Type; 30 | import java.util.Map; 31 | 32 | public class ItemStackSerializer implements JsonSerializer, JsonDeserializer { 33 | 34 | @SneakyThrows 35 | @Override 36 | public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) { 37 | return context.serialize(src.serialize()); 38 | } 39 | 40 | @SneakyThrows 41 | @Override 42 | public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { 43 | return ItemStack.deserialize(context.deserialize(json, new TypeToken>() { 44 | }.getType())); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/buildInfo: -------------------------------------------------------------------------------- 1 | Plugin version ${version}, ref-${commitHash} built by ${buildBy} at ${buildTime} -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: AstralFlow 2 | version: '${version}' 3 | main: io.ib67.astralflow.AstralFlow 4 | api-version: 1.18 5 | libraries: 6 | - "org.spongepowered:configurate-hocon:4.0.0" -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/hook/HookTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.hook; 23 | 24 | import io.ib67.astralflow.AstralFlow; 25 | import io.ib67.astralflow.test.TestUtil; 26 | import org.junit.jupiter.api.Assertions; 27 | import org.junit.jupiter.api.BeforeAll; 28 | import org.junit.jupiter.api.Test; 29 | import org.junit.jupiter.api.TestInstance; 30 | 31 | import java.util.concurrent.ThreadLocalRandom; 32 | import java.util.concurrent.atomic.AtomicBoolean; 33 | 34 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 35 | public class HookTypeTest { 36 | private final int value = ThreadLocalRandom.current().nextInt(); 37 | 38 | @BeforeAll 39 | public void setup() { 40 | TestUtil.init(); 41 | } 42 | 43 | @Test 44 | public void testHookDelivery() { 45 | var hook = new HookType("testHookDelivery"); 46 | AtomicBoolean equals = new AtomicBoolean(false); 47 | hook.register(t -> equals.set(t.value == value)); 48 | AstralFlow.getInstance().callHooks(hook, this); 49 | Assertions.assertTrue(equals.get()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/OreDictTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import io.ib67.astralflow.item.oredict.internal.VanillaOreDict; 25 | import io.ib67.astralflow.test.TestUtil; 26 | import org.bukkit.Material; 27 | import org.bukkit.inventory.ItemStack; 28 | import org.junit.jupiter.api.Assertions; 29 | import org.junit.jupiter.api.BeforeAll; 30 | import org.junit.jupiter.api.Test; 31 | import org.junit.jupiter.api.TestInstance; 32 | 33 | import static org.junit.jupiter.api.Assertions.assertTrue; 34 | 35 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 36 | public final class OreDictTest { 37 | @BeforeAll 38 | public void setup() { 39 | TestUtil.init(); 40 | } 41 | 42 | @Test 43 | public void onTestVanillaOreDict() { 44 | var oreDict = new VanillaOreDict(); 45 | Assertions.assertThrows(UnsupportedOperationException.class, () -> oreDict.registerItem(null, null, null)); 46 | assertTrue(oreDict.matchItem("wool", new ItemStack(Material.WHITE_WOOL))); 47 | assertTrue(oreDict.matchItem("ingot", new ItemStack(Material.DIAMOND))); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/definitions/DummyStatefulItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.definitions; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import io.ib67.astralflow.item.ItemState; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import org.bukkit.Material; 28 | import org.bukkit.inventory.ItemStack; 29 | import org.jetbrains.annotations.NotNull; 30 | import org.jetbrains.annotations.Nullable; 31 | 32 | public final class DummyStatefulItem implements ItemPrototypeFactory { 33 | private final ItemStack item = new ItemStack(Material.EMERALD); 34 | 35 | @Override 36 | public @NotNull 37 | ItemStack getPrototype() { 38 | return item; 39 | } 40 | 41 | @Override 42 | public @Nullable 43 | ItemState getStatePrototype() { 44 | return new ItemState.SimpleItemState(); 45 | } 46 | 47 | @Override 48 | public ItemKey getId() { 49 | return ItemKey.from("astralflow", "test_dummy_stateful_item"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/definitions/DummyStatelessItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.definitions; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import io.ib67.astralflow.item.ItemState; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import org.bukkit.Material; 28 | import org.bukkit.inventory.ItemStack; 29 | import org.jetbrains.annotations.NotNull; 30 | import org.jetbrains.annotations.Nullable; 31 | 32 | public final class DummyStatelessItem implements ItemPrototypeFactory { 33 | private final ItemStack item = new ItemStack(Material.DIAMOND_SWORD); 34 | 35 | @Override 36 | public @NotNull ItemStack getPrototype() { 37 | return item; 38 | } 39 | 40 | @Override 41 | public @Nullable ItemState getStatePrototype() { 42 | return null; 43 | } 44 | 45 | @Override 46 | public ItemKey getId() { 47 | return ItemKey.from("test", "dummy_stateless_item"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/itembuilder/Weapon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.itembuilder; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import io.ib67.astralflow.item.itembuilder.weapon.WeaponItems; 28 | 29 | public enum Weapon implements ItemCategory { 30 | INSTANCE; 31 | 32 | @Override 33 | public ItemPrototypeFactory getFactory(WeaponItems item) { 34 | return ItemPrototype.builder() 35 | .id(item.getId()) 36 | .prototype(item.getPrototype()) 37 | .statePrototype(null) 38 | .holder(item) 39 | .build(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/itembuilder/weapon/Melee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.itembuilder.weapon; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import org.bukkit.inventory.ItemStack; 26 | 27 | public abstract non-sealed class Melee extends WeaponItems { 28 | private final float damage; 29 | 30 | public Melee(ItemKey id, ItemStack prototype, float damage) { 31 | super(id, prototype); 32 | this.damage = damage; 33 | } 34 | 35 | public void onAttack(String usingPlayer, String victim) { 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/itembuilder/weapon/WeaponItems.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.itembuilder.weapon; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | import io.ib67.astralflow.item.LogicalHolder; 26 | import lombok.Getter; 27 | import lombok.RequiredArgsConstructor; 28 | import org.bukkit.inventory.ItemStack; 29 | 30 | @RequiredArgsConstructor 31 | @Getter 32 | public abstract sealed class WeaponItems implements LogicalHolder permits Melee { 33 | private final ItemKey id; 34 | private final ItemStack prototype; 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/item/machine/SimpleStatelessMachine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item.machine; 23 | 24 | import io.ib67.astralflow.machines.AbstractMachine; 25 | import io.ib67.astralflow.machines.AutoFactory; 26 | import io.ib67.astralflow.machines.IMachine; 27 | import io.ib67.astralflow.machines.MachineProperty; 28 | 29 | @AutoFactory 30 | public class SimpleStatelessMachine extends AbstractMachine { 31 | protected SimpleStatelessMachine(MachineProperty property) { 32 | super(property); 33 | } 34 | 35 | @Override 36 | public void update(IMachine self) { 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/storage/DummyStatefulMachine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.storage; 23 | 24 | import io.ib67.astralflow.machines.AbstractMachine; 25 | import io.ib67.astralflow.machines.IMachine; 26 | import io.ib67.astralflow.machines.MachineProperty; 27 | import io.ib67.astralflow.machines.trait.Pushable; 28 | import org.bukkit.Location; 29 | import org.bukkit.util.Vector; 30 | 31 | public class DummyStatefulMachine extends AbstractMachine implements Pushable { 32 | 33 | public DummyStatefulMachine(MachineProperty property) { 34 | super(property); 35 | var state = new SimpleMachineState(); 36 | state.put("nullcat?", "sexy!"); 37 | this.setState(state); 38 | } 39 | 40 | @Override 41 | @SuppressWarnings("unchecked") 42 | public SimpleMachineState getState() { 43 | return (SimpleMachineState) super.getState(); 44 | } 45 | 46 | @Override 47 | public void update(IMachine self) { 48 | 49 | } 50 | 51 | @Override 52 | public void push(Location newLocation, Vector direction) { 53 | super.setLocation(newLocation); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/storage/MockItemStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.storage; 23 | 24 | import io.ib67.astralflow.internal.storage.KeyedStorage; 25 | import io.ib67.astralflow.item.ItemState; 26 | 27 | import java.util.Collection; 28 | import java.util.HashMap; 29 | import java.util.Map; 30 | import java.util.UUID; 31 | 32 | public final class MockItemStorage implements KeyedStorage { 33 | private final Map states = new HashMap<>(); 34 | 35 | @Override 36 | public boolean has(UUID uuid) { 37 | return states.containsKey(uuid); 38 | } 39 | 40 | @Override 41 | public ItemState get(UUID uuid) { 42 | return states.get(uuid); 43 | } 44 | 45 | @Override 46 | public Collection getKeys() { 47 | return states.keySet(); 48 | } 49 | 50 | @Override 51 | public void save(UUID uuid, ItemState state) { 52 | states.put(uuid, state); 53 | } 54 | 55 | @Override 56 | public void remove(UUID uuid) { 57 | states.remove(uuid); 58 | } 59 | 60 | @Override 61 | public void flush() { 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/io/ib67/astralflow/test/TestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.test; 23 | 24 | import be.seeseemelk.mockbukkit.MockBukkit; 25 | import io.ib67.astralflow.AstralFlow; 26 | import io.ib67.astralflow.internal.AstralConstants; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertTrue; 29 | 30 | public final class TestUtil { 31 | public static void init() { 32 | assertTrue(AstralConstants.MOCKING); 33 | if (!MockBukkit.isMocked()) { 34 | MockBukkit.mock(); 35 | MockBukkit.getMock().addSimpleWorld("world"); 36 | } 37 | if (AstralFlow.getInstance() == null) { 38 | MockBukkit.load(AstralFlow.class); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id "com.github.johnrengelman.shadow" version "7.1.2" 4 | } 5 | 6 | group 'io.ib67.astralflow' 7 | version parent.version 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT' 15 | compileOnly parent 16 | } 17 | shadowJar { 18 | relocate 'io.ib67.util', 'astralflow.tester.relocate.util' 19 | } 20 | test { 21 | useJUnitPlatform() 22 | } -------------------------------------------------------------------------------- /test-plugin/src/main/java/io/ib67/astralflow/TestItems.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow; 23 | 24 | import io.ib67.astralflow.item.ItemKey; 25 | 26 | /** 27 | * You should always put your item keys into such an enum since Java supports enum implementing interfaces. 28 | */ 29 | public enum TestItems implements ItemKey { // An ItemKey is an interface that binds to your Item. 30 | JEB_WOOL("jeb_wool"), 31 | STATELESS_ITEM("stateless_item"), 32 | 33 | CANT_STACK("cantstack"), 34 | INTERACTIVE_BARREL("interactive_barrel"), 35 | EX_CALIBUR("ex_calibur"), 36 | STATEFUL_ITEM("simple_stateful_item"); 37 | 38 | private final String id; 39 | 40 | TestItems(String id) { 41 | this.id = id; 42 | } 43 | 44 | @Override 45 | public String getId() { 46 | return id; 47 | } 48 | 49 | @Override 50 | public String getNamespace() { 51 | return "tester"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/io/ib67/astralflow/item/AnotherSimpleState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | public final class AnotherSimpleState extends ItemState { // States are just data classes that can be serialized by Gson. 25 | private String data; 26 | 27 | public AnotherSimpleState(String data) { 28 | this.data = data; 29 | } 30 | 31 | public String getData() { 32 | return data; 33 | } 34 | 35 | public void setData(String data) { 36 | this.data = data; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "AnotherSimpleState{" + 42 | "data='" + data + '\'' + 43 | '}'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/io/ib67/astralflow/item/SimpleStatefulCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import io.ib67.astralflow.util.ItemStacks; 28 | import org.bukkit.Material; 29 | 30 | public final class SimpleStatefulCategory implements ItemCategory { 31 | @Override 32 | public ItemPrototypeFactory getFactory(ItemKey item) { 33 | return ItemPrototype 34 | .builder() 35 | .prototype(ItemStacks.builder(Material.GOLD_INGOT).build()) 36 | .id(item) 37 | .statePrototype(new AnotherSimpleState("default")) 38 | .build(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/io/ib67/astralflow/item/SimpleStatelessCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import io.ib67.astralflow.util.ItemStacks; 28 | import org.bukkit.Material; 29 | 30 | public final class SimpleStatelessCategory implements ItemCategory { 31 | @Override 32 | public ItemPrototypeFactory getFactory(ItemKey item) { 33 | return ItemPrototype.builder() 34 | .statePrototype(null) 35 | .prototype(ItemStacks.builder(Material.IRON_INGOT).build()) 36 | .id(item) 37 | .build(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/io/ib67/astralflow/item/SimpleStatelessUnstackableCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.item; 23 | 24 | import io.ib67.astralflow.item.builder.ItemCategory; 25 | import io.ib67.astralflow.item.builder.ItemPrototype; 26 | import io.ib67.astralflow.item.factory.ItemPrototypeFactory; 27 | import io.ib67.astralflow.util.ItemStacks; 28 | import org.bukkit.Material; 29 | 30 | public final class SimpleStatelessUnstackableCategory implements ItemCategory { 31 | @Override 32 | public ItemPrototypeFactory getFactory(ItemKey item) { 33 | return ItemPrototype.builder() 34 | .statePrototype(null) 35 | .prototype(ItemStacks.builder(Material.IRON_SWORD).build()) 36 | .id(item) 37 | .build(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test-plugin/src/main/java/io/ib67/astralflow/machines/InteractiveBarrel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * AstralFlow - The plugin enriches bukkit servers 4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | */ 21 | 22 | package io.ib67.astralflow.machines; 23 | 24 | import io.ib67.astralflow.machines.trait.Interactive; 25 | import org.bukkit.entity.Player; 26 | import org.bukkit.event.block.Action; 27 | import org.bukkit.inventory.ItemStack; 28 | 29 | @AutoFactory // MachineFactory will be generated automatically. 30 | public class InteractiveBarrel extends AbstractMachine implements Interactive { 31 | 32 | protected InteractiveBarrel(MachineProperty property) { // some basic information, such as location, context. 33 | super(property); 34 | } 35 | 36 | @Override 37 | public void update(IMachine self) { 38 | // executed for every tick. 39 | } 40 | 41 | @Override 42 | public void onInteract(Action clickType, Player player, ItemStack itemInHand) { 43 | this.getLocation().getWorld().createExplosion(this.getLocation(), 5f); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test-plugin/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: AstralFlow.Tester 2 | main: io.ib67.astralflow.TestPlugin 3 | version: 0.1.0 4 | description: A test plugin for astral flow features. DO NOT AND NEVER USE THIS IN PRODUCTION ENVIRONMENT. 5 | api-version: 1.18 6 | depend: 7 | - AstralFlow 8 | commands: 9 | stateless_item: 10 | description: give a stateless item 11 | random_state_item: 12 | description: give a random state item 13 | lookup_simple_state: 14 | description: lookup simple state 15 | jbwool: 16 | description: give jebwool 17 | loc: 18 | description: get location 19 | int_barr: 20 | description: get interactive barrel -------------------------------------------------------------------------------- /translations/en_US.conf: -------------------------------------------------------------------------------- 1 | name = "en_US" 2 | serverIsInitializing = "Server is initializing, please wait a moment." 3 | anyItemName = "&a?? Any Item ??" --------------------------------------------------------------------------------