├── .checkstyle └── checkstyle.xml ├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ └── gradle.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── HEADER ├── LICENSE ├── README.md ├── SUPPORT.md ├── THIRD-PARTY.md ├── build.gradle.kts ├── gradle.properties ├── gradle ├── build-logic │ ├── build.gradle.kts │ ├── settings.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ ├── extensions.kt │ │ ├── hyperverse.base-conventions.gradle.kts │ │ └── hyperverse.publishing-conventions.gradle.kts ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── hyperverse-core ├── build.gradle.kts └── src │ ├── license │ ├── THIRD-PARTY.properties │ └── license.ftl │ └── main │ ├── java │ └── org │ │ └── incendo │ │ └── hyperverse │ │ ├── Hyperverse.java │ │ ├── HyperverseAPI.java │ │ ├── commands │ │ ├── HyperCloudCommandManager.java │ │ ├── HyperCommandManager.java │ │ ├── package-info.java │ │ └── parser │ │ │ ├── EnumParser.java │ │ │ ├── GameRuleParser.java │ │ │ ├── HyperWorldParser.java │ │ │ ├── WorldFlagParser.java │ │ │ └── WorldStructureSettingParser.java │ │ ├── configuration │ │ ├── FileConfigurationObject.java │ │ ├── FileHyperConfiguration.java │ │ ├── HyperConfiguration.java │ │ ├── Message.java │ │ ├── Messages.java │ │ └── package-info.java │ │ ├── database │ │ ├── HyperDatabase.java │ │ ├── LocationType.java │ │ ├── PersistentLocation.java │ │ ├── SQLiteDatabase.java │ │ └── SimpleLocationTransformer.java │ │ ├── events │ │ ├── HyperPlayerEvent.java │ │ ├── HyperWorldCreateEvent.java │ │ ├── HyperWorldDeleteEvent.java │ │ ├── HyperWorldEvent.java │ │ ├── HyperverseEvent.java │ │ ├── PlayerSeekSpawnEvent.java │ │ ├── PlayerSetSpawnEvent.java │ │ └── SimpleHyperEventFactory.java │ │ ├── exception │ │ ├── HyperException.java │ │ ├── HyperWorldCreationException.java │ │ ├── HyperWorldValidationException.java │ │ └── package-info.java │ │ ├── features │ │ ├── PluginFeature.java │ │ ├── PluginFeatureManager.java │ │ └── external │ │ │ ├── EssentialsFeature.java │ │ │ ├── HyperverseExpansion.java │ │ │ └── PlaceholderAPIFeature.java │ │ ├── flags │ │ ├── FlagContainer.java │ │ ├── FlagParseException.java │ │ ├── GlobalWorldFlagContainer.java │ │ ├── WorldFlag.java │ │ ├── WorldFlagContainer.java │ │ └── implementation │ │ │ ├── AdvancementFlag.java │ │ │ ├── AliasFlag.java │ │ │ ├── BooleanFlag.java │ │ │ ├── CreatureSpawnFlag.java │ │ │ ├── DifficultyFlag.java │ │ │ ├── EndFlag.java │ │ │ ├── ForceSpawn.java │ │ │ ├── GamemodeFlag.java │ │ │ ├── IgnoreBedsFlag.java │ │ │ ├── LocalRespawnFlag.java │ │ │ ├── MobSpawnFlag.java │ │ │ ├── NetherFlag.java │ │ │ ├── ProfileGroupFlag.java │ │ │ ├── PveFlag.java │ │ │ ├── PvpFlag.java │ │ │ ├── RespawnWorldFlag.java │ │ │ ├── SaveWorldFlag.java │ │ │ ├── UnloadSpawnFlag.java │ │ │ └── WorldPermissionFlag.java │ │ ├── listeners │ │ ├── EventListener.java │ │ ├── PaperListener.java │ │ ├── WorldListener.java │ │ └── package-info.java │ │ ├── modules │ │ ├── BukkitModule.java │ │ ├── FlagContainerFactory.java │ │ ├── HyperEventFactory.java │ │ ├── HyperWorldCreatorFactory.java │ │ ├── HyperWorldFactory.java │ │ ├── HyperverseModule.java │ │ ├── PersistentLocationTransformer.java │ │ ├── TaskFactoryModule.java │ │ ├── TeleportationManagerFactory.java │ │ ├── WorldConfigurationFactory.java │ │ ├── WorldImporterFactory.java │ │ └── package-info.java │ │ ├── platform │ │ ├── PlatformProvider.java │ │ ├── PlatformProvisionException.java │ │ └── ReflectionPlatformProvider.java │ │ ├── service │ │ ├── internal │ │ │ ├── SafeTeleportService.java │ │ │ └── package-info.java │ │ └── package-info.java │ │ ├── teleportation │ │ ├── SimpleTeleportationManager.java │ │ ├── TeleportationManager.java │ │ └── package-info.java │ │ ├── util │ │ ├── GeneratorUtil.java │ │ ├── IncendoPaster.java │ │ ├── MessageUtil.java │ │ ├── MultiverseImporter.java │ │ ├── MyWorldsImporter.java │ │ ├── NullRouteCommandSender.java │ │ ├── SeedUtil.java │ │ ├── WorldUtil.java │ │ ├── package-info.java │ │ └── versioning │ │ │ ├── PreReleaseType.java │ │ │ ├── Version.java │ │ │ ├── VersionData.java │ │ │ └── VersionUtil.java │ │ └── world │ │ ├── HyperWorld.java │ │ ├── HyperWorldCreator.java │ │ ├── SimpleWorld.java │ │ ├── SimpleWorldConfigurationFactory.java │ │ ├── SimpleWorldManager.java │ │ ├── WorldConfiguration.java │ │ ├── WorldConfigurationBuilder.java │ │ ├── WorldFeatures.java │ │ ├── WorldManager.java │ │ ├── WorldStructureSetting.java │ │ ├── WorldType.java │ │ └── package-info.java │ └── resources │ ├── messages_de.conf │ ├── messages_fr.conf │ ├── messages_sv.conf │ ├── messages_zh_CN.conf │ ├── messages_zh_TW.conf │ └── raw │ └── messages.conf ├── hyperverse-nms-1-20-6 ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── incendo │ └── hyperverse │ └── platform │ └── v1_20_6 │ └── NMSImpl.java ├── hyperverse-nms-1-21-3 ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── incendo │ └── hyperverse │ └── platform │ └── v1_21_3 │ └── NMSImpl.java ├── hyperverse-nms-1-21-4 ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── incendo │ └── hyperverse │ └── platform │ └── v1_21_4 │ └── NMSImpl.java ├── hyperverse-nms-1-21 ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── incendo │ └── hyperverse │ └── platform │ └── v1_21 │ └── NMSImpl.java ├── hyperverse-nms-common ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── incendo │ └── hyperverse │ └── util │ ├── HyperConfigShouldGroupProfiles.java │ ├── NMS.java │ └── package-info.java ├── hyperverse-nms-unsupported ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── incendo │ └── hyperverse │ └── platform │ └── unsupported │ └── NMSImpl.java └── settings.gradle.kts /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: IntellectualSites # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: [ 'https://paypal.me/Sauilitired' ]# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Server Version:** 23 | - Paper version: 24 | - Spigot version: 25 | - CraftBukkit version: 26 | 27 | **Additional context** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | name: Java CI with Gradle 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | build: 7 | # Only run on PRs if the source branch is on someone else's repo 8 | if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} 9 | strategy: 10 | matrix: 11 | os: ["ubuntu-latest", "windows-latest"] 12 | runs-on: "${{ matrix.os }}" 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Set up JDK 21 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: '21' 19 | distribution: 'zulu' 20 | cache: 'gradle' 21 | - uses: gradle/actions/wrapper-validation@v3 22 | - name: Build with Gradle 23 | run: ./gradlew clean build 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | 16 | 17 | ## [Unreleased] 18 | 19 | ### Added 20 | - Configurable messages 21 | - Teleportation manager 22 | - Vanilla-esque end and nether portals 23 | - Code documentation 24 | - Option to keep spawn chunks loaded 25 | - `/hyperverse debugpaste` 26 | - Added per-world player data 27 | 28 | ### Changed 29 | - Made the module(s) version dependent 30 | - Use hocon for configuration rather than yaml 31 | - Made the plugin disable if anything fails to load 32 | - Removed the jar splitting. One jar works for all supported versions. 33 | 34 | ### Removed 35 | - Support for Minecraft 1.16 and 1.16.1. 36 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at contact@alexander-soderberg.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribute 2 | 3 | ## NMS and CB References 4 | 5 | Utility classes (such as GeneratorUtil) can either 6 | make use of reflection, or added to the version specific 7 | submodules. 8 | 9 | If the code is likely to change between versions, 10 | it should be added to a version specific module. 11 | 12 | Code that rarely/never changes can use reflection directly, 13 | but does not necessarily have to. 14 | 15 | ## World Interaction 16 | 17 | Load chunks asynchronously using PaperLib whenever possible. 18 | 19 | ## Dependency Injection 20 | 21 | Hypeverse uses Guice for dependency injection. 22 | Make sure to follow common DI principles. 23 | 24 | ## Style 25 | 26 | This project uses the PlotSquared code style. 27 | A profile for this can be found [here](https://github.com/IntellectualSites/PlotSquared/blob/v5/code_style.xml). 28 | 29 | Other than that, try to keep annotations on the same line 30 | as method and type declarations when possible. Mark 31 | all non-mutable fields as final, and make liberal 32 | use of @Nullable and @NonNull annotations. 33 | 34 | ## Licensing 35 | 36 | The plugin is licensed under GPLv3. Each source file 37 | should have a license header, and the template for this 38 | can be found in the HEADER file. 39 | 40 | By contributing to the project you guarantee that your 41 | code follows the GPLv3 License requirements. 42 | 43 | ## Configuration Options 44 | 45 | Whenever Hyperverse introduces behaviour that deviates from 46 | the vanilla experience, it needs to be configurable. 47 | 48 | All configuration options needs to be added to the `HyperConfig` 49 | interface as getters. These should be implemented in 50 | `FileHyperConfiguration`. This implementation class delegates 51 | the getters to `FileConfigurationObject`, which is read by 52 | [configurate](https://github.com/SpongePowered/Configurate). 53 | All configuration options should be commented and given default 54 | values in `FileConfigurationObject`. 55 | 56 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | **Hyperverse is W.I.P!** 6 | 7 | [![TeamCity](https://ci.intellectualsites.com/app/rest/builds/aggregated/strob:(buildType:(project:(id:Hyperverse_2)))/statusIcon.svg)](https://ci.intellectualsites.com/project.html?projectId=Hyperverse_2&tab=projectOverview&guest=1) 8 | [![CodeFactor](https://www.codefactor.io/repository/github/sauilitired/hyperverse/badge)](https://www.codefactor.io/repository/github/sauilitired/hyperverse) ![Java CI with Maven](https://github.com/Sauilitired/Hyperverse/workflows/Java%20CI%20with%20Maven/badge.svg) 9 | 10 | A Minecraft world management plugin for Bukkit 1.17, 1.18, 1.19 and 1.20. 11 | Only the latest minor version is support (i.e. 1.20.4 for 1.20.x) 12 | More versions may come to be supported in the future. 13 | 14 | ## Features 15 | 16 | Current Features: 17 | - World creation 18 | - World importing (will automatically import worlds) 19 | - World loading/unloading 20 | - World teleportation 21 | - World flags (gamemode, local-spawn, force-spawn, 22 | pve, pvp, world-permission, nether, end, profile-group, difficulty, creature-spawn, mob-spawn, respawn-world, ignore-beds, alias, unload-spawn) 23 | - World game rules 24 | - Tab completed commands 25 | - Persistent world locations 26 | - Nether & end portal linking 27 | - Per world player data 28 | - Per world beds 29 | - World regeneration 30 | 31 | ## Links 32 | 33 | 34 | ### Downloads 35 | - [Spigot](https://www.spigotmc.org/resources/hyperverse-w-i-p.77550/) 36 | - [Development Builds #1](https://ci.athion.net/job/Hyperverse/) 37 | - [Development Builds #2](https://ci.intellectualsites.com/project.html?projectId=Hyperverse_2&tab=projectOverview&guest=1) 38 | - [Issue Tracker](https://issues.intellectualsites.com/projects/58b45c18-71d9-4e6a-9095-68761926c007) 39 | 40 | ### Documentation 41 | - [Wiki](https://wiki.intellectualsites.com/hyperverse/home) 42 | - [JavaDoc](https://plotsquared.com/docs/hyperverse/) 43 | 44 | ## Contributing 45 | 46 | Contributions are very welcome. Some general contribution 47 | guidelines can be found in [CONTRIBUTING.md](https://github.com/Sauilitired/Hyperverse/blob/master/CONTRIBUTING.md) 48 | 49 | 50 |

51 | 52 |

53 | 54 | ## Maven 55 | 56 | ```xml 57 | 58 | 59 | 60 | intellectualsites-snapshots 61 | https://mvn.intellectualsites.com/content/repositories/snapshots 62 | 63 | 64 | 65 | 66 | 67 | org.incendo.hyperverse 68 | Core 69 | 0.11.0-SNAPSHOT 70 | provided 71 | 72 | 73 | org.incendo.hyperverse 74 | Core 75 | 0.11.0-SNAPSHOT 76 | javadoc 77 | provided 78 | 79 | 80 | org.incendo.hyperverse 81 | Core 82 | 0.11.0-SNAPSHOT 83 | sources 84 | provided 85 | 86 | 87 | ``` 88 | 89 | ## API 90 | 91 | A majority of the API is accessible using `Hyperverse.getApi()`. For example, creating 92 | a world is easy as: 93 | 94 | ```java 95 | WorldConfiguration worldConfiguration = WorldConfiguration.builder() 96 | .setName("your world").setType(WorldType.NETHER) 97 | .setWorldFeatures(WorldFeatures.FLATLAND).createWorldConfiguration(); 98 | try { 99 | HyperWorld world = Hyperverse.getApi().createWorld(worldConfiguration); 100 | } catch (HyperWorldCreationException e) { 101 | e.printStackTrace(); 102 | } 103 | ``` 104 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Discord 2 | 3 | It is preferred to use our [Discord](https://discord.gg/KxkjDVg) 4 | to get Hyperverse support 5 | -------------------------------------------------------------------------------- /THIRD-PARTY.md: -------------------------------------------------------------------------------- 1 | Lists of 29 third-party dependencies. 2 | - (Public Domain) [AOP alliance (aopalliance:aopalliance:1.0)](http://aopalliance.sourceforge.net) 3 | - (MIT) [DelegatingMap (co.aikar:DelegatingMap:1.0.0-20180331.052245-5)]() 4 | - (MIT) [Table (co.aikar:Table:1.0.0-20180331.054128-7)]() 5 | - (MIT) [ACF (Bukkit) (co.aikar:acf-bukkit:0.5.0-20200418.224218-165)](https://acf.emc.gs/acf-bukkit) 6 | - (MIT) [ACF (Core) (co.aikar:acf-core:0.5.0-20200418.224207-160)](https://acf.emc.gs/acf-core) 7 | - (MIT) [locales (co.aikar:locales:1.0-20181221.115311-17)]() 8 | - (MIT) [MinecraftTimings (co.aikar:minecraft-timings:1.0.4)]() 9 | - (MIT) [TaskChain (Bukkit) (co.aikar:taskchain-bukkit:3.7.2)](https://taskchain.emc.gs/taskchain-bukkit) 10 | - (MIT) [TaskChain (Core) (co.aikar:taskchain-core:3.7.2)](https://taskchain.emc.gs/taskchain-core) 11 | - (Apache 2.0) [Gson (com.google.code.gson:gson:2.8.0)](https://github.com/google/gson/gson) 12 | - (The Apache Software License, Version 2.0) [Guava: Google Core Libraries for Java (com.google.guava:guava:21.0)](https://github.com/google/guava/guava) 13 | - (The Apache Software License, Version 2.0) [Google Guice - Core Library (com.google.inject:guice:4.2.3)](https://github.com/google/guice/guice) 14 | - (The Apache Software License, Version 2.0) [Google Guice - Extensions - AssistedInject (com.google.inject.extensions:guice-assistedinject:4.2.3)](https://github.com/google/guice/extensions-parent/guice-assistedinject) 15 | - (ISC License) [ORMLite Core (com.j256.ormlite:ormlite-core:5.1)](http://ormlite.sourceforge.net/) 16 | - (ISC License) [ORMLite JDBC (com.j256.ormlite:ormlite-jdbc:5.1)](http://ormlite.sourceforge.net/) 17 | - (Apache License, Version 2.0) [config (com.typesafe:config:1.3.1)](https://github.com/typesafehub/config) 18 | - (The Apache Software License, Version 2.0) [Commons Lang (commons-lang:commons-lang:2.6)](http://commons.apache.org/lang/) 19 | - (MIT) [PaperLib (io.papermc:paperlib:1.0.2)](https://github.com/PaperMC/PaperLib) 20 | - (The Apache Software License, Version 2.0) [javax.inject (javax.inject:javax.inject:1)](http://code.google.com/p/atinject/) 21 | - (MIT) [MiniMessage (me.minidigger:MiniMessage:1.0.1)](https://github.com/MiniDigger/MiniMessage) 22 | - (Apache License, Version 2.0) [ExpiringMap (net.jodah:expiringmap:0.5.8)](http://github.com/jhalterman/expiringmap/) 23 | - (The BSD 3-Clause License) [BungeeCord-Chat (net.md-5:bungeecord-chat:1.15-20200422.221048-64)](https://github.com/SpigotMC/BungeeCord/bungeecord-chat) 24 | - (The GNU Lesser General Public License v3.0) [bstats-bukkit (org.bstats:bstats-bukkit:1.7)](https://bstats.org/bstats-bukkit/) 25 | - (GNU General Public License, version 2 (GPL2), with the classpath exception)- (The MIT License) [Checker Qual (org.checkerframework:checker-qual:2.4.0)](https://checkerframework.org) 26 | - (GNU General Public License v3.0) [Spigot-API (org.spigotmc:spigot-api:1.15.2-R0.1-20200423.014400-96)](https://www.spigotmc.org/) 27 | - (Apache License, Version 2.0) [configurate-core (org.spongepowered:configurate-core:3.6.1)](https://github.com/SpongePowered/configurate/) 28 | - (Apache License, Version 2.0) [configurate-hocon (org.spongepowered:configurate-hocon:3.6.1)](https://github.com/SpongePowered/configurate/) 29 | - (Apache License, Version 2.0) [SnakeYAML (org.yaml:snakeyaml:1.25)](http://www.snakeyaml.org) 30 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.cloud.buildLogic.rootProject.publishing) 3 | alias(libs.plugins.cloud.buildLogic.rootProject.spotless) 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | spotlessPredeclare { 11 | kotlin { ktlint(libs.versions.ktlint.get()) } 12 | kotlinGradle { ktlint(libs.versions.ktlint.get()) } 13 | } 14 | 15 | subprojects { 16 | if ("nms" in name) { 17 | tasks { 18 | whenTaskAdded { 19 | if ("checkstyle" in name) { 20 | enabled = false 21 | } 22 | } 23 | } 24 | } 25 | 26 | afterEvaluate { 27 | tasks.withType().configureEach { 28 | options.compilerArgs.remove("-Werror") 29 | } 30 | tasks.findByName("spotlessConfigsCheck")?.enabled = false 31 | } 32 | } 33 | 34 | tasks { 35 | spotlessCheck { 36 | dependsOn(gradle.includedBuild("build-logic").task(":spotlessCheck") ) 37 | } 38 | spotlessApply { 39 | dependsOn(gradle.includedBuild("build-logic").task(":spotlessApply")) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=org.incendo 2 | version=1.0.0-SNAPSHOT 3 | description=Minecraft world management plugin 4 | 5 | org.gradle.parallel=true 6 | org.gradle.jvmargs=-Xmx512m 7 | org.gradle.java.installations.auto-download=false 8 | org.gradle.caching=true 9 | -------------------------------------------------------------------------------- /gradle/build-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | alias(libs.plugins.cloud.buildLogic.spotless) 4 | } 5 | 6 | repositories { 7 | gradlePluginPortal() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | implementation(libs.cloud.build.logic) 13 | implementation(libs.gradleKotlinJvm) 14 | 15 | implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) 16 | } 17 | 18 | cloudSpotless { 19 | licenseHeaderFile.convention(null as RegularFile?) 20 | ktlintVersion = libs.versions.ktlint 21 | } 22 | -------------------------------------------------------------------------------- /gradle/build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-logic" 2 | 3 | pluginManagement { 4 | repositories { 5 | gradlePluginPortal() 6 | mavenLocal() 7 | } 8 | } 9 | 10 | dependencyResolutionManagement { 11 | versionCatalogs { 12 | create("libs") { 13 | from(files("../libs.versions.toml")) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gradle/build-logic/src/main/kotlin/extensions.kt: -------------------------------------------------------------------------------- 1 | import org.gradle.accessors.dm.LibrariesForLibs 2 | import org.gradle.api.Project 3 | import org.gradle.kotlin.dsl.the 4 | 5 | val Project.libs: LibrariesForLibs 6 | get() = the() 7 | -------------------------------------------------------------------------------- /gradle/build-logic/src/main/kotlin/hyperverse.base-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("org.incendo.cloud-build-logic") 3 | id("org.incendo.cloud-build-logic.spotless") 4 | } 5 | 6 | indra { 7 | javaVersions { 8 | minimumToolchain(21) 9 | target(21) 10 | testWith().set(setOf(21)) 11 | } 12 | checkstyle().set(libs.versions.checkstyle) 13 | } 14 | 15 | repositories { 16 | mavenLocal() 17 | mavenCentral() 18 | maven("https://oss.sonatype.org/content/repositories/snapshots/") { 19 | name = "sonatypeOssSnapshots" 20 | mavenContent { 21 | snapshotsOnly() 22 | } 23 | } 24 | 25 | maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 26 | maven("https://repo.aikar.co/content/groups/aikar/") 27 | maven("https://repo.papermc.io/repository/maven-public/") 28 | maven("https://repo.codemc.org/repository/maven-public/") 29 | maven("https://repo.spongepowered.org/maven") 30 | maven("https://repo.onarandombox.com/content/repositories/multiverse/") 31 | maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") 32 | maven("https://ci.mg-dev.eu/plugin/repository/everything/") 33 | maven("https://repo.essentialsx.net/releases/") 34 | } 35 | -------------------------------------------------------------------------------- /gradle/build-logic/src/main/kotlin/hyperverse.publishing-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.incendo.cloudbuildlogic.city 2 | 3 | plugins { 4 | id("org.incendo.cloud-build-logic.publishing") 5 | } 6 | 7 | indra { 8 | github("Incendo", "hyperverse") { 9 | ci(true) 10 | } 11 | mitLicense() 12 | 13 | configurePublications { 14 | pom { 15 | developers { 16 | city() 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | cloud-build-logic = "0.0.3" 3 | ktlint = "0.50.0" 4 | checkstyle = "10.12.5" 5 | kotlin = "1.9.20" 6 | shadow = "9.0.0-beta8" 7 | paperweight = "2.0.0-beta.14" 8 | run-paper = "2.3.1" 9 | pluginyml = "0.6.0" 10 | 11 | # Platforms 12 | minecraft = "1.20.6-R0.1-SNAPSHOT" 13 | 14 | # Libraries 15 | cloud = "1.8.4" 16 | guice = "5.1.0" 17 | paperlib = "1.0.8" 18 | taskchain = "3.7.2" 19 | bstats = "3.0.2" 20 | configurate = "4.1.2" 21 | 22 | # Minecraft Plugins 23 | multiverse = "4.3.1" 24 | myworlds = "1.20.4-v3" 25 | essentialsx = "2.20.1" 26 | placeholderapi = "2.11.5" 27 | 28 | [libraries] 29 | cloud-build-logic = { module = "org.incendo:cloud-build-logic", version.ref = "cloud-build-logic" } 30 | gradleKotlinJvm = { group = "org.jetbrains.kotlin.jvm", name = "org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" } 31 | 32 | # Platform 33 | paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "minecraft" } 34 | 35 | # Libraries 36 | cloudPaper = { group = "cloud.commandframework", name = "cloud-paper", version.ref = "cloud" } 37 | cloudMinecraftExtras = { group = "cloud.commandframework", name = "cloud-minecraft-extras", version.ref = "cloud" } 38 | cloudAnnotations = { group = "cloud.commandframework", name = "cloud-annotations", version.ref = "cloud" } 39 | guice = { group = "com.google.inject", name = "guice", version.ref = "guice" } 40 | assistedInject = { group = "com.google.inject.extensions", name = "guice-assistedinject", version.ref = "guice" } 41 | paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib"} 42 | taskchain = { group = "co.aikar", name = "taskchain-bukkit", version.ref = "taskchain" } 43 | bstats = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" } 44 | configurateHocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate"} 45 | 46 | # Minecraft Plugins 47 | multiverse = { group = "com.onarandombox.multiversecore", name = "Multiverse-Core", version.ref = "multiverse" } 48 | myworlds = { group = "com.bergerkiller.bukkit", name = "MyWorlds", version.ref = "myworlds" } 49 | essentialsx = { group = "net.essentialsx", name = "EssentialsX", version.ref = "essentialsx" } 50 | placeholderapi = { group = "me.clip", name = "placeholderapi", version.ref = "placeholderapi" } 51 | 52 | [plugins] 53 | paperweight-userdev = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight" } 54 | cloud-buildLogic-spotless = { id = "org.incendo.cloud-build-logic.spotless", version.ref = "cloud-build-logic" } 55 | cloud-buildLogic-rootProject-publishing = { id = "org.incendo.cloud-build-logic.publishing.root-project", version.ref = "cloud-build-logic" } 56 | cloud-buildLogic-rootProject-spotless = { id = "org.incendo.cloud-build-logic.spotless.root-project", version.ref = "cloud-build-logic" } 57 | shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } 58 | run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" } 59 | pluginyml = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" } 60 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Incendo/Hyperverse/857837404d81559aaf6c8e62e0639e99f2dba761/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.12.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /hyperverse-core/src/license/THIRD-PARTY.properties: -------------------------------------------------------------------------------- 1 | # Generated by org.codehaus.mojo.license.AddThirdPartyMojo 2 | #------------------------------------------------------------------------------- 3 | # Already used licenses in project : 4 | # - Apache 2.0 5 | # - Apache License, Version 2.0 6 | # - GNU General Public License, version 2 (GPL2), with the classpath exception 7 | # - ISC License 8 | # - MIT 9 | # - Public Domain 10 | # - The Apache Software License, Version 2.0 11 | # - The BSD 3-Clause License 12 | # - The GNU Lesser General Public License v3.0 13 | # - The MIT License 14 | #------------------------------------------------------------------------------- 15 | # Please fill the missing licenses for dependencies : 16 | # 17 | # 18 | #Thu Apr 23 22:57:57 CEST 2020 19 | co.aikar--taskchain-bukkit--3.7.2=MIT 20 | co.aikar--DelegatingMap--1.0.0-20180331.052245-5=MIT 21 | co.aikar--acf-bukkit--0.5.0-20200418.224218-165=MIT 22 | co.aikar--locales--1.0-20181221.115311-17=MIT 23 | co.aikar--taskchain-core--3.7.2=MIT 24 | co.aikar--minecraft-timings--1.0.4=MIT 25 | co.aikar--Table--1.0.0-20180331.054128-7=MIT 26 | org.spigotmc--spigot-api--1.15.2-R0.1-20200423.014400-96=GNU General Public License v3.0 27 | co.aikar--acf-core--0.5.0-20200418.224207-160=MIT 28 | -------------------------------------------------------------------------------- /hyperverse-core/src/license/license.ftl: -------------------------------------------------------------------------------- 1 | <#function licenseFormat licenses> 2 | <#assign result = ""/> 3 | <#list licenses as license> 4 | <#assign result = result + "- (" + license + ")"/> 5 | 6 | <#return result> 7 | 8 | <#function artifactFormat p> 9 | <#if p.name?index_of('Unnamed') > -1> 10 | <#return "[" + p.artifactId + " (" + p.groupId + ":" + p.artifactId + ":" + p.version +")](" + (p.url!"") + ")"> 11 | <#else> 12 | <#return "[" + p.name + " (" + p.groupId + ":" + p.artifactId + ":" + p.version +")](" + (p.url!"") + ")"> 13 | 14 | 15 | <#if dependencyMap?size == 0> 16 | The project has no dependencies. 17 | <#else> 18 | Lists of ${dependencyMap?size} third-party dependencies. 19 | <#list dependencyMap as e> 20 | <#assign project = e.getKey()/> 21 | <#assign licenses = e.getValue()/> 22 | ${licenseFormat(licenses)} ${artifactFormat(project)} 23 | 24 | 25 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/HyperverseAPI.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse; 19 | 20 | import cloud.commandframework.services.ServicePipeline; 21 | import com.google.inject.Injector; 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.incendo.hyperverse.configuration.HyperConfiguration; 24 | import org.incendo.hyperverse.database.HyperDatabase; 25 | import org.incendo.hyperverse.exception.HyperWorldCreationException; 26 | import org.incendo.hyperverse.features.PluginFeatureManager; 27 | import org.incendo.hyperverse.modules.HyperWorldFactory; 28 | import org.incendo.hyperverse.world.HyperWorld; 29 | import org.incendo.hyperverse.world.WorldConfiguration; 30 | import org.incendo.hyperverse.world.WorldManager; 31 | 32 | /** 33 | * Get an instance of the API using 34 | * {@link Hyperverse#getApi()} 35 | */ 36 | public interface HyperverseAPI { 37 | 38 | /** 39 | * Get the {@link WorldManager} implementation 40 | * used throughout Hyperverse 41 | * 42 | * @return World manager instance 43 | */ 44 | @NonNull WorldManager getWorldManager(); 45 | 46 | /** 47 | * Get the {@link Injector} instance 48 | * used throughout Hyperverse. This 49 | * can be used to create new instances 50 | * of various Hyperverse classes 51 | * 52 | * @return Injector instance. 53 | */ 54 | @NonNull Injector getInjector(); 55 | 56 | /** 57 | * Get the {@link HyperDatabase} implementation 58 | * used throughout Hyperverse 59 | * 60 | * @return Database instance 61 | */ 62 | @NonNull HyperDatabase getDatabase(); 63 | 64 | /** 65 | * Get the {@link HyperConfiguration} implementation 66 | * used throughout Hyperverse 67 | * 68 | * @return Configuration instance 69 | */ 70 | @NonNull HyperConfiguration getConfiguration(); 71 | 72 | /** 73 | * Get a factory class that creates 74 | * {@link org.incendo.hyperverse.world.HyperWorld worlds} 75 | * 76 | * @return World factory 77 | */ 78 | @NonNull HyperWorldFactory getWorldFactory(); 79 | 80 | /** 81 | * Attempt to create a new world from a given configuration. 82 | * This will only succeed if there is no world with the 83 | * given name present in the system, the name is allowed 84 | * and the specified generator exists and is loaded. 85 | * 86 | * @param configuration The configuration from which the 87 | * world will be created 88 | * @return The created world 89 | * @throws HyperWorldCreationException If the world cannot 90 | * be created from the given configuration 91 | */ 92 | @NonNull HyperWorld createWorld(final @NonNull WorldConfiguration configuration) 93 | throws HyperWorldCreationException; 94 | 95 | /** 96 | * Gets the plugin feature manager. This can be used to register third party plugin 97 | * hooks directly into Hyperverse 98 | * 99 | * @return The plugin feature manager 100 | */ 101 | @NonNull PluginFeatureManager getPluginFeatureManager(); 102 | 103 | /** 104 | * Get the service pipeline implementation used by Hyperverse. 105 | * 106 | * @return Service pipeline 107 | */ 108 | @NonNull ServicePipeline getServicePipeline(); 109 | 110 | } 111 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/commands/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Things related to world commands 20 | */ 21 | package org.incendo.hyperverse.commands; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/commands/parser/EnumParser.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.commands.parser; 19 | 20 | import cloud.commandframework.arguments.parser.ArgumentParseResult; 21 | import cloud.commandframework.arguments.parser.ArgumentParser; 22 | import cloud.commandframework.context.CommandContext; 23 | import cloud.commandframework.exceptions.parsing.NoInputProvidedException; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | 26 | import java.util.Arrays; 27 | import java.util.Comparator; 28 | import java.util.List; 29 | import java.util.Optional; 30 | import java.util.Queue; 31 | import java.util.function.Function; 32 | 33 | public final class EnumParser, C> implements ArgumentParser { 34 | 35 | private final Class enumClass; 36 | private final ArgumentParseResult errorResult; 37 | private final Function> fromStringMapper; 38 | private final Function toStringMapper; 39 | 40 | private static > Optional parseConstant(@NonNull final Class enumClass, @NonNull final String input) { 41 | try { 42 | return Optional.of(Enum.valueOf(enumClass, input)); 43 | } catch (IllegalArgumentException ignored) { 44 | // Invalid constant name so we return an empty optional 45 | return Optional.empty(); 46 | } 47 | } 48 | public static , C> @NonNull EnumParser createParer( 49 | @NonNull final Class enumClass, 50 | @NonNull final String errorMessage 51 | ) { 52 | return new EnumParser<>( 53 | enumClass, 54 | s -> parseConstant(enumClass, s), 55 | Enum::name, 56 | errorMessage 57 | ); 58 | } 59 | 60 | public EnumParser( 61 | @NonNull final Class enumClass, 62 | @NonNull final Function<@NonNull String, @NonNull Optional> fromStringMapper, 63 | @NonNull final Function<@NonNull E, @NonNull String> toStringMapper, 64 | @NonNull final String errorMessage 65 | ) { 66 | this.enumClass = enumClass; 67 | this.fromStringMapper = fromStringMapper; 68 | this.toStringMapper = toStringMapper; 69 | this.errorResult = ArgumentParseResult.failure(new IllegalStateException(errorMessage)); 70 | } 71 | 72 | @Override 73 | public @NonNull ArgumentParseResult<@NonNull E> parse( 74 | @NonNull final CommandContext<@NonNull C> commandContext, 75 | @NonNull final Queue<@NonNull String> inputQueue 76 | ) { 77 | if (inputQueue.isEmpty()) { 78 | return ArgumentParseResult.failure(new NoInputProvidedException(getClass(), commandContext)); 79 | } 80 | return this.fromStringMapper.apply(inputQueue.poll()) 81 | .map(ArgumentParseResult::success) 82 | .orElse(this.errorResult); 83 | } 84 | 85 | @Override 86 | public @NonNull List<@NonNull String> suggestions( 87 | @NonNull final CommandContext commandContext, 88 | @NonNull final String input 89 | ) { 90 | return Arrays.stream(this.enumClass.getEnumConstants()) 91 | .map(this.toStringMapper) 92 | .filter(name -> name.startsWith(input)) 93 | .sorted(Comparator.naturalOrder()) 94 | .toList(); 95 | } 96 | 97 | @Override 98 | public boolean isContextFree() { 99 | return true; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/commands/parser/GameRuleParser.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.commands.parser; 19 | 20 | import cloud.commandframework.arguments.parser.ArgumentParseResult; 21 | import cloud.commandframework.arguments.parser.ArgumentParser; 22 | import cloud.commandframework.context.CommandContext; 23 | import cloud.commandframework.exceptions.parsing.NoInputProvidedException; 24 | import org.bukkit.GameRule; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.incendo.hyperverse.configuration.Messages; 27 | 28 | import java.util.Arrays; 29 | import java.util.List; 30 | import java.util.Queue; 31 | 32 | public final class GameRuleParser implements ArgumentParser> { 33 | 34 | @Override 35 | public @NonNull ArgumentParseResult<@NonNull GameRule> parse( 36 | @NonNull final CommandContext<@NonNull C> commandContext, 37 | @NonNull final Queue<@NonNull String> inputQueue 38 | ) { 39 | if (inputQueue.isEmpty()) { 40 | return ArgumentParseResult.failure(new NoInputProvidedException(getClass(), commandContext)); 41 | } 42 | return java.util.Optional.ofNullable(GameRule.getByName(inputQueue.poll())) 43 | .>>map(ArgumentParseResult::success) 44 | .orElseGet(() -> ArgumentParseResult.failure(new IllegalArgumentException(Messages.messageInvalidGameRule.withoutColorCodes()))); 45 | } 46 | 47 | @Override 48 | public @NonNull List<@NonNull String> suggestions( 49 | @NonNull final CommandContext commandContext, 50 | @NonNull final String input 51 | ) { 52 | return Arrays.stream(GameRule.values()) 53 | .map(GameRule::getName) 54 | .filter(name -> name.startsWith(input)) 55 | .toList(); 56 | } 57 | 58 | @Override 59 | public boolean isContextFree() { 60 | return true; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/commands/parser/WorldFlagParser.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.commands.parser; 19 | 20 | import cloud.commandframework.arguments.parser.ArgumentParseResult; 21 | import cloud.commandframework.arguments.parser.ArgumentParser; 22 | import cloud.commandframework.context.CommandContext; 23 | import cloud.commandframework.exceptions.parsing.NoInputProvidedException; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.incendo.hyperverse.configuration.Messages; 26 | import org.incendo.hyperverse.flags.GlobalWorldFlagContainer; 27 | import org.incendo.hyperverse.flags.WorldFlag; 28 | 29 | import java.util.Comparator; 30 | import java.util.List; 31 | import java.util.Locale; 32 | import java.util.Queue; 33 | 34 | public final class WorldFlagParser implements ArgumentParser> { 35 | 36 | private final GlobalWorldFlagContainer flagContainer; 37 | 38 | public WorldFlagParser(@NonNull final GlobalWorldFlagContainer flagContainer) { 39 | this.flagContainer = flagContainer; 40 | } 41 | 42 | @Override 43 | public @NonNull ArgumentParseResult<@NonNull WorldFlag> parse( 44 | @NonNull final CommandContext<@NonNull C> commandContext, 45 | @NonNull final Queue<@NonNull String> inputQueue 46 | ) { 47 | if (inputQueue.isEmpty()) { 48 | return ArgumentParseResult.failure(new NoInputProvidedException(getClass(), commandContext)); 49 | } 50 | final WorldFlag flag = this.flagContainer.getFlagFromString(inputQueue.poll().toLowerCase(Locale.ENGLISH)); 51 | if (flag == null) { 52 | return ArgumentParseResult.failure(new IllegalArgumentException(Messages.messageFlagUnknown.withoutColorCodes())); 53 | } 54 | return ArgumentParseResult.success(flag); 55 | } 56 | 57 | @Override 58 | public @NonNull List suggestions( 59 | @NonNull final CommandContext context, 60 | @NonNull final String input 61 | ) { 62 | return this.flagContainer.getFlagMap().values().stream() 63 | .map(WorldFlag::getName) 64 | .filter(name -> name.startsWith(input)) 65 | .sorted(Comparator.naturalOrder()) 66 | .toList(); 67 | } 68 | 69 | @Override 70 | public boolean isContextFree() { 71 | return true; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/commands/parser/WorldStructureSettingParser.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.commands.parser; 19 | 20 | import cloud.commandframework.arguments.parser.ArgumentParseResult; 21 | import cloud.commandframework.arguments.parser.ArgumentParser; 22 | import cloud.commandframework.context.CommandContext; 23 | import cloud.commandframework.exceptions.parsing.NoInputProvidedException; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.incendo.hyperverse.configuration.Messages; 26 | import org.incendo.hyperverse.world.WorldStructureSetting; 27 | 28 | import java.util.Arrays; 29 | import java.util.Comparator; 30 | import java.util.List; 31 | import java.util.Locale; 32 | import java.util.Queue; 33 | 34 | public final class WorldStructureSettingParser implements ArgumentParser { 35 | 36 | 37 | @Override 38 | public @NonNull ArgumentParseResult<@NonNull WorldStructureSetting> parse( 39 | @NonNull final CommandContext<@NonNull C> commandContext, 40 | @NonNull final Queue<@NonNull String> inputQueue 41 | ) { 42 | if (inputQueue.isEmpty()) { 43 | return ArgumentParseResult.failure(new NoInputProvidedException(getClass(), commandContext)); 44 | } 45 | return switch (inputQueue.poll().toLowerCase(Locale.ENGLISH)) { 46 | case "yes", "true", "generate_structures", "structures" -> 47 | ArgumentParseResult.success(WorldStructureSetting.GENERATE_STRUCTURES); 48 | case "no", "false", "no_structures" -> ArgumentParseResult.success(WorldStructureSetting.NO_STRUCTURES); 49 | default -> 50 | ArgumentParseResult.failure(new IllegalArgumentException(Messages.messageInvalidStructureSetting.withoutColorCodes())); 51 | }; 52 | } 53 | 54 | @Override 55 | public @NonNull List<@NonNull String> suggestions( 56 | @NonNull final CommandContext commandContext, 57 | @NonNull final String input 58 | ) { 59 | List defaults = Arrays.asList( 60 | "yes", "true", "generate_structures", "Structures", 61 | "no", "false", "no_structures" 62 | ); 63 | if (input.isBlank()) { 64 | return defaults; 65 | } 66 | return defaults.stream() 67 | .filter(x -> x.startsWith(input)) 68 | .sorted(Comparator.reverseOrder()) 69 | .toList(); 70 | } 71 | 72 | @Override 73 | public boolean isContextFree() { 74 | return true; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/configuration/FileConfigurationObject.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.configuration; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 22 | import org.spongepowered.configurate.objectmapping.meta.Comment; 23 | import org.spongepowered.configurate.objectmapping.meta.Setting; 24 | 25 | /** 26 | * Data holder class that is instantiated in 27 | * {@link FileHyperConfiguration} 28 | */ 29 | @ConfigSerializable 30 | public final class FileConfigurationObject { 31 | 32 | @Setting(value = "import-automatically") 33 | @Comment(value = "Whether or not worlds should be automatically imported into Hyperverse on load") 34 | private boolean importAutomatically = true; 35 | @Setting(value = "persist-locations") 36 | @Comment(value = "Whether or not player locations should be saved to the database," 37 | + " and be used when a player teleports between worlds") 38 | private boolean persistLocations = true; 39 | @Setting(value = "keep-loaded") 40 | @Comment(value = "Whether or not world spawn chunks should be kept in memory") 41 | private boolean keepSpawnLoaded = true; 42 | @Setting(value = "grouped-inventories") 43 | @Comment(value = "Whether or player profile groups are enabled") 44 | private boolean groupedProfiles = false; 45 | @Setting(value = "language-code") 46 | @Comment(value = "Language code used to resolve translations. Currently supported: en, sv, de, cn") 47 | private String languageCode = "en"; 48 | @Setting(value = "safe-teleport") 49 | @Comment(value = "Whether or not safe teleportation should be enforced") 50 | private boolean safeTeleport = true; 51 | @Setting(value = "hook-essentials") 52 | @Comment(value = "Whether or not Hyperverse should attempt to utilize Essentials' specific features.") 53 | private boolean hookEssentials = true; 54 | @Setting(value = "debug") 55 | @Comment(value = "Whether or not Hyperverse should print verbose debugging messages") 56 | private boolean debug = false; 57 | 58 | boolean isImportAutomatically() { 59 | return this.importAutomatically; 60 | } 61 | 62 | boolean isPersistLocations() { 63 | return this.persistLocations; 64 | } 65 | 66 | boolean isKeepSpawnLoaded() { 67 | return this.keepSpawnLoaded; 68 | } 69 | 70 | boolean useGroupedProfiles() { 71 | return this.groupedProfiles; 72 | } 73 | 74 | @NonNull String getLanguageCode() { 75 | return this.languageCode; 76 | } 77 | 78 | boolean shouldSafeTeleport() { 79 | return this.safeTeleport; 80 | } 81 | 82 | boolean shouldHookEssentials() { 83 | return this.hookEssentials; 84 | } 85 | 86 | boolean shouldPrintDebug() { 87 | return this.debug; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/configuration/HyperConfiguration.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.configuration; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | 22 | /** 23 | * Hyperverse configuration options 24 | */ 25 | public interface HyperConfiguration { 26 | 27 | /** 28 | * Whether or not Hyperverse should 29 | * import detected worlds automatically 30 | * 31 | * @return True if worlds should be imported 32 | * automatically 33 | */ 34 | boolean shouldImportAutomatically(); 35 | 36 | /** 37 | * Whether or not Hyperverse's location 38 | * persistence system should be enabled 39 | * 40 | * @return True if locations should persist 41 | */ 42 | boolean shouldPersistLocations(); 43 | 44 | /** 45 | * Whether or not Hyperverse should keep 46 | * spawn chunks loaded 47 | * 48 | * @return True if spawn chunks should be kept 49 | * loaded 50 | */ 51 | boolean shouldKeepSpawnLoaded(); 52 | 53 | /** 54 | * Whether or not Hyperverse should load 55 | * and store player profiles for specific 56 | * world groups 57 | * 58 | * @return True if the player profile group 59 | * system should be enabled 60 | */ 61 | boolean shouldGroupProfiles(); 62 | 63 | /** 64 | * Get the language code that will be used 65 | * to resolve translations 66 | * 67 | * @return Language code 68 | */ 69 | @NonNull String getLanguageCode(); 70 | 71 | /** 72 | * Whether or not Hyperverse should enforce 73 | * safe teleportation 74 | * 75 | * @return True if Hyperverse should enforce 76 | * safe teleportation 77 | */ 78 | boolean shouldSafeTeleport(); 79 | 80 | /** 81 | * Whether or not Hyperverse should hook into 82 | * and attempt to utilize features present in Essentials. 83 | * 84 | * @return True if Hyperverse should hook into Essentials. 85 | */ 86 | boolean shouldHookEssentials(); 87 | 88 | /** 89 | * Whether or not Hyperverse should print 90 | * verbose debugging messages 91 | * 92 | * @return True if Hyperverse should print verbose debugging messages 93 | */ 94 | boolean shouldPrintDebug(); 95 | 96 | } 97 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/configuration/Message.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.configuration; 19 | 20 | import co.aikar.locales.MessageKey; 21 | import co.aikar.locales.MessageKeyProvider; 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | 24 | import java.util.Objects; 25 | 26 | /** 27 | * Configurable messages 28 | */ 29 | public final class Message implements MessageKeyProvider { 30 | 31 | private final MessageKey messageKey; 32 | private final String key; 33 | private final String defaultValue; 34 | 35 | /** 36 | * Construct a new message 37 | * 38 | * @param key The message key, used as a path in the configuration file 39 | * @param defaultValue The default message 40 | */ 41 | public Message( 42 | final @NonNull String key, 43 | final @NonNull String defaultValue 44 | ) { 45 | this.key = Objects.requireNonNull(key); 46 | this.defaultValue = Objects.requireNonNull(defaultValue); 47 | this.messageKey = MessageKey.of(key); 48 | } 49 | 50 | /** 51 | * Get the configuration key 52 | * 53 | * @return Configuration key 54 | */ 55 | public @NonNull String getKey() { 56 | return this.key; 57 | } 58 | 59 | /** 60 | * Get the default message 61 | * 62 | * @return Default message 63 | */ 64 | public @NonNull String getDefaultValue() { 65 | return this.defaultValue; 66 | } 67 | 68 | @Override 69 | public @NonNull String toString() { 70 | return Messages.getConfigured(this); 71 | } 72 | 73 | public @NonNull String withoutColorCodes() { 74 | return this.toString().replaceAll("&[A-Za-z0-9]", ""); 75 | } 76 | 77 | @Override 78 | public @NonNull MessageKey getMessageKey() { 79 | return this.messageKey; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/configuration/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Configuration utilities and types 20 | */ 21 | package org.incendo.hyperverse.configuration; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/database/LocationType.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.database; 19 | 20 | public enum LocationType { 21 | PLAYER_LOCATION, 22 | BED_SPAWN 23 | } 24 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/database/PersistentLocation.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.database; 19 | 20 | import org.bukkit.Location; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | 23 | import java.util.Objects; 24 | import java.util.UUID; 25 | 26 | public final class PersistentLocation { 27 | 28 | private final String uuid; 29 | private final String world; 30 | private final double x; 31 | private final double y; 32 | private final double z; 33 | private final LocationType locationType; 34 | 35 | public PersistentLocation( 36 | final @NonNull String uuid, 37 | final @NonNull String world, 38 | final double x, 39 | final double y, 40 | final double z, 41 | final @NonNull LocationType locationType 42 | ) { 43 | this.uuid = Objects.requireNonNull(uuid); 44 | this.world = Objects.requireNonNull(world); 45 | this.locationType = Objects.requireNonNull(locationType); 46 | this.x = x; 47 | this.y = y; 48 | this.z = z; 49 | } 50 | 51 | public static @NonNull PersistentLocation fromLocation( 52 | final @NonNull UUID owner, 53 | final @NonNull Location location, 54 | final @NonNull LocationType locationType 55 | ) { 56 | return new PersistentLocation(owner.toString(), Objects.requireNonNull(location.getWorld()).getName(), 57 | location.getX(), location.getY(), location.getZ(), locationType 58 | ); 59 | } 60 | 61 | public @NonNull String getUuid() { 62 | return this.uuid; 63 | } 64 | 65 | public @NonNull String getWorld() { 66 | return this.world; 67 | } 68 | 69 | public double getX() { 70 | return this.x; 71 | } 72 | 73 | public double getY() { 74 | return this.y; 75 | } 76 | 77 | public double getZ() { 78 | return this.z; 79 | } 80 | 81 | public @NonNull LocationType getLocationType() { 82 | return this.locationType; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/database/SimpleLocationTransformer.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.database; 19 | 20 | import com.google.inject.Inject; 21 | import com.google.inject.Singleton; 22 | import org.bukkit.Location; 23 | import org.bukkit.Server; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.incendo.hyperverse.modules.PersistentLocationTransformer; 26 | 27 | @Singleton 28 | public final class SimpleLocationTransformer implements PersistentLocationTransformer { 29 | 30 | private final Server server; 31 | 32 | @Inject 33 | SimpleLocationTransformer(final @NonNull Server server) { 34 | this.server = server; 35 | } 36 | 37 | @Override 38 | public @NonNull Location transform(final @NonNull PersistentLocation persistent) { 39 | return new Location(this.server.getWorld(persistent.getWorld()), persistent.getX(), persistent.getY(), persistent.getZ()); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/HyperPlayerEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import org.bukkit.entity.Player; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.incendo.hyperverse.world.HyperWorld; 23 | 24 | import java.util.Objects; 25 | 26 | /** 27 | * Events involving {@link org.bukkit.entity.Player} inside of a 28 | * {@link org.incendo.hyperverse.world.HyperWorld} 29 | * {@inheritDoc} 30 | */ 31 | public abstract class HyperPlayerEvent extends HyperWorldEvent { 32 | 33 | private final Player player; 34 | 35 | public HyperPlayerEvent( 36 | final @NonNull Player player, 37 | final @NonNull HyperWorld hyperWorld 38 | ) { 39 | super(hyperWorld); 40 | this.player = Objects.requireNonNull(player, "player"); 41 | } 42 | 43 | /** 44 | * Get the player involved in the event 45 | * 46 | * @return Player involved in the event 47 | */ 48 | public final @NonNull Player getPlayer() { 49 | return this.player; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/HyperWorldCreateEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import com.google.inject.assistedinject.Assisted; 21 | import org.bukkit.event.HandlerList; 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.incendo.hyperverse.world.HyperWorld; 24 | 25 | /** 26 | * Called when a new {@link org.incendo.hyperverse.world.HyperWorld} has been created 27 | * {@inheritDoc} 28 | */ 29 | public final class HyperWorldCreateEvent extends HyperWorldEvent { 30 | 31 | private static final HandlerList handlers = new HandlerList(); 32 | 33 | HyperWorldCreateEvent(final @Assisted @NonNull HyperWorld world) { 34 | super(world); 35 | } 36 | 37 | @SuppressWarnings("unused") 38 | public static HandlerList getHandlerList() { 39 | return handlers; 40 | } 41 | 42 | @Override 43 | public @NonNull HandlerList getHandlers() { 44 | return handlers; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/HyperWorldDeleteEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import org.bukkit.event.HandlerList; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.incendo.hyperverse.world.HyperWorld; 23 | 24 | /** 25 | * Called when a {@link org.incendo.hyperverse.world.HyperWorld} has been deleted 26 | * {@inheritDoc} 27 | */ 28 | public final class HyperWorldDeleteEvent extends HyperWorldEvent { 29 | 30 | private static final HandlerList handlers = new HandlerList(); 31 | 32 | HyperWorldDeleteEvent(final @NonNull HyperWorld world) { 33 | super(world); 34 | } 35 | 36 | @SuppressWarnings("unused") 37 | public static HandlerList getHandlerList() { 38 | return handlers; 39 | } 40 | 41 | @Override 42 | public @NonNull HandlerList getHandlers() { 43 | return handlers; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/HyperWorldEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.world.HyperWorld; 22 | 23 | import java.util.Objects; 24 | 25 | /** 26 | * Events involving {@link org.incendo.hyperverse.world.HyperWorld hyper worlds} 27 | */ 28 | public abstract class HyperWorldEvent extends HyperverseEvent { 29 | 30 | private final HyperWorld world; 31 | 32 | public HyperWorldEvent(final @NonNull HyperWorld world) { 33 | this.world = Objects.requireNonNull(world, "world"); 34 | } 35 | 36 | /** 37 | * Get the world involved in this event 38 | * 39 | * @return Event world 40 | */ 41 | public final @NonNull HyperWorld getWorld() { 42 | return this.world; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/HyperverseEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import org.bukkit.event.Event; 21 | 22 | /** 23 | * Just a generic Hyperverse event class 24 | */ 25 | public abstract class HyperverseEvent extends Event { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/PlayerSeekSpawnEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.entity.Player; 22 | import org.bukkit.event.Cancellable; 23 | import org.bukkit.event.HandlerList; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.incendo.hyperverse.world.HyperWorld; 26 | 27 | import java.util.Objects; 28 | 29 | /** 30 | * Called when a {@link org.bukkit.entity.Player} is supposed to re-spawn in a 31 | * {@link org.incendo.hyperverse.world.HyperWorld}, this is used to determine 32 | * their re-spawn location. 33 | *

34 | * Cancelling this event means that Hyperverse ignores the event entirely, 35 | * and lets vanilla/other Bukkit plugins handle it 36 | * {@inheritDoc} 37 | */ 38 | public final class PlayerSeekSpawnEvent extends HyperPlayerEvent implements Cancellable { 39 | 40 | private static final HandlerList handlers = new HandlerList(); 41 | 42 | private boolean cancelled; 43 | private Location respawnLocation; 44 | 45 | PlayerSeekSpawnEvent( 46 | final @NonNull Player player, 47 | final @NonNull HyperWorld world, 48 | final @NonNull Location respawnLocation 49 | ) { 50 | super(player, world); 51 | this.cancelled = false; 52 | this.respawnLocation = Objects.requireNonNull(respawnLocation, "respawn location"); 53 | } 54 | 55 | @SuppressWarnings("unused") 56 | public static HandlerList getHandlerList() { 57 | return handlers; 58 | } 59 | 60 | @Override 61 | public @NonNull HandlerList getHandlers() { 62 | return handlers; 63 | } 64 | 65 | @Override 66 | public boolean isCancelled() { 67 | return this.cancelled; 68 | } 69 | 70 | @Override 71 | public void setCancelled(final boolean cancelled) { 72 | this.cancelled = cancelled; 73 | } 74 | 75 | /** 76 | * Get the location where the player is supposed to re-spawn 77 | * 78 | * @return Re-spawn location 79 | */ 80 | public @NonNull Location getRespawnLocation() { 81 | return this.respawnLocation; 82 | } 83 | 84 | /** 85 | * Set the location where the player is supposed to respawn 86 | * 87 | * @param respawnLocation Re-spawn location 88 | */ 89 | public void setRespawnLocation(final @NonNull Location respawnLocation) { 90 | this.respawnLocation = Objects.requireNonNull(respawnLocation); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/PlayerSetSpawnEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import org.bukkit.entity.Player; 21 | import org.bukkit.event.Cancellable; 22 | import org.bukkit.event.HandlerList; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.incendo.hyperverse.world.HyperWorld; 25 | 26 | /** 27 | * Called when a {@link org.bukkit.entity.Player} attempts to set their 28 | * spawn point using a bed in a {@link org.incendo.hyperverse.world.HyperWorld}. 29 | *

30 | * Cancelling this event will prevent Hyperverse from updating the spawn point. 31 | * This will not affect the vanilla spawn point, however. To do that, one would 32 | * need to interact with {@link org.bukkit.event.player.PlayerBedEnterEvent} 33 | */ 34 | public final class PlayerSetSpawnEvent extends HyperPlayerEvent implements Cancellable { 35 | 36 | private static final HandlerList handlers = new HandlerList(); 37 | 38 | private boolean cancelled; 39 | 40 | PlayerSetSpawnEvent( 41 | final @NonNull Player player, 42 | final @NonNull HyperWorld world 43 | ) { 44 | super(player, world); 45 | this.cancelled = false; 46 | } 47 | 48 | @SuppressWarnings("unused") 49 | public static HandlerList getHandlerList() { 50 | return handlers; 51 | } 52 | 53 | @Override 54 | public @NonNull HandlerList getHandlers() { 55 | return handlers; 56 | } 57 | 58 | @Override 59 | public boolean isCancelled() { 60 | return this.cancelled; 61 | } 62 | 63 | @Override 64 | public void setCancelled(final boolean cancelled) { 65 | this.cancelled = cancelled; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/events/SimpleHyperEventFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.events; 19 | 20 | import com.google.inject.Inject; 21 | import com.google.inject.Singleton; 22 | import org.bukkit.Location; 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.plugin.PluginManager; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.incendo.hyperverse.modules.HyperEventFactory; 28 | import org.incendo.hyperverse.world.HyperWorld; 29 | 30 | @Singleton 31 | public final class SimpleHyperEventFactory implements HyperEventFactory { 32 | 33 | private final PluginManager pluginManager; 34 | 35 | @Inject 36 | SimpleHyperEventFactory(final @NonNull PluginManager pluginManager) { 37 | this.pluginManager = pluginManager; 38 | } 39 | 40 | @Override 41 | public void callWorldCreation(final @NonNull HyperWorld hyperWorld) { 42 | final Event event = new HyperWorldCreateEvent(hyperWorld); 43 | this.pluginManager.callEvent(event); 44 | } 45 | 46 | @Override 47 | public void callWorldDeletion(final @NonNull HyperWorld hyperWorld) { 48 | final Event event = new HyperWorldDeleteEvent(hyperWorld); 49 | this.pluginManager.callEvent(event); 50 | } 51 | 52 | @Override 53 | public @NonNull PlayerSeekSpawnEvent callPlayerSeekSpawn( 54 | final @NonNull Player player, 55 | final @NonNull HyperWorld world, 56 | final @NonNull Location respawnLocation 57 | ) { 58 | final PlayerSeekSpawnEvent playerSetSpawnEvent = new PlayerSeekSpawnEvent(player, world, respawnLocation); 59 | this.pluginManager.callEvent(playerSetSpawnEvent); 60 | return playerSetSpawnEvent; 61 | } 62 | 63 | @Override 64 | public @NonNull PlayerSetSpawnEvent callPlayerSetSpawn(final @NonNull Player player, final @NonNull HyperWorld world) { 65 | final PlayerSetSpawnEvent playerSetSpawnEvent = new PlayerSetSpawnEvent(player, world); 66 | this.pluginManager.callEvent(playerSetSpawnEvent); 67 | return playerSetSpawnEvent; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/exception/HyperException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.exception; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.world.HyperWorld; 22 | 23 | import java.util.Objects; 24 | 25 | /** 26 | * Exception related to a {@link HyperWorld} 27 | */ 28 | public class HyperException extends Exception { 29 | 30 | private static final long serialVersionUID = 4059156250285134733L; 31 | 32 | private final HyperWorld world; 33 | 34 | public HyperException( 35 | final @NonNull HyperWorld world, 36 | final @NonNull String message 37 | ) { 38 | super(Objects.requireNonNull(message)); 39 | this.world = Objects.requireNonNull(world); 40 | } 41 | 42 | /** 43 | * Get the world involved in the exception 44 | * 45 | * @return World 46 | */ 47 | public final @NonNull HyperWorld getWorld() { 48 | return this.world; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/exception/HyperWorldCreationException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.exception; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.world.HyperWorld; 22 | import org.incendo.hyperverse.world.HyperWorldCreator; 23 | import org.incendo.hyperverse.world.WorldConfiguration; 24 | 25 | /** 26 | * Exception thrown during the creation of a {@link HyperWorld}, 27 | * if it for some reason cannot be created 28 | * {@inheritDoc} 29 | */ 30 | public final class HyperWorldCreationException extends Exception { 31 | 32 | private static final long serialVersionUID = 7739603214208515388L; 33 | 34 | private final HyperWorldCreator.ValidationResult validationResult; 35 | private final WorldConfiguration configuration; 36 | 37 | public HyperWorldCreationException( 38 | final HyperWorldCreator.@NonNull ValidationResult validationResult, 39 | final @NonNull WorldConfiguration configuration 40 | ) { 41 | super(String.format("Failed to create world '%s' from configuration. Result: %s", 42 | configuration.getName(), validationResult.name() 43 | )); 44 | this.validationResult = validationResult; 45 | this.configuration = configuration; 46 | } 47 | 48 | public HyperWorldCreationException( 49 | final @NonNull Throwable cause, 50 | final @NonNull WorldConfiguration configuration 51 | ) { 52 | super(String.format( 53 | "Failed to create world '%s' from configuration for an unknown reason.", 54 | configuration.getName() 55 | ), cause); 56 | this.validationResult = HyperWorldCreator.ValidationResult.UNKNOWN_ERROR; 57 | this.configuration = configuration; 58 | } 59 | 60 | public HyperWorldCreator.@NonNull ValidationResult getValidationResult() { 61 | return this.validationResult; 62 | } 63 | 64 | public @NonNull WorldConfiguration getConfiguration() { 65 | return this.configuration; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/exception/HyperWorldValidationException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.exception; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.world.HyperWorld; 22 | import org.incendo.hyperverse.world.HyperWorldCreator; 23 | 24 | /** 25 | * Exception thrown when the validation of a {@link HyperWorld} fails 26 | */ 27 | public final class HyperWorldValidationException extends HyperException { 28 | 29 | private static final long serialVersionUID = 2460058219525178442L; 30 | 31 | private final HyperWorldCreator.ValidationResult validationResult; 32 | 33 | public HyperWorldValidationException( 34 | final HyperWorldCreator.@NonNull ValidationResult validationResult, 35 | final @NonNull HyperWorld world 36 | ) { 37 | super(world, String 38 | .format("Failed to validate world configuration for world %s. Result: %s", 39 | world.getConfiguration().getName(), validationResult.name() 40 | )); 41 | this.validationResult = validationResult; 42 | } 43 | 44 | public HyperWorldCreator.@NonNull ValidationResult getValidationResult() { 45 | return this.validationResult; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/exception/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Custom exceptions, mostly related to worlds 20 | */ 21 | package org.incendo.hyperverse.exception; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/features/PluginFeature.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.features; 19 | 20 | /** 21 | * A third party plugin feature 22 | */ 23 | public abstract class PluginFeature { 24 | 25 | /** 26 | * Initialize the feature 27 | */ 28 | public abstract void initializeFeature(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/features/external/EssentialsFeature.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.features.external; 19 | 20 | import com.earth2me.essentials.Essentials; 21 | import com.earth2me.essentials.IEssentials; 22 | import com.earth2me.essentials.utils.LocationUtil; 23 | import org.bukkit.Location; 24 | import org.bukkit.plugin.java.JavaPlugin; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.checker.nullness.qual.Nullable; 27 | import org.incendo.hyperverse.Hyperverse; 28 | import org.incendo.hyperverse.features.PluginFeature; 29 | import org.incendo.hyperverse.service.internal.SafeTeleportService; 30 | 31 | import java.util.Collections; 32 | 33 | /** 34 | * Feature hooking into Essentials 35 | */ 36 | public final class EssentialsFeature extends PluginFeature { 37 | 38 | @Override 39 | public void initializeFeature() { 40 | final Hyperverse hyperverse = JavaPlugin.getPlugin(Hyperverse.class); 41 | hyperverse.getLogger().info("Using Essentials to provide safe-teleportation lookup."); 42 | hyperverse.getServicePipeline().registerServiceImplementation(SafeTeleportService.class, 43 | new EssentialsSafeTeleportService(JavaPlugin.getPlugin(Essentials.class)), Collections.emptyList() 44 | ); 45 | } 46 | 47 | private static class EssentialsSafeTeleportService implements SafeTeleportService { 48 | 49 | private final IEssentials essentials; 50 | 51 | public EssentialsSafeTeleportService(final @NonNull IEssentials essentials) { 52 | this.essentials = essentials; 53 | } 54 | 55 | @Override 56 | public @Nullable Location handle(final @NonNull Location location) { 57 | try { 58 | return LocationUtil.getSafeDestination(this.essentials, location); 59 | } catch (final Exception ignored) { 60 | } 61 | return null; 62 | } 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/features/external/HyperverseExpansion.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.features.external; 19 | 20 | import me.clip.placeholderapi.expansion.PlaceholderExpansion; 21 | import net.kyori.adventure.text.minimessage.MiniMessage; 22 | import org.bukkit.entity.Player; 23 | import org.bukkit.plugin.PluginDescriptionFile; 24 | import org.bukkit.plugin.java.JavaPlugin; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.checker.nullness.qual.Nullable; 27 | import org.incendo.hyperverse.Hyperverse; 28 | import org.incendo.hyperverse.flags.implementation.DifficultyFlag; 29 | import org.incendo.hyperverse.flags.implementation.PveFlag; 30 | import org.incendo.hyperverse.flags.implementation.PvpFlag; 31 | import org.incendo.hyperverse.world.HyperWorld; 32 | import org.incendo.hyperverse.world.WorldConfiguration; 33 | import org.incendo.hyperverse.world.WorldManager; 34 | 35 | /** 36 | * PlaceholderAPI expansion 37 | */ 38 | final class HyperverseExpansion extends PlaceholderExpansion { 39 | 40 | private final Hyperverse plugin; 41 | 42 | private final String author; 43 | private final String version; 44 | 45 | public HyperverseExpansion() { 46 | this.plugin = JavaPlugin.getPlugin(Hyperverse.class); 47 | final PluginDescriptionFile descriptionFile = this.plugin.getDescription(); 48 | this.author = descriptionFile.getAuthors().toString(); 49 | this.version = descriptionFile.getVersion(); 50 | } 51 | 52 | @Override 53 | public @NonNull String getIdentifier() { 54 | return "hyperverse"; 55 | } 56 | 57 | @Override 58 | public @NonNull String getAuthor() { 59 | return this.author; 60 | } 61 | 62 | @Override 63 | public @NonNull String getVersion() { 64 | return this.version; 65 | } 66 | 67 | @Override 68 | public boolean persist() { 69 | return true; 70 | } 71 | 72 | @Override 73 | public boolean canRegister() { 74 | return true; 75 | } 76 | 77 | @Override 78 | public @Nullable String onPlaceholderRequest( 79 | final @Nullable Player player, 80 | final @NonNull String identifier 81 | ) { 82 | if (player == null) { 83 | return ""; 84 | } 85 | 86 | final WorldManager worldManager = this.plugin.getWorldManager(); 87 | 88 | final HyperWorld hyperWorld = worldManager.getWorld(player.getWorld()); 89 | if (hyperWorld == null) { 90 | return ""; 91 | } 92 | 93 | final WorldConfiguration worldConfiguration = hyperWorld.getConfiguration(); 94 | 95 | switch (identifier.toLowerCase()) { 96 | case "world_display_name": 97 | return MiniMessage.miniMessage().escapeTags(hyperWorld.getDisplayName()); 98 | case "world_name": 99 | return worldConfiguration.getName(); 100 | case "world_generator": 101 | return worldConfiguration.getGenerator(); 102 | case "world_difficulty": 103 | return hyperWorld.getFlag(DifficultyFlag.class).name(); 104 | case "world_pvp": 105 | return hyperWorld.getFlag(PvpFlag.class).toString(); 106 | case "world_pve": 107 | return hyperWorld.getFlag(PveFlag.class).toString(); 108 | default: 109 | return null; 110 | } 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/features/external/PlaceholderAPIFeature.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.features.external; 19 | 20 | import org.incendo.hyperverse.features.PluginFeature; 21 | 22 | /** 23 | * {@link PluginFeature} adding PlaceholderAPI support 24 | */ 25 | public final class PlaceholderAPIFeature extends PluginFeature { 26 | 27 | @Override 28 | public void initializeFeature() { 29 | final HyperverseExpansion hyperverseExpansion = new HyperverseExpansion(); 30 | hyperverseExpansion.register(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/FlagParseException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags; 19 | 20 | import org.incendo.hyperverse.util.MessageUtil; 21 | 22 | public class FlagParseException extends Exception { 23 | 24 | private static final long serialVersionUID = 3442434713845764748L; 25 | 26 | private final WorldFlag flag; 27 | private final String value; 28 | private final String errorMessage; 29 | 30 | /** 31 | * Construct a new flag parse exception to indicate that an attempt to parse a world 32 | * flag was unsuccessful. 33 | * 34 | * @param flag Flag instance 35 | * @param value Value that failed ot parse 36 | * @param errorMessage An error message explaining the failure 37 | * @param args Arguments used to format the error message 38 | */ 39 | public FlagParseException( 40 | final WorldFlag flag, final String value, 41 | final String errorMessage, final String... args 42 | ) { 43 | super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.", 44 | flag.getName(), value 45 | )); 46 | this.flag = flag; 47 | this.value = value; 48 | this.errorMessage = MessageUtil.format(errorMessage, args); 49 | } 50 | 51 | /** 52 | * Returns the value that caused the parse exception 53 | * 54 | * @return Value that failed to parse 55 | */ 56 | public String getValue() { 57 | return this.value; 58 | } 59 | 60 | /** 61 | * Returns the class that threw the exception 62 | * 63 | * @return Flag that threw the exception 64 | */ 65 | public WorldFlag getFlag() { 66 | return this.flag; 67 | } 68 | 69 | /** 70 | * Get the error message that was supplied by the flag instance. 71 | * 72 | * @return Error message. 73 | */ 74 | public String getErrorMessage() { 75 | return this.errorMessage; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/AdvancementFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class AdvancementFlag extends BooleanFlag { 24 | 25 | public static final AdvancementFlag ADVANCEMENTS_ALLOWED = new AdvancementFlag(true); 26 | public static final AdvancementFlag ADVANCEMENTS_FORBIDDEN = new AdvancementFlag(false); 27 | 28 | private AdvancementFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionAdvancements); 30 | } 31 | 32 | @Override 33 | protected AdvancementFlag flagOf(final @NonNull Boolean value) { 34 | return value ? ADVANCEMENTS_ALLOWED : ADVANCEMENTS_FORBIDDEN; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/AliasFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | import org.incendo.hyperverse.flags.WorldFlag; 23 | 24 | public final class AliasFlag extends WorldFlag { 25 | 26 | public static final AliasFlag ALIAS_NONE = new AliasFlag(""); 27 | 28 | private AliasFlag(final @NonNull String alias) { 29 | super(alias, Messages.flagDescriptionAlias); 30 | } 31 | 32 | @Override 33 | public AliasFlag parse(final @NonNull String input) { 34 | return this.flagOf(input.replaceAll("&[A-Za-z0-9]", "")); 35 | } 36 | 37 | @Override 38 | public AliasFlag merge(final @NonNull String newValue) { 39 | return this.flagOf(newValue); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return this.getValue(); 45 | } 46 | 47 | @Override 48 | public String getExample() { 49 | return "&cFancy World Name"; 50 | } 51 | 52 | @Override 53 | protected AliasFlag flagOf(final @NonNull String value) { 54 | return new AliasFlag(value); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/BooleanFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Message; 22 | import org.incendo.hyperverse.flags.FlagParseException; 23 | import org.incendo.hyperverse.flags.WorldFlag; 24 | 25 | import java.util.Arrays; 26 | import java.util.Collection; 27 | import java.util.Locale; 28 | 29 | public abstract class BooleanFlag> extends WorldFlag { 30 | 31 | private static final Collection POSITIVE_VALUES = 32 | Arrays.asList("1", "yes", "allow", "true"); 33 | private static final Collection NEGATIVE_VALUES = 34 | Arrays.asList("0", "no", "deny", "disallow", "false"); 35 | 36 | /** 37 | * Construct a new flag instance. 38 | * 39 | * @param value Flag value 40 | * @param description Flag description 41 | */ 42 | protected BooleanFlag(final boolean value, final Message description) { 43 | super(value, description); 44 | } 45 | 46 | /** 47 | * Construct a new boolean flag, with 48 | * {@code false} as the default value. 49 | * 50 | * @param description Flag description 51 | */ 52 | protected BooleanFlag(final Message description) { 53 | this(false, description); 54 | } 55 | 56 | @Override 57 | public final F parse(final @NonNull String input) throws FlagParseException { 58 | if (POSITIVE_VALUES.contains(input.toLowerCase(Locale.ENGLISH))) { 59 | return this.flagOf(true); 60 | } else if (NEGATIVE_VALUES.contains(input.toLowerCase(Locale.ENGLISH))) { 61 | return this.flagOf(false); 62 | } else { 63 | throw new FlagParseException(this, input, "The value must be a boolean value (true/false)"); 64 | } 65 | } 66 | 67 | @Override 68 | public final F merge(final @NonNull Boolean newValue) { 69 | return this.flagOf(getValue() || newValue); 70 | } 71 | 72 | @Override 73 | public final String getExample() { 74 | return "true"; 75 | } 76 | 77 | @Override 78 | public final String toString() { 79 | return this.getValue().toString(); 80 | } 81 | 82 | @Override 83 | public final Collection getTabCompletions() { 84 | return Arrays.asList("true", "false"); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/CreatureSpawnFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class CreatureSpawnFlag extends BooleanFlag { 24 | 25 | public static final CreatureSpawnFlag CREATURE_SPAWN_ALLOWED = new CreatureSpawnFlag(true); 26 | public static final CreatureSpawnFlag CREATURE_SPAWN_FORBIDDEN = new CreatureSpawnFlag(false); 27 | 28 | private CreatureSpawnFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionCreatureSpawn); 30 | } 31 | 32 | @Override 33 | protected CreatureSpawnFlag flagOf(final @NonNull Boolean value) { 34 | return value ? CREATURE_SPAWN_ALLOWED : CREATURE_SPAWN_FORBIDDEN; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/DifficultyFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.bukkit.Difficulty; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.incendo.hyperverse.configuration.Messages; 23 | import org.incendo.hyperverse.flags.FlagParseException; 24 | import org.incendo.hyperverse.flags.WorldFlag; 25 | 26 | import java.util.Arrays; 27 | import java.util.Collection; 28 | 29 | public final class DifficultyFlag extends WorldFlag { 30 | 31 | public static final DifficultyFlag DIFFICULTY_FLAG_PEACEFUL = new DifficultyFlag(Difficulty.PEACEFUL); 32 | public static final DifficultyFlag DIFFICULTY_FLAG_EASY = new DifficultyFlag(Difficulty.EASY); 33 | public static final DifficultyFlag DIFFICULTY_FLAG_NORMAL = new DifficultyFlag(Difficulty.NORMAL); 34 | public static final DifficultyFlag DIFFICULTY_FLAG_HARD = new DifficultyFlag(Difficulty.HARD); 35 | 36 | private DifficultyFlag(final @NonNull Difficulty difficulty) { 37 | super(difficulty, Messages.flagDescriptionDifficulty); 38 | } 39 | 40 | @Override 41 | public DifficultyFlag parse(final @NonNull String input) throws FlagParseException { 42 | switch (input.toLowerCase()) { 43 | case "peaceful": 44 | return this.flagOf(Difficulty.PEACEFUL); 45 | case "easy": 46 | return this.flagOf(Difficulty.EASY); 47 | case "normal": 48 | return this.flagOf(Difficulty.NORMAL); 49 | case "hard": 50 | return this.flagOf(Difficulty.HARD); 51 | default: 52 | throw new FlagParseException(this, input, 53 | "Invalid difficulty. Available values are: peaceful, easy, normal and hard" 54 | ); 55 | } 56 | } 57 | 58 | @Override 59 | public DifficultyFlag merge(final @NonNull Difficulty newValue) { 60 | return this.flagOf(newValue); 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return this.getValue().name().toLowerCase(); 66 | } 67 | 68 | @Override 69 | public String getExample() { 70 | return "peaceful"; 71 | } 72 | 73 | @Override 74 | protected DifficultyFlag flagOf(final @NonNull Difficulty value) { 75 | switch (value) { 76 | case PEACEFUL: 77 | return DIFFICULTY_FLAG_PEACEFUL; 78 | case EASY: 79 | return DIFFICULTY_FLAG_EASY; 80 | case HARD: 81 | return DIFFICULTY_FLAG_HARD; 82 | default: 83 | return DIFFICULTY_FLAG_NORMAL; 84 | } 85 | } 86 | 87 | @Override 88 | public Collection getTabCompletions() { 89 | return Arrays.asList("peaceful", "easy", "normal", "hard"); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/EndFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.Hyperverse; 22 | import org.incendo.hyperverse.configuration.Messages; 23 | import org.incendo.hyperverse.flags.FlagParseException; 24 | import org.incendo.hyperverse.flags.WorldFlag; 25 | import org.incendo.hyperverse.util.WorldUtil; 26 | import org.incendo.hyperverse.world.HyperWorld; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Collection; 30 | 31 | public final class EndFlag extends WorldFlag { 32 | 33 | public static final EndFlag END_FLAG_DEFAULT = new EndFlag(""); 34 | 35 | private EndFlag(final @NonNull String value) { 36 | super(value, Messages.flagDescriptionEnd); 37 | } 38 | 39 | @Override 40 | public EndFlag parse(final @NonNull String input) throws FlagParseException { 41 | if (WorldUtil.validateName(input)) { 42 | return this.flagOf(input); 43 | } 44 | throw new FlagParseException(this, input, "A world name may only contain (up to) 16 alphanumerical characters, - and _"); 45 | } 46 | 47 | @Override 48 | public EndFlag merge(final @NonNull String newValue) { 49 | return this.flagOf(newValue); 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return this.getValue(); 55 | } 56 | 57 | @Override 58 | public String getExample() { 59 | return "end_world"; 60 | } 61 | 62 | @Override 63 | protected EndFlag flagOf(final @NonNull String value) { 64 | return new EndFlag(value); 65 | } 66 | 67 | @Override 68 | public Collection getTabCompletions() { 69 | final Collection configurations = Hyperverse.getApi().getWorldManager().getWorlds(); 70 | final Collection worldNames = new ArrayList<>(configurations.size()); 71 | for (final HyperWorld world : configurations) { 72 | worldNames.add(world.getDisplayName()); 73 | } 74 | return worldNames; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/ForceSpawn.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class ForceSpawn extends BooleanFlag { 24 | 25 | public static final ForceSpawn FORCE_SPAWN_TRUE = new ForceSpawn(true); 26 | public static final ForceSpawn FORCE_SPAWN_FALSE = new ForceSpawn(false); 27 | 28 | private ForceSpawn(final boolean value) { 29 | super(value, Messages.flagDescriptionForceSpawn); 30 | } 31 | 32 | @Override 33 | protected ForceSpawn flagOf(final @NonNull Boolean value) { 34 | return value ? FORCE_SPAWN_TRUE : FORCE_SPAWN_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/GamemodeFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.bukkit.GameMode; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.incendo.hyperverse.configuration.Messages; 23 | import org.incendo.hyperverse.flags.FlagParseException; 24 | import org.incendo.hyperverse.flags.WorldFlag; 25 | 26 | import java.util.Arrays; 27 | import java.util.Collection; 28 | 29 | public final class GamemodeFlag extends WorldFlag { 30 | 31 | public static final GamemodeFlag GAMEMODE_SURVIVAL = new GamemodeFlag(GameMode.SURVIVAL); 32 | public static final GamemodeFlag GAMEMODE_CREATIVE = new GamemodeFlag(GameMode.CREATIVE); 33 | public static final GamemodeFlag GAMEMODE_ADVENTURE = new GamemodeFlag(GameMode.ADVENTURE); 34 | public static final GamemodeFlag GAMEMODE_SPECTATOR = new GamemodeFlag(GameMode.SPECTATOR); 35 | 36 | private GamemodeFlag(final @NonNull GameMode value) { 37 | super(value, Messages.flagDescriptionGamemode); 38 | } 39 | 40 | @Override 41 | public GamemodeFlag parse(final @NonNull String input) throws FlagParseException { 42 | switch (input.toLowerCase()) { 43 | case "survival": 44 | case "0": 45 | case "s": 46 | return GAMEMODE_SURVIVAL; 47 | case "creative": 48 | case "1": 49 | case "c": 50 | return GAMEMODE_CREATIVE; 51 | case "adventure": 52 | case "2": 53 | case "a": 54 | return GAMEMODE_ADVENTURE; 55 | case "spectator": 56 | case "3": 57 | return GAMEMODE_SPECTATOR; 58 | default: 59 | throw new FlagParseException(this, input, "There is no such game mode"); 60 | } 61 | } 62 | 63 | @Override 64 | public GamemodeFlag merge(final @NonNull GameMode newValue) { 65 | return this.flagOf(newValue); 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return this.getValue().name(); 71 | } 72 | 73 | @Override 74 | public String getExample() { 75 | return "survival"; 76 | } 77 | 78 | @Override 79 | protected GamemodeFlag flagOf(final @NonNull GameMode value) { 80 | switch (value) { 81 | case SURVIVAL: 82 | return GAMEMODE_SURVIVAL; 83 | case CREATIVE: 84 | return GAMEMODE_CREATIVE; 85 | case ADVENTURE: 86 | return GAMEMODE_ADVENTURE; 87 | case SPECTATOR: 88 | return GAMEMODE_SPECTATOR; 89 | default: 90 | throw new IllegalArgumentException("Unknown gamemode: " + value.name()); 91 | } 92 | } 93 | 94 | @Override 95 | public Collection getTabCompletions() { 96 | return Arrays.asList("survival", "creative", "adventure", "spectator"); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/IgnoreBedsFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class IgnoreBedsFlag extends BooleanFlag { 24 | 25 | public static final IgnoreBedsFlag IGNORE_BEDS_TRUE = new IgnoreBedsFlag(true); 26 | public static final IgnoreBedsFlag IGNORE_BEDS_FALSE = new IgnoreBedsFlag(false); 27 | 28 | private IgnoreBedsFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionIgnoreBeds); 30 | } 31 | 32 | @Override 33 | protected IgnoreBedsFlag flagOf(final @NonNull Boolean value) { 34 | return value ? IGNORE_BEDS_TRUE : IGNORE_BEDS_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/LocalRespawnFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class LocalRespawnFlag extends BooleanFlag { 24 | 25 | public static final LocalRespawnFlag RESPAWN_TRUE = new LocalRespawnFlag(true); 26 | public static final LocalRespawnFlag RESPAWN_FALSE = new LocalRespawnFlag(false); 27 | 28 | private LocalRespawnFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionLocalRespawn); 30 | } 31 | 32 | @Override 33 | protected LocalRespawnFlag flagOf(final @NonNull Boolean value) { 34 | return value ? RESPAWN_TRUE : RESPAWN_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/MobSpawnFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class MobSpawnFlag extends BooleanFlag { 24 | 25 | public static final MobSpawnFlag MOB_SPAWN_ALLOWED = new MobSpawnFlag(true); 26 | public static final MobSpawnFlag MOB_SPAWN_FORBIDDEN = new MobSpawnFlag(false); 27 | 28 | private MobSpawnFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionMobSpawn); 30 | } 31 | 32 | @Override 33 | protected MobSpawnFlag flagOf(final @NonNull Boolean value) { 34 | return value ? MOB_SPAWN_ALLOWED : MOB_SPAWN_FORBIDDEN; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/NetherFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.Hyperverse; 22 | import org.incendo.hyperverse.configuration.Messages; 23 | import org.incendo.hyperverse.flags.FlagParseException; 24 | import org.incendo.hyperverse.flags.WorldFlag; 25 | import org.incendo.hyperverse.util.WorldUtil; 26 | import org.incendo.hyperverse.world.HyperWorld; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Collection; 30 | 31 | public final class NetherFlag extends WorldFlag { 32 | 33 | public static final NetherFlag NETHER_FLAG_DEFAULT = new NetherFlag(""); 34 | 35 | private NetherFlag(final @NonNull String value) { 36 | super(value, Messages.flagDescriptionNether); 37 | } 38 | 39 | @Override 40 | public NetherFlag parse(final @NonNull String input) throws FlagParseException { 41 | if (WorldUtil.validateName(input)) { 42 | return this.flagOf(input); 43 | } 44 | throw new FlagParseException(this, input, "A world name may only contain (up to) 16 alphanumerical characters, - and _"); 45 | } 46 | 47 | @Override 48 | public NetherFlag merge(final @NonNull String newValue) { 49 | return this.flagOf(newValue); 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return this.getValue(); 55 | } 56 | 57 | @Override 58 | public String getExample() { 59 | return "nether_world"; 60 | } 61 | 62 | @Override 63 | protected NetherFlag flagOf(final @NonNull String value) { 64 | return new NetherFlag(value); 65 | } 66 | 67 | @Override 68 | public Collection getTabCompletions() { 69 | final Collection configurations = Hyperverse.getApi().getWorldManager().getWorlds(); 70 | final Collection worldNames = new ArrayList<>(configurations.size()); 71 | for (final HyperWorld world : configurations) { 72 | worldNames.add(world.getDisplayName()); 73 | } 74 | return worldNames; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/ProfileGroupFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | import org.incendo.hyperverse.flags.FlagParseException; 23 | import org.incendo.hyperverse.flags.WorldFlag; 24 | import org.incendo.hyperverse.util.WorldUtil; 25 | 26 | public final class ProfileGroupFlag extends WorldFlag { 27 | 28 | public static final ProfileGroupFlag PROFILE_GROUP_FLAG_EMPTY = new ProfileGroupFlag("default"); 29 | 30 | private ProfileGroupFlag(final @NonNull String group) { 31 | super(group, Messages.flagDescriptionProfileGroup); 32 | } 33 | 34 | @Override 35 | public ProfileGroupFlag parse(final @NonNull String input) throws FlagParseException { 36 | if (WorldUtil.validateName(input)) { 37 | return this.flagOf(input); 38 | } 39 | throw new FlagParseException(this, input, "A world name may only contain (up to) 16 alphanumerical characters, - and _"); 40 | } 41 | 42 | @Override 43 | public ProfileGroupFlag merge(final @NonNull String newValue) { 44 | return this.flagOf(newValue); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return this.getValue(); 50 | } 51 | 52 | @Override 53 | public String getExample() { 54 | return "survival_worlds"; 55 | } 56 | 57 | @Override 58 | protected ProfileGroupFlag flagOf(final @NonNull String value) { 59 | return new ProfileGroupFlag(value); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/PveFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class PveFlag extends BooleanFlag { 24 | 25 | public static final PveFlag PVE_FLAG_TRUE = new PveFlag(true); 26 | public static final PveFlag PVE_FLAG_FALSE = new PveFlag(false); 27 | 28 | private PveFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionPve); 30 | } 31 | 32 | @Override 33 | protected PveFlag flagOf(final @NonNull Boolean value) { 34 | return value ? PVE_FLAG_TRUE : PVE_FLAG_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/PvpFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class PvpFlag extends BooleanFlag { 24 | 25 | public static final PvpFlag PVP_FLAG_TRUE = new PvpFlag(true); 26 | public static final PvpFlag PVP_FLAG_FALSE = new PvpFlag(false); 27 | 28 | private PvpFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionPvp); 30 | } 31 | 32 | @Override 33 | protected PvpFlag flagOf(final @NonNull Boolean value) { 34 | return value ? PVP_FLAG_TRUE : PVP_FLAG_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/RespawnWorldFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | import org.incendo.hyperverse.flags.FlagParseException; 23 | import org.incendo.hyperverse.flags.WorldFlag; 24 | import org.incendo.hyperverse.util.WorldUtil; 25 | 26 | public final class RespawnWorldFlag extends WorldFlag { 27 | 28 | public static final RespawnWorldFlag RESPAWN_WORLD_FLAG_EMPTY = new RespawnWorldFlag(""); 29 | 30 | private RespawnWorldFlag(final @NonNull String world) { 31 | super(world, Messages.flagDescriptionRespawnWorld); 32 | } 33 | 34 | @Override 35 | public RespawnWorldFlag parse(final @NonNull String input) throws FlagParseException { 36 | if (WorldUtil.validateName(input)) { 37 | return this.flagOf(input); 38 | } 39 | throw new FlagParseException(this, input, "A world name may only contain (up to) 16 alphanumerical characters, - and _"); 40 | } 41 | 42 | @Override 43 | public RespawnWorldFlag merge(final @NonNull String newValue) { 44 | return this.flagOf(newValue); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return this.getValue(); 50 | } 51 | 52 | @Override 53 | public String getExample() { 54 | return "world"; 55 | } 56 | 57 | @Override 58 | protected RespawnWorldFlag flagOf(final @NonNull String value) { 59 | return new RespawnWorldFlag(value); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/SaveWorldFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class SaveWorldFlag extends BooleanFlag { 24 | 25 | public static final SaveWorldFlag SAVE_WORLD_TRUE = new SaveWorldFlag(true); 26 | public static final SaveWorldFlag SAVE_WORLD_FALSE = new SaveWorldFlag(false); 27 | 28 | private SaveWorldFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionIgnoreBeds); 30 | } 31 | 32 | @Override 33 | protected SaveWorldFlag flagOf(final @NonNull Boolean value) { 34 | return value ? SAVE_WORLD_TRUE : SAVE_WORLD_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/UnloadSpawnFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | 23 | public final class UnloadSpawnFlag extends BooleanFlag { 24 | 25 | public static final UnloadSpawnFlag UNLOAD_SPAWN_FALSE = new UnloadSpawnFlag(false); 26 | public static final UnloadSpawnFlag UNLOAD_SPAWN_TRUE = new UnloadSpawnFlag(true); 27 | 28 | public UnloadSpawnFlag(final boolean value) { 29 | super(value, Messages.flagDescriptionUnloadSpawn); 30 | } 31 | 32 | @Override 33 | protected UnloadSpawnFlag flagOf(final @NonNull Boolean value) { 34 | return value ? UNLOAD_SPAWN_TRUE : UNLOAD_SPAWN_FALSE; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/flags/implementation/WorldPermissionFlag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.flags.implementation; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.configuration.Messages; 22 | import org.incendo.hyperverse.flags.FlagParseException; 23 | import org.incendo.hyperverse.flags.WorldFlag; 24 | 25 | import java.util.regex.Pattern; 26 | 27 | public final class WorldPermissionFlag extends WorldFlag { 28 | 29 | public static final WorldPermissionFlag WORLD_PERMISSION_FLAG_DEFAULT = new WorldPermissionFlag(""); 30 | private static final Pattern PERMISSION_PATTERN = Pattern.compile("[A-Za-z0-9\\-_.]+"); 31 | 32 | public WorldPermissionFlag(final @NonNull String value) { 33 | super(value, Messages.flagDescriptionWorldPermission); 34 | } 35 | 36 | @Override 37 | public WorldPermissionFlag parse(final @NonNull String input) throws 38 | FlagParseException { 39 | if (input.isEmpty()) { 40 | return WORLD_PERMISSION_FLAG_DEFAULT; 41 | } 42 | if (PERMISSION_PATTERN.matcher(input).matches()) { 43 | return this.flagOf(input); 44 | } 45 | throw new FlagParseException(this, input, "A permission node may only contain alphanumerical characters," 46 | + " -, . and _"); 47 | } 48 | 49 | @Override 50 | public WorldPermissionFlag merge(final @NonNull String newValue) { 51 | return this.flagOf(newValue); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return getValue(); 57 | } 58 | 59 | @Override 60 | public String getExample() { 61 | return "your.permission.node"; 62 | } 63 | 64 | @Override 65 | protected WorldPermissionFlag flagOf(final @NonNull String value) { 66 | return new WorldPermissionFlag(value); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/listeners/PaperListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.listeners; 19 | 20 | import com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent; 21 | import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent; 22 | import com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent; 23 | import org.bukkit.event.EventHandler; 24 | import org.bukkit.event.Listener; 25 | import org.bukkit.event.entity.CreatureSpawnEvent; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | import org.incendo.hyperverse.flags.implementation.AdvancementFlag; 28 | import org.incendo.hyperverse.flags.implementation.CreatureSpawnFlag; 29 | import org.incendo.hyperverse.flags.implementation.MobSpawnFlag; 30 | import org.incendo.hyperverse.world.HyperWorld; 31 | import org.incendo.hyperverse.world.WorldManager; 32 | 33 | public final class PaperListener implements Listener { 34 | 35 | private final WorldManager worldManager; 36 | 37 | PaperListener(final @NonNull WorldManager worldManager) { 38 | this.worldManager = worldManager; 39 | } 40 | 41 | @EventHandler 42 | public void onEntityPreSpawn(final @NonNull PreCreatureSpawnEvent event) { 43 | final HyperWorld hyperWorld = this.worldManager.getWorld(event.getSpawnLocation().getWorld()); 44 | if (hyperWorld == null) { 45 | return; 46 | } 47 | if (hyperWorld.getFlag(CreatureSpawnFlag.class)) { 48 | return; 49 | } 50 | if (event.getReason() != CreatureSpawnEvent.SpawnReason.NATURAL) { 51 | return; 52 | } 53 | event.setCancelled(true); 54 | event.setShouldAbortSpawn(true); 55 | } 56 | 57 | @EventHandler 58 | public void onMobPreSpawn(final @NonNull PlayerNaturallySpawnCreaturesEvent event) { 59 | final HyperWorld hyperWorld = this.worldManager.getWorld(event.getPlayer().getWorld()); 60 | if (hyperWorld == null) { 61 | return; 62 | } 63 | if (hyperWorld.getFlag(MobSpawnFlag.class)) { 64 | return; 65 | } 66 | event.setCancelled(true); 67 | } 68 | 69 | @EventHandler 70 | public void onAdvancementGrant(final @NonNull PlayerAdvancementCriterionGrantEvent event) { 71 | final HyperWorld hyperWorld = this.worldManager.getWorld(event.getPlayer().getWorld()); 72 | if (hyperWorld == null) { 73 | return; 74 | } 75 | if (hyperWorld.getFlag(AdvancementFlag.class)) { 76 | return; 77 | } 78 | event.setCancelled(true); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/listeners/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Event listeners 20 | */ 21 | package org.incendo.hyperverse.listeners; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/BukkitModule.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import com.google.inject.AbstractModule; 21 | import com.google.inject.Singleton; 22 | import org.bukkit.Server; 23 | import org.bukkit.inventory.ItemFactory; 24 | import org.bukkit.plugin.PluginManager; 25 | import org.bukkit.plugin.ServicesManager; 26 | import org.bukkit.scheduler.BukkitScheduler; 27 | import org.bukkit.scoreboard.ScoreboardManager; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | 30 | /** 31 | * Utility module binding commonly used bukkit interfaces to bukkit 32 | */ 33 | public final class BukkitModule extends AbstractModule { 34 | 35 | private final Server server; 36 | 37 | public BukkitModule(final @NonNull Server server) { 38 | this.server = server; 39 | } 40 | 41 | @Override 42 | protected void configure() { 43 | bind(Server.class).toInstance(this.server); 44 | bind(PluginManager.class).toProvider(this.server::getPluginManager).in(Singleton.class); 45 | bind(BukkitScheduler.class).toProvider(this.server::getScheduler).in(Singleton.class); 46 | bind(ItemFactory.class).toProvider(this.server::getItemFactory).in(Singleton.class); 47 | bind(ServicesManager.class).toProvider(this.server::getServicesManager).in(Singleton.class); 48 | bind(ScoreboardManager.class).toProvider(this.server::getScoreboardManager).in(Singleton.class); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/FlagContainerFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.flags.FlagContainer; 22 | 23 | public interface FlagContainerFactory { 24 | 25 | FlagContainer create(final FlagContainer.@NonNull WorldFlagUpdateHandler flagUpdateHandler); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/HyperEventFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.entity.Player; 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.incendo.hyperverse.events.PlayerSeekSpawnEvent; 24 | import org.incendo.hyperverse.events.PlayerSetSpawnEvent; 25 | import org.incendo.hyperverse.world.HyperWorld; 26 | 27 | public interface HyperEventFactory { 28 | 29 | void callWorldCreation(@NonNull HyperWorld hyperWorld); 30 | 31 | void callWorldDeletion(@NonNull HyperWorld hyperWorld); 32 | 33 | @NonNull PlayerSeekSpawnEvent callPlayerSeekSpawn( 34 | @NonNull Player player, 35 | @NonNull HyperWorld world, 36 | @NonNull Location respawnLocation 37 | ); 38 | 39 | 40 | @NonNull PlayerSetSpawnEvent callPlayerSetSpawn( 41 | final @NonNull Player player, 42 | final @NonNull HyperWorld world 43 | ); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/HyperWorldCreatorFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.world.HyperWorld; 22 | import org.incendo.hyperverse.world.HyperWorldCreator; 23 | 24 | public interface HyperWorldCreatorFactory { 25 | 26 | @NonNull HyperWorldCreator create(final @NonNull HyperWorld hyperWorld); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/HyperWorldFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.world.HyperWorld; 22 | import org.incendo.hyperverse.world.WorldConfiguration; 23 | 24 | import java.util.UUID; 25 | 26 | public interface HyperWorldFactory { 27 | 28 | @NonNull HyperWorld create(@NonNull UUID uuid, @NonNull WorldConfiguration worldConfiguration); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/PersistentLocationTransformer.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.bukkit.Location; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.incendo.hyperverse.database.PersistentLocation; 23 | 24 | /** 25 | * Transforms a {@link PersistentLocation} to a Bukkit {@link Location}. 26 | * This class exists so that the {@link org.bukkit.Bukkit} static server singleton 27 | * isn't used to lookup worlds. 28 | */ 29 | @FunctionalInterface 30 | public interface PersistentLocationTransformer { 31 | 32 | @NonNull Location transform(@NonNull PersistentLocation persistentLocation); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/TaskFactoryModule.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import co.aikar.taskchain.BukkitTaskChainFactory; 21 | import co.aikar.taskchain.TaskChainFactory; 22 | import com.google.inject.AbstractModule; 23 | import com.google.inject.Provides; 24 | import com.google.inject.Singleton; 25 | import org.bukkit.plugin.Plugin; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | 28 | public final class TaskFactoryModule extends AbstractModule { 29 | 30 | @Override 31 | protected void configure() { 32 | } 33 | 34 | @Provides 35 | @Singleton 36 | public @NonNull TaskChainFactory provideTaskChainFactory(final @NonNull Plugin plugin) { 37 | return BukkitTaskChainFactory.create(plugin); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/TeleportationManagerFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.teleportation.TeleportationManager; 22 | import org.incendo.hyperverse.world.HyperWorld; 23 | 24 | public interface TeleportationManagerFactory { 25 | 26 | @NonNull TeleportationManager create(@NonNull HyperWorld hyperWorld); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/WorldConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.bukkit.World; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.checkerframework.checker.nullness.qual.Nullable; 23 | import org.incendo.hyperverse.world.WorldConfiguration; 24 | import org.incendo.hyperverse.world.WorldConfigurationBuilder; 25 | 26 | import java.nio.file.Path; 27 | 28 | public interface WorldConfigurationFactory { 29 | 30 | default WorldConfigurationBuilder builder() { 31 | return new WorldConfigurationBuilder(); 32 | } 33 | @NonNull WorldConfiguration fromWorld(@NonNull World world); 34 | 35 | @Nullable WorldConfiguration fromFile(@NonNull Path file); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/WorldImporterFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.modules; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.incendo.hyperverse.util.MultiverseImporter; 22 | import org.incendo.hyperverse.util.MyWorldsImporter; 23 | 24 | public interface WorldImporterFactory { 25 | 26 | @NonNull MultiverseImporter createMultiverseImporter(@NonNull HyperWorldFactory hyperWorldFactory); 27 | 28 | @NonNull MyWorldsImporter createMyWorldsImporter(@NonNull HyperWorldFactory hyperWorldFactory); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/modules/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Guice modules and factory types 20 | */ 21 | package org.incendo.hyperverse.modules; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/platform/PlatformProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.platform; 19 | 20 | import org.incendo.hyperverse.util.NMS; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | @FunctionalInterface 24 | public interface PlatformProvider { 25 | 26 | @NotNull Class providePlatform() throws PlatformProvisionException; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/platform/PlatformProvisionException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.platform; 19 | 20 | public class PlatformProvisionException extends Exception { 21 | 22 | public PlatformProvisionException() { 23 | } 24 | 25 | public PlatformProvisionException(final String message) { 26 | super(message); 27 | } 28 | 29 | public PlatformProvisionException(final String message, final Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public PlatformProvisionException(final Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | public PlatformProvisionException( 38 | final String message, 39 | final Throwable cause, 40 | final boolean enableSuppression, 41 | final boolean writableStackTrace 42 | ) { 43 | super(message, cause, enableSuppression, writableStackTrace); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/platform/ReflectionPlatformProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.platform; 19 | 20 | import org.incendo.hyperverse.util.NMS; 21 | import org.incendo.hyperverse.util.versioning.Version; 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | import java.util.Locale; 25 | 26 | public final class ReflectionPlatformProvider implements PlatformProvider { 27 | 28 | private final Version minecraftVersion; 29 | public ReflectionPlatformProvider(@NotNull final Version version) { 30 | this.minecraftVersion = version; 31 | } 32 | 33 | @Override 34 | public @NotNull Class providePlatform() throws PlatformProvisionException { 35 | String expectedPackage = this.minecraftVersion.original().toLowerCase(Locale.ENGLISH).replace('.', '_'); 36 | String packageName = "org.incendo.hyperverse.platform.v" + expectedPackage; 37 | try { 38 | Class clazz = Class.forName(packageName + ".NMSImpl"); 39 | return clazz.asSubclass(NMS.class); 40 | } catch (ReflectiveOperationException ex) { 41 | throw new PlatformProvisionException("Could not provide platform for version: " + this.minecraftVersion + "!", ex); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/service/internal/SafeTeleportService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.service.internal; 19 | 20 | import cloud.commandframework.services.types.Service; 21 | import org.bukkit.Location; 22 | import org.bukkit.Material; 23 | import org.bukkit.block.Block; 24 | import org.bukkit.block.BlockFace; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | 27 | /** 28 | * A {@link Service} used to find safe teleportation locations 29 | */ 30 | public interface SafeTeleportService extends Service { 31 | 32 | /** 33 | * Get the default service implementation 34 | * 35 | * @return Default implementation 36 | */ 37 | static @NonNull SafeTeleportService defaultService() { 38 | return new DefaultSafeTeleportService(); 39 | } 40 | 41 | /** 42 | * Default {@link SafeTeleportService} implementation that just scans 43 | * for safe locations in a vertical column 44 | */ 45 | final class DefaultSafeTeleportService implements SafeTeleportService { 46 | 47 | @Override 48 | public @NonNull Location handle(final @NonNull Location location) { 49 | Block locationBlock = location.getBlock(); 50 | do { 51 | if (locationBlock.getRelative(BlockFace.DOWN).getType().isSolid()) { 52 | return locationBlock.getLocation(); 53 | } 54 | } while (locationBlock.getY() > 0 55 | && (locationBlock = locationBlock.getRelative(BlockFace.DOWN)).getType() != Material.VOID_AIR); 56 | return location; 57 | } 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/service/internal/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Internal service types. 20 | */ 21 | package org.incendo.hyperverse.service.internal; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/service/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Services used by Hyperverse internally. 20 | */ 21 | package org.incendo.hyperverse.service; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/teleportation/TeleportationManager.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.teleportation; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.entity.Entity; 22 | import org.bukkit.entity.Player; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.checkerframework.checker.nullness.qual.Nullable; 25 | import org.incendo.hyperverse.world.HyperWorld; 26 | 27 | import java.util.concurrent.CompletableFuture; 28 | 29 | /** 30 | * Manager responsible for teleportation related actions 31 | */ 32 | public interface TeleportationManager { 33 | 34 | /** 35 | * Get the spawn location for a player in a particular world. This can be a bed 36 | * spawn location, the world spawn location, or some other location 37 | * 38 | * @param player Player to check the location for 39 | * @param hyperWorld The world in which the location exists 40 | * @return The spawn location 41 | */ 42 | @NonNull Location getSpawnLocation( 43 | @NonNull Player player, 44 | @NonNull HyperWorld hyperWorld 45 | ); 46 | 47 | /** 48 | * Check whether or not the player is allowed 49 | * to teleport to the specified location 50 | * 51 | * @param player Player that is about to teleport 52 | * @param location Location the player is teleporting to 53 | * @return True if the player is allowed to teleport to the location 54 | */ 55 | @NonNull CompletableFuture allowedTeleport( 56 | @NonNull Player player, 57 | @NonNull Location location 58 | ); 59 | 60 | /** 61 | * Check whether or not the player can safely teleport 62 | * to the specified location 63 | * 64 | * @param player Player that is about to teleport 65 | * @param location Location the player is teleporting to 66 | * @return True if the player is able to teleport to the location 67 | */ 68 | @NonNull CompletableFuture canTeleport( 69 | @NonNull Player player, 70 | @NonNull Location location 71 | ); 72 | 73 | /** 74 | * Find a safe teleportation location near the specified 75 | * location 76 | * 77 | * @param location Search origin 78 | * @return Safe location 79 | */ 80 | @NonNull CompletableFuture findSafe(@NonNull Location location); 81 | 82 | /** 83 | * Teleport the player to a given location 84 | * 85 | * @param player Player to teleport 86 | * @param location Location to teleport the player to 87 | */ 88 | void teleportPlayer( 89 | @NonNull Player player, 90 | @NonNull Location location 91 | ); 92 | 93 | /** 94 | * Handle nether portal teleportation 95 | * 96 | * @param entity Entity to teleport 97 | * @param location Portal location 98 | * @return The destination location 99 | */ 100 | @Nullable Location netherDestination( 101 | @NonNull Entity entity, 102 | @NonNull Location location 103 | ); 104 | 105 | /** 106 | * Handle end portal teleportation 107 | * 108 | * @param entity Entity to teleport 109 | * @return The destination location 110 | */ 111 | @Nullable Location endDestination(@NonNull Entity entity); 112 | 113 | } 114 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/teleportation/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Teleportation related classes 20 | */ 21 | package org.incendo.hyperverse.teleportation; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/GeneratorUtil.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util; 19 | 20 | import org.bukkit.Bukkit; 21 | import org.bukkit.Server; 22 | import org.bukkit.generator.ChunkGenerator; 23 | import org.bukkit.plugin.java.JavaPlugin; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.checker.nullness.qual.Nullable; 26 | 27 | import java.lang.reflect.Field; 28 | import java.lang.reflect.InvocationTargetException; 29 | import java.lang.reflect.Method; 30 | import java.util.Objects; 31 | import java.util.regex.Pattern; 32 | 33 | /** 34 | * Generator utility methods 35 | */ 36 | public final class GeneratorUtil { 37 | 38 | private static Method generatorGetter; 39 | private static Class pluginClassLoaderClass; 40 | private static Field pluginGetter; 41 | 42 | private GeneratorUtil() { 43 | } 44 | 45 | /** 46 | * Attempt to find the generator for a given world name 47 | * 48 | * @param world world name 49 | * @return Generator, if found 50 | */ 51 | public static @Nullable ChunkGenerator getGenerator(final @NonNull String world) 52 | throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { 53 | if (generatorGetter == null) { 54 | final Class serverClass = Bukkit.getServer().getClass(); 55 | generatorGetter = serverClass.getDeclaredMethod("getGenerator", String.class); 56 | generatorGetter.setAccessible(true); 57 | } 58 | return (ChunkGenerator) generatorGetter 59 | .invoke(Bukkit.getServer(), Objects.requireNonNull(world)); 60 | } 61 | 62 | /** 63 | * Attempt to find the generator plugin from a chunk generator instance 64 | * 65 | * @param generator Generator instance 66 | * @return Plugin, if found 67 | */ 68 | public static @Nullable JavaPlugin matchGenerator(final @NonNull ChunkGenerator generator) 69 | throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { 70 | Objects.requireNonNull(generator); 71 | final ClassLoader classLoader = generator.getClass().getClassLoader(); 72 | if (pluginClassLoaderClass == null) { 73 | pluginClassLoaderClass = Class.forName("org.bukkit.plugin.java.PluginClassLoader"); 74 | pluginGetter = pluginClassLoaderClass.getDeclaredField("plugin"); 75 | pluginGetter.setAccessible(true); 76 | } 77 | if (pluginClassLoaderClass.isInstance(classLoader)) { 78 | return (JavaPlugin) pluginGetter.get(classLoader); 79 | } 80 | return null; 81 | } 82 | 83 | /** 84 | * Check if there is an available generator with the given name 85 | * 86 | * @param generatorName Generator name 87 | * @return True if the generator is available, false if not 88 | */ 89 | public static boolean isGeneratorAvailable(final @Nullable String generatorName) { 90 | if (generatorName == null 91 | || generatorName.isEmpty() 92 | || generatorName.equalsIgnoreCase("vanilla")) { 93 | return true; 94 | } 95 | final String pluginName; 96 | if (generatorName.contains(":")) { 97 | pluginName = generatorName.split(Pattern.quote(":"))[0]; 98 | } else { 99 | pluginName = generatorName; 100 | } 101 | return Bukkit.getPluginManager().isPluginEnabled(pluginName); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/SeedUtil.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util; 19 | 20 | import java.util.concurrent.ThreadLocalRandom; 21 | 22 | /** 23 | * Seed utility methods 24 | */ 25 | public final class SeedUtil { 26 | 27 | private SeedUtil() { 28 | } 29 | 30 | /** 31 | * Generate a random seed 32 | * 33 | * @return Randomly generated seed 34 | */ 35 | public static long randomSeed() { 36 | return ThreadLocalRandom.current().nextLong(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/WorldUtil.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util; 19 | 20 | import org.bukkit.Bukkit; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.incendo.hyperverse.world.WorldManager; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.nio.file.Files; 27 | import java.nio.file.Path; 28 | import java.util.regex.Pattern; 29 | import java.util.stream.Stream; 30 | 31 | /** 32 | * World utility methods 33 | */ 34 | public final class WorldUtil { 35 | 36 | private static final Pattern WORLD_NAME_PATTERN = Pattern.compile("[A-Za-z\\-_0-9]{1,16}"); 37 | 38 | private WorldUtil() { 39 | } 40 | 41 | /** 42 | * Check whether or not a world name is valid 43 | * 44 | * @param worldName World name 45 | * @return True if the world name is valid, false if not 46 | */ 47 | public static boolean validateName(final @NonNull String worldName) { 48 | return WORLD_NAME_PATTERN.matcher(worldName).matches(); 49 | } 50 | 51 | /** 52 | * Check whether or not a world is suitable to be imported 53 | * 54 | * @param worldName World name 55 | * @param manager World manager 56 | * @return True of directory containing a level.dat file with the same name is found 57 | */ 58 | public static boolean isSuitableImportCandidate( 59 | final @NonNull String worldName, 60 | final @NonNull WorldManager manager 61 | ) { 62 | if (manager.getWorld(worldName) != null) { 63 | return false; 64 | } 65 | try (final Stream files = Files.list(Bukkit.getWorldContainer().toPath())) { 66 | return files.anyMatch(path -> { 67 | final File file = path.toFile(); 68 | return file.getName().equals(worldName) && file.isDirectory() && new File( 69 | file, 70 | "level.dat" 71 | ).isFile(); 72 | }); 73 | } catch (IOException e) { 74 | return false; 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Utility classes 20 | */ 21 | package org.incendo.hyperverse.util; 22 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/versioning/PreReleaseType.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util.versioning; 19 | 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | import javax.annotation.Nullable; 23 | import java.util.Locale; 24 | 25 | public enum PreReleaseType { 26 | 27 | UNKNOWN("unknown"), 28 | 29 | ALPHA("alpha"), 30 | BETA("beta"), 31 | SNAPSHOT("snapshot"), 32 | RELEASE_CANDIDATE("rc"); 33 | 34 | private static final PreReleaseType[] VALUES = values(); 35 | 36 | private final String asString; 37 | 38 | PreReleaseType(@NotNull final String asString) { 39 | this.asString = asString; 40 | } 41 | 42 | @Nullable 43 | public static PreReleaseType parse(@NotNull final String release) { 44 | if (release.isEmpty()) { 45 | return null; 46 | } 47 | String sanitized = release.toLowerCase(Locale.ENGLISH); 48 | for (PreReleaseType preReleaseType : VALUES) { 49 | if (preReleaseType.asString.equals(sanitized)) { 50 | return preReleaseType; 51 | } 52 | } 53 | return UNKNOWN; 54 | } 55 | 56 | public @NotNull String asString() { 57 | return this.asString; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/versioning/Version.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util.versioning; 19 | 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | import java.util.StringJoiner; 23 | import java.util.regex.Matcher; 24 | import java.util.regex.Pattern; 25 | 26 | public record Version(@NotNull String original, @NotNull VersionData versionData) { 27 | 28 | /** 29 | * Semver pattern, cg1 = major, cg2 = minor, cg3 = patch, cg4 = prerelease and cg5 = buildmetadata 30 | * Taken from https://semver.org/ and https://regex101.com/r/vkijKf/1/ 31 | */ 32 | public static final Pattern SEMVER_PATTERN = Pattern.compile( 33 | "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); 34 | 35 | public static @NotNull Version parseMinecraft(@NotNull final String version) throws IllegalArgumentException { 36 | String[] split = version.split("\\."); 37 | if (split.length < 2) { 38 | throw new IllegalArgumentException("Invalid minecraft version: " + version); 39 | } 40 | if (split.length == 2) { 41 | StringJoiner joiner = new StringJoiner("."); 42 | // insert a .0 to make it correctly formatted 43 | joiner.add(split[0]); 44 | joiner.add("0"); 45 | joiner.add(split[1]); 46 | Version formatted = parseSemVer(joiner.toString()); 47 | return new Version(version, formatted.versionData()); 48 | } 49 | return parseSemVer(version); 50 | } 51 | 52 | public static @NotNull Version parseSemVer(@NotNull final String version) throws IllegalArgumentException { 53 | Matcher matcher = SEMVER_PATTERN.matcher(version); 54 | if (!matcher.find()) { 55 | throw new IllegalArgumentException("Invalid version: " + version); 56 | } 57 | String majorRaw = matcher.group(1); 58 | String minorRaw = matcher.group(2); 59 | String patchRaw = matcher.group(3); 60 | String preReleaseRaw = matcher.group(4); 61 | int major; 62 | int minor; 63 | try { 64 | major = Integer.parseInt(majorRaw); 65 | minor = Integer.parseInt(minorRaw); 66 | } catch (NumberFormatException ex) { 67 | throw new IllegalArgumentException("Invalid version: " + version); 68 | } 69 | if (patchRaw == null || patchRaw.isEmpty()) { 70 | return new Version(version, new VersionData(major, minor, 0, null)); 71 | } 72 | int patch; 73 | try { 74 | patch = Integer.parseInt(patchRaw); 75 | } catch (NumberFormatException ex) { 76 | throw new IllegalArgumentException("Invalid version: " + version); 77 | } 78 | if (preReleaseRaw == null || preReleaseRaw.isEmpty()) { 79 | return new Version(version, new VersionData(major, minor, patch, null)); 80 | } 81 | PreReleaseType releaseType = PreReleaseType.parse(preReleaseRaw); 82 | return new Version(version, new VersionData(major, minor, patch, releaseType)); 83 | } 84 | 85 | @Override 86 | public @NotNull String toString() { 87 | return this.original; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/versioning/VersionData.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util.versioning; 19 | 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | public record VersionData(int major, int minor, Integer patch, PreReleaseType preReleaseType) 23 | implements Comparable { 24 | 25 | public VersionData(final int major, final int minor, final int patch) { 26 | this(major, minor, patch, null); 27 | } 28 | 29 | public VersionData(final int major, final int minor) { 30 | this(major, minor, 0); 31 | } 32 | 33 | @Override 34 | public @NotNull String toString() { 35 | return String.format("%d.%d.%d", this.major, this.minor, this.patch); 36 | } 37 | 38 | public boolean isNewerThan(@NotNull final VersionData other) { 39 | return this.compareTo(other) > 0; 40 | } 41 | 42 | public boolean isOlderThan(@NotNull final VersionData other) { 43 | return this.compareTo(other) < 0; 44 | } 45 | 46 | 47 | @Override 48 | public int compareTo(@NotNull final VersionData o) { 49 | int majorComp = Integer.compare(this.major, o.major); 50 | if (majorComp != 0) { 51 | return majorComp; 52 | } 53 | int minorComp = Integer.compare(this.minor, o.minor); 54 | if (minorComp != 0) { 55 | return minorComp; 56 | } 57 | int patchComp = Integer.compare(this.patch, o.patch); 58 | if (patchComp != 0) { 59 | return patchComp; 60 | } 61 | if (this.preReleaseType == null && o.preReleaseType == null) { 62 | return 0; 63 | } 64 | if (this.preReleaseType == null) { 65 | return 1; 66 | } 67 | return this.preReleaseType.compareTo(o.preReleaseType); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/util/versioning/VersionUtil.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util.versioning; 19 | 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | public final class VersionUtil { 23 | 24 | private VersionUtil() { 25 | throw new IllegalStateException("Cannot instantiate static utility class"); 26 | } 27 | 28 | public static @NotNull Version parseMinecraftVersion(@NotNull final String minecraftVersion) throws IllegalArgumentException { 29 | // Expecting 1.X.X-R0.1-SNAPSHOT 30 | int stripLength = "-R0.1-SNAPSHOT".length(); 31 | int length = minecraftVersion.length(); 32 | if (length <= stripLength) { 33 | throw new IllegalArgumentException("Invalid minecraft version: " + minecraftVersion); 34 | } 35 | String strippedVersion = minecraftVersion.substring(0, length - stripLength); 36 | try { 37 | return Version.parseMinecraft(strippedVersion); 38 | } catch (IllegalArgumentException ex) { 39 | throw new IllegalArgumentException("Invalid minecraft version: " + minecraftVersion, ex); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/world/HyperWorldCreator.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.world; 19 | 20 | import com.google.inject.Inject; 21 | import com.google.inject.assistedinject.Assisted; 22 | import org.bukkit.WorldCreator; 23 | import org.bukkit.WorldType; 24 | import org.bukkit.generator.ChunkGenerator; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.incendo.hyperverse.util.NullRouteCommandSender; 27 | 28 | import java.util.Objects; 29 | 30 | /** 31 | * World creator instance used to create a {@link HyperWorld} 32 | */ 33 | public final class HyperWorldCreator extends WorldCreator { 34 | 35 | private final HyperWorld hyperWorld; 36 | 37 | @Inject 38 | public HyperWorldCreator(@Assisted final @NonNull HyperWorld hyperWorld) { 39 | super(Objects.requireNonNull(hyperWorld).getConfiguration().getName()); 40 | this.hyperWorld = hyperWorld; 41 | } 42 | 43 | /** 44 | * Validate the world configuration 45 | * 46 | * @return Result of the validation 47 | */ 48 | public @NonNull ValidationResult validate() { 49 | final WorldConfiguration worldConfiguration = this.hyperWorld.getConfiguration(); 50 | if (!worldConfiguration.getGenerator().isEmpty() 51 | && !worldConfiguration.getGenerator().equalsIgnoreCase("vanilla")) { 52 | final ChunkGenerator chunkGenerator = 53 | getGeneratorForName(worldConfiguration.getName(), this.getJoinedName(), 54 | NullRouteCommandSender.getInstance() 55 | ); 56 | if (chunkGenerator == null) { 57 | return ValidationResult.UNKNOWN_GENERATOR; 58 | } 59 | } 60 | return ValidationResult.SUCCESS; 61 | } 62 | 63 | /** 64 | * Configure the world creator 65 | */ 66 | public void configure() { 67 | final WorldConfiguration worldConfiguration = this.hyperWorld.getConfiguration(); 68 | if (worldConfiguration.getWorldFeatures() != null) { 69 | this.type(worldConfiguration.getWorldFeatures().getBukkitType()); 70 | } else { 71 | this.type(WorldType.NORMAL); 72 | } 73 | this.environment(worldConfiguration.getType().getBukkitType()); 74 | this.generatorSettings(worldConfiguration.getSettings()); 75 | this.seed(worldConfiguration.getSeed()); 76 | this.generateStructures(worldConfiguration.isGenerateStructures()); 77 | this.generator(this.getJoinedName(), NullRouteCommandSender.getInstance()); 78 | } 79 | 80 | private @NonNull String getJoinedName() { 81 | if (this.hyperWorld.getConfiguration().getGeneratorArg().isEmpty()) { 82 | return this.hyperWorld.getConfiguration().getGenerator(); 83 | } 84 | return String.format("%s:%s", this.hyperWorld.getConfiguration().getGenerator(), 85 | this.hyperWorld.getConfiguration().getGeneratorArg() 86 | ); 87 | } 88 | 89 | /** 90 | * Result of configuration validation 91 | */ 92 | public enum ValidationResult { 93 | SUCCESS, 94 | UNKNOWN_GENERATOR, 95 | NAME_TAKEN, 96 | UNKNOWN_ERROR 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/world/WorldStructureSetting.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.world; 19 | 20 | /** 21 | * Setting that indicates whether or not 22 | * worlds should generate structures 23 | */ 24 | public enum WorldStructureSetting { 25 | NO_STRUCTURES, 26 | GENERATE_STRUCTURES 27 | } 28 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/world/WorldType.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.world; 19 | 20 | import org.bukkit.World; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | 23 | import java.util.Arrays; 24 | import java.util.Collection; 25 | import java.util.Objects; 26 | import java.util.Optional; 27 | 28 | /** 29 | * World type, mirroring Bukkit's {@link World.Environment} 30 | */ 31 | public enum WorldType { 32 | OVER_WORLD(World.Environment.NORMAL, Arrays.asList("overworld", "over_world", "normal")), 33 | NETHER(World.Environment.NETHER, Arrays.asList("the_nether", "nether", "hell")), 34 | END(World.Environment.THE_END, Arrays.asList("end", "the_end")); 35 | 36 | private final World.Environment bukkitType; 37 | private final Collection aliases; 38 | 39 | WorldType( 40 | final World.@NonNull Environment bukkitType, 41 | final @NonNull Collection<@NonNull String> aliases 42 | ) { 43 | this.bukkitType = bukkitType; 44 | this.aliases = aliases; 45 | } 46 | 47 | /** 48 | * Attempt to map a string to a world type 49 | * 50 | * @param string String to match 51 | * @return Optional containing the type, if found 52 | */ 53 | public static @NonNull Optional<@NonNull WorldType> fromString(final @NonNull String string) { 54 | final String normalized = Objects.requireNonNull(string.toLowerCase()); 55 | for (final WorldType worldType : values()) { 56 | if (worldType.getAliases().contains(normalized)) { 57 | return Optional.of(worldType); 58 | } 59 | } 60 | return Optional.empty(); 61 | } 62 | 63 | /** 64 | * Get the world type from a bukkit environment 65 | * 66 | * @param environment Bukkit environment 67 | * @return Equivalent Hyperverse world type 68 | */ 69 | public static @NonNull WorldType fromBukkit(final World.@NonNull Environment environment) { 70 | for (final WorldType worldType : values()) { 71 | if (worldType.getBukkitType() == environment) { 72 | return worldType; 73 | } 74 | } 75 | return WorldType.OVER_WORLD; 76 | } 77 | 78 | /** 79 | * Get the bukkit equivalent 80 | * 81 | * @return Bukkit equivalent 82 | */ 83 | public World.@NonNull Environment getBukkitType() { 84 | return this.bukkitType; 85 | } 86 | 87 | /** 88 | * Get all aliases of the type name 89 | * 90 | * @return Name aliases 91 | */ 92 | public @NonNull Collection<@NonNull String> getAliases() { 93 | return this.aliases; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /hyperverse-core/src/main/java/org/incendo/hyperverse/world/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | /** 19 | * Classes related to worlds, world creation, world properties, etc 20 | */ 21 | package org.incendo.hyperverse.world; 22 | -------------------------------------------------------------------------------- /hyperverse-nms-1-20-6/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("hyperverse.base-conventions") 3 | alias(libs.plugins.paperweight.userdev) 4 | } 5 | 6 | indra { 7 | javaVersions { 8 | minimumToolchain(21) 9 | target(21) 10 | } 11 | } 12 | 13 | dependencies { 14 | paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT") 15 | compileOnly(projects.hyperverseNmsCommon) 16 | } 17 | 18 | tasks { 19 | assemble { 20 | dependsOn(reobfJar) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hyperverse-nms-1-21-3/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("hyperverse.base-conventions") 3 | alias(libs.plugins.paperweight.userdev) 4 | } 5 | 6 | indra { 7 | javaVersions { 8 | minimumToolchain(21) 9 | target(21) 10 | } 11 | } 12 | 13 | dependencies { 14 | paperweight.paperDevBundle("1.21.3-R0.1-SNAPSHOT") 15 | compileOnly(projects.hyperverseNmsCommon) 16 | } 17 | 18 | tasks { 19 | assemble { 20 | dependsOn(reobfJar) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hyperverse-nms-1-21-4/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("hyperverse.base-conventions") 3 | alias(libs.plugins.paperweight.userdev) 4 | } 5 | 6 | indra { 7 | javaVersions { 8 | minimumToolchain(21) 9 | target(21) 10 | } 11 | } 12 | 13 | dependencies { 14 | paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") 15 | compileOnly(projects.hyperverseNmsCommon) 16 | } 17 | 18 | tasks { 19 | assemble { 20 | dependsOn(reobfJar) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hyperverse-nms-1-21/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("hyperverse.base-conventions") 3 | alias(libs.plugins.paperweight.userdev) 4 | } 5 | 6 | indra { 7 | javaVersions { 8 | minimumToolchain(21) 9 | target(21) 10 | } 11 | } 12 | 13 | dependencies { 14 | paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") 15 | compileOnly(projects.hyperverseNmsCommon) 16 | } 17 | 18 | tasks { 19 | assemble { 20 | dependsOn(reobfJar) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hyperverse-nms-common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("hyperverse.base-conventions") 3 | } 4 | 5 | dependencies { 6 | compileOnly(libs.paper) 7 | compileOnlyApi(libs.paperlib) 8 | compileOnlyApi(libs.guice) 9 | compileOnlyApi(libs.taskchain) 10 | } 11 | -------------------------------------------------------------------------------- /hyperverse-nms-common/src/main/java/org/incendo/hyperverse/util/HyperConfigShouldGroupProfiles.java: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Hyperverse - A minecraft world management plugin 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | 19 | package org.incendo.hyperverse.util; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | // This is a slight hack around the fact we can't have circular dependencies. 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ElementType.PARAMETER, ElementType.METHOD}) 29 | public @interface HyperConfigShouldGroupProfiles { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hyperverse-nms-common/src/main/java/org/incendo/hyperverse/util/NMS.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.util; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.entity.Entity; 22 | import org.bukkit.entity.Player; 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.checkerframework.checker.nullness.qual.Nullable; 25 | 26 | import java.nio.file.Path; 27 | 28 | /** 29 | * Version specific NMS utility methods 30 | */ 31 | public interface NMS { 32 | 33 | /** 34 | * Get the nether portal at the given location or create a new one 35 | * 36 | * @param entity Entity that is searching for the portal 37 | * @param origin Origin location 38 | * @return Portal location 39 | */ 40 | @Nullable 41 | Location getOrCreateNetherPortal( 42 | @NonNull Entity entity, 43 | @NonNull Location origin 44 | ); 45 | 46 | /** 47 | * Get the spawn for the dimension containing the given location 48 | * 49 | * @param origin Origin location 50 | * @return Dimension spawn 51 | */ 52 | @Nullable Location getDimensionSpawn(@NonNull Location origin); 53 | 54 | /** 55 | * Find the respawn location for a location that contains a bed 56 | * 57 | * @param spawnLocation Location to search from 58 | * @return The bed respawn location, if found 59 | */ 60 | @Nullable Location findBedRespawn(@NonNull Location spawnLocation); 61 | 62 | /** 63 | * Save {@link Player player} data to a {@link Path file} 64 | * 65 | * @param player Player that owns the data. 66 | * @param file File to save the data to. 67 | */ 68 | void writePlayerData(@NonNull Player player, @NonNull Path file); 69 | 70 | /** 71 | * Read the {@link Player player} data from a {@link Path file} into the given {@link Player} object 72 | * 73 | * @param player Player to read data into. 74 | * @param file File to read data from. 75 | * @param whenDone Runnable that runs when the reading is complete. 76 | */ 77 | void readPlayerData( 78 | @NonNull Player player, 79 | @NonNull Path file, 80 | @NonNull Runnable whenDone 81 | ); 82 | 83 | } 84 | -------------------------------------------------------------------------------- /hyperverse-nms-common/src/main/java/org/incendo/hyperverse/util/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Hyperverse - A minecraft world management plugin 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | 19 | /** 20 | * Utility classes. 21 | */ 22 | package org.incendo.hyperverse.util; 23 | -------------------------------------------------------------------------------- /hyperverse-nms-unsupported/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("hyperverse.base-conventions") 3 | } 4 | 5 | dependencies { 6 | compileOnly(projects.hyperverseNmsCommon) 7 | compileOnly(libs.paper) 8 | } 9 | -------------------------------------------------------------------------------- /hyperverse-nms-unsupported/src/main/java/org/incendo/hyperverse/platform/unsupported/NMSImpl.java: -------------------------------------------------------------------------------- 1 | // 2 | // Hyperverse - A minecraft world management plugin 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | // 17 | 18 | package org.incendo.hyperverse.platform.unsupported; 19 | 20 | import org.bukkit.Location; 21 | import org.bukkit.World; 22 | import org.bukkit.entity.Entity; 23 | import org.bukkit.entity.Player; 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.checker.nullness.qual.Nullable; 26 | import org.incendo.hyperverse.util.NMS; 27 | 28 | import java.nio.file.Path; 29 | import java.util.Objects; 30 | 31 | @SuppressWarnings("unused") 32 | public class NMSImpl implements NMS { 33 | 34 | @Override 35 | public @Nullable Location getOrCreateNetherPortal( 36 | final @NonNull Entity entity, 37 | final @NonNull Location origin 38 | ) { 39 | throw new UnsupportedOperationException("Not supported."); 40 | } 41 | 42 | @Override 43 | public @Nullable Location getDimensionSpawn(final @NonNull Location origin) { 44 | if (Objects.requireNonNull(origin.getWorld()).getEnvironment() 45 | == World.Environment.THE_END) { 46 | return new Location(origin.getWorld(), 100, 50, 0); 47 | } 48 | return origin.getWorld().getSpawnLocation(); 49 | } 50 | 51 | @Override 52 | public void writePlayerData(final @NonNull Player player, final @NonNull Path file) { 53 | throw new UnsupportedOperationException("Not supported."); 54 | } 55 | 56 | @Override 57 | public void readPlayerData(final @NonNull Player player, final @NonNull Path file, final @NonNull Runnable whenDone) { 58 | throw new UnsupportedOperationException("Not supported."); 59 | } 60 | 61 | @Override 62 | public @Nullable Location findBedRespawn(final @NonNull Location spawnLocation) { 63 | throw new UnsupportedOperationException("Not supported."); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 2 | 3 | pluginManagement { 4 | repositories { 5 | gradlePluginPortal() 6 | } 7 | includeBuild("gradle/build-logic") 8 | } 9 | 10 | rootProject.name = "Hyperverse" 11 | 12 | include(":hyperverse-nms-common") 13 | include(":hyperverse-core") 14 | 15 | include(":hyperverse-nms-unsupported") 16 | include(":hyperverse-nms-1-20-6") 17 | include(":hyperverse-nms-1-21") 18 | include(":hyperverse-nms-1-21-3") 19 | include(":hyperverse-nms-1-21-4") 20 | --------------------------------------------------------------------------------