├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ └── feature-request.yml └── workflows │ ├── call.github_release.yml │ ├── call.platform_uploads.yml │ ├── dispatch.create_release.yml │ ├── dispatch.javadoc.yml │ ├── dispatch.platform_uploads.yml │ ├── dispatch.promote_release.yml │ ├── generic.checkstyle.yml │ ├── generic.github_release.yml │ ├── generic.platform_uploads.yml │ ├── generic.test.yml │ ├── main.prerelease.yml │ ├── pr.checkstyle.yml │ ├── pr.require_label.yml │ └── pr.test.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── build.gradle ├── config ├── .gitignore ├── Doxyfile ├── convert-locale-enum.py ├── multiverse-banner.png ├── multiverse-square-trans.png ├── multiverse-square.png ├── multiverse2-long.png ├── multiverse2-short-small.png ├── multiverse2-short.png └── mv_checks.xml ├── docs └── .keep ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main ├── java │ └── org │ │ └── mvplugins │ │ └── multiverse │ │ └── core │ │ ├── BstatsMetricsConfigurator.java │ │ ├── MultiverseCore.java │ │ ├── MultiverseCoreApi.java │ │ ├── MultiverseCorePluginBinder.java │ │ ├── PlaceholderExpansionHook.java │ │ ├── TestingMode.java │ │ ├── anchor │ │ ├── AnchorManager.java │ │ ├── MultiverseAnchor.java │ │ └── package-info.java │ │ ├── command │ │ ├── LegacyAliasCommand.java │ │ ├── MVCommandCompletions.java │ │ ├── MVCommandConditions.java │ │ ├── MVCommandContexts.java │ │ ├── MVCommandIssuer.java │ │ ├── MVCommandManager.java │ │ ├── MVCommandPermissions.java │ │ ├── MVDefaultExceptionHandler.java │ │ ├── MVRootCommand.java │ │ ├── MultiverseCommand.java │ │ ├── context │ │ │ ├── GameRuleValue.java │ │ │ └── package-info.java │ │ ├── flag │ │ │ ├── CommandFlag.java │ │ │ ├── CommandFlagGroup.java │ │ │ ├── CommandFlagsManager.java │ │ │ ├── CommandFlagsParser.java │ │ │ ├── CommandValueFlag.java │ │ │ ├── FlagBuilder.java │ │ │ ├── ParsedCommandFlags.java │ │ │ └── package-info.java │ │ ├── flags │ │ │ ├── FilterCommandFlag.java │ │ │ ├── PageCommandFlag.java │ │ │ ├── PageFilterFlags.java │ │ │ ├── RemovePlayerFlags.java │ │ │ ├── UnsafeFlags.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ └── queue │ │ │ ├── CommandQueueManager.java │ │ │ ├── CommandQueuePayload.java │ │ │ ├── ConfirmMode.java │ │ │ ├── RunQueuedFailedReason.java │ │ │ └── package-info.java │ │ ├── commands │ │ ├── AnchorDeleteCommand.java │ │ ├── AnchorListCommand.java │ │ ├── AnchorSetCommand.java │ │ ├── CheckCommand.java │ │ ├── CloneCommand.java │ │ ├── ConfigCommand.java │ │ ├── ConfirmCommand.java │ │ ├── CoordinatesCommand.java │ │ ├── CoreCommand.java │ │ ├── CreateCommand.java │ │ ├── DebugCommand.java │ │ ├── DeleteCommand.java │ │ ├── DumpsCommand.java │ │ ├── DumpsLogPoster.java │ │ ├── DumpsService.java │ │ ├── EntitySpawnConfigCommand.java │ │ ├── GameruleCommand.java │ │ ├── GeneratorsCommand.java │ │ ├── HelpCommand.java │ │ ├── ImportCommand.java │ │ ├── InfoCommand.java │ │ ├── ListCommand.java │ │ ├── LoadCommand.java │ │ ├── ModifyCommand.java │ │ ├── PurgeAllEntitiesCommand.java │ │ ├── PurgeEntitiesCommand.java │ │ ├── RegenCommand.java │ │ ├── ReloadCommand.java │ │ ├── RemoveCommand.java │ │ ├── RootCommand.java │ │ ├── SetSpawnCommand.java │ │ ├── SpawnCommand.java │ │ ├── TeleportCommand.java │ │ ├── UnloadCommand.java │ │ ├── VersionCommand.java │ │ ├── WhoCommand.java │ │ ├── WorldBorderCommand.java │ │ └── package-info.java │ │ ├── config │ │ ├── CoreConfig.java │ │ ├── CoreConfigNodes.java │ │ ├── handle │ │ │ ├── BaseConfigurationHandle.java │ │ │ ├── CommentedConfigurationHandle.java │ │ │ ├── ConfigurationSectionHandle.java │ │ │ ├── FileConfigurationHandle.java │ │ │ ├── MemoryConfigurationHandle.java │ │ │ ├── PropertyModifyAction.java │ │ │ ├── StringPropertyHandle.java │ │ │ ├── YamlConfigurationHandle.java │ │ │ └── package-info.java │ │ ├── migration │ │ │ ├── ConfigMigrator.java │ │ │ ├── VersionMigrator.java │ │ │ ├── action │ │ │ │ ├── BooleanMigratorAction.java │ │ │ │ ├── DeleteMigratorAction.java │ │ │ │ ├── DoubleMigratorAction.java │ │ │ │ ├── IntegerMigratorAction.java │ │ │ │ ├── InvertBoolMigratorAction.java │ │ │ │ ├── LongMigratorAction.java │ │ │ │ ├── MigratorAction.java │ │ │ │ ├── MoveMigratorAction.java │ │ │ │ ├── NullStringMigratorAction.java │ │ │ │ └── SetMigratorAction.java │ │ │ └── package-info.java │ │ ├── node │ │ │ ├── CommentedNode.java │ │ │ ├── ConfigHeaderNode.java │ │ │ ├── ConfigNode.java │ │ │ ├── ConfigNodeNotFoundException.java │ │ │ ├── ListConfigNode.java │ │ │ ├── ListValueNode.java │ │ │ ├── Node.java │ │ │ ├── NodeGroup.java │ │ │ ├── ValueNode.java │ │ │ ├── functions │ │ │ │ ├── DefaultStringParserProvider.java │ │ │ │ ├── DefaultSuggesterProvider.java │ │ │ │ ├── NodeStringParser.java │ │ │ │ ├── NodeSuggester.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── serializer │ │ │ │ ├── DefaultSerializerProvider.java │ │ │ │ └── NodeSerializer.java │ │ └── package-info.java │ │ ├── destination │ │ ├── Destination.java │ │ ├── DestinationInstance.java │ │ ├── DestinationSuggestionPacket.java │ │ ├── DestinationsProvider.java │ │ ├── core │ │ │ ├── AnchorDestination.java │ │ │ ├── AnchorDestinationInstance.java │ │ │ ├── BedDestination.java │ │ │ ├── BedDestinationInstance.java │ │ │ ├── CannonDestination.java │ │ │ ├── CannonDestinationInstance.java │ │ │ ├── ExactDestination.java │ │ │ ├── ExactDestinationInstance.java │ │ │ ├── PlayerDestination.java │ │ │ ├── PlayerDestinationInstance.java │ │ │ ├── WorldDestination.java │ │ │ ├── WorldDestinationInstance.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── display │ │ ├── ContentDisplay.java │ │ ├── filters │ │ │ ├── ContentFilter.java │ │ │ ├── DefaultContentFilter.java │ │ │ ├── RegexContentFilter.java │ │ │ └── package-info.java │ │ ├── handlers │ │ │ ├── BaseSendHandler.java │ │ │ ├── DefaultSendHandler.java │ │ │ ├── InlineSendHandler.java │ │ │ ├── PagedSendHandler.java │ │ │ ├── SendHandler.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ └── parsers │ │ │ ├── ContentProvider.java │ │ │ ├── ListContentProvider.java │ │ │ ├── MapContentProvider.java │ │ │ └── package-info.java │ │ ├── dynamiclistener │ │ ├── DynamicListener.java │ │ ├── DynamicListenerRegistration.java │ │ ├── EventPriorityMapper.java │ │ ├── EventRunnable.java │ │ ├── EventRunnableExecutor.java │ │ └── annotations │ │ │ ├── DefaultEventPriority.java │ │ │ ├── EventClass.java │ │ │ ├── EventMethod.java │ │ │ ├── EventPriorityKey.java │ │ │ ├── IgnoreIfCancelled.java │ │ │ └── SkipIfEventExist.java │ │ ├── economy │ │ ├── ItemEconomy.java │ │ ├── MVEconomist.java │ │ ├── VaultHandler.java │ │ └── package-info.java │ │ ├── event │ │ ├── MVConfigReloadEvent.java │ │ ├── MVDebugModeEvent.java │ │ ├── MVDumpsDebugInfoEvent.java │ │ ├── MVPlayerTouchedPortalEvent.java │ │ ├── MVRespawnEvent.java │ │ ├── MVTeleportDestinationEvent.java │ │ ├── package-info.java │ │ └── world │ │ │ ├── MVWorldClonedEvent.java │ │ │ ├── MVWorldCreatedEvent.java │ │ │ ├── MVWorldDeleteEvent.java │ │ │ ├── MVWorldImportedEvent.java │ │ │ ├── MVWorldLoadedEvent.java │ │ │ ├── MVWorldPropertyChangedEvent.java │ │ │ ├── MVWorldRegeneratedEvent.java │ │ │ ├── MVWorldRemovedEvent.java │ │ │ ├── MVWorldUnloadedEvent.java │ │ │ └── MultiverseWorldEvent.java │ │ ├── exceptions │ │ ├── MultiverseException.java │ │ ├── command │ │ │ └── MVInvalidCommandArgument.java │ │ ├── package-info.java │ │ └── world │ │ │ └── MultiverseWorldException.java │ │ ├── inject │ │ ├── PluginServiceLocator.java │ │ ├── PluginServiceLocatorFactory.java │ │ ├── binder │ │ │ ├── JavaPluginBinder.java │ │ │ ├── PluginBinder.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── listeners │ │ ├── CoreListener.java │ │ ├── MVAdvancementListener.java │ │ ├── MVChatListener.java │ │ ├── MVEntityListener.java │ │ ├── MVPlayerListener.java │ │ ├── MVPortalListener.java │ │ ├── MVWeatherListener.java │ │ ├── MVWorldListener.java │ │ └── package-info.java │ │ ├── locale │ │ ├── FileResClassLoader.java │ │ ├── MVCorei18n.java │ │ ├── PluginLocales.java │ │ ├── message │ │ │ ├── LocalizableMessage.java │ │ │ ├── LocalizedMessage.java │ │ │ ├── Message.java │ │ │ ├── MessageReplacement.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── module │ │ ├── MultiverseModule.java │ │ ├── MultiverseModuleBinder.java │ │ └── MultiverseModulesRegistry.java │ │ ├── package-info.java │ │ ├── permissions │ │ ├── CorePermissions.java │ │ ├── CorePermissionsChecker.java │ │ ├── PermissionUtils.java │ │ └── package-info.java │ │ ├── teleportation │ │ ├── AsyncSafetyTeleporter.java │ │ ├── AsyncSafetyTeleporterAction.java │ │ ├── BlockSafety.java │ │ ├── LocationManipulation.java │ │ ├── TeleportFailureReason.java │ │ ├── TeleportQueue.java │ │ └── package-info.java │ │ ├── utils │ │ ├── FileUtils.java │ │ ├── MaterialConverter.java │ │ ├── PlayerFinder.java │ │ ├── REPatterns.java │ │ ├── ReflectHelper.java │ │ ├── ServerProperties.java │ │ ├── StringFormatter.java │ │ ├── WorldTickDeferrer.java │ │ ├── package-info.java │ │ ├── result │ │ │ ├── AsyncAttempt.java │ │ │ ├── AsyncAttemptsAggregate.java │ │ │ ├── Attempt.java │ │ │ ├── AttemptsAggregate.java │ │ │ ├── FailureReason.java │ │ │ ├── Result.java │ │ │ ├── ResultChain.java │ │ │ └── SuccessReason.java │ │ └── webpaste │ │ │ ├── BitlyURLShortener.java │ │ │ ├── GitHubPasteService.java │ │ │ ├── HttpAPIClient.java │ │ │ ├── McloGsPasteService.java │ │ │ ├── PasteFailedException.java │ │ │ ├── PasteGGPasteService.java │ │ │ ├── PasteService.java │ │ │ ├── PasteServiceFactory.java │ │ │ ├── PasteServiceType.java │ │ │ ├── PastebinPasteService.java │ │ │ ├── PastesDevPasteService.java │ │ │ ├── URLShortener.java │ │ │ ├── URLShortenerFactory.java │ │ │ ├── URLShortenerType.java │ │ │ └── package-info.java │ │ └── world │ │ ├── AllowedPortalType.java │ │ ├── LoadedMultiverseWorld.java │ │ ├── MultiverseWorld.java │ │ ├── NewAndRemovedWorlds.java │ │ ├── WorldConfig.java │ │ ├── WorldConfigNodes.java │ │ ├── WorldManager.java │ │ ├── WorldsConfigManager.java │ │ ├── biomeprovider │ │ ├── BiomeProviderFactory.java │ │ ├── BiomeProviderParser.java │ │ ├── SingleBiomeProvider.java │ │ └── SingleBiomeProviderParser.java │ │ ├── entity │ │ ├── EntityPurger.java │ │ ├── EntitySpawnConfig.java │ │ ├── SpawnCategoryConfig.java │ │ └── SpawnCategoryMapper.java │ │ ├── entrycheck │ │ ├── BlacklistResult.java │ │ ├── EntryFeeResult.java │ │ ├── PlayerLimitResult.java │ │ ├── WorldAccessResult.java │ │ ├── WorldEntryChecker.java │ │ ├── WorldEntryCheckerProvider.java │ │ └── package-info.java │ │ ├── generators │ │ ├── GeneratorPlugin.java │ │ ├── GeneratorProvider.java │ │ ├── SimpleGeneratorPlugin.java │ │ └── package-info.java │ │ ├── helpers │ │ ├── DataStore.java │ │ ├── DataTransfer.java │ │ ├── DimensionFinder.java │ │ ├── EnforcementHandler.java │ │ ├── PlayerWorldTeleporter.java │ │ ├── WorldNameChecker.java │ │ └── package-info.java │ │ ├── location │ │ ├── NullSpawnLocation.java │ │ ├── SpawnLocation.java │ │ ├── UnloadedWorldLocation.java │ │ └── package-info.java │ │ ├── options │ │ ├── CloneWorldOptions.java │ │ ├── CreateWorldOptions.java │ │ ├── DeleteWorldOptions.java │ │ ├── ImportWorldOptions.java │ │ ├── KeepWorldSettingsOptions.java │ │ ├── RegenWorldOptions.java │ │ ├── UnloadWorldOptions.java │ │ └── package-info.java │ │ ├── package-info.java │ │ └── reasons │ │ ├── CloneFailureReason.java │ │ ├── CreateFailureReason.java │ │ ├── DeleteFailureReason.java │ │ ├── ImportFailureReason.java │ │ ├── LoadFailureReason.java │ │ ├── RegenFailureReason.java │ │ ├── RemoveFailureReason.java │ │ ├── UnloadFailureReason.java │ │ ├── WorldCreatorFailureReason.java │ │ └── package-info.java └── resources │ ├── META-INF │ └── services │ │ └── org.mvplugins.multiverse.external.glassfish.hk2.extension.ServiceLocatorGenerator │ ├── defaults │ └── config.yml │ ├── multiverse-core_en.properties │ ├── multiverse-core_zh.properties │ └── plugin.yml └── test ├── java └── org │ └── mvplugins │ └── multiverse │ └── core │ ├── MockBukkitTest.kt │ ├── TestWithMockBukkit.kt │ ├── anchor │ └── AnchorManagerTest.kt │ ├── api │ └── MultiverseCoreApiTest.kt │ ├── command │ └── LocalizationTest.kt │ ├── commands │ ├── AbstractCommandTest.kt │ ├── ConfigCommandTest.kt │ ├── CreateCommandTest.kt │ ├── DeleteCommandTest.kt │ ├── ModifyCommandTest.kt │ ├── RegenCommandTest.kt │ ├── SpawnCommandTest.kt │ ├── TeleportCommandTest.kt │ └── VersionCommandTest.kt │ ├── config │ ├── ConfigTeleportInterceptTest.kt │ └── ConfigTest.kt │ ├── destination │ └── DestinationTest.kt │ ├── inject │ └── InjectionTest.kt │ ├── mock │ ├── MVServerMock.java │ └── MVWorldMock.java │ ├── utils │ ├── MaterialConverterTest.kt │ └── StringFormatterTest.kt │ └── world │ ├── WorldConfigMangerTest.kt │ ├── WorldConfigTest.kt │ ├── WorldManagerTest.kt │ ├── WorldNameCheckerTest.kt │ └── helper │ └── DimensionFormatTest.kt └── resources ├── anchors ├── anchors_saved.yml └── default_anchors.yml ├── configs ├── broken_config.yml ├── fresh_config.yml └── old_config.yml └── worlds ├── default_worlds.yml ├── delete_worlds.yml ├── edgecase_worlds.yml ├── migrated_worlds.yml ├── newworld_worlds.yml ├── old_worlds.yml ├── properties_worlds.yml └── updated_worlds.yml /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 💬 Multiverse Discord Server 4 | url: https://discord.gg/NZtfKky 5 | about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help! 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: 💡 Request a Feature 2 | description: Suggest a feature you want to see in Multiverse-Core! 3 | title: "[Idea]: " 4 | labels: ["Type: Idea"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for taking the time to share your ideas! 10 | 11 | If you are look for other submodules of Multiverse, go to their respective git repo: 12 | Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose 13 | Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose 14 | Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose 15 | Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose 16 | 17 | Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky 18 | - type: textarea 19 | id: feature-description 20 | attributes: 21 | label: Describe the feature 22 | description: What feature are you suggesting? 23 | placeholder: "Example: I hope multiverse can implement random teleport feature..." 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: feature-reasoning 28 | attributes: 29 | label: How is the feature useful to all Multiverse users? 30 | description: How is the feature useful to all players, server owners and/or developers? 31 | placeholder: "Example: Random teleporting can be integrated into many multiverse modules such as mv-portals..." 32 | validations: 33 | required: true 34 | - type: checkboxes 35 | id: agreements 36 | attributes: 37 | label: Agreements 38 | description: Ensure you have done the following being submitting this issue. 39 | options: 40 | - label: I have searched for and ensured there isn't already an open issue regarding this. 41 | required: true 42 | -------------------------------------------------------------------------------- /.github/workflows/call.github_release.yml: -------------------------------------------------------------------------------- 1 | name: 'Call: GitHub Release' 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | release_mode: 7 | description: 'Release mode' 8 | required: true 9 | type: string 10 | version_bump: 11 | description: 'Version bump' 12 | required: false 13 | type: string 14 | promote_from: 15 | description: 'Promote from' 16 | required: false 17 | type: string 18 | outputs: 19 | release_created: 20 | description: 'Release created' 21 | value: ${{ jobs.github_release.outputs.release_created }} 22 | tag_name: 23 | description: 'Tag name' 24 | value: ${{ jobs.github_release.outputs.tag_name }} 25 | 26 | jobs: 27 | github_release: 28 | uses: ./.github/workflows/generic.github_release.yml 29 | secrets: inherit 30 | with: 31 | plugin_name: multiverse-core 32 | release_mode: ${{ inputs.release_mode }} 33 | version_bump: ${{ inputs.version_bump }} 34 | promote_from: ${{ inputs.promote_from }} 35 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.create_release.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Create Release' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | release_type: 7 | description: 'Stable or pre-release' 8 | required: true 9 | type: choice 10 | options: 11 | - prerelease 12 | - release 13 | version_bump: 14 | description: 'Version bump type' 15 | required: true 16 | type: choice 17 | options: 18 | - major 19 | - minor 20 | - patch 21 | 22 | jobs: 23 | github_release: 24 | uses: ./.github/workflows/call.github_release.yml 25 | secrets: inherit 26 | with: 27 | release_mode: ${{ inputs.release_type }} 28 | version_bump: ${{ inputs.version_bump }} 29 | 30 | platform_uploads: 31 | needs: github_release 32 | if: needs.github_release.outputs.release_created == 'true' 33 | uses: ./.github/workflows/call.platform_uploads.yml 34 | secrets: inherit 35 | with: 36 | target_tag: ${{ needs.github_release.outputs.tag_name }} 37 | upload_modrinth: 'true' 38 | upload_dbo: 'false' 39 | upload_hangar: 'false' 40 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.javadoc.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Deploy Javadoc' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | target_tag: 7 | description: 'Version to generate javadoc' 8 | required: true 9 | replace_latest: 10 | description: 'Replace the latest folder' 11 | type: boolean 12 | 13 | jobs: 14 | javadocs: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | with: 19 | ref: ${{ inputs.target_tag }} 20 | 21 | - uses: actions/setup-java@v4 22 | with: 23 | java-version: '21' 24 | distribution: 'adopt' 25 | cache: gradle 26 | 27 | - name: Setup Gradle 28 | uses: gradle/actions/setup-gradle@v4 29 | 30 | - name: build javadoc 31 | run: ./gradlew javadoc 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | GITHUB_VERSION: ${{ inputs.target_tag }} 35 | 36 | - name: Copy javadoc to deploy folder 37 | run: | 38 | mkdir -p build/docs/javadoc-deploy/${{ inputs.target_tag }} 39 | cp -r build/docs/javadoc/* build/docs/javadoc-deploy/${{ inputs.target_tag }} 40 | 41 | - name: Copy javadoc to latest folder 42 | if: inputs.replace_latest 43 | run: | 44 | mkdir -p build/docs/javadoc-deploy/latest 45 | cp -r build/docs/javadoc/* build/docs/javadoc-deploy/latest 46 | 47 | - name: Deploy javadoc to gh pages 48 | uses: JamesIves/github-pages-deploy-action@v4 49 | with: 50 | token: ${{ secrets.GITHUB_TOKEN }} 51 | folder: build/docs/javadoc-deploy 52 | branch: javadoc 53 | target-folder: javadoc 54 | clean: false 55 | commit-message: Deploy javadoc for ${{ inputs.target_tag }} 56 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.platform_uploads.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Platform Uploads' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | target_tag: 7 | description: 'Version to upload' 8 | required: true 9 | type: string 10 | upload_modrinth: 11 | description: 'Upload to modrinth.com' 12 | required: true 13 | type: boolean 14 | upload_dbo: 15 | description: 'Upload to dev.bukkit.org' 16 | required: true 17 | type: boolean 18 | upload_hangar: 19 | description: 'Upload to hangar.papermc.io' 20 | required: true 21 | type: boolean 22 | 23 | jobs: 24 | dispatch_platform_uploads: 25 | uses: ./.github/workflows/call.platform_uploads.yml 26 | secrets: inherit 27 | with: 28 | target_tag: ${{ github.event.inputs.target_tag }} 29 | upload_modrinth: ${{ github.event.inputs.upload_modrinth }} 30 | upload_dbo: ${{ github.event.inputs.upload_dbo }} 31 | upload_hangar: ${{ github.event.inputs.upload_hangar }} 32 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.promote_release.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Promote Release' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | target_tag: 7 | description: 'Version to promote' 8 | required: true 9 | 10 | jobs: 11 | check_version: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Verify input version is prerelease 15 | run: | 16 | if [[ "${{ github.event.inputs.target_tag }}" != *"pre"* ]]; then 17 | echo "Version must be a prerelease" 18 | exit 1 19 | fi 20 | 21 | github_release: 22 | needs: check_version 23 | uses: ./.github/workflows/call.github_release.yml 24 | secrets: inherit 25 | with: 26 | release_mode: promote 27 | promote_from: ${{ github.event.inputs.target_tag }} 28 | 29 | platform_uploads: 30 | needs: github_release 31 | if: needs.github_release.outputs.release_created == 'true' 32 | uses: ./.github/workflows/call.platform_uploads.yml 33 | secrets: inherit 34 | with: 35 | target_tag: ${{ needs.github_release.outputs.tag_name }} 36 | upload_modrinth: 'true' 37 | upload_dbo: 'true' 38 | upload_hangar: 'true' 39 | -------------------------------------------------------------------------------- /.github/workflows/generic.checkstyle.yml: -------------------------------------------------------------------------------- 1 | name: 'Generic: Checkstyle' 2 | 3 | on: 4 | workflow_call: 5 | 6 | jobs: 7 | checkstyle: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | contents: read 11 | pull-requests: write 12 | continue-on-error: true 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - uses: dbelyaev/action-checkstyle@v0.8.4 17 | continue-on-error: true 18 | with: 19 | github_token: ${{ secrets.GITHUB_TOKEN }} 20 | checkstyle_version: 10.12.2 21 | checkstyle_config: ./config/mv_checks.xml 22 | level: warning 23 | -------------------------------------------------------------------------------- /.github/workflows/generic.test.yml: -------------------------------------------------------------------------------- 1 | name: 'Generic: Test' 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | plugin_name: 7 | description: 'Plugin name' 8 | required: true 9 | type: string 10 | 11 | jobs: 12 | test-and-artifact: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - uses: actions/setup-java@v4 20 | with: 21 | java-version: '21' 22 | distribution: 'adopt' 23 | cache: gradle 24 | 25 | - name: Setup Gradle 26 | uses: gradle/actions/setup-gradle@v4 27 | 28 | - name: Run unit tests 29 | run: ./gradlew build 30 | env: 31 | GITHUB_VERSION: pr${{ github.event.pull_request.number }} 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | 34 | - name: Artifact output 35 | uses: actions/upload-artifact@v4 36 | with: 37 | name: ${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }} 38 | path: build/libs/${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}.jar 39 | 40 | comment-artifact: 41 | needs: test-and-artifact 42 | runs-on: ubuntu-latest 43 | permissions: 44 | pull-requests: write 45 | steps: 46 | - uses: benwoo1110/artifact-comment-action@v1 47 | with: 48 | github_token: ${{ secrets.GITHUB_TOKEN }} 49 | -------------------------------------------------------------------------------- /.github/workflows/main.prerelease.yml: -------------------------------------------------------------------------------- 1 | name: 'Main: Prerelease' 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | github_release_on_push: 9 | uses: ./.github/workflows/call.github_release.yml 10 | secrets: inherit 11 | with: 12 | release_mode: prerelease 13 | version_bump: prlabel 14 | 15 | platform_uploads_on_push: 16 | needs: github_release_on_push 17 | if: needs.github_release_on_push.outputs.release_created == 'true' 18 | uses: ./.github/workflows/call.platform_uploads.yml 19 | secrets: inherit 20 | with: 21 | target_tag: ${{ needs.github_release_on_push.outputs.tag_name }} 22 | upload_modrinth: 'true' 23 | upload_dbo: 'false' 24 | upload_hangar: 'false' 25 | -------------------------------------------------------------------------------- /.github/workflows/pr.checkstyle.yml: -------------------------------------------------------------------------------- 1 | name: 'PR: Checkstyle' 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize] 6 | 7 | jobs: 8 | checkstyle: 9 | uses: ./.github/workflows/generic.checkstyle.yml 10 | -------------------------------------------------------------------------------- /.github/workflows/pr.require_label.yml: -------------------------------------------------------------------------------- 1 | name: 'PR: Require Label' 2 | 3 | on: 4 | pull_request: 5 | types: [opened, labeled, unlabeled, synchronize] 6 | branches: [main] 7 | 8 | jobs: 9 | require_label: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: mheap/github-action-required-labels@v2 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | with: 16 | mode: exactly 17 | count: 1 18 | labels: "release:major, release:minor, release:patch, no release" 19 | -------------------------------------------------------------------------------- /.github/workflows/pr.test.yml: -------------------------------------------------------------------------------- 1 | name: 'PR: Test' 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize] 6 | 7 | jobs: 8 | test: 9 | uses: ./.github/workflows/generic.test.yml 10 | with: 11 | plugin_name: multiverse-core 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse stuff 2 | /.classpath 3 | /.project 4 | /.settings 5 | /.checkstyle 6 | 7 | # netbeans 8 | /nbproject 9 | 10 | # we use maven! 11 | /build.xml 12 | 13 | # maven 14 | /target 15 | dependency-reduced-pom.xml 16 | 17 | # vim 18 | .*.sw[a-p] 19 | 20 | # various other potential build files 21 | /build 22 | /bin 23 | /dist 24 | /manifest.mf 25 | 26 | /world 27 | 28 | # Mac filesystem dust 29 | *.DS_Store 30 | 31 | # intellij 32 | *.iml 33 | *.ipr 34 | *.iws 35 | .idea/ 36 | 37 | # Fern's utils 38 | uploadtoserver.sh 39 | 40 | # Testing files: 41 | debug.log 42 | 43 | # Doxygen 44 | /docs/html 45 | debug.txt 46 | 47 | # Gradle 48 | .gradle 49 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, The Multiverse Team All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6 | 7 | -------------------------------------------------------------------------------- /config/.gitignore: -------------------------------------------------------------------------------- 1 | out.txt -------------------------------------------------------------------------------- /config/convert-locale-enum.py: -------------------------------------------------------------------------------- 1 | filepath = "../src/main/resources/multiverse-core_en.properties" 2 | 3 | enumList = [] 4 | 5 | with open(filepath) as f: 6 | for line in f: 7 | line = line.strip() 8 | if len(line) == 0: 9 | enumList.append("") 10 | elif line.startswith("#"): 11 | enumList.append(line.replace("#", "//")) 12 | else: 13 | parts = line.split("=") 14 | if (len(parts) < 2): 15 | continue 16 | parts = parts[0].split(".")[1:] 17 | enumList.append("_".join([p.upper() for p in parts]) + ",") 18 | 19 | with open("out.txt", "w") as f: 20 | f.write("\n".join(enumList)) -------------------------------------------------------------------------------- /config/multiverse-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/config/multiverse-banner.png -------------------------------------------------------------------------------- /config/multiverse-square-trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/config/multiverse-square-trans.png -------------------------------------------------------------------------------- /config/multiverse-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/config/multiverse-square.png -------------------------------------------------------------------------------- /config/multiverse2-long.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/config/multiverse2-long.png -------------------------------------------------------------------------------- /config/multiverse2-short-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/config/multiverse2-short-small.png -------------------------------------------------------------------------------- /config/multiverse2-short.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/config/multiverse2-short.png -------------------------------------------------------------------------------- /docs/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/docs/.keep -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Multiverse/Multiverse-Core/a55ce680df0b96e633356add29798d3aea74ad42/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | pluginManagement { 6 | repositories { 7 | gradlePluginPortal() 8 | maven { 9 | url = uri('https://repo.onarandombox.com/multiverse-releases') 10 | } 11 | } 12 | } 13 | 14 | rootProject.name = 'multiverse-core' 15 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/MultiverseCorePluginBinder.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core; 2 | 3 | import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import org.mvplugins.multiverse.core.module.MultiverseModuleBinder; 7 | 8 | final class MultiverseCorePluginBinder extends MultiverseModuleBinder { 9 | 10 | MultiverseCorePluginBinder(@NotNull MultiverseCore plugin) { 11 | super(plugin); 12 | } 13 | 14 | @Override 15 | protected ScopedBindingBuilder bindPluginClass( 16 | ScopedBindingBuilder bindingBuilder) { 17 | return super.bindPluginClass(bindingBuilder).to(MultiverseCore.class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/TestingMode.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core; 2 | 3 | /** 4 | * A utility class that enables automated tests to flag Multiverse for testing. This allows Multiverse to not perform 5 | * certain behaviors such as enabled stats uploads. 6 | */ 7 | final class TestingMode { 8 | 9 | private static boolean enabled = false; 10 | 11 | private TestingMode() { 12 | // No instantiation 13 | } 14 | 15 | static void enable() { 16 | enabled = true; 17 | } 18 | 19 | static boolean isDisabled() { 20 | return !enabled; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/anchor/MultiverseAnchor.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.anchor; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.World; 5 | import org.jetbrains.annotations.Nullable; 6 | import org.mvplugins.multiverse.core.world.location.UnloadedWorldLocation; 7 | 8 | /** 9 | * Represents a single anchor location. 10 | */ 11 | public final class MultiverseAnchor { 12 | 13 | private final String name; 14 | private UnloadedWorldLocation location; 15 | 16 | MultiverseAnchor(String name, UnloadedWorldLocation location) { 17 | this.name = name; 18 | this.location = location; 19 | } 20 | 21 | /** 22 | * Gets the name of the anchor. 23 | * 24 | * @return The name. 25 | */ 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | /** 31 | * Gets a copy of the anchor's location. 32 | * 33 | * @return The location. 34 | */ 35 | public Location getLocation() { 36 | return location.toBukkitLocation(); 37 | } 38 | 39 | void setLocation(Location location) { 40 | this.location = new UnloadedWorldLocation(location); 41 | } 42 | 43 | /** 44 | * Gets the world of the anchor's location. 45 | * 46 | * @return The world. 47 | */ 48 | @Nullable World getLocationWorld() { 49 | if (location == null) { 50 | return null; 51 | } 52 | return location.getWorld(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/anchor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * this package contains the classes that are used for the anchor system. 3 | */ 4 | package org.mvplugins.multiverse.core.anchor; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/LegacyAliasCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command; 2 | 3 | /** 4 | * Extends a command class to add legacy alias annotations. 5 | */ 6 | public interface LegacyAliasCommand { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/MVDefaultExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command; 2 | 3 | import co.aikar.commands.BaseCommand; 4 | import co.aikar.commands.CommandIssuer; 5 | import co.aikar.commands.ExceptionHandler; 6 | import co.aikar.commands.RegisteredCommand; 7 | import com.dumptruckman.minecraft.util.Logging; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Default handler that will print the stack trace when the command throws an exception. 13 | */ 14 | public class MVDefaultExceptionHandler implements ExceptionHandler { 15 | @Override 16 | public boolean execute(BaseCommand command, RegisteredCommand registeredCommand, CommandIssuer sender, List args, Throwable t) { 17 | Logging.severe("Failed to execute command /%s %s %s", 18 | registeredCommand.getCommand(), registeredCommand.getPrefSubCommand(), String.join(" ", args)); 19 | t.printStackTrace(); 20 | return false; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/MVRootCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command; 2 | 3 | import co.aikar.commands.BaseCommand; 4 | import co.aikar.commands.BukkitCommandManager; 5 | import co.aikar.commands.BukkitRootCommand; 6 | import co.aikar.commands.CommandIssuer; 7 | import org.mvplugins.multiverse.core.utils.StringFormatter; 8 | 9 | import java.util.List; 10 | 11 | public class MVRootCommand extends BukkitRootCommand { 12 | protected MVRootCommand(BukkitCommandManager manager, String name) { 13 | super(manager, name); 14 | } 15 | 16 | @Override 17 | public BaseCommand execute(CommandIssuer sender, String commandLabel, String[] args) { 18 | String[] quoteFormatedArgs = StringFormatter.parseQuotesInArgs(args).toArray(String[]::new); 19 | return super.execute(sender, commandLabel, quoteFormatedArgs); 20 | } 21 | 22 | @Override 23 | public List getTabCompletions(CommandIssuer sender, String alias, String[] args, boolean commandsOnly, boolean isAsync) { 24 | String[] quoteFormatedArgs = StringFormatter.parseQuotesInArgs(args).toArray(String[]::new); 25 | return super.getTabCompletions(sender, alias, quoteFormatedArgs, commandsOnly, isAsync); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/MultiverseCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command; 2 | 3 | import co.aikar.commands.BaseCommand; 4 | import com.dumptruckman.minecraft.util.Logging; 5 | import jakarta.annotation.PostConstruct; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jvnet.hk2.annotations.Contract; 8 | 9 | import org.mvplugins.multiverse.core.command.flag.CommandFlag; 10 | import org.mvplugins.multiverse.core.command.flag.CommandFlagGroup; 11 | import org.mvplugins.multiverse.core.command.flag.CommandFlagsManager; 12 | import org.mvplugins.multiverse.core.command.flag.ParsedCommandFlags; 13 | 14 | /** 15 | * Base class for all Multiverse commands. 16 | */ 17 | @Contract 18 | public abstract class MultiverseCommand extends BaseCommand { 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/context/GameRuleValue.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.context; 2 | 3 | /** 4 | * Simple wrapper for game rule value, as they may be different types. 5 | */ 6 | public record GameRuleValue(Object value) { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/context/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.context; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flag/FlagBuilder.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.flag; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import jakarta.annotation.PostConstruct; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jvnet.hk2.annotations.Contract; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Builds and registers a flag group on initialization. Flags should be final fields that calls {@link #flag(CommandFlag)}. 13 | */ 14 | @Contract 15 | public abstract class FlagBuilder { 16 | 17 | private final String name; 18 | private final CommandFlagsManager flagsManager; 19 | private final List flags; 20 | 21 | protected FlagBuilder(@NotNull String name, @NotNull CommandFlagsManager flagsManager) { 22 | this.name = name; 23 | this.flagsManager = flagsManager; 24 | this.flags = new ArrayList<>(); 25 | } 26 | 27 | @PostConstruct 28 | private void postConstruct() { 29 | CommandFlagGroup.Builder flagGroupBuilder = CommandFlagGroup.builder(name); 30 | flags.forEach(flagGroupBuilder::add); 31 | registerFlagGroup(flagGroupBuilder.build()); 32 | } 33 | 34 | private void registerFlagGroup(@NotNull CommandFlagGroup flagGroup) { 35 | flagsManager.registerFlagGroup(flagGroup); 36 | Logging.finer("Registered flag group: " + flagGroup.getName()); 37 | } 38 | 39 | /** 40 | * Add a new flag to the flag builder. 41 | * 42 | * @param flag The flag to add. 43 | * @param The type of the flag. 44 | * @return The flag. 45 | */ 46 | protected T flag(T flag) { 47 | flags.add(flag); 48 | Logging.finer("Added flag: " + flag); 49 | return flag; 50 | } 51 | 52 | /** 53 | * Parses flags. 54 | * 55 | * @param flags The raw string array to parse into flags. 56 | * @return The parsed flags. 57 | */ 58 | public @NotNull ParsedCommandFlags parse(@NotNull String[] flags) { 59 | return flagsManager.parse(name, flags); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flag/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains classes related to parsing command flags. 3 | */ 4 | package org.mvplugins.multiverse.core.command.flag; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flags/FilterCommandFlag.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.flags; 2 | 3 | import java.util.List; 4 | import java.util.function.Function; 5 | 6 | import co.aikar.commands.InvalidCommandArgument; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import org.mvplugins.multiverse.core.command.flag.CommandValueFlag; 10 | import org.mvplugins.multiverse.core.display.filters.ContentFilter; 11 | import org.mvplugins.multiverse.core.display.filters.RegexContentFilter; 12 | 13 | /** 14 | * A command flag for regex filtering. 15 | *
16 | * Parses the value of the --filter (or -f) flag as a {@link ContentFilter}. 17 | */ 18 | public final class FilterCommandFlag extends CommandValueFlag { 19 | 20 | private static final Function VALUE_PARSER = value -> { 21 | try { 22 | return RegexContentFilter.fromString(value); 23 | } catch (IllegalArgumentException e) { 24 | throw new InvalidCommandArgument("Invalid filter: " + value); 25 | } 26 | }; 27 | 28 | /** 29 | * Creates a new instance of this flag. 30 | * 31 | * @return The new instance. 32 | */ 33 | @NotNull 34 | public static FilterCommandFlag create() { 35 | return new FilterCommandFlag(); 36 | } 37 | 38 | private FilterCommandFlag() { 39 | super("--filter", List.of("-f"), ContentFilter.class, false, null, VALUE_PARSER, null); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flags/PageCommandFlag.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.flags; 2 | 3 | import java.util.List; 4 | import java.util.function.Function; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import org.mvplugins.multiverse.core.command.flag.CommandValueFlag; 9 | 10 | /** 11 | * A command flag for page number. 12 | *
13 | * Parses the value of the --page (or -p) flag as an integer. 14 | */ 15 | public final class PageCommandFlag extends CommandValueFlag { 16 | 17 | private static final Function VALUE_PARSER = value -> { 18 | try { 19 | return Integer.parseInt(value); 20 | } catch (NumberFormatException e) { 21 | throw new IllegalArgumentException("Invalid page number: " + value); 22 | } 23 | }; 24 | 25 | /** 26 | * Creates a new instance of this flag. 27 | * 28 | * @return The new instance. 29 | */ 30 | @NotNull 31 | public static PageCommandFlag create() { 32 | return new PageCommandFlag(); 33 | } 34 | 35 | private PageCommandFlag() { 36 | super("--page", List.of("-p"), Integer.class, false, null, VALUE_PARSER, null); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flags/PageFilterFlags.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.flags; 2 | 3 | import jakarta.inject.Inject; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jvnet.hk2.annotations.Service; 6 | import org.mvplugins.multiverse.core.command.flag.CommandFlagsManager; 7 | import org.mvplugins.multiverse.core.command.flag.CommandValueFlag; 8 | import org.mvplugins.multiverse.core.command.flag.FlagBuilder; 9 | import org.mvplugins.multiverse.core.display.filters.ContentFilter; 10 | 11 | @Service 12 | public class PageFilterFlags extends FlagBuilder { 13 | 14 | public static final String NAME = "pagefilter"; 15 | 16 | protected PageFilterFlags(@NotNull String name, @NotNull CommandFlagsManager flagsManager) { 17 | super(name, flagsManager); 18 | } 19 | 20 | @Inject 21 | protected PageFilterFlags(@NotNull CommandFlagsManager flagsManager) { 22 | super(NAME, flagsManager); 23 | } 24 | 25 | public final CommandValueFlag page = flag(PageCommandFlag.create()); 26 | 27 | public final CommandValueFlag filter = flag(FilterCommandFlag.create()); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flags/RemovePlayerFlags.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.flags; 2 | 3 | import jakarta.inject.Inject; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jvnet.hk2.annotations.Service; 6 | import org.mvplugins.multiverse.core.command.flag.CommandFlag; 7 | import org.mvplugins.multiverse.core.command.flag.CommandFlagsManager; 8 | import org.mvplugins.multiverse.core.command.flag.FlagBuilder; 9 | 10 | @Service 11 | public class RemovePlayerFlags extends FlagBuilder { 12 | 13 | public static final String NAME = "removeplayer"; 14 | 15 | protected RemovePlayerFlags(@NotNull String name, @NotNull CommandFlagsManager flagsManager) { 16 | super(name, flagsManager); 17 | } 18 | 19 | @Inject 20 | protected RemovePlayerFlags(@NotNull CommandFlagsManager flagsManager) { 21 | super(NAME, flagsManager); 22 | } 23 | 24 | public final CommandFlag removePlayers = flag(CommandFlag.builder("--remove-players") 25 | .addAlias("-r") 26 | .build()); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flags/UnsafeFlags.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.flags; 2 | 3 | import jakarta.inject.Inject; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jvnet.hk2.annotations.Service; 6 | import org.mvplugins.multiverse.core.command.flag.CommandFlag; 7 | import org.mvplugins.multiverse.core.command.flag.CommandFlagsManager; 8 | import org.mvplugins.multiverse.core.command.flag.FlagBuilder; 9 | 10 | @Service 11 | public class UnsafeFlags extends FlagBuilder { 12 | 13 | public static final String NAME = "unsafe"; 14 | 15 | protected UnsafeFlags(@NotNull String name, @NotNull CommandFlagsManager flagsManager) { 16 | super(name, flagsManager); 17 | } 18 | 19 | @Inject 20 | protected UnsafeFlags(@NotNull CommandFlagsManager flagsManager) { 21 | super(NAME, flagsManager); 22 | } 23 | 24 | public final CommandFlag unsafe = flag(CommandFlag.builder("--unsafe") 25 | .addAlias("-u") 26 | .build()); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/flags/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains predefined flags for commands. 3 | */ 4 | package org.mvplugins.multiverse.core.command.flags; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the classes that manages command handling. 3 | */ 4 | package org.mvplugins.multiverse.core.command; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/queue/ConfirmMode.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.queue; 2 | 3 | /** 4 | * Sets whether the command executor needs to confirm before executing a command. 5 | */ 6 | public enum ConfirmMode { 7 | /** 8 | * Every command executor needs to confirm before executing a command. 9 | */ 10 | ENABLE, 11 | 12 | /** 13 | * Only players need to confirm before executing a command. Command blocks and console will not need to confirm. 14 | */ 15 | PLAYER_ONLY, 16 | 17 | /** 18 | * Everyone except command blocks will not need to confirm before executing a command. 19 | */ 20 | DISABLE_COMMAND_BLOCKS, 21 | 22 | /** 23 | * Everyone except console will not need to confirm before executing a command. 24 | */ 25 | DISABLE_CONSOLE, 26 | 27 | /** 28 | * Everyone will not need to confirm before executing a command. 29 | */ 30 | DISABLE, 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/queue/RunQueuedFailedReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.command.queue; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 6 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 7 | 8 | public enum RunQueuedFailedReason implements FailureReason { 9 | NO_COMMAND_IN_QUEUE(MVCorei18n.QUEUECOMMAND_NOCOMMANDINQUEUE), 10 | INVALID_OTP(MVCorei18n.QUEUECOMMAND_INVALIDOTP), 11 | COMMAND_EXECUTION_ERROR(MVCorei18n.QUEUECOMMAND_COMMANDEXECUTIONERROR), 12 | ; 13 | 14 | private final MessageKeyProvider message; 15 | 16 | RunQueuedFailedReason(MessageKeyProvider message) { 17 | this.message = message; 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | public MessageKey getMessageKey() { 25 | return message.getMessageKey(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/command/queue/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Manager queuing of dangerous commands in need of confirmation. 3 | */ 4 | package org.mvplugins.multiverse.core.command.queue; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/AnchorDeleteCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.annotation.CommandCompletion; 4 | import co.aikar.commands.annotation.CommandPermission; 5 | import co.aikar.commands.annotation.Description; 6 | import co.aikar.commands.annotation.Subcommand; 7 | import co.aikar.commands.annotation.Syntax; 8 | import jakarta.inject.Inject; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jvnet.hk2.annotations.Service; 11 | 12 | import org.mvplugins.multiverse.core.anchor.AnchorManager; 13 | import org.mvplugins.multiverse.core.anchor.MultiverseAnchor; 14 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 15 | 16 | @Service 17 | final class AnchorDeleteCommand extends CoreCommand { 18 | 19 | private final AnchorManager anchorManager; 20 | 21 | @Inject 22 | AnchorDeleteCommand(@NotNull AnchorManager anchorManager) { 23 | this.anchorManager = anchorManager; 24 | } 25 | 26 | @Subcommand("anchor delete") 27 | @CommandPermission("multiverse.core.anchor.delete") 28 | @CommandCompletion("@anchornames") 29 | @Syntax("") 30 | @Description("") 31 | void onAnchorDeleteCommand( 32 | MVCommandIssuer issuer, 33 | 34 | @Syntax("") 35 | @Description("") 36 | MultiverseAnchor anchor) { 37 | if (anchorManager.deleteAnchor(anchor).isSuccess()) { 38 | issuer.sendMessage("&aAnchor &f" + anchor.getName() + "&a deleted."); 39 | } else { 40 | issuer.sendMessage("&cFailed to delete anchor."); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/ConfirmCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.annotation.CommandAlias; 4 | import co.aikar.commands.annotation.CommandPermission; 5 | import co.aikar.commands.annotation.Default; 6 | import co.aikar.commands.annotation.Description; 7 | import co.aikar.commands.annotation.Subcommand; 8 | import co.aikar.commands.annotation.Syntax; 9 | import jakarta.inject.Inject; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jvnet.hk2.annotations.Service; 12 | 13 | import org.mvplugins.multiverse.core.command.LegacyAliasCommand; 14 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 15 | import org.mvplugins.multiverse.core.command.queue.CommandQueueManager; 16 | 17 | @Service 18 | class ConfirmCommand extends CoreCommand { 19 | 20 | @NotNull 21 | private final CommandQueueManager commandQueueManager; 22 | 23 | @Inject 24 | ConfirmCommand(@NotNull CommandQueueManager commandQueueManager) { 25 | this.commandQueueManager = commandQueueManager; 26 | } 27 | 28 | @Subcommand("confirm") 29 | @CommandPermission("multiverse.core.confirm") 30 | @Syntax("[otp]") 31 | @Description("{@@mv-core.confirm.description}") 32 | void onConfirmCommand( 33 | MVCommandIssuer issuer, 34 | 35 | @Default("0") 36 | String otp) { 37 | this.commandQueueManager.runQueuedCommand(issuer, otp) 38 | .onFailure(failure -> issuer.sendError(failure.getFailureMessage())); 39 | } 40 | 41 | @Service 42 | private final static class LegacyAlias extends ConfirmCommand implements LegacyAliasCommand { 43 | @Inject 44 | LegacyAlias(@NotNull CommandQueueManager commandQueueCommand) { 45 | super(commandQueueCommand); 46 | } 47 | 48 | @Override 49 | @CommandAlias("mvconfirm") 50 | void onConfirmCommand(MVCommandIssuer issuer, String otp) { 51 | super.onConfirmCommand(issuer, otp); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/CoreCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.annotation.CommandAlias; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jvnet.hk2.annotations.Contract; 6 | 7 | import org.mvplugins.multiverse.core.command.MVCommandManager; 8 | import org.mvplugins.multiverse.core.command.MultiverseCommand; 9 | 10 | /** 11 | * Represents a command that is part of the Multiverse-Core plugin. 12 | */ 13 | @Contract 14 | @CommandAlias("mv") 15 | public abstract class CoreCommand extends MultiverseCommand { 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/HelpCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.CommandHelp; 4 | import co.aikar.commands.annotation.CommandAlias; 5 | import co.aikar.commands.annotation.CommandCompletion; 6 | import co.aikar.commands.annotation.CommandPermission; 7 | import co.aikar.commands.annotation.Description; 8 | import co.aikar.commands.annotation.Subcommand; 9 | import co.aikar.commands.annotation.Syntax; 10 | import jakarta.inject.Inject; 11 | import org.jetbrains.annotations.NotNull; 12 | import org.jvnet.hk2.annotations.Service; 13 | 14 | import org.mvplugins.multiverse.core.command.LegacyAliasCommand; 15 | import org.mvplugins.multiverse.core.command.MVCommandManager; 16 | import org.mvplugins.multiverse.core.config.CoreConfig; 17 | 18 | @Service 19 | class HelpCommand extends CoreCommand { 20 | 21 | private final MVCommandManager commandManager; 22 | 23 | @Inject 24 | HelpCommand(@NotNull MVCommandManager commandManager) { 25 | this.commandManager = commandManager; 26 | } 27 | 28 | @co.aikar.commands.annotation.HelpCommand 29 | @Subcommand("help") 30 | @CommandPermission("multiverse.core.help") 31 | @CommandCompletion("@commands:mv") 32 | @Syntax("[filter] [page]") 33 | @Description("{@@mv-core.usage.description}") 34 | void onHelpCommand(CommandHelp help) { 35 | if (help.getIssuer().isPlayer()) { 36 | // Prevent flooding the chat 37 | help.setPerPage(4); 38 | } 39 | this.commandManager.showUsage(help); 40 | } 41 | 42 | @Service 43 | private static final class LegacyAlias extends HelpCommand implements LegacyAliasCommand { 44 | @Inject 45 | LegacyAlias(@NotNull MVCommandManager commandManager) { 46 | super(commandManager); 47 | } 48 | 49 | @Override 50 | @CommandAlias("mvhelp") 51 | public void onHelpCommand(CommandHelp help) { 52 | super.onHelpCommand(help); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/PurgeEntitiesCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.annotation.CommandCompletion; 4 | import co.aikar.commands.annotation.CommandPermission; 5 | import co.aikar.commands.annotation.Flags; 6 | import co.aikar.commands.annotation.Subcommand; 7 | import co.aikar.commands.annotation.Syntax; 8 | import jakarta.inject.Inject; 9 | import org.jvnet.hk2.annotations.Service; 10 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 11 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 12 | import org.mvplugins.multiverse.core.world.entity.EntityPurger; 13 | 14 | @Service 15 | final class PurgeEntitiesCommand extends CoreCommand { 16 | 17 | private final EntityPurger entityPurger; 18 | 19 | @Inject 20 | PurgeEntitiesCommand(EntityPurger entityPurger) { 21 | this.entityPurger = entityPurger; 22 | } 23 | 24 | @Subcommand("purge-entities") 25 | @CommandPermission("multiverse.core.purge") 26 | @CommandCompletion("@mvworlds:scope=loaded") 27 | @Syntax("[world]") 28 | void onPurgeEntityCommand( 29 | MVCommandIssuer issuer, 30 | 31 | @Flags("resolve=issuerAware") 32 | @Syntax("[world]") 33 | LoadedMultiverseWorld world 34 | ) { 35 | int purgeCount = entityPurger.purgeEntities(world); 36 | issuer.sendMessage("Successfully purged " + purgeCount + " entities in world " + world.getName() + "."); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/RootCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.CommandIssuer; 4 | import co.aikar.commands.annotation.CommandAlias; 5 | import jakarta.inject.Inject; 6 | import org.bukkit.plugin.Plugin; 7 | import org.bukkit.plugin.PluginDescriptionFile; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jvnet.hk2.annotations.Service; 10 | 11 | import org.mvplugins.multiverse.core.MultiverseCore; 12 | import org.mvplugins.multiverse.core.command.MVCommandManager; 13 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 14 | 15 | @Service 16 | final class RootCommand extends CoreCommand { 17 | 18 | private final Plugin plugin; 19 | 20 | @Inject 21 | RootCommand(@NotNull MultiverseCore plugin) { 22 | this.plugin = plugin; 23 | } 24 | 25 | @CommandAlias("mv") 26 | void onRootCommand(CommandIssuer issuer) { 27 | PluginDescriptionFile description = this.plugin.getDescription(); 28 | issuer.sendInfo(MVCorei18n.ROOT_TITLE, 29 | "{name}", description.getName(), 30 | "{version}", description.getVersion()); 31 | issuer.sendInfo(MVCorei18n.ROOT_HELP); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/VersionCommand.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands; 2 | 3 | import co.aikar.commands.BukkitCommandIssuer; 4 | import co.aikar.commands.MessageType; 5 | import co.aikar.commands.annotation.CommandAlias; 6 | import co.aikar.commands.annotation.CommandPermission; 7 | import co.aikar.commands.annotation.Description; 8 | import co.aikar.commands.annotation.Subcommand; 9 | import jakarta.inject.Inject; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jvnet.hk2.annotations.Service; 12 | 13 | import org.mvplugins.multiverse.core.MultiverseCore; 14 | import org.mvplugins.multiverse.core.command.LegacyAliasCommand; 15 | import org.mvplugins.multiverse.core.command.MVCommandManager; 16 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 17 | 18 | @Service 19 | class VersionCommand extends CoreCommand { 20 | 21 | private final MultiverseCore plugin; 22 | 23 | @Inject 24 | VersionCommand(MultiverseCore plugin) { 25 | this.plugin = plugin; 26 | } 27 | 28 | @Subcommand("version") 29 | @CommandPermission("multiverse.core.version") 30 | @Description("{@@mv-core.version.description}") 31 | void versionCommand(BukkitCommandIssuer issuer) { 32 | issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_MV, "{version}", plugin.getDescription().getVersion()); 33 | issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_AUTHORS, 34 | "{authors}", String.join(", ", plugin.getDescription().getAuthors())); 35 | // An in joke I don't get... 36 | issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_SECRETCODE); 37 | } 38 | 39 | @Service 40 | private static final class LegacyAlias extends VersionCommand implements LegacyAliasCommand { 41 | @Inject 42 | LegacyAlias(MultiverseCore plugin) { 43 | super(plugin); 44 | } 45 | 46 | @Override 47 | @CommandAlias("mvversion") 48 | void versionCommand(BukkitCommandIssuer issuer) { 49 | super.versionCommand(issuer); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the commands for Multiverse-Core. 3 | */ 4 | package org.mvplugins.multiverse.core.commands; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/handle/PropertyModifyAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.handle; 2 | 3 | /** 4 | * The type of modification to a config. 5 | */ 6 | public enum PropertyModifyAction { 7 | /** 8 | * Sets a new value based on the provided input. 9 | */ 10 | SET(true), 11 | 12 | /** 13 | * Add an item to a list. Only applies to values of type List. 14 | */ 15 | ADD(true), 16 | 17 | /** 18 | * Remove an item from a list. Only applies to values of type List. 19 | */ 20 | REMOVE(true), 21 | 22 | /** 23 | * Reset the value to the default. 24 | */ 25 | RESET(false), 26 | ; 27 | 28 | private final boolean requireValue; 29 | 30 | PropertyModifyAction(boolean requireValue) { 31 | this.requireValue = requireValue; 32 | } 33 | 34 | /** 35 | * Whether this action requires a value. 36 | * 37 | * @return True if this action requires a value, false otherwise. 38 | */ 39 | public boolean isRequireValue() { 40 | return requireValue; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/handle/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.handle; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/BooleanMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import co.aikar.commands.ACFUtil; 4 | import com.dumptruckman.minecraft.util.Logging; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | /** 8 | * Single migrator action that converts a string value to a boolean. 9 | */ 10 | public final class BooleanMigratorAction implements MigratorAction { 11 | 12 | public static BooleanMigratorAction of(String path) { 13 | return new BooleanMigratorAction(path); 14 | } 15 | 16 | private final String path; 17 | 18 | private BooleanMigratorAction(String path) { 19 | this.path = path; 20 | } 21 | 22 | @Override 23 | public void migrate(ConfigurationSection config) { 24 | config.set(path, ACFUtil.isTruthy(config.getString(path, ""))); 25 | Logging.config("Converted %s to boolean %s", path, config.getBoolean(path)); 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/DeleteMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | public final class DeleteMigratorAction implements MigratorAction { 7 | 8 | public static DeleteMigratorAction of(String path) { 9 | return new DeleteMigratorAction(path); 10 | } 11 | 12 | private final String path; 13 | 14 | private DeleteMigratorAction(String path) { 15 | this.path = path; 16 | } 17 | 18 | @Override 19 | public void migrate(ConfigurationSection config) { 20 | config.set(path, null); 21 | Logging.config("Deleted %s", path); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/DoubleMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import co.aikar.commands.ACFUtil; 4 | import com.dumptruckman.minecraft.util.Logging; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public final class DoubleMigratorAction implements MigratorAction { 8 | 9 | public static DoubleMigratorAction of(String path) { 10 | return new DoubleMigratorAction(path); 11 | } 12 | 13 | private final String path; 14 | 15 | private DoubleMigratorAction(String path) { 16 | this.path = path; 17 | } 18 | 19 | @Override 20 | public void migrate(ConfigurationSection config) { 21 | config.set(path, ACFUtil.parseDouble(config.getString(path))); 22 | Logging.config("Converted %s to double %s", path, config.getDouble(path)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/IntegerMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import co.aikar.commands.ACFUtil; 4 | import com.dumptruckman.minecraft.util.Logging; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | /** 8 | * Single migrator action that converts a string value to an integer. 9 | */ 10 | public final class IntegerMigratorAction implements MigratorAction { 11 | 12 | public static IntegerMigratorAction of(String path) { 13 | return new IntegerMigratorAction(path); 14 | } 15 | 16 | private final String path; 17 | 18 | private IntegerMigratorAction(String path) { 19 | this.path = path; 20 | } 21 | 22 | @Override 23 | public void migrate(ConfigurationSection config) { 24 | config.set(path, ACFUtil.parseInt(config.getString(path))); 25 | Logging.config("Converted %s to integer %s", path, config.getInt(path)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/InvertBoolMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | /** 7 | * Single migrator action that inverts a boolean value for a given path. 8 | */ 9 | public final class InvertBoolMigratorAction implements MigratorAction { 10 | 11 | /** 12 | * Creates a new migrator action that inverts a boolean value for a given path. 13 | * 14 | * @param path The path to invert value of. 15 | * @return The new migrator action. 16 | */ 17 | public static InvertBoolMigratorAction of(String path) { 18 | return new InvertBoolMigratorAction(path); 19 | } 20 | 21 | private final String path; 22 | 23 | private InvertBoolMigratorAction(String path) { 24 | this.path = path; 25 | } 26 | 27 | /** 28 | * {@inheritDoc} 29 | */ 30 | @Override 31 | public void migrate(ConfigurationSection config) { 32 | boolean boolValue = !config.getBoolean(path); 33 | config.set(path, boolValue); 34 | Logging.config("Inverted %s to boolean %s", path, boolValue); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/LongMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import co.aikar.commands.ACFUtil; 4 | import com.dumptruckman.minecraft.util.Logging; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | /** 8 | * Single migrator action that converts a string value to a long. 9 | */ 10 | public final class LongMigratorAction implements MigratorAction { 11 | 12 | public static LongMigratorAction of(String path) { 13 | return new LongMigratorAction(path); 14 | } 15 | 16 | private final String path; 17 | 18 | private LongMigratorAction(String path) { 19 | this.path = path; 20 | } 21 | 22 | /** 23 | * {@inheritDoc} 24 | */ 25 | @Override 26 | public void migrate(ConfigurationSection config) { 27 | config.set(path, ACFUtil.parseLong(config.getString(path))); 28 | Logging.config("Converted %s to long %s", path, config.getLong(path)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/MigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import org.bukkit.configuration.ConfigurationSection; 4 | 5 | /** 6 | * A migrator action is a single action that is performed when migrating a config. 7 | */ 8 | public interface MigratorAction { 9 | 10 | /** 11 | * Performs the migration action. 12 | * 13 | * @param config The target settings instance to migrate. 14 | */ 15 | void migrate(ConfigurationSection config); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/MoveMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import java.util.Optional; 4 | 5 | import com.dumptruckman.minecraft.util.Logging; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | 8 | /** 9 | * Single migrator action that moves a value from one path to another. 10 | */ 11 | public final class MoveMigratorAction implements MigratorAction { 12 | 13 | /** 14 | * Creates a new migrator action that moves a value from one path to another. 15 | * 16 | * @param fromPath The path to move value from. 17 | * @param toPath The path to move value to. 18 | * @return The new migrator action. 19 | */ 20 | public static MoveMigratorAction of(String fromPath, String toPath) { 21 | return new MoveMigratorAction(fromPath, toPath); 22 | } 23 | 24 | private final String fromPath; 25 | private final String toPath; 26 | 27 | private MoveMigratorAction(String fromPath, String toPath) { 28 | this.fromPath = fromPath; 29 | this.toPath = toPath; 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | @Override 36 | public void migrate(ConfigurationSection config) { 37 | Optional.ofNullable(config.get(fromPath)) 38 | .ifPresent(value -> { 39 | config.set(fromPath, null); 40 | config.set(toPath, value); 41 | Logging.config("Moved path %s to %s", fromPath, toPath); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/NullStringMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | /** 7 | * Single migrator action changes a string value of "null" to an empty string. 8 | */ 9 | public final class NullStringMigratorAction implements MigratorAction { 10 | 11 | public static NullStringMigratorAction of(String path) { 12 | return new NullStringMigratorAction(path); 13 | } 14 | 15 | private final String path; 16 | 17 | private NullStringMigratorAction(String path) { 18 | this.path = path; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public void migrate(ConfigurationSection config) { 26 | config.set(path, "null".equals(config.getString(path)) ? "" : config.getString(path)); 27 | Logging.config("Converted %s to %s", path, config.getString(path)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/action/SetMigratorAction.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration.action; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public final class SetMigratorAction implements MigratorAction { 9 | 10 | public static SetMigratorAction of(String path, T value) { 11 | return new SetMigratorAction<>(path, () -> value); 12 | } 13 | 14 | public static SetMigratorAction of(String path, Supplier value) { 15 | return new SetMigratorAction<>(path, value); 16 | } 17 | 18 | private final String path; 19 | private final Supplier value; 20 | 21 | SetMigratorAction(String path, Supplier value) { 22 | this.path = path; 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public void migrate(ConfigurationSection config) { 28 | config.set(path, value.get()); 29 | Logging.config("Set %s to %s", path, value.get()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/migration/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.migration; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/CommentedNode.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface CommentedNode extends Node { 6 | 7 | /** 8 | * Gets the comment of the node. 9 | * 10 | * @return The comment of the node. 11 | */ 12 | @NotNull String[] getComments(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/ConfigNodeNotFoundException.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import org.mvplugins.multiverse.core.exceptions.MultiverseException; 6 | 7 | import static org.mvplugins.multiverse.core.locale.MVCorei18n.CONFIG_NODE_NOTFOUND; 8 | import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace; 9 | 10 | public class ConfigNodeNotFoundException extends MultiverseException { 11 | 12 | public ConfigNodeNotFoundException(@Nullable String nodeName) { 13 | super(CONFIG_NODE_NOTFOUND.bundle("Config node not found: {node}", replace("{node}").with(nodeName)), null); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/ListValueNode.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | 6 | import io.vavr.control.Try; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import org.mvplugins.multiverse.core.config.node.serializer.NodeSerializer; 11 | 12 | /** 13 | * A node that holds a list of values of a specific type. 14 | * 15 | * @param The type of list item. 16 | */ 17 | public interface ListValueNode extends ValueNode> { 18 | 19 | /** 20 | * Gets the class type of list item. 21 | * 22 | * @return The class type of list item. 23 | */ 24 | @NotNull Class getItemType(); 25 | 26 | /** 27 | * Suggests possible string values for this node. 28 | * 29 | * @param input The input string. 30 | * @return A collection of possible string values. 31 | */ 32 | @NotNull Collection suggestItem(@Nullable String input); 33 | 34 | /** 35 | * Parses the given string into a value of type {@link I}. Used for property set by user input. 36 | * 37 | * @param input The string to parse. 38 | * @return The parsed value, or given exception if parsing failed. 39 | */ 40 | @NotNull Try parseItemFromString(@Nullable String input); 41 | 42 | /** 43 | * Gets the serializer for this node. 44 | * 45 | * @return The serializer for this node. 46 | */ 47 | @Nullable NodeSerializer getItemSerializer(); 48 | 49 | /** 50 | * Validates the value of this node. 51 | * 52 | * @param value The value to validate. 53 | * @return A successful try if validation passed, else the exception object throw. 54 | */ 55 | Try validateItem(@Nullable I value); 56 | 57 | /** 58 | * Called when the value of this node is set. 59 | * 60 | * @param oldValue The old value. 61 | * @param newValue The new value. 62 | */ 63 | void onSetItemValue(@Nullable I oldValue, @Nullable I newValue); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/Node.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface Node { 6 | 7 | /** 8 | * Gets the YAML path of the node. 9 | * 10 | * @return The YAML path of the node. 11 | */ 12 | @NotNull String getPath(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/functions/NodeStringParser.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node.functions; 2 | 3 | import io.vavr.control.Try; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | /** 8 | * A function that parses a string into a node value object of type {@link T}. 9 | * 10 | * @param The type of the object to parse. 11 | */ 12 | @FunctionalInterface 13 | public interface NodeStringParser { 14 | /** 15 | * Parses a string into a node value object of type {@link T}. 16 | * 17 | * @param string The string to parse. 18 | * @param type The type of the object to parse. 19 | * @return The parsed object, or {@link Try.Failure} if the string could not be parsed. 20 | */ 21 | @NotNull Try parse(@Nullable String string, @NotNull Class type); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/functions/NodeSuggester.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node.functions; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | /** 9 | * A function that suggests possible values for a node value. 10 | */ 11 | @FunctionalInterface 12 | public interface NodeSuggester { 13 | /** 14 | * Suggests possible values for a node value. Generated based on the current user input. 15 | * 16 | * @param input The current partial user input 17 | * @return The possible values. 18 | */ 19 | @NotNull Collection suggest(@Nullable String input); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/functions/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node.functions; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/node/serializer/NodeSerializer.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config.node.serializer; 2 | 3 | /** 4 | * A function that serializes and deserializes objects to and from YAML. 5 | * 6 | * @param The type of the object to serialize and deserialize. 7 | */ 8 | public interface NodeSerializer { 9 | /** 10 | * Deserializes an object from YAML. 11 | * 12 | * @param object The object to deserialize. 13 | * @param type The type of the object to deserialize. 14 | * @return The deserialized typed value. 15 | */ 16 | T deserialize(Object object, Class type); 17 | 18 | /** 19 | * Serializes an object to YAML. 20 | * 21 | * @param object The object to serialize. 22 | * @param type The type of the object to serialize. 23 | * @return The serialized object. 24 | */ 25 | Object serialize(T object, Class type); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/config/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.config; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/destination/DestinationSuggestionPacket.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.destination; 2 | 3 | /** 4 | * Data of a possible destination for tab completion and permission checking 5 | * 6 | * @param destination The destination 7 | * @param destinationString The destination string 8 | * @param finerPermissionSuffix The finer permission suffix 9 | */ 10 | public record DestinationSuggestionPacket(Destination destination, String destinationString, String finerPermissionSuffix) { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/destination/core/AnchorDestinationInstance.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.destination.core; 2 | 3 | import io.vavr.control.Option; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Entity; 6 | import org.bukkit.util.Vector; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import org.mvplugins.multiverse.core.destination.DestinationInstance; 10 | 11 | /** 12 | * Destination instance implementation for the {@link AnchorDestination}. 13 | */ 14 | public final class AnchorDestinationInstance extends DestinationInstance { 15 | private final String anchorName; 16 | private final Location anchorLocation; 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param anchorName The name of the anchor. 22 | * @param anchorLocation The location of the anchor. 23 | */ 24 | AnchorDestinationInstance( 25 | @NotNull AnchorDestination destination, 26 | @NotNull String anchorName, 27 | @NotNull Location anchorLocation 28 | ) { 29 | super(destination); 30 | this.anchorName = anchorName; 31 | this.anchorLocation = anchorLocation; 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | @Override 38 | public @NotNull Option getLocation(@NotNull Entity teleportee) { 39 | return Option.of(anchorLocation.clone()); 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | @Override 46 | public @NotNull Option getVelocity(@NotNull Entity teleportee) { 47 | return Option.none(); 48 | } 49 | 50 | /** 51 | * {@inheritDoc} 52 | */ 53 | @Override 54 | public boolean checkTeleportSafety() { 55 | return true; 56 | } 57 | 58 | /** 59 | * {@inheritDoc} 60 | */ 61 | @Override 62 | public @NotNull Option getFinerPermissionSuffix() { 63 | return Option.of(anchorName); 64 | } 65 | 66 | /** 67 | * {@inheritDoc} 68 | */ 69 | @Override 70 | public @NotNull String serialise() { 71 | return anchorName; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/destination/core/BedDestinationInstance.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.destination.core; 2 | 3 | import io.vavr.control.Option; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Entity; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.util.Vector; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.jetbrains.annotations.Nullable; 10 | 11 | import org.mvplugins.multiverse.core.destination.DestinationInstance; 12 | 13 | /** 14 | * Destination instance implementation for the {@link BedDestination}. 15 | */ 16 | public final class BedDestinationInstance extends DestinationInstance { 17 | private final Player player; 18 | 19 | /** 20 | * Constructor. 21 | * 22 | * @param player The player whose bed to use. 23 | */ 24 | BedDestinationInstance(@NotNull BedDestination destination, @Nullable Player player) { 25 | super(destination); 26 | this.player = player; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | @Override 33 | public @NotNull Option getLocation(@NotNull Entity teleportee) { 34 | if (player != null) { 35 | return Option.of(player.getBedSpawnLocation()); 36 | } 37 | if (teleportee instanceof Player) { 38 | return Option.of(((Player) teleportee).getBedSpawnLocation()); 39 | } 40 | return Option.none(); 41 | } 42 | 43 | /** 44 | * {@inheritDoc} 45 | */ 46 | @Override 47 | public @NotNull Option getVelocity(@NotNull Entity teleportee) { 48 | return Option.none(); 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | @Override 55 | public boolean checkTeleportSafety() { 56 | return false; 57 | } 58 | 59 | /** 60 | * {@inheritDoc} 61 | */ 62 | @Override 63 | public @NotNull Option getFinerPermissionSuffix() { 64 | return Option.of(player != null ? player.getName() : BedDestination.OWN_BED_STRING); 65 | } 66 | 67 | /** 68 | * {@inheritDoc} 69 | */ 70 | @Override 71 | public @NotNull String serialise() { 72 | return player != null ? player.getName() : BedDestination.OWN_BED_STRING; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/destination/core/PlayerDestinationInstance.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.destination.core; 2 | 3 | import io.vavr.control.Option; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.Entity; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.util.Vector; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import org.mvplugins.multiverse.core.destination.DestinationInstance; 12 | 13 | import java.util.UUID; 14 | 15 | /** 16 | * Destination instance implementation for the {@link PlayerDestination}. 17 | */ 18 | public final class PlayerDestinationInstance extends DestinationInstance { 19 | private final UUID playerUUID; 20 | private final String playerName; 21 | 22 | /** 23 | * Constructor. 24 | * 25 | * @param player The player whose location to go to. 26 | */ 27 | PlayerDestinationInstance(@NotNull PlayerDestination destination, @NotNull Player player) { 28 | super(destination); 29 | this.playerUUID = player.getUniqueId(); 30 | this.playerName = player.getName(); 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | @Override 37 | public @NotNull Option getLocation(@NotNull Entity teleportee) { 38 | Player player = Bukkit.getPlayer(playerUUID); 39 | if (player == null || !player.isOnline()) { 40 | return Option.none(); 41 | } 42 | return Option.of(player.getLocation()); 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | public @NotNull Option getVelocity(@NotNull Entity teleportee) { 50 | return Option.none(); 51 | } 52 | 53 | /** 54 | * {@inheritDoc} 55 | */ 56 | @Override 57 | public boolean checkTeleportSafety() { 58 | return true; 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | @Override 65 | public @NotNull Option getFinerPermissionSuffix() { 66 | return Option.of(playerName); 67 | } 68 | 69 | /** 70 | * {@inheritDoc} 71 | */ 72 | @Override 73 | public @NotNull String serialise() { 74 | return playerName; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/destination/core/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the in-built implementations of the Destination interface. 3 | */ 4 | package org.mvplugins.multiverse.core.destination.core; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/destination/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all destination-types. 3 | */ 4 | package org.mvplugins.multiverse.core.destination; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/filters/ContentFilter.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.display.filters; 2 | 3 | /** 4 | * Filter display content for it show only certain string. 5 | */ 6 | public interface ContentFilter { 7 | /** 8 | * Checks if a particular string should be displayed. 9 | * 10 | * @param value String to check on. 11 | * @return True if should be display, false otherwise. 12 | */ 13 | boolean checkMatch(String value); 14 | 15 | /** 16 | * Gets whether content needs to be filtered by this filter. 17 | * 18 | * @return True if content should be filtered, false otherwise. 19 | */ 20 | boolean needToFilter(); 21 | 22 | /** 23 | * Gets the string representation of this filter. 24 | * 25 | * @return The string representation of this filter. 26 | */ 27 | String toString(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/filters/DefaultContentFilter.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.display.filters; 2 | 3 | /** 4 | * Default implementation of {@link ContentFilter} that doesn't filter anything. 5 | */ 6 | public final class DefaultContentFilter implements ContentFilter { 7 | 8 | private static DefaultContentFilter instance; 9 | 10 | /** 11 | * Gets the singleton instance of this class. 12 | * 13 | * @return The singleton instance of this class. 14 | */ 15 | public static DefaultContentFilter get() { 16 | if (instance == null) { 17 | instance = new DefaultContentFilter(); 18 | } 19 | return instance; 20 | } 21 | 22 | private DefaultContentFilter() { 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | @Override 29 | public boolean checkMatch(String value) { 30 | return true; 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | @Override 37 | public boolean needToFilter() { 38 | return false; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "N/A"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/filters/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the filters that can be used to choose specific data to display. 3 | */ 4 | package org.mvplugins.multiverse.core.display.filters; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/handlers/DefaultSendHandler.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.display.handlers; 2 | 3 | import java.util.List; 4 | 5 | import co.aikar.commands.BukkitCommandIssuer; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 8 | 9 | /** 10 | * Most basic implementation of {@link SendHandler} that just sends content with no formatting. 11 | */ 12 | public final class DefaultSendHandler implements SendHandler { 13 | 14 | private static DefaultSendHandler instance; 15 | 16 | /** 17 | * Gets the singleton instance of this class. 18 | * 19 | * @return The singleton instance of this class. 20 | */ 21 | public static DefaultSendHandler getInstance() { 22 | if (instance == null) { 23 | instance = new DefaultSendHandler(); 24 | } 25 | return instance; 26 | } 27 | 28 | private DefaultSendHandler() { 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public void send(@NotNull MVCommandIssuer issuer, @NotNull List content) { 36 | content.forEach(issuer::sendMessage); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/handlers/SendHandler.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.display.handlers; 2 | 3 | import java.util.List; 4 | 5 | import co.aikar.commands.BukkitCommandIssuer; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 8 | 9 | /** 10 | * Handles the sending of all content to the command sender. 11 | */ 12 | @FunctionalInterface 13 | public interface SendHandler { 14 | /** 15 | * Sends all the content to the given command sender. 16 | * 17 | * @param issuer The target which the content will be displayed to. 18 | * @param content The content to display. 19 | */ 20 | void send(@NotNull MVCommandIssuer issuer, @NotNull List content); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/handlers/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the handlers for the display system. 3 | */ 4 | package org.mvplugins.multiverse.core.display.handlers; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the classes that are used to display nicely formatted information to the user. 3 | */ 4 | package org.mvplugins.multiverse.core.display; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/parsers/ContentProvider.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.display.parsers; 2 | 3 | import java.util.Collection; 4 | 5 | import co.aikar.commands.BukkitCommandIssuer; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 8 | 9 | /** 10 | * Parse objects into string or list of strings. 11 | */ 12 | @FunctionalInterface 13 | public interface ContentProvider { 14 | /** 15 | * Parse the object to string(s) and add it to the content. 16 | * 17 | * @param issuer The target which the content will be displayed to. 18 | * @return The parsed content list. 19 | */ 20 | Collection parse(@NotNull MVCommandIssuer issuer); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/parsers/ListContentProvider.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.display.parsers; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import co.aikar.commands.BukkitCommandIssuer; 8 | import org.jetbrains.annotations.NotNull; 9 | import org.mvplugins.multiverse.core.command.MVCommandIssuer; 10 | import org.mvplugins.multiverse.core.locale.message.Message; 11 | 12 | /** 13 | * Simple parser for list object. 14 | * 15 | * @param List element type. 16 | */ 17 | public class ListContentProvider implements ContentProvider { 18 | 19 | /** 20 | * New list content parser for the given list. 21 | * 22 | * @param list The list object to parse. 23 | * @param List element type. 24 | * @return New {@link MapContentProvider} instance. 25 | */ 26 | public static ListContentProvider forContent(List list) { 27 | return new ListContentProvider<>(list); 28 | } 29 | 30 | private final List list; 31 | 32 | ListContentProvider(List list) { 33 | this.list = list; 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public Collection parse(@NotNull MVCommandIssuer issuer) { 41 | return list.stream() 42 | .map(object -> object instanceof Message message ? message.formatted(issuer) : String.valueOf(object)) 43 | .toList(); 44 | } 45 | 46 | public List getList() { 47 | return list; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/display/parsers/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the parsers for the display system. 3 | */ 4 | package org.mvplugins.multiverse.core.display.parsers; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/DynamicListener.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener; 2 | 3 | import org.bukkit.event.Listener; 4 | 5 | /** 6 | * Base interface for tagging all dynamic listeners. 7 | */ 8 | public interface DynamicListener extends Listener { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/EventPriorityMapper.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import io.vavr.control.Option; 5 | import jakarta.inject.Inject; 6 | import org.bukkit.event.EventPriority; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jvnet.hk2.annotations.Service; 9 | import org.mvplugins.multiverse.core.dynamiclistener.annotations.EventPriorityKey; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * Allow for event priority to be set dynamically with key mapping instead of just fixed in EventHandler annotation. 16 | */ 17 | @Service 18 | public final class EventPriorityMapper { 19 | 20 | private final Map eventPriorityMap; 21 | 22 | @Inject 23 | EventPriorityMapper() { 24 | this.eventPriorityMap = new HashMap<>(); 25 | } 26 | 27 | /** 28 | * Sets the event priority for the given key. 29 | * 30 | * @param key The key referenced in {@link EventPriorityKey} 31 | * @param priority The priority to set 32 | */ 33 | public void setPriority(@NotNull String key, @NotNull EventPriority priority) { 34 | Logging.finest("Setting event priority for %s to %s", key, priority); 35 | eventPriorityMap.put(key, priority); 36 | } 37 | 38 | /** 39 | * Gets the event priority for the given key 40 | * 41 | * @param key The key referenced in {@link EventPriorityKey} 42 | * @return The event priority 43 | */ 44 | public Option getPriority(String key) { 45 | return Option.of(eventPriorityMap.get(key)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/EventRunnable.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.Listener; 5 | 6 | /** 7 | * Runnable of an event that may not be available on the server. This is to prevent class not found errors when 8 | * initializing the listener class. 9 | * 10 | * @param The type of event to listen to. 11 | */ 12 | @FunctionalInterface 13 | public interface EventRunnable { 14 | void onEvent(T event); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/EventRunnableExecutor.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.Listener; 5 | import org.bukkit.plugin.EventExecutor; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | final class EventRunnableExecutor implements EventExecutor { 9 | 10 | private final Class eventClass; 11 | private final EventRunnable runnable; 12 | 13 | EventRunnableExecutor(Class eventClass, EventRunnable runnable) { 14 | this.eventClass = eventClass; 15 | this.runnable = runnable; 16 | } 17 | 18 | @Override 19 | public void execute(@NotNull Listener listener, @NotNull Event event) { 20 | if (!eventClass.isInstance(event)) { 21 | return; 22 | } 23 | runnable.onEvent((T) event); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/annotations/DefaultEventPriority.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener.annotations; 2 | 3 | import org.bukkit.event.EventPriority; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.dynamiclistener.EventPriorityMapper; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * The event priority to use for the event if {@link EventPriorityKey} is not set in {@link EventPriorityMapper}. 14 | */ 15 | @Target(ElementType.METHOD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface DefaultEventPriority { 18 | @NotNull EventPriority value(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/annotations/EventClass.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Specifies the class name of an event. Used when an event may not be available on the server. 10 | */ 11 | @Target(ElementType.METHOD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface EventClass { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/annotations/EventMethod.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener.annotations; 2 | 3 | import org.bukkit.event.EventHandler; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Annotate a method as an event method. Similar to {@link EventHandler}. 12 | */ 13 | @Target(ElementType.METHOD) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface EventMethod { 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/annotations/EventPriorityKey.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener.annotations; 2 | 3 | import org.mvplugins.multiverse.core.dynamiclistener.EventPriorityMapper; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Sets a key to allow event priority to be set by {@link EventPriorityMapper}. 12 | */ 13 | @Target(ElementType.METHOD) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface EventPriorityKey { 16 | String value(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/annotations/IgnoreIfCancelled.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Does not invoke the event's method if the event is cancelled. 10 | */ 11 | @Target(ElementType.METHOD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface IgnoreIfCancelled { 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/dynamiclistener/annotations/SkipIfEventExist.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.dynamiclistener.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Do not register the event if the following event class exists on the server. This is useful for fallback events 10 | * if another event class is not available on the server. 11 | */ 12 | @Target(ElementType.METHOD) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface SkipIfEventExist { 15 | String value(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/economy/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the economy classes to handle external economy plugins. 3 | */ 4 | package org.mvplugins.multiverse.core.economy; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/MVConfigReloadEvent.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package org.mvplugins.multiverse.core.event; 9 | 10 | import java.util.List; 11 | 12 | import org.bukkit.event.Event; 13 | import org.bukkit.event.HandlerList; 14 | import org.jetbrains.annotations.NotNull; 15 | 16 | /** 17 | * Called when the Multiverse-config should be reloaded. 18 | */ 19 | public final class MVConfigReloadEvent extends Event { 20 | private final List configsLoaded; 21 | 22 | public MVConfigReloadEvent(List configsLoaded) { 23 | this.configsLoaded = configsLoaded; 24 | } 25 | 26 | private static final HandlerList HANDLERS = new HandlerList(); 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | public @NotNull HandlerList getHandlers() { 33 | return HANDLERS; 34 | } 35 | 36 | /** 37 | * Gets the handler list. This is required by the event system. 38 | * 39 | * @return A list of HANDLERS. 40 | */ 41 | public static HandlerList getHandlerList() { 42 | return HANDLERS; 43 | } 44 | 45 | /** 46 | * Adds a config to this event. 47 | * 48 | * @param config The config to add. 49 | */ 50 | public void addConfig(String config) { 51 | this.configsLoaded.add(config); 52 | } 53 | 54 | /** 55 | * Gets all loaded configs. 56 | * 57 | * @return A list of all loaded configs. 58 | */ 59 | public List getAllConfigsLoaded() { 60 | return this.configsLoaded; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/MVDebugModeEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * Called when Core's debug level is changed. 9 | */ 10 | public final class MVDebugModeEvent extends Event { 11 | 12 | private static final HandlerList HANDLERS = new HandlerList(); 13 | 14 | private final int level; 15 | 16 | public MVDebugModeEvent(int level) { 17 | this.level = level; 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | public @NotNull HandlerList getHandlers() { 25 | return HANDLERS; 26 | } 27 | 28 | /** 29 | * Gets the handler list. This is required by the event system. 30 | * 31 | * @return A list of HANDLERS. 32 | */ 33 | public static HandlerList getHandlerList() { 34 | return HANDLERS; 35 | } 36 | 37 | /** 38 | * Returns the current debug level of Core. 39 | * 40 | * @return the current debug level of Core. 41 | */ 42 | public int getLevel() { 43 | return level; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all multiverse core events. 3 | */ 4 | package org.mvplugins.multiverse.core.event; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldClonedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully cloned. 9 | */ 10 | public final class MVWorldClonedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | private final LoadedMultiverseWorld fromWorld; 14 | 15 | public MVWorldClonedEvent(LoadedMultiverseWorld world, LoadedMultiverseWorld fromWorld) { 16 | super(world); 17 | this.fromWorld = fromWorld; 18 | } 19 | 20 | public LoadedMultiverseWorld getFromWorld() { 21 | return fromWorld; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | @Override 28 | public @NotNull HandlerList getHandlers() { 29 | return HANDLERS; 30 | } 31 | 32 | /** 33 | * Gets the handler list. This is required by the event system. 34 | * 35 | * @return A list of HANDLERS. 36 | */ 37 | public static HandlerList getHandlerList() { 38 | return HANDLERS; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully created. 9 | */ 10 | public final class MVWorldCreatedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | public MVWorldCreatedEvent(LoadedMultiverseWorld world) { 14 | super(world); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public @NotNull HandlerList getHandlers() { 22 | return HANDLERS; 23 | } 24 | 25 | /** 26 | * Gets the handler list. This is required by the event system. 27 | * 28 | * @return A list of HANDLERS. 29 | */ 30 | public static HandlerList getHandlerList() { 31 | return HANDLERS; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.Cancellable; 4 | import org.bukkit.event.HandlerList; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 8 | 9 | /** 10 | * Called when a world is about to be deleted by Multiverse. 11 | */ 12 | public final class MVWorldDeleteEvent extends MultiverseWorldEvent implements Cancellable { 13 | private static final HandlerList HANDLERS = new HandlerList(); 14 | 15 | private boolean cancelled = false; 16 | 17 | public MVWorldDeleteEvent(@NotNull LoadedMultiverseWorld world) { 18 | super(world); 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public boolean isCancelled() { 26 | return cancelled; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | @Override 33 | public void setCancelled(boolean cancel) { 34 | cancelled = cancel; 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | @Override 41 | public @NotNull HandlerList getHandlers() { 42 | return HANDLERS; 43 | } 44 | 45 | /** 46 | * Gets the handler list. This is required by the event system. 47 | * 48 | * @return A list of HANDLERS. 49 | */ 50 | public static HandlerList getHandlerList() { 51 | return HANDLERS; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldImportedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully imported. 9 | */ 10 | public final class MVWorldImportedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | public MVWorldImportedEvent(LoadedMultiverseWorld world) { 14 | super(world); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public @NotNull HandlerList getHandlers() { 22 | return HANDLERS; 23 | } 24 | 25 | /** 26 | * Gets the handler list. This is required by the event system. 27 | * 28 | * @return A list of HANDLERS. 29 | */ 30 | public static HandlerList getHandlerList() { 31 | return HANDLERS; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldLoadedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully loaded. 9 | */ 10 | public final class MVWorldLoadedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | public MVWorldLoadedEvent(LoadedMultiverseWorld world) { 14 | super(world); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public @NotNull HandlerList getHandlers() { 22 | return HANDLERS; 23 | } 24 | 25 | /** 26 | * Gets the handler list. This is required by the event system. 27 | * 28 | * @return A list of HANDLERS. 29 | */ 30 | public static HandlerList getHandlerList() { 31 | return HANDLERS; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldRegeneratedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully regenerated. 9 | */ 10 | public final class MVWorldRegeneratedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | public MVWorldRegeneratedEvent(LoadedMultiverseWorld world) { 14 | super(world); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public @NotNull HandlerList getHandlers() { 22 | return HANDLERS; 23 | } 24 | 25 | /** 26 | * Gets the handler list. This is required by the event system. 27 | * 28 | * @return A list of HANDLERS. 29 | */ 30 | public static HandlerList getHandlerList() { 31 | return HANDLERS; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldRemovedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.MultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully removed. 9 | */ 10 | public final class MVWorldRemovedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | public MVWorldRemovedEvent(MultiverseWorld world) { 14 | super(world); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public @NotNull HandlerList getHandlers() { 22 | return HANDLERS; 23 | } 24 | 25 | /** 26 | * Gets the handler list. This is required by the event system. 27 | * 28 | * @return A list of HANDLERS. 29 | */ 30 | public static HandlerList getHandlerList() { 31 | return HANDLERS; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MVWorldUnloadedEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.HandlerList; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.world.MultiverseWorld; 6 | 7 | /** 8 | * Called when a world has been successfully unloaded. 9 | */ 10 | public final class MVWorldUnloadedEvent extends MultiverseWorldEvent { 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | public MVWorldUnloadedEvent(MultiverseWorld world) { 14 | super(world); 15 | } 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public @NotNull HandlerList getHandlers() { 22 | return HANDLERS; 23 | } 24 | 25 | /** 26 | * Gets the handler list. This is required by the event system. 27 | * 28 | * @return A list of HANDLERS. 29 | */ 30 | public static HandlerList getHandlerList() { 31 | return HANDLERS; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/event/world/MultiverseWorldEvent.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.event.world; 2 | 3 | import org.bukkit.event.Event; 4 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; 5 | import org.mvplugins.multiverse.core.world.MultiverseWorld; 6 | 7 | abstract class MultiverseWorldEvent extends Event { 8 | protected final W world; 9 | 10 | MultiverseWorldEvent(W world) { 11 | this.world = world; 12 | } 13 | 14 | /** 15 | * Gets the world that's about to be deleted. 16 | * 17 | * @return That {@link LoadedMultiverseWorld}. 18 | */ 19 | public W getWorld() { 20 | return world; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/exceptions/command/MVInvalidCommandArgument.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.exceptions.command; 2 | 3 | import co.aikar.commands.InvalidCommandArgument; 4 | import org.mvplugins.multiverse.core.locale.message.LocalizedMessage; 5 | import org.mvplugins.multiverse.core.locale.message.Message; 6 | 7 | /** 8 | * ACF's InvalidCommandArgument with added support for MV's LocalizedMessage class. 9 | */ 10 | public class MVInvalidCommandArgument extends InvalidCommandArgument { 11 | 12 | public static MVInvalidCommandArgument of(Message message) { 13 | return of(message, true); 14 | } 15 | 16 | public static MVInvalidCommandArgument of(Message message, boolean showSyntax) { 17 | return message instanceof LocalizedMessage 18 | ? new MVInvalidCommandArgument((LocalizedMessage) message, showSyntax) 19 | : new MVInvalidCommandArgument(message, showSyntax); 20 | } 21 | 22 | private MVInvalidCommandArgument(Message message, boolean showSyntax) { 23 | super(message.formatted(), showSyntax); 24 | } 25 | 26 | private MVInvalidCommandArgument(LocalizedMessage message, boolean showSyntax) { 27 | super(message.getMessageKey(), showSyntax, message.getReplacements()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all exceptions. 3 | */ 4 | package org.mvplugins.multiverse.core.exceptions; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/exceptions/world/MultiverseWorldException.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.exceptions.world; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | import org.mvplugins.multiverse.core.exceptions.MultiverseException; 5 | import org.mvplugins.multiverse.core.locale.message.Message; 6 | 7 | public class MultiverseWorldException extends MultiverseException { 8 | public MultiverseWorldException(String message) { 9 | super(message); 10 | } 11 | 12 | public MultiverseWorldException(@Nullable Message message) { 13 | super(message); 14 | } 15 | 16 | public MultiverseWorldException(@Nullable String message, @Nullable Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public MultiverseWorldException(@Nullable Message message, @Nullable Throwable cause) { 21 | super(message, cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/inject/binder/JavaPluginBinder.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.inject.binder; 2 | 3 | import org.bukkit.plugin.java.JavaPlugin; 4 | import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * A base class for java plugin binders. Binds the plugin to the {@link JavaPlugin} interface. 9 | * 10 | * @param The type of the plugin. 11 | */ 12 | public abstract class JavaPluginBinder extends PluginBinder { 13 | 14 | protected JavaPluginBinder(@NotNull T plugin) { 15 | super(plugin); 16 | } 17 | 18 | @Override 19 | protected ScopedBindingBuilder bindPluginClass(ScopedBindingBuilder bindingBuilder) { 20 | return bindingBuilder.to(JavaPlugin.class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/inject/binder/PluginBinder.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.inject.binder; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import org.bukkit.plugin.Plugin; 6 | import org.glassfish.hk2.utilities.binding.AbstractBinder; 7 | import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * The base class for all plugin binders. Initiates the binding of the plugin instance and initially binds it to the 12 | * {@link Plugin} interface. 13 | * 14 | * @param The type of the plugin. 15 | */ 16 | public abstract class PluginBinder extends AbstractBinder { 17 | 18 | private final T plugin; 19 | 20 | protected PluginBinder(@NotNull T plugin) { 21 | this.plugin = plugin; 22 | } 23 | 24 | @NotNull 25 | public T getPlugin() { 26 | return plugin; 27 | } 28 | 29 | @Override 30 | protected final void configure() { 31 | var bindingBuilder = bindPlugin(getPlugin()); 32 | bindingBuilder.to(Plugin.class); 33 | bindPluginClass(bindingBuilder); 34 | bind(plugin.getLogger()).to(Logger.class); 35 | } 36 | 37 | private ScopedBindingBuilder bindPlugin(T plugin) { 38 | return bind(plugin); 39 | } 40 | 41 | protected abstract ScopedBindingBuilder bindPluginClass(ScopedBindingBuilder bindingBuilder); 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/inject/binder/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.inject.binder; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/inject/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.inject; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/listeners/CoreListener.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.listeners; 2 | 3 | import org.jvnet.hk2.annotations.Contract; 4 | import org.mvplugins.multiverse.core.dynamiclistener.DynamicListener; 5 | 6 | @Contract 7 | public sealed interface CoreListener extends DynamicListener permits 8 | MVAdvancementListener, 9 | MVChatListener, 10 | MVEntityListener, 11 | MVPlayerListener, 12 | MVPortalListener, 13 | MVWeatherListener, 14 | MVWorldListener 15 | { } 16 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/listeners/MVAdvancementListener.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.listeners; 2 | 3 | import com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent; 4 | import com.dumptruckman.minecraft.util.Logging; 5 | import jakarta.inject.Inject; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jvnet.hk2.annotations.Service; 8 | import org.mvplugins.multiverse.core.dynamiclistener.annotations.EventClass; 9 | import org.mvplugins.multiverse.core.dynamiclistener.EventRunnable; 10 | import org.mvplugins.multiverse.core.world.WorldManager; 11 | 12 | @Service 13 | final class MVAdvancementListener implements CoreListener { 14 | 15 | private final WorldManager worldManager; 16 | 17 | @Inject 18 | MVAdvancementListener(@NotNull WorldManager worldManager) { 19 | this.worldManager = worldManager; 20 | } 21 | 22 | @EventClass("com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent") 23 | EventRunnable playerAdvancementCriterionGrant() { 24 | return new EventRunnable() { 25 | @Override 26 | public void onEvent(PlayerAdvancementCriterionGrantEvent event) { 27 | worldManager.getLoadedWorld(event.getPlayer().getWorld()).peek(mvWorld -> { 28 | if (!mvWorld.isAllowAdvancementGrant() && !event.getCriterion().equals("unlock_right_away")) { 29 | Logging.finest("Advancement criterion cancelled: %s", event.getCriterion()); 30 | event.setCancelled(true); 31 | } 32 | }); 33 | } 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/listeners/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all listeners. 3 | */ 4 | package org.mvplugins.multiverse.core.listeners; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/locale/FileResClassLoader.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.locale; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.InputStream; 7 | import java.net.MalformedURLException; 8 | import java.net.URL; 9 | 10 | import org.bukkit.plugin.Plugin; 11 | 12 | /** 13 | * A class loader that loads resources from the plugin's locales folder. 14 | */ 15 | final class FileResClassLoader extends ClassLoader { 16 | 17 | private final transient File targetFolder; 18 | 19 | /** 20 | * Creates a new FileResClassLoader. 21 | * 22 | * @param plugin The plugin to load resources from. 23 | * @param subFolder The subfolder to load resources from. 24 | */ 25 | FileResClassLoader(final Plugin plugin, final String subFolder) { 26 | super(plugin.getClass().getClassLoader()); 27 | this.targetFolder = new File(plugin.getDataFolder(), subFolder); 28 | } 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | @Override 34 | public URL getResource(final String string) { 35 | final File file = new File(targetFolder, string); 36 | if (file.exists()) { 37 | try { 38 | return file.toURI().toURL(); 39 | } catch (final MalformedURLException ignored) { 40 | } 41 | } 42 | return null; 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | public InputStream getResourceAsStream(final String string) { 50 | final File file = new File(targetFolder, string); 51 | if (file.exists()) { 52 | try { 53 | return new FileInputStream(file); 54 | } catch (final FileNotFoundException ignored) { 55 | } 56 | } 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/locale/PluginLocales.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.locale; 2 | 3 | import co.aikar.commands.BukkitLocales; 4 | import jakarta.inject.Inject; 5 | import org.bukkit.plugin.Plugin; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import org.jvnet.hk2.annotations.Service; 9 | import org.mvplugins.multiverse.core.command.MVCommandManager; 10 | 11 | /** 12 | * Locale manager with additional methods for loading locales from plugin's locales folder. 13 | */ 14 | @Service 15 | public final class PluginLocales extends BukkitLocales { 16 | 17 | private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales"; 18 | 19 | /** 20 | * Creates a new instance of {@link PluginLocales}. 21 | * 22 | * @param manager The command manager. 23 | */ 24 | @Inject 25 | public PluginLocales(MVCommandManager manager) { 26 | super(manager); 27 | } 28 | 29 | /** 30 | * Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from. 31 | * 32 | * @param plugin The plugin. 33 | * @return True if the class loader was added successfully. 34 | */ 35 | public boolean addFileResClassLoader(@NotNull Plugin plugin) { 36 | return this.addBundleClassLoader(new FileResClassLoader(plugin, DEFAULT_LOCALE_FOLDER_PATH)); 37 | } 38 | 39 | /** 40 | * Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from. 41 | * 42 | * @param plugin The plugin. 43 | * @param localesFolderPath The path to the folder containing the locales. 44 | * @return True if the class loader was added successfully. 45 | */ 46 | public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) { 47 | return this.addBundleClassLoader(new FileResClassLoader(plugin, localesFolderPath)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/locale/message/LocalizableMessage.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.locale.message; 2 | 3 | import co.aikar.commands.CommandIssuer; 4 | import org.jetbrains.annotations.Nullable; 5 | import org.mvplugins.multiverse.core.locale.PluginLocales; 6 | 7 | /** 8 | * Contains a localizable {@link Message}. 9 | */ 10 | public interface LocalizableMessage { 11 | /** 12 | * Gets the localizable message for this object. 13 | *
14 | * This can be null if the object does not have a localizable message. 15 | *
16 | * The returned message will be localized with the {@link PluginLocales} provided by the {@link CommandIssuer} 17 | * that called the method which returned this object. 18 | * 19 | * @return The localizable message, or null if none exists. 20 | */ 21 | @Nullable Message getLocalizableMessage(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/locale/message/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.locale.message; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/locale/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.locale; -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/module/MultiverseModuleBinder.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.module; 2 | 3 | import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mvplugins.multiverse.core.inject.binder.JavaPluginBinder; 6 | 7 | /** 8 | * Binder for a {@link MultiverseModule} 9 | * @param The type of the module 10 | */ 11 | public abstract class MultiverseModuleBinder extends JavaPluginBinder { 12 | 13 | protected MultiverseModuleBinder(@NotNull T module) { 14 | super(module); 15 | } 16 | 17 | @Override 18 | protected ScopedBindingBuilder bindPluginClass(ScopedBindingBuilder bindingBuilder) { 19 | return super.bindPluginClass(bindingBuilder).to(MultiverseModule.class); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The "master"-package, containing everything related to Multiverse-Core. 3 | */ 4 | package org.mvplugins.multiverse.core; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/permissions/PermissionUtils.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.permissions; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.command.ConsoleCommandSender; 6 | 7 | public final class PermissionUtils { 8 | 9 | private static boolean debugPermissions = false; 10 | 11 | private PermissionUtils() { 12 | // Prevent instantiation 13 | } 14 | 15 | public static boolean isDebugPermissions() { 16 | return debugPermissions; 17 | } 18 | 19 | public static void setDebugPermissions(boolean debugPermissions) { 20 | PermissionUtils.debugPermissions = debugPermissions; 21 | } 22 | 23 | /** 24 | * Joins permissions with a dot. 25 | * 26 | * @param permission The permission 27 | * @param child The string(s) to join 28 | * @return The newly joined permission node. 29 | */ 30 | public static String concatPermission(String permission, String... child) { 31 | return permission + "." + String.join(".", child); 32 | } 33 | 34 | /** 35 | * Check and log if the sender has the permission. 36 | * 37 | * @param sender The sender 38 | * @param permission The permission 39 | * @return True if the sender has the permission, else false. 40 | */ 41 | public static boolean hasPermission(CommandSender sender, String permission) { 42 | if (sender.hasPermission(permission)) { 43 | if (debugPermissions && !(sender instanceof ConsoleCommandSender)) { 44 | Logging.finer("Checking sender [%s] has permission [%s] : YES", sender.getName(), permission); 45 | } 46 | return true; 47 | } 48 | if (debugPermissions && !(sender instanceof ConsoleCommandSender)) { 49 | Logging.finer("Checking sender [%s] has permission [%s] : NO", sender.getName(), permission); 50 | } 51 | return false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/permissions/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.permissions; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/teleportation/TeleportFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.teleportation; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | import org.mvplugins.multiverse.core.event.MVTeleportDestinationEvent; 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Reasons for a failed teleport. 11 | */ 12 | public enum TeleportFailureReason implements FailureReason { 13 | /** 14 | * The destination was null. 15 | */ 16 | NULL_DESTINATION(MVCorei18n.TELEPORTFAILUREREASON_NULL_DESTINATION), 17 | 18 | /** 19 | * The location was null. 20 | */ 21 | NULL_LOCATION(MVCorei18n.TELEPORTFAILUREREASON_NULL_LOCATION), 22 | 23 | /** 24 | * The location was null. 25 | */ 26 | NULL_WORLD(MVCorei18n.TELEPORTFAILUREREASON_NULL_WORLD), 27 | 28 | /** 29 | * The location was unsafe. 30 | */ 31 | UNSAFE_LOCATION(MVCorei18n.TELEPORTFAILUREREASON_UNSAFE_LOCATION), 32 | 33 | /** 34 | * The server teleport return false. 35 | */ 36 | TELEPORT_FAILED(MVCorei18n.TELEPORTFAILUREREASON_TELEPORT_FAILED), 37 | 38 | /** 39 | * An exception was thrown. 40 | */ 41 | TELEPORT_FAILED_EXCEPTION(MVCorei18n.TELEPORTFAILUREREASON_TELEPORT_FAILED_EXCEPTION), 42 | 43 | /** 44 | * The {@link MVTeleportDestinationEvent} was cancelled. 45 | */ 46 | EVENT_CANCELLED(MVCorei18n.TELEPORTFAILUREREASON_EVENT_CANCELLED), 47 | ; 48 | 49 | private final MessageKeyProvider messageKey; 50 | 51 | TeleportFailureReason(MessageKeyProvider message) { 52 | this.messageKey = message; 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public MessageKey getMessageKey() { 60 | return messageKey.getMessageKey(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/teleportation/TeleportQueue.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.teleportation; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.dumptruckman.minecraft.util.Logging; 7 | import io.vavr.control.Option; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.entity.Player; 10 | import org.jvnet.hk2.annotations.Service; 11 | 12 | @Service 13 | public final class TeleportQueue { 14 | 15 | private final Map teleportQueueMap; 16 | 17 | TeleportQueue() { 18 | teleportQueueMap = new HashMap<>(); 19 | } 20 | 21 | /** 22 | * This method is used to add a teleportation to the teleportQueue. 23 | * 24 | * @param teleporter The sender that initiated the teleportation. 25 | * @param teleportee The player that will be teleported. 26 | */ 27 | public void addToQueue(CommandSender teleporter, Player teleportee) { 28 | addToQueue(teleporter.getName(), teleportee.getName()); 29 | } 30 | 31 | /** 32 | * This method is used to add a teleportation to the teleportQueue. 33 | * 34 | * @param teleporter The name of the sender that initiated the teleportation. 35 | * @param teleportee The name of the player that will be teleported. 36 | */ 37 | public void addToQueue(String teleporter, String teleportee) { 38 | Logging.finest("Adding mapping '%s' => '%s' to teleport queue", teleporter, teleportee); 39 | teleportQueueMap.put(teleportee, teleporter); 40 | } 41 | 42 | /** 43 | * This method is used to find out who is teleporting a player. 44 | * @param playerName The teleported player (the teleportee). 45 | * @return The player that teleported the other one (the teleporter). 46 | */ 47 | public Option popFromQueue(String playerName) { 48 | if (teleportQueueMap.containsKey(playerName)) { 49 | String teleportee = teleportQueueMap.get(playerName); 50 | teleportQueueMap.remove(playerName); 51 | return Option.of(teleportee); 52 | } 53 | return Option.none(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/teleportation/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all the teleportation and location safety related classes. 3 | */ 4 | package org.mvplugins.multiverse.core.teleportation; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/MaterialConverter.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils; 2 | 3 | import de.themoep.idconverter.IdMappings; 4 | import org.bukkit.Material; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | /** 8 | * A tool for converting values which may be an old type ID to a Material. 9 | */ 10 | public final class MaterialConverter { 11 | 12 | /** 13 | * Converts a string representing a numeric id or flattened material name to a Material. 14 | * 15 | * @param value The value to convert. 16 | * @return The converted Material type or null if no matching type. 17 | */ 18 | @Nullable 19 | public static Material stringToMaterial(@Nullable String value) { 20 | IdMappings.Mapping mapping = IdMappings.getById(value != null ? value : ""); 21 | if (mapping != null) { 22 | return Material.matchMaterial(mapping.getFlatteningType()); 23 | } else { 24 | return Material.matchMaterial(value != null ? value : ""); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/REPatterns.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.regex.Pattern; 6 | 7 | public class REPatterns { 8 | 9 | private static final Map patternCache = new HashMap<>(); 10 | 11 | public static Pattern get(String regex) { 12 | return patternCache.computeIfAbsent(regex, Pattern::compile); 13 | } 14 | 15 | public static final Pattern COLON = get(":"); 16 | public static final Pattern COMMA = get(","); 17 | public static final Pattern DOT = get("\\."); 18 | public static final Pattern EQUALS = get("="); 19 | public static final Pattern SEMICOLON = get(";"); 20 | public static final Pattern UNDERSCORE = get("_"); 21 | public static final Pattern UUID = get("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/ServerProperties.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import io.vavr.control.Option; 5 | import jakarta.inject.Inject; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jvnet.hk2.annotations.Service; 8 | 9 | import java.io.IOException; 10 | import java.nio.file.Files; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Service 15 | public final class ServerProperties { 16 | 17 | private final Map properties; 18 | private final FileUtils fileUtils; 19 | 20 | @Inject 21 | public ServerProperties(@NotNull FileUtils fileUtils) { 22 | this.fileUtils = fileUtils; 23 | properties = new HashMap<>(); 24 | parseServerPropertiesFile(); 25 | } 26 | 27 | private void parseServerPropertiesFile() { 28 | if (fileUtils.getServerProperties() == null) { 29 | return; 30 | } 31 | try { 32 | Files.readAllLines(fileUtils.getServerProperties().toPath()).stream() 33 | .map(String::strip) 34 | .filter(line -> !line.startsWith("#")) 35 | .map(line -> REPatterns.EQUALS.split(line, 2)) 36 | .filter(line -> line.length == 2) 37 | .forEach(line -> properties.put(line[0], line[1])); 38 | } catch (IOException e) { 39 | Logging.warning("Could not read server.properties file! Some features such as default world may not work as expected."); 40 | } 41 | } 42 | 43 | public Option getLevelName() { 44 | return getProperty("level-name"); 45 | } 46 | 47 | public boolean getAllowNether() { 48 | return getProperty("allow-nether").map(Boolean::parseBoolean).getOrElse(true); 49 | } 50 | 51 | public Option getProperty(String key) { 52 | return Option.of(properties.get(key)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all Utility-clases. 3 | */ 4 | package org.mvplugins.multiverse.core.utils; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/result/FailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.result; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | 8 | /** 9 | * Represents a failure reason for an {@link Attempt}. 10 | */ 11 | public interface FailureReason extends MessageKeyProvider { 12 | default MessageKey getMessageKey() { 13 | return MVCorei18n.GENERIC_FAILURE.getMessageKey(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/result/SuccessReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.result; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | 8 | public interface SuccessReason extends MessageKeyProvider { 9 | default MessageKey getMessageKey() { 10 | return MVCorei18n.GENERIC_SUCCESS.getMessageKey(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/BitlyURLShortener.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import net.minidev.json.JSONObject; 7 | import net.minidev.json.parser.JSONParser; 8 | import net.minidev.json.parser.ParseException; 9 | 10 | /** 11 | * A {@link URLShortener} using {@code bit.ly}. Requires an access token. 12 | */ 13 | final class BitlyURLShortener extends URLShortener { 14 | private static final String ACCESS_TOKEN = "Bearer @bitly-access-token@"; 15 | private static final String BITLY_POST_REQUEST = "https://api-ssl.bitly.com/v4/shorten"; 16 | 17 | BitlyURLShortener() { 18 | super(BITLY_POST_REQUEST, ACCESS_TOKEN); 19 | if (ACCESS_TOKEN.endsWith("access-token")) { 20 | throw new UnsupportedOperationException(); 21 | } 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | @Override 28 | String encodeData(String data) { 29 | JSONObject json = new JSONObject(); 30 | json.put("long_url", data); 31 | return json.toJSONString(); 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | @Override 38 | String encodeData(Map data) { 39 | throw new UnsupportedOperationException(); 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | @Override 46 | public String shorten(String longUrl) { 47 | try { 48 | String stringJSON = this.exec(encodeData(longUrl), ContentType.JSON); 49 | return (String) ((JSONObject) new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE).parse(stringJSON)).get("link"); 50 | } catch (IOException | ParseException e) { 51 | e.printStackTrace(); 52 | return longUrl; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/McloGsPasteService.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | import java.io.IOException; 4 | import java.net.URLEncoder; 5 | import java.nio.charset.StandardCharsets; 6 | import java.util.Map; 7 | 8 | import net.minidev.json.JSONObject; 9 | import net.minidev.json.parser.JSONParser; 10 | import net.minidev.json.parser.ParseException; 11 | 12 | final class McloGsPasteService extends PasteService { 13 | 14 | private static final String MCLOGS_POST_REQUEST = "https://api.mclo.gs/1/log"; 15 | 16 | McloGsPasteService() { 17 | super(MCLOGS_POST_REQUEST); 18 | } 19 | 20 | @Override 21 | String encodeData(String data) { 22 | return "content=" + URLEncoder.encode(data, StandardCharsets.UTF_8); 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | @Override 29 | String encodeData(Map data) { 30 | throw new UnsupportedOperationException(); 31 | } 32 | 33 | @Override 34 | public String postData(String data) throws PasteFailedException { 35 | try { 36 | String stringJSON = this.exec(encodeData(data), ContentType.URLENCODED); // Execute request 37 | return String.valueOf(((JSONObject) new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE).parse(stringJSON)).get("url")); // Interpret result 38 | } catch (IOException | ParseException e) { 39 | throw new PasteFailedException(e); 40 | } 41 | } 42 | 43 | @Override 44 | public String postData(Map data) throws PasteFailedException { 45 | try { 46 | String stringJSON = this.exec(encodeData(data), ContentType.JSON); // Execute request 47 | return String.valueOf(((JSONObject) new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE).parse(stringJSON)).get("url")); // Interpret result 48 | } catch (IOException | ParseException e) { 49 | throw new PasteFailedException(e); 50 | } 51 | } 52 | 53 | @Override 54 | public boolean supportsMultiFile() { 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/PasteFailedException.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | /** 4 | * Thrown when pasting fails. 5 | */ 6 | public class PasteFailedException extends Exception { 7 | public PasteFailedException() { 8 | super(); 9 | } 10 | 11 | public PasteFailedException(Throwable cause) { 12 | super(cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/PasteService.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * An interface to a web-based text-pasting service. Classes extending this 7 | * should implement its methods to send data to an online text-sharing service, 8 | * such as pastebin.com. Given some PasteService instance ps, a paste is accomplished by: 9 | *
10 | * {@code ps.postData(someString);} 11 | * 12 | * Services that provide a distinction between "public" and "private" pastes 13 | * should implement a constructor that specifies which kind the PasteService 14 | * instance is submitting; an example of this is the PastebinPasteService class. 15 | */ 16 | public abstract sealed class PasteService extends HttpAPIClient 17 | permits GitHubPasteService, 18 | McloGsPasteService, 19 | PastebinPasteService, 20 | PasteGGPasteService, 21 | PastesDevPasteService { 22 | PasteService(String url) { 23 | super(url); 24 | } 25 | 26 | PasteService(String url, String accessToken) { 27 | super(url, accessToken); 28 | } 29 | 30 | /** 31 | * Post data to the Web. 32 | * 33 | * @param data A String to post to the web. 34 | * @throws PasteFailedException When pasting/posting the data failed. 35 | * @return The URL at which the new paste is visible. 36 | */ 37 | public abstract String postData(String data) throws PasteFailedException; 38 | 39 | /** 40 | * Post data to the Web. 41 | * 42 | * @param data A Map to post to the web. 43 | * @throws PasteFailedException When pasting/posting the data failed. 44 | * @return The URL at which the new paste is visible. 45 | */ 46 | public abstract String postData(Map data) throws PasteFailedException; 47 | 48 | /** 49 | * Does this service support uploading multiple files. 50 | *
51 | * Newer services like GitHub's Gist support multi-file pastes, 52 | * which allows us to upload configs in addition to the standard logs. 53 | * 54 | * @return True if this service supports multiple file upload. 55 | */ 56 | public abstract boolean supportsMultiFile(); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/PasteServiceFactory.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | /** 4 | * Used to construct {@link PasteService}s. 5 | */ 6 | public class PasteServiceFactory { 7 | private PasteServiceFactory() { } 8 | 9 | /** 10 | * Constructs a new {@link PasteService}. 11 | * @param type The {@link PasteServiceType}. 12 | * @param isPrivate Whether the new {@link PasteService} should create private pastes. 13 | * @return The newly created {@link PasteService}. 14 | */ 15 | public static PasteService getService(PasteServiceType type, boolean isPrivate) { 16 | return switch (type) { 17 | case PASTEGG -> new PasteGGPasteService(isPrivate); 18 | case PASTEBIN -> new PastebinPasteService(isPrivate); 19 | case PASTESDEV -> new PastesDevPasteService(); 20 | case GITHUB -> new GitHubPasteService(isPrivate); 21 | case MCLOGS -> new McloGsPasteService(); 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/PasteServiceType.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | /** 4 | * An enum containing all known {@link PasteService}s. 5 | * 6 | * @see PasteService 7 | * @see PasteServiceFactory 8 | */ 9 | public enum PasteServiceType { 10 | /** 11 | * @see PasteGGPasteService 12 | */ 13 | PASTEGG, 14 | /** 15 | * @see PastebinPasteService 16 | */ 17 | PASTEBIN, 18 | /** 19 | * @see PastesDevPasteService 20 | */ 21 | PASTESDEV, 22 | /** 23 | * @see GitHubPasteService 24 | */ 25 | GITHUB, 26 | /** 27 | * @see McloGsPasteService 28 | */ 29 | MCLOGS 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/PastesDevPasteService.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import net.minidev.json.JSONObject; 7 | import net.minidev.json.parser.JSONParser; 8 | import net.minidev.json.parser.ParseException; 9 | 10 | /** 11 | * Pastes to {@code hastebin.com}. 12 | */ 13 | final class PastesDevPasteService extends PasteService { 14 | private static final String PASTESDEV_POST_REQUEST = "https://api.pastes.dev/post"; 15 | 16 | PastesDevPasteService() { 17 | super(PASTESDEV_POST_REQUEST); 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | String encodeData(String data) { 25 | return data; 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | String encodeData(Map data) { 33 | throw new UnsupportedOperationException(); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public String postData(String data) throws PasteFailedException { 41 | try { 42 | String stringJSON = this.exec(encodeData(data), ContentType.PLAINTEXT_YAML); 43 | return "https://pastes.dev/" + ((JSONObject) new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE).parse(stringJSON)).get("key"); 44 | } catch (IOException | ParseException e) { 45 | throw new PasteFailedException(e); 46 | } 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | */ 52 | @Override 53 | public String postData(Map data) throws UnsupportedOperationException { 54 | throw new UnsupportedOperationException(); 55 | } 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public boolean supportsMultiFile() { 62 | return false; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/URLShortener.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | /** 4 | * An interface to a web-based URL Shortener. Classes extending this should 5 | * implement its methods to shorten links using the service. Given some 6 | * URLShortener instance us, a URL is shortened by: 7 | *
8 | * {@code us.shorten(longUrl);} 9 | * 10 | * An example of this, is the BitlyURLShortener. 11 | */ 12 | public abstract sealed class URLShortener extends HttpAPIClient permits BitlyURLShortener { 13 | URLShortener(String url) { 14 | super(url); 15 | } 16 | 17 | URLShortener(String url, String accessToken) { 18 | super(url, accessToken); 19 | } 20 | 21 | /** 22 | * Shorten a URL. 23 | * @param longUrl The long form. 24 | * @return The shortened URL. 25 | */ 26 | public abstract String shorten(String longUrl); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/URLShortenerFactory.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | /** 4 | * Used to construct {@link URLShortener}s. 5 | */ 6 | public class URLShortenerFactory { 7 | private URLShortenerFactory() { } 8 | 9 | /** 10 | * Constructs a new {@link URLShortener}. 11 | * @param type The {@link URLShortenerType}. 12 | * @return The newly created {@link URLShortener}. 13 | */ 14 | public static URLShortener getService(URLShortenerType type) { 15 | if (type == URLShortenerType.BITLY) { 16 | try { 17 | return new BitlyURLShortener(); 18 | } catch (UnsupportedOperationException ignored) {} 19 | } 20 | 21 | return null; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/URLShortenerType.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils.webpaste; 2 | 3 | /** 4 | * An enum containing all known {@link URLShortener}s. 5 | * 6 | * @see URLShortener 7 | * @see URLShortenerFactory 8 | */ 9 | public enum URLShortenerType { 10 | /** 11 | * @see BitlyURLShortener 12 | */ 13 | BITLY 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/utils/webpaste/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains webpaste-utilities. 3 | */ 4 | package org.mvplugins.multiverse.core.utils.webpaste; 5 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/AllowedPortalType.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2012. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package org.mvplugins.multiverse.core.world; 9 | 10 | import org.bukkit.PortalType; 11 | 12 | /** 13 | * Custom enum that adds all/none for allowing portal creation. 14 | */ 15 | public enum AllowedPortalType { 16 | /** 17 | * No portals are allowed. 18 | */ 19 | NONE(PortalType.CUSTOM), 20 | 21 | /** 22 | * All portal types are allowed. 23 | */ 24 | ALL(PortalType.CUSTOM), 25 | 26 | /** 27 | * Only Nether style portals are allowed. 28 | */ 29 | NETHER(PortalType.NETHER), 30 | 31 | /** 32 | * Only Ender style portals are allowed. 33 | */ 34 | END(PortalType.ENDER); 35 | 36 | private final PortalType type; 37 | 38 | AllowedPortalType(PortalType type) { 39 | this.type = type; 40 | } 41 | 42 | /** 43 | * Gets the text. 44 | * 45 | * @return The text. 46 | */ 47 | public PortalType getActualPortalType() { 48 | return this.type; 49 | } 50 | 51 | /** 52 | * Checks if the given portal type is allowed. 53 | * 54 | * @param portalType The portal type. 55 | * @return True if allowed, else false. 56 | */ 57 | public boolean isPortalAllowed(PortalType portalType) { 58 | return this != NONE && (getActualPortalType() == portalType || this == ALL); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/NewAndRemovedWorlds.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * A record containing a list of the new WorldConfigs added and a list of the worlds removed from the config. 7 | * 8 | * @param newWorlds List of the new WorldConfigs added 9 | * @param removedWorlds List of the worlds removed from the config 10 | */ 11 | record NewAndRemovedWorlds(List newWorlds, List removedWorlds) { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/biomeprovider/BiomeProviderParser.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.biomeprovider; 2 | 3 | import org.bukkit.generator.BiomeProvider; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * A parser for BiomeProvider objects. 10 | *
11 | * This interface provides methods for parsing biome provider strings and generating suggested biome provider strings. 12 | */ 13 | public interface BiomeProviderParser { 14 | 15 | /** 16 | * Parses a biome provider string and returns a corresponding BiomeProvider object. 17 | * 18 | * @param worldName the name of the world 19 | * @param params the parameters to parse 20 | * @return the parsed BiomeProvider object 21 | */ 22 | BiomeProvider parseBiomeProvider(@NotNull String worldName, @NotNull String params); 23 | 24 | /** 25 | * Generates a list of suggested biome provider strings based on the user's current input. 26 | * 27 | * @param currentInput the user's current input 28 | * @return a collection of suggested biome provider strings 29 | */ 30 | Collection suggestParams(@NotNull String currentInput); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/biomeprovider/SingleBiomeProvider.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.biomeprovider; 2 | 3 | import org.bukkit.WorldCreator; 4 | import org.bukkit.block.Biome; 5 | import org.bukkit.generator.BiomeProvider; 6 | import org.bukkit.generator.WorldInfo; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Helps create a world with only 1 type of Biome specified. Used in {@link WorldCreator#biomeProvider(BiomeProvider)} 13 | */ 14 | final class SingleBiomeProvider extends BiomeProvider { 15 | 16 | private final Biome biome; 17 | private final List biomes; 18 | 19 | public SingleBiomeProvider(Biome biome) { 20 | this.biome = biome; 21 | this.biomes = List.of(biome); 22 | } 23 | 24 | @Override 25 | public @NotNull Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z) { 26 | return this.biome; 27 | } 28 | 29 | @Override 30 | public @NotNull List getBiomes(@NotNull WorldInfo worldInfo) { 31 | return this.biomes; 32 | } 33 | 34 | public Biome getBiome() { 35 | return biome; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/biomeprovider/SingleBiomeProviderParser.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.biomeprovider; 2 | 3 | import org.bukkit.block.Biome; 4 | import org.bukkit.generator.BiomeProvider; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Arrays; 8 | import java.util.Collection; 9 | import java.util.List; 10 | 11 | /** 12 | * A parser for {@link SingleBiomeProvider} 13 | */ 14 | final class SingleBiomeProviderParser implements BiomeProviderParser { 15 | 16 | private List biomes; 17 | 18 | @Override 19 | public BiomeProvider parseBiomeProvider(@NotNull String worldName, @NotNull String params) { 20 | return new SingleBiomeProvider(Biome.valueOf(params.toUpperCase())); 21 | } 22 | 23 | @Override 24 | public Collection suggestParams(@NotNull String currentInput) { 25 | if (biomes == null) { 26 | biomes = Arrays.stream(Biome.values()).map(biome -> biome.toString().toLowerCase()).toList(); 27 | } 28 | return biomes; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/entrycheck/BlacklistResult.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.entrycheck; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | import org.mvplugins.multiverse.core.utils.result.SuccessReason; 9 | 10 | /** 11 | * Result of a world blacklist check. 12 | */ 13 | public final class BlacklistResult { 14 | /** 15 | * Success reasons for a blacklist check. 16 | */ 17 | public enum Success implements SuccessReason { 18 | UNKNOWN_FROM_WORLD, 19 | BYPASSED_BLACKLISTED, 20 | NOT_BLACKLISTED 21 | } 22 | 23 | /** 24 | * Failure reasons for a blacklist check. 25 | */ 26 | public enum Failure implements FailureReason { 27 | BLACKLISTED(MVCorei18n.ENTRYCHECK_BLACKLISTED); 28 | 29 | private final MessageKeyProvider message; 30 | 31 | Failure(MessageKeyProvider message) { 32 | this.message = message; 33 | } 34 | 35 | @Override 36 | public MessageKey getMessageKey() { 37 | return message.getMessageKey(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/entrycheck/EntryFeeResult.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.entrycheck; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | import org.mvplugins.multiverse.core.utils.result.SuccessReason; 9 | 10 | /** 11 | * Result of a world entry fee check. 12 | */ 13 | public final class EntryFeeResult { 14 | /** 15 | * Success reasons for an entry fee check. 16 | */ 17 | public enum Success implements SuccessReason { 18 | FREE_ENTRY, 19 | ENOUGH_MONEY, 20 | EXEMPT_FROM_ENTRY_FEE, 21 | CONSOLE_OR_BLOCK_COMMAND_SENDER 22 | } 23 | 24 | /** 25 | * Failure reasons for an entry fee check. 26 | */ 27 | public enum Failure implements FailureReason { 28 | NOT_ENOUGH_MONEY(MVCorei18n.ENTRYCHECK_NOTENOUGHMONEY), 29 | CANNOT_PAY_ENTRY_FEE(MVCorei18n.ENTRYCHECK_CANNOTPAYENTRYFEE); 30 | 31 | private final MessageKeyProvider message; 32 | 33 | Failure(MessageKeyProvider message) { 34 | this.message = message; 35 | } 36 | 37 | @Override 38 | public MessageKey getMessageKey() { 39 | return message.getMessageKey(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/entrycheck/PlayerLimitResult.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.entrycheck; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | import org.mvplugins.multiverse.core.utils.result.SuccessReason; 9 | 10 | /** 11 | * Result of a world player limit check. 12 | */ 13 | public final class PlayerLimitResult { 14 | /** 15 | * Success reasons for a player limit check. 16 | */ 17 | public enum Success implements SuccessReason { 18 | NO_PLAYERLIMIT, 19 | WITHIN_PLAYERLIMIT, 20 | BYPASS_PLAYERLIMIT 21 | } 22 | 23 | /** 24 | * Failure reasons for a player limit check. 25 | */ 26 | public enum Failure implements FailureReason { 27 | EXCEED_PLAYERLIMIT(MVCorei18n.ENTRYCHECK_EXCEEDPLAYERLIMIT); 28 | 29 | private final MessageKeyProvider message; 30 | 31 | Failure(MessageKeyProvider message) { 32 | this.message = message; 33 | } 34 | 35 | @Override 36 | public MessageKey getMessageKey() { 37 | return message.getMessageKey(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldAccessResult.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.entrycheck; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | import org.mvplugins.multiverse.core.utils.result.SuccessReason; 9 | 10 | /** 11 | * Result of a world access check. 12 | */ 13 | public final class WorldAccessResult { 14 | /** 15 | * Success reasons for a world access check. 16 | */ 17 | public enum Success implements SuccessReason { 18 | NO_ENFORCE_WORLD_ACCESS, 19 | HAS_WORLD_ACCESS 20 | } 21 | 22 | /** 23 | * Failure reasons for a world access check. 24 | */ 25 | public enum Failure implements FailureReason { 26 | NO_WORLD_ACCESS(MVCorei18n.ENTRYCHECK_NOWORLDACCESS); 27 | 28 | private final MessageKeyProvider message; 29 | 30 | Failure(MessageKeyProvider message) { 31 | this.message = message; 32 | } 33 | 34 | @Override 35 | public MessageKey getMessageKey() { 36 | return message.getMessageKey(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryCheckerProvider.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.entrycheck; 2 | 3 | import jakarta.inject.Inject; 4 | import org.bukkit.command.CommandSender; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jvnet.hk2.annotations.Service; 7 | 8 | import org.mvplugins.multiverse.core.config.CoreConfig; 9 | import org.mvplugins.multiverse.core.economy.MVEconomist; 10 | import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker; 11 | 12 | @Service 13 | public final class WorldEntryCheckerProvider { 14 | 15 | private final @NotNull CoreConfig config; 16 | private final @NotNull MVEconomist economist; 17 | private final @NotNull CorePermissionsChecker permissionsChecker; 18 | 19 | @Inject 20 | WorldEntryCheckerProvider( 21 | @NotNull CoreConfig config, 22 | @NotNull MVEconomist economist, 23 | @NotNull CorePermissionsChecker permissionsChecker) { 24 | this.config = config; 25 | this.economist = economist; 26 | this.permissionsChecker = permissionsChecker; 27 | } 28 | 29 | public @NotNull WorldEntryChecker forSender(@NotNull CommandSender sender) { 30 | return new WorldEntryChecker(config, permissionsChecker, economist, sender); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/entrycheck/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.entrycheck; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/generators/SimpleGeneratorPlugin.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.generators; 2 | 3 | import java.util.Collection; 4 | import java.util.Collections; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * A default implementation of {@link GeneratorPlugin} for those generator plugins that do not provide their own 11 | * custom {@link GeneratorPlugin} implementation to Multiverse. 12 | */ 13 | final class SimpleGeneratorPlugin implements GeneratorPlugin { 14 | private final String pluginName; 15 | 16 | SimpleGeneratorPlugin(@NotNull String pluginName) { 17 | this.pluginName = pluginName; 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | public @NotNull Collection suggestIds(@Nullable String currentIdInput) { 25 | return Collections.emptyList(); 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | public @Nullable Collection getExampleUsages() { 33 | return null; 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public @Nullable String getInfoLink() { 41 | return null; 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | */ 47 | @Override 48 | public @NotNull String getPluginName() { 49 | return pluginName; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/generators/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.generators; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/helpers/DataTransfer.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.helpers; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * A data transfer for storing and restoring data from multiple {@link DataStore} from one object to another. 8 | * 9 | * @param The type of the object to transfer data from and to. 10 | */ 11 | public final class DataTransfer { 12 | private final List> dataStores; 13 | 14 | /** 15 | * Creates a new {@link DataTransfer} instance. 16 | */ 17 | public DataTransfer() { 18 | this.dataStores = new ArrayList<>(); 19 | } 20 | 21 | /** 22 | * Adds a {@link DataStore} to this {@link DataTransfer} instance. 23 | * 24 | * @param dataStore The {@link DataStore} to add. 25 | * @param object The object to copy data from. 26 | * @return This {@link DataTransfer} instance. 27 | */ 28 | public DataTransfer addDataStore(DataStore dataStore, T object) { 29 | this.dataStores.add(dataStore.copyFrom(object)); 30 | return this; 31 | } 32 | 33 | /** 34 | * Copies the data from all {@link DataStore} instances in this {@link DataTransfer} instance to the given object. 35 | * 36 | * @param object The object to paste data to. 37 | * @return This {@link DataTransfer} instance. 38 | */ 39 | public DataTransfer pasteAllTo(T object) { 40 | this.dataStores.forEach(dataStore -> dataStore.pasteTo(object)); 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/helpers/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.helpers; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/location/NullSpawnLocation.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.location; 2 | 3 | import java.util.Collections; 4 | import java.util.Map; 5 | 6 | import org.bukkit.Location; 7 | import org.bukkit.configuration.serialization.SerializableAs; 8 | import org.bukkit.util.Vector; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | /** 12 | * Null-location. 13 | */ 14 | @SerializableAs("MVNullLocation (It's a bug if you see this in your config file)") 15 | public final class NullSpawnLocation extends SpawnLocation { 16 | private static final NullSpawnLocation INSTANCE = new NullSpawnLocation(); 17 | 18 | /** 19 | * Get the default null location instance. 20 | * 21 | * @return The instance. 22 | */ 23 | public static NullSpawnLocation get() { 24 | return INSTANCE; 25 | } 26 | 27 | private NullSpawnLocation() { 28 | super(0, -1, 0); 29 | } 30 | 31 | @Override 32 | public @NotNull NullSpawnLocation clone() { 33 | throw new UnsupportedOperationException(); 34 | } 35 | 36 | @Override 37 | public @NotNull Map serialize() { 38 | return Collections.emptyMap(); 39 | } 40 | 41 | /** 42 | * Let Bukkit be able to deserialize this. 43 | * 44 | * @param args The map. 45 | * @return The deserialized object. 46 | */ 47 | public static NullSpawnLocation deserialize(Map args) { 48 | return new NullSpawnLocation(); 49 | } 50 | 51 | @Override 52 | public @NotNull Vector toVector() { 53 | throw new UnsupportedOperationException(); 54 | } 55 | 56 | @Override 57 | public int hashCode() { 58 | return -1; 59 | } 60 | 61 | @Override 62 | public boolean equals(Object obj) { 63 | return obj instanceof NullSpawnLocation; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return "Location{null}"; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/location/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.location; -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/options/DeleteWorldOptions.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.options; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.mvplugins.multiverse.core.world.MultiverseWorld; 5 | 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | /** 10 | * Options for customizing the deletion of a world. 11 | */ 12 | public final class DeleteWorldOptions { 13 | 14 | /** 15 | * Creates a new {@link DeleteWorldOptions} instance with the given world. 16 | * 17 | * @param world The world to delete. 18 | * @return A new {@link DeleteWorldOptions} instance. 19 | */ 20 | public static @NotNull DeleteWorldOptions world(@NotNull MultiverseWorld world) { 21 | return new DeleteWorldOptions(world); 22 | } 23 | 24 | private final MultiverseWorld world; 25 | private List keepFiles = Collections.emptyList(); 26 | 27 | DeleteWorldOptions(MultiverseWorld world) { 28 | this.world = world; 29 | } 30 | 31 | public MultiverseWorld world() { 32 | return world; 33 | } 34 | 35 | /** 36 | * Sets the files to keep during deletion. 37 | * 38 | * @param keepFilesInput The files to keep during deletion. 39 | * @return This {@link DeleteWorldOptions} instance. 40 | */ 41 | public @NotNull DeleteWorldOptions keepFiles(List keepFilesInput) { 42 | this.keepFiles = keepFilesInput == null ? Collections.emptyList() : keepFilesInput.stream().toList(); 43 | return this; 44 | } 45 | 46 | /** 47 | * Gets the files to keep during deletion. Note: The list is unmodifiable. 48 | * 49 | * @return The files to keep during deletion. 50 | */ 51 | public List keepFiles() { 52 | return keepFiles; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/options/KeepWorldSettingsOptions.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.options; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * Options for customizing the keeping of world settings. Used by clone and regen. 7 | */ 8 | public sealed interface KeepWorldSettingsOptions permits CloneWorldOptions, RegenWorldOptions { 9 | 10 | /** 11 | * Sets whether to keep the game rule of the world. 12 | * 13 | * @param keepGameRuleInput Whether to keep the game rule of the world. 14 | * @return This {@link KeepWorldSettingsOptions} instance. 15 | */ 16 | @NotNull KeepWorldSettingsOptions keepGameRule(boolean keepGameRuleInput); 17 | 18 | /** 19 | * Gets whether to keep the game rule of the world. 20 | * 21 | * @return Whether to keep the game rule of the world. 22 | */ 23 | boolean keepGameRule(); 24 | 25 | /** 26 | * Sets whether to keep the world config of the world. 27 | * 28 | * @param keepWorldConfigInput Whether to keep the world config of the world. 29 | * @return This {@link KeepWorldSettingsOptions} instance. 30 | */ 31 | @NotNull KeepWorldSettingsOptions keepWorldConfig(boolean keepWorldConfigInput); 32 | 33 | /** 34 | * Gets whether to keep the world config of the world. 35 | * 36 | * @return Whether to keep the world config of the world. 37 | */ 38 | boolean keepWorldConfig(); 39 | 40 | /** 41 | * Sets whether to keep the world border of the world. 42 | * 43 | * @param keepWorldBorderInput Whether to keep the world border of the world. 44 | * @return This {@link KeepWorldSettingsOptions} instance. 45 | */ 46 | @NotNull KeepWorldSettingsOptions keepWorldBorder(boolean keepWorldBorderInput); 47 | 48 | /** 49 | * Gets whether to keep the world border of the world. 50 | * 51 | * @return Whether to keep the world border of the world. 52 | */ 53 | boolean keepWorldBorder(); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/options/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.options; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world; 2 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/CloneFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world clone operation. 11 | */ 12 | public enum CloneFailureReason implements FailureReason { 13 | /** 14 | * The world name is invalid. 15 | */ 16 | INVALID_WORLDNAME(MVCorei18n.CLONEWORLD_INVALIDWORLDNAME), 17 | 18 | /** 19 | * The target new world folder already exists. 20 | */ 21 | WORLD_EXIST_FOLDER(MVCorei18n.CLONEWORLD_WORLDEXISTFOLDER), 22 | 23 | /** 24 | * The target new world is already exist but unloaded. 25 | */ 26 | WORLD_EXIST_UNLOADED(MVCorei18n.CLONEWORLD_WORLDEXISTUNLOADED), 27 | 28 | /** 29 | * The target new world is already loaded. 30 | */ 31 | WORLD_EXIST_LOADED(MVCorei18n.CLONEWORLD_WORLDEXISTLOADED), 32 | 33 | /** 34 | * Failed to copy the world folder contents. 35 | */ 36 | COPY_FAILED(MVCorei18n.CLONEWORLD_COPYFAILED), 37 | 38 | /** 39 | * Failed to import the new world. 40 | */ 41 | IMPORT_FAILED(MVCorei18n.GENERIC_FAILURE); 42 | 43 | private final MessageKeyProvider message; 44 | 45 | CloneFailureReason(MessageKeyProvider message) { 46 | this.message = message; 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | */ 52 | @Override 53 | public MessageKey getMessageKey() { 54 | return message.getMessageKey(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/CreateFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world creation operation. 11 | */ 12 | public enum CreateFailureReason implements FailureReason { 13 | /** 14 | * The world name is invalid. 15 | */ 16 | INVALID_WORLDNAME(MVCorei18n.CREATEWORLD_INVALIDWORLDNAME), 17 | 18 | /** 19 | * The target new world folder already exists. 20 | */ 21 | WORLD_EXIST_FOLDER(MVCorei18n.CREATEWORLD_WORLDEXISTFOLDER), 22 | 23 | /** 24 | * The target new world is already exist but unloaded. 25 | */ 26 | WORLD_EXIST_UNLOADED(MVCorei18n.CREATEWORLD_WORLDEXISTUNLOADED), 27 | 28 | /** 29 | * The target new world is already exist and loaded. 30 | */ 31 | WORLD_EXIST_LOADED(MVCorei18n.CREATEWORLD_WORLDEXISTLOADED), 32 | 33 | /** 34 | * Bukkit API failed to create the world. 35 | */ 36 | WORLD_CREATOR_FAILED(MVCorei18n.GENERIC_FAILURE), 37 | ; 38 | 39 | private final MessageKeyProvider message; 40 | 41 | CreateFailureReason(MessageKeyProvider message) { 42 | this.message = message; 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | public MessageKey getMessageKey() { 50 | return message.getMessageKey(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.event.world.MVWorldDeleteEvent; 7 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 8 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 9 | 10 | /** 11 | * Result of a world deletion operation. 12 | */ 13 | public enum DeleteFailureReason implements FailureReason { 14 | /** 15 | * The world does not exist. 16 | */ 17 | WORLD_NON_EXISTENT(MVCorei18n.DELETEWORLD_WORLDNONEXISTENT), 18 | 19 | /** 20 | * The world could not be loaded. 21 | */ 22 | LOAD_FAILED(MVCorei18n.DELETEWORLD_LOADFAILED), 23 | 24 | /** 25 | * The world could not be unloaded. 26 | */ 27 | WORLD_FOLDER_NOT_FOUND(MVCorei18n.DELETEWORLD_WORLDFOLDERNOTFOUND), 28 | 29 | /** 30 | * The world could not be removed. 31 | */ 32 | REMOVE_FAILED(MVCorei18n.GENERIC_FAILURE), 33 | 34 | /** 35 | * The world folder could not be deleted. 36 | */ 37 | FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER), 38 | 39 | /** 40 | * The {@link MVWorldDeleteEvent} was cancelled. 41 | */ 42 | EVENT_CANCELLED(MVCorei18n.GENERIC_FAILURE); // todo: messaging 43 | 44 | private final MessageKeyProvider message; 45 | 46 | DeleteFailureReason(MessageKeyProvider message) { 47 | this.message = message; 48 | } 49 | 50 | /** 51 | * {@inheritDoc} 52 | */ 53 | @Override 54 | public MessageKey getMessageKey() { 55 | return message.getMessageKey(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/ImportFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world import operation. 11 | */ 12 | public enum ImportFailureReason implements FailureReason { 13 | /** 14 | * The world name is invalid. 15 | */ 16 | INVALID_WORLDNAME(MVCorei18n.IMPORTWORLD_INVALIDWORLDNAME), 17 | 18 | /** 19 | * The world folder is invalid. 20 | */ 21 | WORLD_FOLDER_INVALID(MVCorei18n.IMPORTWORLD_WORLDFOLDERINVALID), 22 | 23 | /** 24 | * The target world folder already exists. You should load it instead. 25 | */ 26 | WORLD_EXIST_UNLOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTUNLOADED), 27 | 28 | /** 29 | * The target world is already exist and loaded. 30 | */ 31 | WORLD_EXIST_LOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTLOADED), 32 | 33 | /** 34 | * Bukkit API failed to create the world. 35 | */ 36 | WORLD_CREATOR_FAILED(MVCorei18n.GENERIC_FAILURE); 37 | 38 | private final MessageKeyProvider message; 39 | 40 | ImportFailureReason(MessageKeyProvider message) { 41 | this.message = message; 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | */ 47 | @Override 48 | public MessageKey getMessageKey() { 49 | return message.getMessageKey(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/LoadFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world loading operation. 11 | */ 12 | public enum LoadFailureReason implements FailureReason { 13 | /** 14 | * Loading operation is underway. 15 | */ 16 | WORLD_ALREADY_LOADING(MVCorei18n.LOADWORLD_WORLDALREADYLOADING), 17 | 18 | /** 19 | * The world does not exist. 20 | */ 21 | WORLD_NON_EXISTENT(MVCorei18n.LOADWORLD_WORLDNONEXISTENT), 22 | 23 | /** 24 | * The world folder exists but is not known to Multiverse. 25 | */ 26 | WORLD_EXIST_FOLDER(MVCorei18n.LOADWORLD_WORLDEXISTFOLDER), 27 | 28 | /** 29 | * The world is already loaded. 30 | */ 31 | WORLD_EXIST_LOADED(MVCorei18n.LOADWORLD_WORLDEXISTLOADED), 32 | 33 | /** 34 | * Bukkit API failed to create the world. 35 | */ 36 | WORLD_CREATOR_FAILED(MVCorei18n.GENERIC_FAILURE), 37 | ; 38 | 39 | private final MessageKeyProvider message; 40 | 41 | LoadFailureReason(MessageKeyProvider message) { 42 | this.message = message; 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | public MessageKey getMessageKey() { 50 | return message.getMessageKey(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/RegenFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world regeneration operation. 11 | */ 12 | public enum RegenFailureReason implements FailureReason { 13 | /** 14 | * The world does not exist. 15 | */ 16 | DELETE_FAILED(MVCorei18n.GENERIC_FAILURE), 17 | 18 | /** 19 | * The new world could not be created. 20 | */ 21 | CREATE_FAILED(MVCorei18n.GENERIC_FAILURE); 22 | 23 | private final MessageKeyProvider message; 24 | 25 | RegenFailureReason(MessageKeyProvider message) { 26 | this.message = message; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | @Override 33 | public MessageKey getMessageKey() { 34 | return message.getMessageKey(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/RemoveFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world removal operation. 11 | */ 12 | public enum RemoveFailureReason implements FailureReason { 13 | /** 14 | * The world does not exist. 15 | */ 16 | WORLD_NON_EXISTENT(MVCorei18n.REMOVEWORLD_WORLDNONEXISTENT), 17 | 18 | /** 19 | * The world could not be unloaded. 20 | */ 21 | UNLOAD_FAILED(MVCorei18n.GENERIC_FAILURE); 22 | 23 | private final MessageKeyProvider message; 24 | 25 | RemoveFailureReason(MessageKeyProvider message) { 26 | this.message = message; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | @Override 33 | public MessageKey getMessageKey() { 34 | return message.getMessageKey(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/UnloadFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 7 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 8 | 9 | /** 10 | * Result of a world unloading operation. 11 | */ 12 | public enum UnloadFailureReason implements FailureReason { 13 | /** 14 | * Unloading operation is underway. 15 | */ 16 | WORLD_ALREADY_UNLOADING(MVCorei18n.UNLOADWORLD_WORLDALREADYUNLOADING), 17 | 18 | /** 19 | * The world does not exist. 20 | */ 21 | WORLD_NON_EXISTENT(MVCorei18n.UNLOADWORLD_WORLDNONEXISTENT), 22 | 23 | /** 24 | * The world is already unloaded. 25 | */ 26 | WORLD_UNLOADED(MVCorei18n.UNLOADWORLD_WORLDUNLOADED), 27 | 28 | /** 29 | * Bukkit API failed to unload the world. 30 | */ 31 | BUKKIT_UNLOAD_FAILED(MVCorei18n.UNLOADWORLD_BUKKITUNLOADFAILED); 32 | 33 | private final MessageKeyProvider message; 34 | 35 | UnloadFailureReason(MessageKeyProvider message) { 36 | this.message = message; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | @Override 43 | public MessageKey getMessageKey() { 44 | return message.getMessageKey(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/WorldCreatorFailureReason.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | 3 | import co.aikar.locales.MessageKey; 4 | import co.aikar.locales.MessageKeyProvider; 5 | import org.mvplugins.multiverse.core.locale.MVCorei18n; 6 | import org.mvplugins.multiverse.core.utils.result.FailureReason; 7 | 8 | /** 9 | * Result of bukkit's world creator failure. 10 | */ 11 | public enum WorldCreatorFailureReason implements FailureReason { 12 | 13 | /** 14 | * Biome provider parsed is invalid and thrown an exception. 15 | */ 16 | INVALID_BIOME_PROVIDER(MVCorei18n.WORLDCREATOR_INVALIDBIOMEPROVIDER), 17 | 18 | /** 19 | * Chunk generator parsed is invalid and thrown an exception. 20 | */ 21 | INVALID_CHUNK_GENERATOR(MVCorei18n.WORLDCREATOR_INVALIDCHUNKGENERATOR), 22 | 23 | /** 24 | * Chunk generator parsed is invalid and thrown an exception. 25 | */ 26 | BUKKIT_CREATION_FAILED(MVCorei18n.WORLDCREATOR_BUKKITCREATIONFAILED), 27 | ; 28 | 29 | private final MessageKeyProvider message; 30 | 31 | WorldCreatorFailureReason(MessageKeyProvider message) { 32 | this.message = message; 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | @Override 39 | public MessageKey getMessageKey() { 40 | return message.getMessageKey(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/mvplugins/multiverse/core/world/reasons/package-info.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.reasons; 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org.mvplugins.multiverse.external.glassfish.hk2.extension.ServiceLocatorGenerator: -------------------------------------------------------------------------------- 1 | org.mvplugins.multiverse.external.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl 2 | -------------------------------------------------------------------------------- /src/main/resources/defaults/config.yml: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------- # 2 | # This is the MV2 Config. If you mess it up, copy the values out # 3 | # delete it, and it will be regenerated. Then use the ingame interface # 4 | # to add your values back via the "/mv conf" command. # 5 | # When in-game, simply type: "/mv conf ?" for help. # 6 | # A config with explanations can be found here: # 7 | # https://github.com/Multiverse/Multiverse-Core/wiki/config.yml # 8 | # # 9 | # # 10 | # IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !!IMPORTANT # 11 | # # 12 | # Do NOT delete this line from your config!!!! # 13 | # ==: com.onarandombox.MultiverseCore.MultiverseCoreConfiguration # 14 | # # 15 | # IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !!IMPORTANT # 16 | # ------------------------------------------------------------------------- # 17 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Multiverse-Core 2 | main: org.mvplugins.multiverse.core.MultiverseCore 3 | authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--', 'benwoo1110', 'Zax71'] 4 | website: 'https://dev.bukkit.org/projects/multiverse-core' 5 | softdepend: ['Vault', 'PlaceholderAPI'] 6 | api-version: 1.13 7 | version: ${version} 8 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core 2 | 3 | import kotlin.test.Test 4 | import kotlin.test.assertNotNull 5 | 6 | open class MockBukkitTest : TestWithMockBukkit() { 7 | 8 | @Test 9 | fun `MockBukkit loads the plugin`() { 10 | assertNotNull(multiverseCore) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/api/MultiverseCoreApiTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.api 2 | 3 | import org.mvplugins.multiverse.core.MultiverseCoreApi 4 | import org.mvplugins.multiverse.core.TestWithMockBukkit 5 | import kotlin.test.Test 6 | import kotlin.test.assertNotNull 7 | 8 | class MultiverseCoreApiTest : TestWithMockBukkit() { 9 | 10 | @Test 11 | fun `MultiverseCoreApi is available`() { 12 | val api = assertNotNull(MultiverseCoreApi.get()) 13 | assertNotNull(api.blockSafety) 14 | assertNotNull(api.destinationsProvider) 15 | assertNotNull(api.generatorProvider) 16 | assertNotNull(api.locationManipulation) 17 | assertNotNull(api.coreConfig) 18 | assertNotNull(api.safetyTeleporter) 19 | assertNotNull(api.worldManager) 20 | } 21 | 22 | @Test 23 | fun `Get MultiverseCoreApi from bukkit service`() { 24 | val registeredService = server.servicesManager.getRegistration(MultiverseCoreApi::class.java) 25 | val api = assertNotNull(registeredService?.provider) 26 | testApiAccess(api) 27 | } 28 | 29 | private fun testApiAccess(api: MultiverseCoreApi?) { 30 | assertNotNull(api?.anchorManager) 31 | assertNotNull(api?.blockSafety) 32 | assertNotNull(api?.destinationsProvider) 33 | assertNotNull(api?.mvEconomist) 34 | assertNotNull(api?.generatorProvider) 35 | assertNotNull(api?.locationManipulation) 36 | assertNotNull(api?.coreConfig) 37 | assertNotNull(api?.safetyTeleporter) 38 | assertNotNull(api?.worldManager) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/commands/CreateCommandTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands 2 | 3 | import org.bukkit.Bukkit 4 | import org.bukkit.World 5 | import org.bukkit.WorldType 6 | import org.junit.jupiter.api.Test 7 | import kotlin.test.assertEquals 8 | import kotlin.test.assertFalse 9 | import kotlin.test.assertTrue 10 | 11 | class CreateCommandTest : AbstractCommandTest() { 12 | 13 | @Test 14 | fun `Create nether world with default options`() { 15 | assertTrue(Bukkit.dispatchCommand(console, "mv create world1_nether nether")) 16 | val world = worldManager.getLoadedWorld("world1_nether") 17 | assertTrue(world.isDefined) 18 | assertEquals(World.Environment.NETHER, world.get().environment) 19 | } 20 | 21 | @Test 22 | fun `Create normal world with specific seed and flat world type without structures`() { 23 | assertTrue(Bukkit.dispatchCommand(console, "mv create world1 normal --seed 1234 --world-type flat --no-structures")) 24 | val world = worldManager.getLoadedWorld("world1") 25 | assertTrue(world.isDefined) 26 | assertEquals(1234L, world.get().seed) 27 | assertEquals(WorldType.FLAT, world.get().worldType.get()) 28 | assertFalse(world.get().canGenerateStructures().get()) 29 | } 30 | 31 | //todo: Fix mockbukkit getBiomeProvider then added test on single biome world creation 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/commands/DeleteCommandTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands 2 | 3 | import org.bukkit.Bukkit 4 | import org.mvplugins.multiverse.core.command.queue.ConfirmMode 5 | import org.mvplugins.multiverse.core.config.CoreConfig 6 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld 7 | import org.mvplugins.multiverse.core.world.options.CreateWorldOptions 8 | import org.mvplugins.multiverse.core.world.options.UnloadWorldOptions 9 | import kotlin.test.BeforeTest 10 | import kotlin.test.Test 11 | import kotlin.test.assertFalse 12 | import kotlin.test.assertTrue 13 | 14 | class DeleteCommandTest : AbstractCommandTest() { 15 | 16 | private lateinit var testWorld : LoadedMultiverseWorld 17 | 18 | @BeforeTest 19 | fun setUp() { 20 | // Disable confirmation to make tests easier 21 | val config = serviceLocator.getActiveService(CoreConfig::class.java).takeIf { it != null } ?: run { 22 | throw IllegalStateException("CoreConfig is not available as a service") } 23 | config.confirmMode = ConfirmMode.DISABLE 24 | 25 | testWorld = worldManager.createWorld(CreateWorldOptions.worldName("test")).get() 26 | } 27 | 28 | @Test 29 | fun `Delete loaded world`() { 30 | assertTrue(Bukkit.dispatchCommand(console, "mv delete test")) 31 | assertFalse(worldManager.getWorld("test").isDefined) 32 | } 33 | 34 | @Test 35 | fun `Delete unloaded world`() { 36 | worldManager.unloadWorld(UnloadWorldOptions.world(testWorld)) 37 | assertTrue(Bukkit.dispatchCommand(console, "mv delete test")) 38 | assertFalse(worldManager.getWorld("test").isDefined) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/commands/ModifyCommandTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands 2 | 3 | import org.bukkit.Bukkit 4 | import org.mvplugins.multiverse.core.command.queue.ConfirmMode 5 | import org.mvplugins.multiverse.core.config.CoreConfig 6 | import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld 7 | import org.mvplugins.multiverse.core.world.options.CreateWorldOptions 8 | import kotlin.test.BeforeTest 9 | import kotlin.test.Test 10 | import kotlin.test.assertEquals 11 | import kotlin.test.assertTrue 12 | 13 | class ModifyCommandTest : AbstractCommandTest() { 14 | 15 | private lateinit var testWorld : LoadedMultiverseWorld 16 | 17 | @BeforeTest 18 | fun setUp() { 19 | // Disable confirmation to make tests easier 20 | val config = serviceLocator.getActiveService(CoreConfig::class.java).takeIf { it != null } ?: run { 21 | throw IllegalStateException("CoreConfig is not available as a service") } 22 | config.confirmMode = ConfirmMode.DISABLE 23 | 24 | testWorld = worldManager.createWorld(CreateWorldOptions.worldName("test")).get() 25 | } 26 | 27 | @Test 28 | fun `Modify alias name with space`() { 29 | assertTrue(Bukkit.dispatchCommand(console, "mv modify test set alias \"Test World\"")) 30 | assertEquals("Test World", testWorld.alias) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/commands/VersionCommandTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.commands 2 | 3 | import co.aikar.commands.MessageKeys 4 | import org.bukkit.Bukkit 5 | import org.bukkit.ChatColor 6 | import org.mvplugins.multiverse.core.locale.MVCorei18n 7 | import org.mvplugins.multiverse.core.locale.message.Message 8 | import org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace 9 | import kotlin.test.Test 10 | import kotlin.test.assertEquals 11 | import kotlin.test.assertTrue 12 | 13 | class VersionCommandTest : AbstractCommandTest() { 14 | 15 | @Test 16 | fun `Run version command as console`() { 17 | assertTrue(Bukkit.dispatchCommand(console, "mv version")) 18 | val output = ChatColor.stripColor(console.nextMessage()) 19 | assertEquals("Multiverse Core Version v" + multiverseCore.getDescription().getVersion(), output) 20 | } 21 | 22 | @Test 23 | fun `Run version command as player`() { 24 | addPermission("multiverse.core.version") 25 | assertTrue(player.performCommand("mv version")) 26 | assertCommandOutput( 27 | Message.of( 28 | MVCorei18n.VERSION_MV, 29 | "", 30 | replace("{version}").with(multiverseCore.getDescription().getVersion()))) 31 | } 32 | 33 | @Test 34 | fun `Run version command as player - no permission`() { 35 | assertTrue(player.performCommand("mv version")) 36 | assertCommandOutput(Message.of(MessageKeys.PERMISSION_DENIED, "")) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/mock/MVServerMock.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.mock; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.WorldCreator; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.mockbukkit.mockbukkit.ServerMock; 7 | import org.mockbukkit.mockbukkit.command.CommandMapMock; 8 | import org.mockbukkit.mockbukkit.world.WorldMock; 9 | 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.nio.file.Files; 13 | 14 | public class MVServerMock extends ServerMock { 15 | 16 | private final File worldContainer; 17 | 18 | public MVServerMock() throws IOException { 19 | super(); 20 | this.worldContainer = Files.createTempDirectory("world-container").toFile(); 21 | this.worldContainer.deleteOnExit(); 22 | System.out.println("Created test world folder: " + this.worldContainer.getAbsolutePath()); 23 | } 24 | 25 | // This is required for acf reflection to work 26 | @Override 27 | public @NotNull CommandMapMock getCommandMap() { 28 | return super.getCommandMap(); 29 | } 30 | 31 | @Override 32 | public @NotNull File getWorldContainer() { 33 | return this.worldContainer; 34 | } 35 | 36 | @Override 37 | public World createWorld(@NotNull WorldCreator creator) { 38 | WorldMock world = new MVWorldMock(creator); 39 | world.getWorldFolder().mkdirs(); 40 | createFile(new File(world.getWorldFolder(), "uid.dat")); 41 | createFile(new File(world.getWorldFolder(), "level.dat")); 42 | addWorld(world); 43 | return world; 44 | } 45 | 46 | private void createFile(File file) { 47 | try { 48 | file.createNewFile(); 49 | } catch (IOException e) { 50 | throw new RuntimeException(e); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/mock/MVWorldMock.java: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.mock; 2 | 3 | import org.bukkit.WorldCreator; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.mockbukkit.mockbukkit.MockBukkit; 6 | import org.mockbukkit.mockbukkit.world.WorldMock; 7 | 8 | import java.io.File; 9 | 10 | public class MVWorldMock extends WorldMock { 11 | 12 | private final File worldFolder; 13 | 14 | public MVWorldMock(@NotNull WorldCreator creator) { 15 | super(creator); 16 | this.worldFolder = new File(MockBukkit.getMock().getWorldContainer(), getName()); 17 | } 18 | 19 | @Override 20 | public @NotNull File getWorldFolder() { 21 | return this.worldFolder; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "MVWorldMock{'name': '" + this.getName() + "'}"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/utils/MaterialConverterTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils 2 | 3 | import org.bukkit.Material 4 | import kotlin.test.Test 5 | import kotlin.test.assertEquals 6 | import kotlin.test.assertNull 7 | 8 | class MaterialConverterTest { 9 | 10 | @Test 11 | fun `Convert dirt name to material`() { 12 | assertEquals(Material.DIRT, MaterialConverter.stringToMaterial("dirt")) 13 | } 14 | 15 | @Test 16 | fun `Convert Spruce Planks numerical id to material`() { 17 | assertEquals(Material.SPRUCE_PLANKS, MaterialConverter.stringToMaterial("5:1")) 18 | } 19 | 20 | @Test 21 | fun `Convert Oak Sapling item id to material`() { 22 | assertEquals(Material.OAK_SAPLING, MaterialConverter.stringToMaterial("minecraft:oak_sapling")) 23 | } 24 | 25 | @Test 26 | fun `Convert invalid string to material`() { 27 | assertNull(MaterialConverter.stringToMaterial("invalid")) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/utils/StringFormatterTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.utils 2 | 3 | import kotlin.test.Test 4 | import kotlin.test.assertEquals 5 | 6 | class StringFormatterTest { 7 | @Test 8 | fun `StringFormatter parseQuotesInArgs`() { 9 | assertEquals( 10 | listOf("before", "this is a test", "after"), 11 | StringFormatter.parseQuotesInArgs(arrayOf("before", "\"this", "is", "a", "test\"", "after")) 12 | ) 13 | assertEquals( 14 | listOf("\""), 15 | StringFormatter.parseQuotesInArgs(arrayOf("\"")) 16 | ) 17 | assertEquals( 18 | listOf("\"", "after"), 19 | StringFormatter.parseQuotesInArgs(arrayOf("\"", "after")) 20 | ) 21 | assertEquals( 22 | listOf("\"word", "after"), 23 | StringFormatter.parseQuotesInArgs(arrayOf("\"word", "after")) 24 | ) 25 | assertEquals( 26 | listOf("word\"", "after\""), 27 | StringFormatter.parseQuotesInArgs(arrayOf("word\"", "after\"")) 28 | ) 29 | assertEquals( 30 | listOf("word\"", "af\"ter"), 31 | StringFormatter.parseQuotesInArgs(arrayOf("word\"", "af\"ter")) 32 | ) 33 | } 34 | 35 | @Test 36 | fun `StringFormatter quoteMultiWordString`() { 37 | assertEquals( 38 | "\"this is a test\"", 39 | StringFormatter.quoteMultiWordString("this is a test") 40 | ) 41 | assertEquals( 42 | "test", 43 | StringFormatter.quoteMultiWordString("test") 44 | ) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/org/mvplugins/multiverse/core/world/helper/DimensionFormatTest.kt: -------------------------------------------------------------------------------- 1 | package org.mvplugins.multiverse.core.world.helper 2 | 3 | import org.mvplugins.multiverse.core.TestWithMockBukkit 4 | import org.mvplugins.multiverse.core.world.helpers.DimensionFinder.DimensionFormat 5 | import kotlin.test.Test 6 | import kotlin.test.assertEquals 7 | import kotlin.test.assertFailsWith 8 | import kotlin.test.assertFalse 9 | 10 | class DimensionFormatTest : TestWithMockBukkit() { 11 | 12 | @Test 13 | fun `Test invalid DimensionFormat`() { 14 | assertFailsWith(IllegalArgumentException::class) { 15 | DimensionFormat("%idk%_nether") 16 | } 17 | } 18 | 19 | @Test 20 | fun `Test DimensionFormat replace`() { 21 | val dimensionFormat = DimensionFormat("%overworld%_nether") 22 | assertEquals("cool_nether", dimensionFormat.replaceOverworld("cool")) 23 | } 24 | 25 | @Test 26 | fun `Test DimensionFormat get overworld`() { 27 | val dimensionFormat = DimensionFormat("%overworld%_n") 28 | assertEquals("cool", dimensionFormat.getOverworldFromName("cool_n").get()) 29 | } 30 | 31 | @Test 32 | fun `Test DimensionFormat does not match`() { 33 | val dimensionFormat = DimensionFormat("%overworld%_nether") 34 | assertFalse(dimensionFormat.getOverworldFromName("cool_end").isDefined) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/resources/anchors/anchors_saved.yml: -------------------------------------------------------------------------------- 1 | anchors: 2 | a1: w1:0.50,70.00,0.50:-68.25:10.35 3 | a2: w2:3.3,9.9,6.6:-1.1:2 4 | a3: w3:3.00,3.00,3.00:-3.00:3.00 -------------------------------------------------------------------------------- /src/test/resources/anchors/default_anchors.yml: -------------------------------------------------------------------------------- 1 | anchors: 2 | a1: w1:0.50,70.00,0.50:-68.25:10.35 3 | a2: w2:3.3,9.9,6.6:-1.1:2 4 | -------------------------------------------------------------------------------- /src/test/resources/configs/broken_config.yml: -------------------------------------------------------------------------------- 1 | world: 2 | enforce-access: false 3 | enforce-gamemode: true 4 | auto-purge-entities: false 5 | 6 | teleport: 7 | use-finer-teleport-permissions: true 8 | concurrent-teleport-limit: 50 9 | teleport-intercept: true 10 | 11 | spawn: 12 | first-spawn-override: true 13 | first-spawn-location: '' 14 | enable-join-destination: false 15 | join-destination: '' 16 | 17 | portal: 18 | use-custom-portal-search: false 19 | custom-portal-search-radius: 128 20 | 21 | messaging: 22 | enable-chat-prefix: false 23 | chat-prefix-format: '[%world%]%chat%' 24 | register-papi-hook: true 25 | default-locale: en 26 | per-player-locale: true 27 | ?! 28 | command: 29 | resolve-alias-name: true 30 | confirm-mode: enable 31 | use-confirm-otp: true 32 | 33 | misc: 34 | global-debug: 0 35 | silent-start: false 36 | show-donation-message: true 37 | 38 | version: 5.1 39 | -------------------------------------------------------------------------------- /src/test/resources/configs/fresh_config.yml: -------------------------------------------------------------------------------- 1 | world: 2 | auto-import-default-worlds: true 3 | auto-import-3rd-party-worlds: true 4 | enforce-access: false 5 | enforce-gamemode: true 6 | enforce-flight: true 7 | auto-purge-entities: false 8 | world-name-format: 9 | nether: '%overworld%_nether' 10 | end: '%overworld%_the_end' 11 | 12 | teleport: 13 | use-finer-teleport-permissions: true 14 | concurrent-teleport-limit: 50 15 | teleport-intercept: true 16 | safe-location-horizontal-search-radius: 3 17 | safe-location-vertical-search-radius: 3 18 | 19 | spawn: 20 | first-spawn-override: false 21 | first-spawn-location: '' 22 | enable-join-destination: false 23 | join-destination: '' 24 | default-respawn-in-overworld: true 25 | default-respawn-within-same-world: true 26 | enforce-respawn-at-world-spawn: true 27 | 28 | portal: 29 | use-custom-portal-search: false 30 | custom-portal-search-radius: 128 31 | 32 | messaging: 33 | enable-chat-prefix: false 34 | chat-prefix-format: '[%world%]%chat%' 35 | register-papi-hook: true 36 | default-locale: en 37 | per-player-locale: true 38 | 39 | command: 40 | resolve-alias-name: true 41 | confirm-mode: enable 42 | use-confirm-otp: true 43 | confirm-timeout: 30 44 | show-legacy-aliases: false 45 | 46 | event-priority: 47 | player-portal: high 48 | player-respawn: low 49 | player-spawn-location: normal 50 | player-teleport: highest 51 | 52 | misc: 53 | bukkit-yml-path: bukkit.yml 54 | global-debug: 0 55 | debug-permissions: false 56 | silent-start: false 57 | show-donation-message: true 58 | 59 | version: 5.2 60 | -------------------------------------------------------------------------------- /src/test/resources/configs/old_config.yml: -------------------------------------------------------------------------------- 1 | multiverse-configuration: 2 | ==: com.onarandombox.MultiverseCore.MultiverseCoreConfiguration 3 | enforceaccess: 'true' 4 | prefixchat: 'false' 5 | prefixchatformat: '[%world%]>>%chat%' 6 | useasyncchat: 'true' 7 | teleportintercept: 'false' 8 | firstspawnoverride: 'true' 9 | displaypermerrors: 'false' 10 | enablebuscript: 'false' 11 | globaldebug: '2' 12 | silentstart: 'false' 13 | messagecooldown: '5000' 14 | version: '2.9' 15 | firstspawnworld: world 16 | teleportcooldown: '1000' 17 | defaultportalsearch: 'true' 18 | portalsearchradius: '128' 19 | autopurge: 'true' 20 | idonotwanttodonate: 'true' 21 | -------------------------------------------------------------------------------- /src/test/resources/worlds/default_worlds.yml: -------------------------------------------------------------------------------- 1 | world: 2 | adjust-spawn: false 3 | alias: my world 4 | allow-advancement-grant: true 5 | allow-flight: false 6 | allow-weather: true 7 | anchor-respawn: true 8 | auto-heal: true 9 | auto-load: true 10 | bed-respawn: true 11 | difficulty: normal 12 | entry-fee: 13 | enabled: false 14 | amount: 0.0 15 | currency: '@vault-economy' 16 | environment: normal 17 | gamemode: survival 18 | biome: '' 19 | generator: '' 20 | hidden: false 21 | hunger: true 22 | keep-spawn-in-memory: true 23 | player-limit: -1 24 | portal-form: all 25 | pvp: true 26 | respawn-world: '' 27 | scale: 1.0 28 | seed: -9223372036854775808 29 | spawn-location: 30 | ==: MVSpawnLocation 31 | x: -64.0 32 | y: 64.0 33 | z: 48.0 34 | pitch: 0.0 35 | yaw: 0.0 36 | spawning: {} 37 | world-blacklist: [] 38 | version: 1.2 39 | world_nether: 40 | adjust-spawn: false 41 | alias: '' 42 | allow-advancement-grant: true 43 | allow-flight: false 44 | allow-weather: true 45 | anchor-respawn: true 46 | auto-heal: true 47 | auto-load: true 48 | bed-respawn: true 49 | difficulty: normal 50 | entry-fee: 51 | enabled: false 52 | amount: 0.0 53 | currency: '@vault-economy' 54 | environment: nether 55 | gamemode: survival 56 | biome: '' 57 | generator: '' 58 | hidden: false 59 | hunger: true 60 | keep-spawn-in-memory: true 61 | player-limit: -1 62 | portal-form: all 63 | pvp: true 64 | respawn-world: '' 65 | scale: 8.0 66 | seed: -9223372036854775808 67 | spawn-location: 68 | ==: MVSpawnLocation 69 | x: -64.0 70 | y: 64.0 71 | z: 48.0 72 | pitch: 0.0 73 | yaw: 0.0 74 | spawning: {} 75 | world-blacklist: [] 76 | version: 1.2 77 | -------------------------------------------------------------------------------- /src/test/resources/worlds/delete_worlds.yml: -------------------------------------------------------------------------------- 1 | world_nether: 2 | adjust-spawn: false 3 | alias: '' 4 | allow-advancement-grant: true 5 | allow-flight: false 6 | allow-weather: true 7 | anchor-respawn: true 8 | auto-heal: true 9 | auto-load: true 10 | bed-respawn: true 11 | difficulty: normal 12 | entry-fee: 13 | enabled: false 14 | amount: 0.0 15 | currency: '@vault-economy' 16 | environment: nether 17 | gamemode: survival 18 | biome: '' 19 | generator: '' 20 | hidden: false 21 | hunger: true 22 | keep-spawn-in-memory: true 23 | player-limit: -1 24 | portal-form: all 25 | pvp: true 26 | respawn-world: '' 27 | scale: 8.0 28 | seed: -9223372036854775808 29 | spawn-location: 30 | ==: MVSpawnLocation 31 | x: -64.0 32 | y: 64.0 33 | z: 48.0 34 | pitch: 0.0 35 | yaw: 0.0 36 | spawning: {} 37 | world-blacklist: [] 38 | version: 1.2 39 | -------------------------------------------------------------------------------- /src/test/resources/worlds/edgecase_worlds.yml: -------------------------------------------------------------------------------- 1 | world: 2 | adjust-spawn: false 3 | alias: 1234 # should be parsed as string and not integer 4 | allow-advancement-grant: true 5 | allow-flight: false 6 | allow-weather: true 7 | anchor-respawn: true 8 | auto-heal: true 9 | auto-load: true 10 | bed-respawn: allow # should parse to true as boolean 11 | difficulty: normal 12 | entry-fee: 13 | enabled: false 14 | amount: 0.0 15 | currency: dirt # should be parsed to @minecraft:dirt 16 | environment: normal 17 | gamemode: sUrvivAl # random casing shouldn't affect parsing 18 | biome: '' 19 | generator: '' 20 | hidden: false 21 | hunger: true 22 | keep-spawn-in-memory: true 23 | player-limit: -1 24 | portal-form: all 25 | pvp: true 26 | respawn-world: '' 27 | scale: '4' # string number should be parsed as double 28 | seed: -9223372036854775808 29 | spawn-location: 30 | ==: MVSpawnLocation 31 | x: -64.0 32 | y: 64.0 33 | z: 48.0 34 | pitch: 0.0 35 | yaw: 0.0 36 | spawning: 37 | animal: 38 | spawn: falSe 39 | tick-rate: 123 40 | spawn-limit: -1 41 | exceptions: [cow] 42 | world-blacklist: # should be parsed as list of string 43 | - a 44 | - 1 45 | - 2 46 | version: 1.2 47 | world_nether: 48 | adjust-spawn: false 49 | alias: '' 50 | allow-advancement-grant: true 51 | allow-flight: false 52 | allow-weather: true 53 | auto-heal: true 54 | auto-load: true 55 | bed-respawn: true 56 | difficulty: normal 57 | entry-fee: 58 | enabled: false 59 | amount: 0.0 60 | currency: '@vault-economy' 61 | environment: nether 62 | gamemode: survival 63 | biome: '' 64 | generator: '' 65 | hidden: false 66 | hunger: true 67 | keep-spawn-in-memory: true 68 | player-limit: -1 69 | portal-form: all 70 | pvp: true 71 | respawn-world: '' 72 | scale: 8.0 73 | seed: -9223372036854775808 74 | spawn-location: 75 | ==: MVSpawnLocation 76 | x: -64.0 77 | y: 64.0 78 | z: 48.0 79 | pitch: 0.0 80 | yaw: 0.0 81 | spawning: {} 82 | world-blacklist: [] 83 | version: 1.2 84 | -------------------------------------------------------------------------------- /src/test/resources/worlds/migrated_worlds.yml: -------------------------------------------------------------------------------- 1 | world_the_end: 2 | adjust-spawn: false 3 | alias: '&aworld the end' 4 | allow-advancement-grant: true 5 | allow-flight: true 6 | allow-weather: true 7 | anchor-respawn: true 8 | auto-heal: true 9 | auto-load: true 10 | bed-respawn: true 11 | difficulty: normal 12 | entry-fee: 13 | enabled: false 14 | amount: 0.0 15 | currency: '@vault-economy' 16 | environment: the_end 17 | gamemode: survival 18 | biome: '' 19 | generator: '' 20 | hidden: false 21 | hunger: true 22 | keep-spawn-in-memory: true 23 | player-limit: -1 24 | portal-form: all 25 | pvp: true 26 | respawn-world: '' 27 | scale: 16.0 28 | seed: -5176596003035866649 29 | spawn-location: 30 | ==: MVSpawnLocation 31 | x: 0.0 32 | y: 65.0 33 | z: 0.0 34 | pitch: 0.0 35 | yaw: 0.0 36 | spawning: 37 | animal: 38 | exceptions: [ ] 39 | spawn: true 40 | spawn-limit: -1 41 | tick-rate: -1 42 | monster: 43 | exceptions: [ ] 44 | spawn: true 45 | spawn-limit: -1 46 | tick-rate: -1 47 | world-blacklist: [] 48 | version: 1.2 49 | world: 50 | adjust-spawn: true 51 | alias: '' 52 | allow-advancement-grant: true 53 | allow-flight: false 54 | allow-weather: true 55 | anchor-respawn: true 56 | auto-heal: true 57 | auto-load: true 58 | bed-respawn: true 59 | difficulty: normal 60 | entry-fee: 61 | enabled: true 62 | amount: 5.0 63 | currency: DIRT 64 | environment: normal 65 | gamemode: survival 66 | biome: '' 67 | generator: '' 68 | hidden: false 69 | hunger: true 70 | keep-spawn-in-memory: true 71 | player-limit: -1 72 | portal-form: all 73 | pvp: true 74 | respawn-world: '' 75 | scale: 1.0 76 | seed: -5176596003035866649 77 | spawn-location: 78 | ==: MVSpawnLocation 79 | x: -64.0 80 | y: 64.0 81 | z: 48.0 82 | pitch: 0.0 83 | yaw: 0.0 84 | spawning: 85 | animal: 86 | exceptions: [ ] 87 | spawn: true 88 | spawn-limit: -1 89 | tick-rate: -1 90 | monster: 91 | exceptions: [ ] 92 | spawn: true 93 | spawn-limit: -1 94 | tick-rate: -1 95 | world-blacklist: 96 | - test 97 | version: 1.2 98 | -------------------------------------------------------------------------------- /src/test/resources/worlds/properties_worlds.yml: -------------------------------------------------------------------------------- 1 | world: 2 | adjust-spawn: true 3 | alias: newalias 4 | allow-advancement-grant: true 5 | allow-flight: false 6 | allow-weather: true 7 | anchor-respawn: true 8 | auto-heal: true 9 | auto-load: true 10 | bed-respawn: true 11 | difficulty: NORMAL 12 | entry-fee: 13 | enabled: false 14 | amount: 0.0 15 | currency: @vault-economy 16 | environment: NORMAL 17 | gamemode: SURVIVAL 18 | biome: '' 19 | generator: '' 20 | hidden: false 21 | hunger: true 22 | keep-spawn-in-memory: true 23 | player-limit: -1 24 | portal-form: ALL 25 | pvp: true 26 | respawn-world: '' 27 | scale: 1.0 28 | seed: -9223372036854775808 29 | spawn-location: 30 | ==: MVSpawnLocation 31 | x: -64.0 32 | y: 64.0 33 | z: 48.0 34 | pitch: 0.0 35 | yaw: 0.0 36 | spawning: {} 37 | world-blacklist: [] 38 | version: 1.2 39 | world_nether: 40 | adjust-spawn: false 41 | alias: '' 42 | allow-advancement-grant: true 43 | allow-flight: false 44 | allow-weather: true 45 | anchor-respawn: true 46 | auto-heal: true 47 | auto-load: true 48 | bed-respawn: true 49 | difficulty: NORMAL 50 | entry-fee: 51 | enabled: false 52 | amount: 0.0 53 | currency: @vault-economy 54 | environment: NETHER 55 | gamemode: SURVIVAL 56 | biome: '' 57 | generator: '' 58 | hidden: false 59 | hunger: true 60 | keep-spawn-in-memory: true 61 | player-limit: -1 62 | portal-form: ALL 63 | pvp: true 64 | respawn-world: '' 65 | scale: 1.0 66 | seed: -9223372036854775808 67 | spawn-location: 68 | ==: MVNullLocation (It's a bug if you see this in your config file) 69 | spawning: {} 70 | world-blacklist: [] 71 | version: 1.2 72 | -------------------------------------------------------------------------------- /src/test/resources/worlds/updated_worlds.yml: -------------------------------------------------------------------------------- 1 | world: 2 | adjust-spawn: true 3 | alias: newalias 4 | allow-advancement-grant: true 5 | allow-flight: false 6 | allow-weather: true 7 | anchor-respawn: true 8 | auto-heal: true 9 | auto-load: true 10 | bed-respawn: true 11 | difficulty: normal 12 | entry-fee: 13 | enabled: false 14 | amount: 0.0 15 | currency: '@vault-economy' 16 | environment: normal 17 | gamemode: survival 18 | biome: '' 19 | generator: '' 20 | hidden: false 21 | hunger: true 22 | keep-spawn-in-memory: true 23 | player-limit: -1 24 | portal-form: all 25 | pvp: true 26 | respawn-world: '' 27 | scale: 1.0 28 | seed: -9223372036854775808 29 | spawn-location: 30 | ==: MVSpawnLocation 31 | x: -50.0 32 | y: 50.0 33 | z: 50.0 34 | pitch: 0.0 35 | yaw: 0.0 36 | spawning: 37 | animal: 38 | spawn: true 39 | tick-rate: 111 40 | spawn-limit: -1 41 | exceptions: 42 | - cow 43 | - pig 44 | misc: 45 | spawn: false 46 | tick-rate: -1 47 | spawn-limit: -1 48 | exceptions: [ ] 49 | world-blacklist: [] 50 | version: 1.2 51 | world_nether: 52 | adjust-spawn: false 53 | alias: '' 54 | allow-advancement-grant: true 55 | allow-flight: false 56 | allow-weather: true 57 | anchor-respawn: true 58 | auto-heal: true 59 | auto-load: true 60 | bed-respawn: true 61 | difficulty: normal 62 | entry-fee: 63 | enabled: false 64 | amount: 0.0 65 | currency: '@vault-economy' 66 | environment: nether 67 | gamemode: survival 68 | biome: '' 69 | generator: '' 70 | hidden: false 71 | hunger: true 72 | keep-spawn-in-memory: true 73 | player-limit: -1 74 | portal-form: all 75 | pvp: true 76 | respawn-world: '' 77 | scale: 8.0 78 | seed: -9223372036854775808 79 | spawn-location: 80 | ==: MVSpawnLocation 81 | x: -64.0 82 | y: 64.0 83 | z: 48.0 84 | pitch: 0.0 85 | yaw: 0.0 86 | spawning: {} 87 | world-blacklist: [] 88 | version: 1.2 89 | --------------------------------------------------------------------------------