Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3db789fb17 | ||
|
|
bf4119c6ee | ||
|
|
6a056a0c31 |
No files matched your search
@@ -1,77 +0,0 @@
|
||||
name: 🐛 Report a Bug
|
||||
description: Report a problem with Multiverse-Core.
|
||||
title: "[Bug]: "
|
||||
labels: ["Bug: Unconfirmed"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
If you are having issues with other submodules of Multiverse, please go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
|
||||
|
||||
Not sure if this is a bug with Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
|
||||
|
||||
When completing the report, please ensure all fields are filled with the correct details requested. Failure to do so will result in your issue being closed.
|
||||
- type: input
|
||||
id: mutliverse-version-info
|
||||
attributes:
|
||||
label: '`/mv version -p` output'
|
||||
description: Run `/mv version -p` in the console, then copy and paste the link from the output of the command into this box.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: server-logs
|
||||
attributes:
|
||||
label: Server logs
|
||||
description: >
|
||||
Include full startup log and console error (if any). upload all relevant logs to either https://paste.gg
|
||||
or https://gist.github.com, save and the paste the link in this box.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: server-version
|
||||
attributes:
|
||||
label: Server Version
|
||||
description: Output of `/version` command.
|
||||
placeholder: server version info
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Bug Description
|
||||
description: Describe in detail what the bug is about. Include the expected behaviour and actual behaviour.
|
||||
placeholder: "Example: When running `/mv` it cause the server to crash..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce-steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Provide detailed intructions to trigger the bug.
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Start a server with only multiverse installed.
|
||||
2. Run `/mv` command.
|
||||
3. Players all get kicked with a "server closed" message.
|
||||
...
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: agreements
|
||||
attributes:
|
||||
label: Agreements
|
||||
description: Ensure you have done the following being submitting this issue.
|
||||
options:
|
||||
- label: I have searched for and ensured there isn't already an open or resolved issue(s) regarding this.
|
||||
required: true
|
||||
- label: >
|
||||
I was able to reproduce my issue on a freshly setup and up-to-date server with the latest
|
||||
version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
|
||||
required: true
|
||||
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 Multiverse Discord Server
|
||||
url: https://discord.gg/NZtfKky
|
||||
about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help!
|
||||
@@ -1,41 +0,0 @@
|
||||
name: 💡 Request a Feature
|
||||
description: Suggest a feature you want to see in Multiverse-Core!
|
||||
title: "[Idea]: "
|
||||
labels: ["Type: Idea"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to share your ideas!
|
||||
|
||||
If you are look for other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
|
||||
|
||||
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
|
||||
- type: textarea
|
||||
id: feature-description
|
||||
attributes:
|
||||
label: Describe the feature
|
||||
description: What feature are you suggesting?
|
||||
placeholder: "Example: I hope multiverse can implement random teleport feature..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: feature-reasoning
|
||||
attributes:
|
||||
label: How is the feature useful to all Multiverse users?
|
||||
description: How is the feature useful to all players, server owners and/or developers?
|
||||
placeholder: "Example: Random teleporting can be integrated into many multiverse modules such as mv-portals..."
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: agreements
|
||||
attributes:
|
||||
label: Agreements
|
||||
description: Ensure you have done the following being submitting this issue.
|
||||
options:
|
||||
- label: I have searched for and ensured there isn't already an open issue regarding this.
|
||||
required: true
|
||||
@@ -1,2 +0,0 @@
|
||||
prerelease:
|
||||
- '*'
|
||||
@@ -1,38 +0,0 @@
|
||||
name: Create Release Version & Publish Package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [dbo-test]
|
||||
|
||||
jobs:
|
||||
dbo_upload_test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download release artifact
|
||||
id: release-artifact
|
||||
uses: dsaltares/fetch-gh-release-asset@master
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# version: tags/${{ github.event.inputs.version }}
|
||||
regex: true
|
||||
file: multiverse-core-(.*)\.jar
|
||||
target: 'subdir/'
|
||||
|
||||
- name: Upload to dev.bukkit.org
|
||||
uses: benwoo1110/dbo-upload-action@v0.1.0
|
||||
with:
|
||||
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
|
||||
project_id: 30765
|
||||
changelog: ${{ steps.release-artifact.outputs.body }}
|
||||
changelog_type: markdown
|
||||
display_name: ${{ steps.release-artifact.outputs.version }}
|
||||
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
|
||||
project_relations: >
|
||||
[
|
||||
{"slug": "multiverse-portals", "type": "optionalDependency"},
|
||||
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
|
||||
{"slug": "multiverse-signportals", "type": "optionalDependency"},
|
||||
{"slug": "multiverse-inventories", "type": "optionalDependency"}
|
||||
]
|
||||
file_path: ${{ github.workspace }}/subdir/multiverse-core-${{ steps.release-artifact.outputs.version }}.jar
|
||||
debug: true
|
||||
@@ -1,17 +0,0 @@
|
||||
name: "Pull Request Labeler"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
prerelease_labeler:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
@@ -1,90 +0,0 @@
|
||||
name: Manually promote last prerelease to release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to promote'
|
||||
required: true
|
||||
version-bump:
|
||||
description: 'Version bump to apply - should usually match the version bump used for the prerelease since last release'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- 'patch'
|
||||
- 'minor'
|
||||
- 'major'
|
||||
|
||||
jobs:
|
||||
manually_promote_release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Verify input version is prerelease
|
||||
run: |
|
||||
if [[ "${{ github.event.inputs.version }}" != *"pre"* ]]; then
|
||||
echo "Version must be a prerelease"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Get release info
|
||||
id: get-release
|
||||
uses: cardinalby/git-get-release-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
with:
|
||||
tag: ${{ github.event.inputs.version }}
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ steps.get-release.outputs.tag_name }}
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Remove prerelease tag
|
||||
run: |
|
||||
echo "Removing prerelease tag from version"
|
||||
echo "VERSION=$(echo ${{ steps.get-release.outputs.tag_name }} | sed -E 's/-pre.*//')" >> $GITHUB_ENV
|
||||
|
||||
- name: Build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: clean build -x test -x checkstyleMain -x checkstyleTest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
uses: Multiverse/release-on-push-action@skip_prs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
bump_version_scheme: ${{ github.event.inputs.version-bump }}
|
||||
tag_prefix: ''
|
||||
release_name: "<RELEASE_VERSION>"
|
||||
use_github_release_notes: true
|
||||
ref: ${{ steps.get-release.outputs.target_commitish }}
|
||||
skip_prs: true
|
||||
|
||||
- name: Publish package
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_VERSION: ${{ env.VERSION }}
|
||||
|
||||
- name: Upload release artifact
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/libs/multiverse-core-${{ env.VERSION }}.jar
|
||||
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
||||
@@ -1,64 +0,0 @@
|
||||
name: Create Release Version & Publish Package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
release_on_push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Test & Build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: clean build -x assemble -x shadowJar
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
uses: Multiverse/release-on-push-action@support_prerelease
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
bump_version_scheme: norelease
|
||||
tag_prefix: ''
|
||||
release_name: "<RELEASE_VERSION>"
|
||||
use_github_release_notes: true
|
||||
|
||||
- name: Modify version scheme
|
||||
run: |
|
||||
if [[ "${{ steps.release.outputs.tag_name }}" == *"pre"* ]]; then
|
||||
echo "Replacing prerelease version scheme with SNAPSHOT"
|
||||
echo "VERSION=$(echo ${{ steps.release.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Using release version scheme"
|
||||
echo "VERSION=${{ steps.release.outputs.tag_name }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Publish package
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: publish
|
||||
env:
|
||||
GITHUB_VERSION: ${{ env.VERSION }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload release artifact
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/libs/multiverse-core-${{ env.VERSION }}.jar
|
||||
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
||||
@@ -1,18 +0,0 @@
|
||||
name: Require PR Labels
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, labeled, unlabeled, synchronize]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
require_label:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: mheap/github-action-required-labels@v2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
mode: exactly
|
||||
count: 1
|
||||
labels: "release:major, release:minor, release:patch, no version bump"
|
||||
@@ -1,36 +0,0 @@
|
||||
name: Run unit tests against all PRs
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Run unit tests
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build -x checkstyleMain -x checkstyleTest -x javadoc
|
||||
env:
|
||||
GITHUB_VERSION: pr${{ github.event.pull_request.number }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Artifact output
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: multiverse-core-pr${{ github.event.pull_request.number }}
|
||||
path: build/libs/multiverse-core-pr${{ github.event.pull_request.number }}.jar
|
||||
@@ -1,48 +0,0 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
/.checkstyle
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Fern's utils
|
||||
uploadtoserver.sh
|
||||
|
||||
# Testing files:
|
||||
debug.log
|
||||
|
||||
# Doxygen
|
||||
/docs/html
|
||||
debug.txt
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
@@ -1,6 +0,0 @@
|
||||
Copyright (c) 2011, The Multiverse Team All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||

|
||||
|
||||
[](https://github.com/Multiverse/Multiverse-Core/actions/workflows/build.yml)
|
||||
[](https://dev.bukkit.org/projects/multiverse-core)
|
||||
[](https://ci.onarandombox.com/job/Multiverse-Core/)
|
||||
[](https://discord.gg/NZtfKky)
|
||||
[](https://patreon.com/dumptruckman)
|
||||
[](LICENSE.md)
|
||||
|
||||
About
|
||||
========
|
||||
[Multiverse](https://dev.bukkit.org/projects/multiverse-core) was created at the dawn of Bukkit multiworld support. It has since then grown into a **complete world management solution!** Multiverse provides the easiest to use world management solution for your Minecraft server, big or small, and with great addons like [Portals](https://dev.bukkit.org/projects/multiverse-portals) and [NetherPortals](https://dev.bukkit.org/projects/multiverse-netherportals/), what's not to love!
|
||||
<br><br>
|
||||
Now it's time to create your very own Multiverse server, do check out our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) and [Usage Guide](https://github.com/Multiverse/Multiverse-Core/wiki/Basics) to get started. Feel free to hop onto our [Discord](https://discord.gg/NZtfKky) if you have any question or just want to have a chat with us!
|
||||
|
||||
### Amazing sub-modules available:
|
||||
* [Multiverse-NetherPortals](https://github.com/Multiverse/Multiverse-NetherPortals) -> Have separate nether and end worlds for each of your overworlds!
|
||||
* [Multiverse-Portals](https://github.com/Multiverse/Multiverse-Portals) -> Make custom portals to go to any destination!
|
||||
* [Multiverse-Inventories](https://github.com/Multiverse/Multiverse-Inventories) -> Have separated players stats and inventories per world or per group of worlds.
|
||||
* [Multiverse-SignPortals](https://github.com/Multiverse/Multiverse-SignPortals) -> Signs as teleprompters!
|
||||
|
||||
Building
|
||||
========
|
||||
Simply build the source with Gradle:
|
||||
```
|
||||
./gradlew build
|
||||
```
|
||||
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
||||
|
||||
|
||||
Contributing
|
||||
=======
|
||||
**Want to help improve Multiverse?** There are several ways you can support and contribute to the project.
|
||||
* Take a look at our "Bug: Unconfirmed" issues, where you can find issues that need extra testing and investigation.
|
||||
* Want others to love Multiverse too? You can join the [Multiverse Discord community](https://discord.gg/NZtfKky) and help others with issues and setup!
|
||||
* A Multiverse guru? You can update our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) with your latest tip, tricks and guides! The wiki open for all to edit and improve.
|
||||
* Love coding? You could look at ["State: Open to PR"](https://github.com/Multiverse/Multiverse-Core/labels/State%3A%20Open%20to%20PR) and ["Resolution: Accepted"](https://github.com/Multiverse/Multiverse-Core/labels/Resolution%3A%20Accepted) issues. We're always happy to receive bug fixes and feature additions as [pull requests](https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/).
|
||||
* If you'd like to make a financial contribution to the project, do consider joining our [patreon](https://www.patreon.com/dumptruckman) or make a one-time donation [here](https://paypal.me/dumptruckman)!
|
||||
|
||||
Additionally, we would like to give a big thanks to everyone that has supported Multiverse over the years, as well as those in the years to come. Thank you!
|
||||
|
||||
License
|
||||
=======
|
||||
Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info.
|
||||
@@ -1,286 +0,0 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'checkstyle'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
||||
id "org.jetbrains.kotlin.jvm" version "1.8.10"
|
||||
}
|
||||
|
||||
version = System.getenv('GITHUB_VERSION') ?: 'local'
|
||||
group = 'com.onarandombox.multiversecore'
|
||||
description = 'Multiverse-Core'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.onarandombox.com/content/groups/public')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://hub.spigotmc.org/nexus/content/groups/public/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://jitpack.io')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.minebench.de/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.maven.apache.org/maven2/')
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'aikar repo'
|
||||
url = uri('https://repo.aikar.co/content/groups/aikar/')
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'glaremasters repo'
|
||||
url = 'https://repo.glaremasters.me/repository/towny/'
|
||||
}
|
||||
maven {
|
||||
name = 'PlaceholderAPI'
|
||||
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
oldTestImplementation.extendsFrom implementation
|
||||
oldTestRuntime.extendsFrom runtime
|
||||
relocatedApi
|
||||
compileClasspath.extendsFrom relocatedApi
|
||||
runtimeClasspath.extendsFrom relocatedApi
|
||||
testCompileClasspath.extendsFrom relocatedApi
|
||||
testRuntimeClasspath.extendsFrom relocatedApi
|
||||
oldTestCompileClasspath.extendsFrom relocatedApi
|
||||
oldTestRuntimeClasspath.extendsFrom relocatedApi
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
|
||||
// Economy
|
||||
implementation('com.github.MilkBowl:VaultAPI:1.7.1') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
|
||||
// PlaceholderAPI
|
||||
implementation 'me.clip:placeholderapi:2.11.3'
|
||||
|
||||
// Command Framework
|
||||
relocatedApi 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
|
||||
|
||||
// Config
|
||||
relocatedApi('me.main__.util:SerializationConfig:1.7') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
relocatedApi('io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.1') {
|
||||
exclude group: 'org.spigotmc', module: 'spigot-api'
|
||||
}
|
||||
|
||||
// Utils
|
||||
relocatedApi 'io.vavr:vavr:0.10.4'
|
||||
relocatedApi 'org.glassfish.hk2:hk2-locator:3.0.3'
|
||||
relocatedApi('com.dumptruckman.minecraft:Logging:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
relocatedApi 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
|
||||
relocatedApi 'org.bstats:bstats-bukkit:2.2.1'
|
||||
relocatedApi 'net.minidev:json-smart:2.4.8'
|
||||
relocatedApi 'org.jetbrains:annotations:22.0.0'
|
||||
relocatedApi 'io.papermc:paperlib:1.0.8'
|
||||
|
||||
// Tests
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10'
|
||||
testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.141.0'
|
||||
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test'
|
||||
testImplementation 'com.natpryce:hamkrest:1.8.0.1'
|
||||
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0'
|
||||
|
||||
// Old Tests
|
||||
oldTestImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
|
||||
oldTestImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
oldTestImplementation 'junit:junit:4.13.1'
|
||||
oldTestImplementation 'org.mockito:mockito-core:3.11.2'
|
||||
oldTestImplementation 'commons-io:commons-io:2.7'
|
||||
|
||||
// Annotation Processors
|
||||
annotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
|
||||
testAnnotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
|
||||
}
|
||||
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
|
||||
configurations {
|
||||
[apiElements, runtimeElements].each {
|
||||
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
|
||||
it.outgoing.artifact(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
oldTest {
|
||||
java {
|
||||
compileClasspath += main.output
|
||||
runtimeClasspath += main.output
|
||||
srcDir file('src/old-test/java')
|
||||
}
|
||||
resources.srcDir file('src/old-test/resources')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Core"
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ext.bitlyAccessToken = System.getenv('BITLY_ACCESS_TOKEN') ?: 'bitly-access-token'
|
||||
|
||||
task prepareSource(type: Sync) {
|
||||
inputs.property 'bitlyAccessToken', bitlyAccessToken
|
||||
from sourceSets.main.java
|
||||
into "$buildDir/src"
|
||||
filter(ReplaceTokens, tokens: [
|
||||
'bitly-access-token': bitlyAccessToken,
|
||||
])
|
||||
}
|
||||
|
||||
compileJava {
|
||||
source = prepareSource.outputs
|
||||
}
|
||||
tasks.withType(JavaCompile) {
|
||||
configure(options) {
|
||||
options.compilerArgs << '-Aorg.glassfish.hk2.metadata.location=META-INF/hk2-locator/Multiverse-Core'
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
// We're not using Kotlin in the plugin itself, just tests!
|
||||
enabled = false
|
||||
}
|
||||
configurations.findAll { !it.name.startsWith('test') }.each {
|
||||
it.exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
|
||||
}
|
||||
|
||||
processResources {
|
||||
def props = [version: "${project.version}"]
|
||||
inputs.properties props
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
|
||||
// This task should never be skipped. The tests depend on this having been run but we want the new version number
|
||||
// that is created after tests are run and before we run again to publish.
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
|
||||
checkstyle {
|
||||
toolVersion = '6.1.1'
|
||||
configFile file('config/mv_checks.xml')
|
||||
ignoreFailures = true
|
||||
}
|
||||
|
||||
|
||||
javadoc {
|
||||
source = sourceSets.main.allJava
|
||||
classpath = configurations.compileClasspath
|
||||
}
|
||||
|
||||
|
||||
project.configurations.api.canBeResolved = true
|
||||
|
||||
shadowJar {
|
||||
relocate 'co.aikar.commands', 'com.onarandombox.acf'
|
||||
relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.MultiverseCore.utils.CoreLogging'
|
||||
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.MultiverseCore.utils.DebugFileLogger'
|
||||
relocate 'de.themoep.idconverter', 'com.onarandombox.idconverter'
|
||||
relocate 'io.github.townyadvanced.commentedconfiguration', 'com.onarandombox.commentedconfiguration'
|
||||
relocate 'me.main__.util', 'com.onarandombox.serializationconfig'
|
||||
relocate 'org.bstats', 'com.onarandombox.bstats'
|
||||
relocate 'com.sun', 'com.onarandombox.sun'
|
||||
relocate 'net.minidev', 'com.onarandombox.minidev'
|
||||
relocate 'org.objectweb', 'com.onarandombox.objectweb'
|
||||
relocate 'io.vavr', 'com.onarandombox.vavr'
|
||||
relocate 'jakarta', 'com.onarandombox.jakarta'
|
||||
relocate 'javassist', 'com.onarandombox.javassist'
|
||||
relocate 'org.aopalliance', 'com.onarandombox.aopalliance'
|
||||
relocate 'org.glassfish', 'com.onarandombox.glassfish'
|
||||
relocate 'org.jvnet', 'com.onarandombox.jvnet'
|
||||
relocate 'org.intellij', 'com.onarandombox.intellij'
|
||||
relocate 'org.jetbrains', 'com.onarandombox.jetbrains'
|
||||
relocate 'io.papermc.lib', 'com.onarandombox.paperlib'
|
||||
|
||||
configurations = [project.configurations.api, project.configurations.relocatedApi]
|
||||
|
||||
archiveFileName = "$baseName-$version.$extension"
|
||||
|
||||
dependencies {
|
||||
exclude(dependency {
|
||||
it.moduleGroup == 'org.jetbrains.kotlin'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar
|
||||
jar.enabled = false
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
|
||||
testLogging {
|
||||
exceptionFormat = 'full'
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 23 KiB |
@@ -1,141 +0,0 @@
|
||||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Multiverse 2 Copyright (c) the Multiverse Team 2011. ~
|
||||
~ Multiverse 2 is licensed under the BSD License. ~
|
||||
~ For more information please check the README.md file included ~
|
||||
~ with this project. ~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<!-- Future reference: valid severity values are 'ignore', 'info', 'warning', 'error' -->
|
||||
<module name="Checker">
|
||||
<module name="JavadocPackage">
|
||||
<property name="allowLegacy" value="true"/>
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile" />
|
||||
<module name="Translation"/>
|
||||
<module name="FileLength"/>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
<property name="format" value="\s+$"/>
|
||||
</module>
|
||||
<module name="SuppressWithNearbyCommentFilter">
|
||||
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
</module>
|
||||
<module name="TreeWalker">
|
||||
<!-- Make suppression possible -->
|
||||
<module name="FileContentsHolder"/>
|
||||
<!-- Actual checks -->
|
||||
<module name="LineLength">
|
||||
<property name="max" value="160"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="scope" value="package"/><!-- We don't need javadoc for private methods -->
|
||||
<property name="tokens" value="METHOD_DEF"/><!-- We don't need javadoc for constructors -->
|
||||
</module>
|
||||
<module name="JavadocType"/>
|
||||
<module name="JavadocVariable">
|
||||
<property name="scope" value="package"/><!-- We don't need javadoc for private variables -->
|
||||
</module>
|
||||
<module name="JavadocStyle"/>
|
||||
<module name="WriteTag">
|
||||
<property name="tag" value="@author"/>
|
||||
<property name="tagFormat" value="\S"/>
|
||||
<property name="severity" value="ignore"/>
|
||||
<property name="tagSeverity" value="warning"/>
|
||||
</module>
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
<module name="AvoidStarImport">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="excludes" value="com.onarandombox.MultiverseCore.utils,com.onarandombox.MultiverseCore.configuration,com.onarandombox.MultiverseCore.commandsold,com.onarandombox.MultiverseCore.destination"/>
|
||||
</module>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="MethodLength">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="countEmpty" value="false"/>
|
||||
</module>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter">
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_FOR,LITERAL_TRY,LITERAL_WHILE,INSTANCE_INIT,STATIC_INIT"/>
|
||||
</module>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="HiddenField">
|
||||
<property name="tokens" value="VARIABLE_DEF"/><!-- We don't care if parameters hide fields. -->
|
||||
</module>
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MagicNumber">
|
||||
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
|
||||
</module>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<!-- Don't like errors for `final` missing
|
||||
<module name="DesignForExtension"/>
|
||||
<module name="FinalClass"/>
|
||||
-->
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="VisibilityModifier">
|
||||
<property name="protectedAllowed" value="true"/>
|
||||
</module>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<!-- Don't like errors for `final` missing
|
||||
<module name="FinalParameters"/>
|
||||
-->
|
||||
<module name="TodoComment">
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="UpperEll"/>
|
||||
<module name="Indentation"/>
|
||||
<module name="MissingDeprecated"/>
|
||||
<module name="MissingOverride"/>
|
||||
</module>
|
||||
</module>
|
||||
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,244 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<title>Multiverse-Core by Multiverse</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container">
|
||||
<div class="inner">
|
||||
|
||||
<header>
|
||||
<h1>Multiverse-core</h1>
|
||||
<h2>The original Bukkit Multi-World Plugin! </h2>
|
||||
</header>
|
||||
|
||||
<section id="downloads" class="clearfix">
|
||||
<a href="https://github.com/Multiverse/Multiverse-Core/zipball/master" id="download-zip" class="button"><span>Download .zip</span></a>
|
||||
<a href="https://github.com/Multiverse/Multiverse-Core/tarball/master" id="download-tar-gz" class="button"><span>Download .tar.gz</span></a>
|
||||
<a href="https://github.com/Multiverse/Multiverse-Core" id="view-on-github" class="button"><span>View on GitHub</span></a>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
|
||||
<section id="main_content">
|
||||
<h3>Welcome to GitHub Pages.</h3>
|
||||
|
||||
<p>This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:</p>
|
||||
|
||||
<pre><code>$ cd your_repo_root/repo_name
|
||||
$ git fetch origin
|
||||
$ git checkout gh-pages
|
||||
</code></pre>
|
||||
|
||||
<p>If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.</p>
|
||||
|
||||
<h3>Designer Templates</h3>
|
||||
|
||||
<p>We've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.</p>
|
||||
|
||||
<h3>Rather Drive Stick?</h3>
|
||||
|
||||
<p>If you prefer to not use the automatic generator, push a branch named <code>gh-pages</code> to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.</p>
|
||||
|
||||
<h3>Authors and Contributors</h3>
|
||||
|
||||
<p>You can <a href="https://github.com/blog/821" class="user-mention">@mention</a> a GitHub username to generate a link to their profile. The resulting <code><a></code> element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (<a href="https://github.com/defunkt" class="user-mention">@defunkt</a>), PJ Hyett (<a href="https://github.com/pjhyett" class="user-mention">@pjhyett</a>), and Tom Preston-Werner (<a href="https://github.com/mojombo" class="user-mention">@mojombo</a>) founded GitHub.</p>
|
||||
|
||||
<h3>Support or Contact</h3>
|
||||
|
||||
<p>Having trouble with Pages? Check out the documentation at <a href="http://help.github.com/pages">http://help.github.com/pages</a> or contact <a href="mailto:support@github.com">support@github.com</a> and we’ll help you sort it out.</p>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
Multiverse-core is maintained by <a href="https://github.com/Multiverse">Multiverse</a><br>
|
||||
This page was generated by <a href="http://pages.github.com">GitHub Pages</a>. Tactile theme by <a href="http://twitter.com/jasonlong">Jason Long</a>.
|
||||
</footer>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
console.log('This would be the main JS file.');
|
||||
@@ -0,0 +1 @@
|
||||
{"tagline":"The original Bukkit Multi-World Plugin! ","body":"### Welcome to GitHub Pages.\r\nThis automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:\r\n\r\n```\r\n$ cd your_repo_root/repo_name\r\n$ git fetch origin\r\n$ git checkout gh-pages\r\n```\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Designer Templates\r\nWe've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.\r\n\r\n### Rather Drive Stick?\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `<a>` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.","note":"Don't delete this file! It's used internally to help with page regeneration.","google":"","name":"Multiverse-core"}
|
||||
@@ -1,5 +0,0 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
|
||||
rootProject.name = 'multiverse-core'
|
||||
@@ -1,13 +0,0 @@
|
||||
package co.aikar.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Exists just so we can extend BukkitCommandIssuer since it has a package-private constructor.
|
||||
*/
|
||||
public abstract class OpenBukkitCommandIssuer extends BukkitCommandIssuer {
|
||||
|
||||
protected OpenBukkitCommandIssuer(BukkitCommandManager manager, CommandSender sender) {
|
||||
super(manager, sender);
|
||||
}
|
||||
}
|
||||
@@ -1,426 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.anchor.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.api.Destination;
|
||||
import com.onarandombox.MultiverseCore.api.MVCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.PluginLocales;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.economy.MVEconomist;
|
||||
import com.onarandombox.MultiverseCore.inject.InjectableListener;
|
||||
import com.onarandombox.MultiverseCore.inject.PluginInjection;
|
||||
import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders;
|
||||
import com.onarandombox.MultiverseCore.utils.TestingMode;
|
||||
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
import com.onarandombox.MultiverseCore.world.WorldProperties;
|
||||
import io.vavr.control.Try;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Provider;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
import org.glassfish.hk2.api.MultiException;
|
||||
import org.glassfish.hk2.api.ServiceHandle;
|
||||
import org.glassfish.hk2.api.ServiceLocator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* The implementation of the Multiverse-{@link MVCore}.
|
||||
*/
|
||||
@Service
|
||||
public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
private static final int PROTOCOL = 50;
|
||||
|
||||
private ServiceLocator serviceLocator;
|
||||
@Inject
|
||||
private MVCoreConfig config;
|
||||
@Inject
|
||||
private Provider<MVWorldManager> worldManagerProvider;
|
||||
@Inject
|
||||
private Provider<AnchorManager> anchorManagerProvider;
|
||||
@Inject
|
||||
private Provider<MVCommandManager> commandManagerProvider;
|
||||
@Inject
|
||||
private Provider<DestinationsProvider> destinationsProviderProvider;
|
||||
@Inject
|
||||
private Provider<MetricsConfigurator> metricsConfiguratorProvider;
|
||||
@Inject
|
||||
private Provider<MVEconomist> economistProvider;
|
||||
@Inject
|
||||
private Provider<PluginLocales> pluginLocalesProvider;
|
||||
|
||||
// Counter for the number of plugins that have registered with us
|
||||
private int pluginCount;
|
||||
|
||||
/**
|
||||
* This is the constructor for the MultiverseCore.
|
||||
*/
|
||||
public MultiverseCore() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Create our DataFolder
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
// Setup our Logging
|
||||
Logging.init(this);
|
||||
|
||||
// Register our config classes
|
||||
SerializationConfig.registerAll(WorldProperties.class);
|
||||
SerializationConfig.initLogging(Logging.getLogger());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
initializeDependencyInjection();
|
||||
|
||||
// Load our configs first as we need them for everything else.
|
||||
if (config == null || !config.isLoaded()) {
|
||||
Logging.severe("Your configs were not loaded.");
|
||||
Logging.severe("Please check your configs and restart the server.");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.setShowingConfig(shouldShowConfig());
|
||||
|
||||
var worldManager = worldManagerProvider.get();
|
||||
|
||||
worldManager.loadWorldsConfig();
|
||||
worldManager.getDefaultWorldGenerators();
|
||||
worldManager.loadDefaultWorlds();
|
||||
worldManager.loadWorlds(true);
|
||||
|
||||
// Now set the firstspawnworld (after the worlds are loaded):
|
||||
worldManager.setFirstSpawnWorld(config.getFirstSpawnLocation());
|
||||
MVWorld firstSpawnWorld = worldManager.getFirstSpawnWorld();
|
||||
if (firstSpawnWorld != null) {
|
||||
config.setFirstSpawnLocation(firstSpawnWorld.getName());
|
||||
}
|
||||
|
||||
//Setup economy here so vault is loaded
|
||||
this.loadEconomist();
|
||||
|
||||
// Init all the other stuff
|
||||
this.loadAnchors();
|
||||
this.registerEvents();
|
||||
this.setUpLocales();
|
||||
this.registerCommands();
|
||||
this.registerDestinations();
|
||||
this.setupMetrics();
|
||||
this.loadPlaceholderAPIIntegration();
|
||||
this.saveAllConfigs();
|
||||
this.logEnableMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.saveAllConfigs();
|
||||
shutdownDependencyInjection();
|
||||
Logging.shutdown();
|
||||
}
|
||||
|
||||
private void initializeDependencyInjection() {
|
||||
serviceLocator = PluginInjection.createServiceLocator(new MultiverseCorePluginBinder(this))
|
||||
.andThenTry(locator -> {
|
||||
PluginInjection.enable(this, locator);
|
||||
})
|
||||
.getOrElseThrow(exception -> {
|
||||
Logging.severe("Failed to initialize dependency injection");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return new RuntimeException(exception);
|
||||
});
|
||||
}
|
||||
|
||||
private void shutdownDependencyInjection() {
|
||||
if (serviceLocator != null) {
|
||||
PluginInjection.disable(this, serviceLocator);
|
||||
serviceLocator = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldShowConfig() {
|
||||
return !config.getSilentStart();
|
||||
}
|
||||
|
||||
private void loadEconomist() {
|
||||
Try.run(() -> economistProvider.get())
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to load economy integration");
|
||||
e.printStackTrace();
|
||||
});
|
||||
}
|
||||
|
||||
private void loadAnchors() {
|
||||
Try.of(() -> anchorManagerProvider.get())
|
||||
.onSuccess(AnchorManager::loadAnchors)
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to load anchors");
|
||||
e.printStackTrace();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to Register all the Events needed.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
var pluginManager = getServer().getPluginManager();
|
||||
|
||||
Try.run(() -> serviceLocator.getAllServices(InjectableListener.class)
|
||||
.forEach(listener -> pluginManager.registerEvents(listener, this)))
|
||||
.onFailure(e -> {
|
||||
throw new RuntimeException("Failed to register listeners. Terminating...", e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Multiverse-Core commands to Command Manager.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
Try.of(() -> commandManagerProvider.get())
|
||||
.andThenTry(commandManager -> {
|
||||
serviceLocator.getAllServices(MultiverseCommand.class)
|
||||
.forEach(commandManager::registerCommand);
|
||||
})
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to register commands");
|
||||
e.printStackTrace();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register locales
|
||||
*/
|
||||
private void setUpLocales() {
|
||||
Try.of(() -> commandManagerProvider.get())
|
||||
.andThen(commandManager -> {
|
||||
commandManager.usePerIssuerLocale(true, true);
|
||||
})
|
||||
.mapTry(commandManager -> pluginLocalesProvider.get())
|
||||
.andThen(pluginLocales -> {
|
||||
pluginLocales.addFileResClassLoader(this);
|
||||
pluginLocales.addMessageBundles("multiverse-core");
|
||||
})
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to register locales");
|
||||
e.printStackTrace();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all the destinations.
|
||||
*/
|
||||
private void registerDestinations() {
|
||||
Try.of(() -> destinationsProviderProvider.get())
|
||||
.andThenTry(destinationsProvider -> {
|
||||
serviceLocator.getAllServices(Destination.class)
|
||||
.forEach(destinationsProvider::registerDestination);
|
||||
})
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to register destinations");
|
||||
e.printStackTrace();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup bstats Metrics.
|
||||
*/
|
||||
private void setupMetrics() {
|
||||
if (TestingMode.isDisabled()) {
|
||||
// Load metrics
|
||||
Try.of(() -> metricsConfiguratorProvider.get())
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to setup metrics");
|
||||
e.printStackTrace();
|
||||
});
|
||||
} else {
|
||||
Logging.info("Metrics are disabled in testing mode.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the enable message.
|
||||
*/
|
||||
private void logEnableMessage() {
|
||||
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
|
||||
|
||||
if (config.isShowingDonateMessage()) {
|
||||
Logging.config("Help dumptruckman keep this project alive. Become a patron! https://www.patreon.com/dumptruckman");
|
||||
Logging.config("One time donations are also appreciated: https://www.paypal.me/dumptruckman");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPlaceholderAPIIntegration() {
|
||||
if (config.isRegisterPapiHook()
|
||||
&& getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
Try.run(() -> serviceLocator.createAndInitialize(MultiverseCorePlaceholders.class))
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to load PlaceholderAPI integration.");
|
||||
e.printStackTrace();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MVCore getCore() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return PROTOCOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getAuthors() {
|
||||
List<String> authorsList = this.getDescription().getAuthors();
|
||||
if (authorsList.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder authors = new StringBuilder();
|
||||
authors.append(authorsList.get(0));
|
||||
|
||||
for (int i = 1; i < authorsList.size(); i++) {
|
||||
if (i == authorsList.size() - 1) {
|
||||
authors.append(" and ").append(authorsList.get(i));
|
||||
} else {
|
||||
authors.append(", ").append(authorsList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return authors.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getPluginCount() {
|
||||
return this.pluginCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return Logging.getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void incrementPluginCount() {
|
||||
this.pluginCount += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void decrementPluginCount() {
|
||||
this.pluginCount -= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAllConfigs() {
|
||||
return config.save()
|
||||
&& worldManagerProvider.get().saveWorldsConfig()
|
||||
&& anchorManagerProvider.get().saveAnchors();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the best service from this plugin that implements the given contract or has the given implementation.
|
||||
*
|
||||
* @param contractOrImpl The contract or concrete implementation to get the best instance of
|
||||
* @param qualifiers The set of qualifiers that must match this service definition
|
||||
* @return An instance of the contract or impl if it is a service and is already instantiated, null otherwise
|
||||
* @throws MultiException if there was an error during service lookup
|
||||
*/
|
||||
@Nullable
|
||||
public <T> T getService(@NotNull Class<T> contractOrImpl, Annotation... qualifiers) throws MultiException {
|
||||
var handle = serviceLocator.getServiceHandle(contractOrImpl, qualifiers);
|
||||
if (handle != null && handle.isActive()) {
|
||||
return handle.getService();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all services from this plugin that implement the given contract or have the given implementation and have
|
||||
* the provided qualifiers.
|
||||
*
|
||||
* @param contractOrImpl The contract or concrete implementation to get the best instance of
|
||||
* @param qualifiers The set of qualifiers that must match this service definition
|
||||
* @return A list of services implementing this contract or concrete implementation. May not return null, but may
|
||||
* return an empty list
|
||||
* @throws MultiException if there was an error during service lookup
|
||||
*/
|
||||
@NotNull
|
||||
public <T> List<T> getAllServices(
|
||||
@NotNull Class<T> contractOrImpl,
|
||||
Annotation... qualifiers
|
||||
) throws MultiException {
|
||||
var handles = serviceLocator.getAllServiceHandles(contractOrImpl, qualifiers);
|
||||
return handles.stream()
|
||||
.filter(ServiceHandle::isActive)
|
||||
.map(ServiceHandle::getService)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for unit testing ONLY. Do not use this constructor.
|
||||
*
|
||||
* @param loader The PluginLoader to use.
|
||||
* @param description The Description file to use.
|
||||
* @param dataFolder The folder that other datafiles can be found in.
|
||||
* @param file The location of the plugin.
|
||||
*/
|
||||
public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
|
||||
super(loader, description, dataFolder, file);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVCore;
|
||||
import com.onarandombox.MultiverseCore.inject.binder.JavaPluginBinder;
|
||||
import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class MultiverseCorePluginBinder extends JavaPluginBinder<MultiverseCore> {
|
||||
|
||||
protected MultiverseCorePluginBinder(@NotNull MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScopedBindingBuilder<MultiverseCore> bindPluginClass(ScopedBindingBuilder<MultiverseCore> bindingBuilder) {
|
||||
return super.bindPluginClass(bindingBuilder).to(MVCore.class).to(MultiverseCore.class);
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.anchor;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Manages anchors.
|
||||
*/
|
||||
@Service
|
||||
public class AnchorManager {
|
||||
private Map<String, Location> anchors;
|
||||
private FileConfiguration anchorConfig;
|
||||
|
||||
private final Plugin plugin;
|
||||
private final LocationManipulation locationManipulation;
|
||||
private final MVCoreConfig config;
|
||||
|
||||
@Inject
|
||||
public AnchorManager(
|
||||
MultiverseCore plugin,
|
||||
LocationManipulation locationManipulation,
|
||||
MVCoreConfig config
|
||||
) {
|
||||
this.plugin = plugin;
|
||||
this.locationManipulation = locationManipulation;
|
||||
this.config = config;
|
||||
|
||||
this.anchors = new HashMap<String, Location>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all anchors.
|
||||
*/
|
||||
public void loadAnchors() {
|
||||
this.anchors = new HashMap<String, Location>();
|
||||
this.anchorConfig = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "anchors.yml"));
|
||||
this.ensureConfigIsPrepared();
|
||||
ConfigurationSection anchorsSection = this.anchorConfig.getConfigurationSection("anchors");
|
||||
Set<String> anchorKeys = anchorsSection.getKeys(false);
|
||||
for (String key : anchorKeys) {
|
||||
//world:x,y,z:pitch:yaw
|
||||
Location anchorLocation = this.locationManipulation.stringToLocation(anchorsSection.getString(key, ""));
|
||||
if (anchorLocation != null) {
|
||||
Logging.config("Loading anchor: '%s'...", key);
|
||||
this.anchors.put(key, anchorLocation);
|
||||
} else {
|
||||
Logging.warning("The location for anchor '%s' is INVALID.", key);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureConfigIsPrepared() {
|
||||
if (this.anchorConfig.getConfigurationSection("anchors") == null) {
|
||||
this.anchorConfig.createSection("anchors");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all anchors.
|
||||
* @return True if all anchors were successfully saved.
|
||||
*/
|
||||
public boolean saveAnchors() {
|
||||
try {
|
||||
this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Failed to save anchors.yml. Please check your file permissions.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Location} associated with an anchor.
|
||||
* @param anchor The name of the anchor.
|
||||
* @return The {@link Location}.
|
||||
*/
|
||||
public Location getAnchorLocation(String anchor) {
|
||||
if (this.anchors.containsKey(anchor)) {
|
||||
return this.anchors.get(anchor);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an anchor.
|
||||
* @param anchor The name of the anchor.
|
||||
* @param location The location of the anchor as string.
|
||||
* @return True if the anchor was successfully saved.
|
||||
*/
|
||||
public boolean saveAnchorLocation(String anchor, String location) {
|
||||
Location parsed = this.locationManipulation.stringToLocation(location);
|
||||
return parsed != null && this.saveAnchorLocation(anchor, parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an anchor.
|
||||
* @param anchor The name of the anchor.
|
||||
* @param l The {@link Location} of the anchor.
|
||||
* @return True if the anchor was successfully saved.
|
||||
*/
|
||||
public boolean saveAnchorLocation(String anchor, Location l) {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
this.anchorConfig.set("anchors." + anchor, this.locationManipulation.locationToString(l));
|
||||
this.anchors.put(anchor, l);
|
||||
return this.saveAnchors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all anchors.
|
||||
* @return An unmodifiable {@link Set} containing all anchors.
|
||||
*/
|
||||
public Set<String> getAllAnchors() {
|
||||
return Collections.unmodifiableSet(this.anchors.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all anchors that the specified {@link Player} can access.
|
||||
* @param p The {@link Player}.
|
||||
* @return An unmodifiable {@link Set} containing all anchors the specified {@link Player} can access.
|
||||
*/
|
||||
public Set<String> getAnchors(Player p) {
|
||||
if (p == null) {
|
||||
return this.anchors.keySet();
|
||||
}
|
||||
Set<String> myAnchors = new HashSet<String>();
|
||||
for (String anchor : this.anchors.keySet()) {
|
||||
Location ancLoc = this.anchors.get(anchor);
|
||||
if (ancLoc == null) {
|
||||
continue;
|
||||
}
|
||||
String worldPerm = "multiverse.access." + ancLoc.getWorld().getName();
|
||||
// Add to the list if we're not enforcing access
|
||||
// OR
|
||||
// We are enforcing access and the user has the permission.
|
||||
if (!config.getEnforceAccess() ||
|
||||
(config.getEnforceAccess() && p.hasPermission(worldPerm))) {
|
||||
myAnchors.add(anchor);
|
||||
} else {
|
||||
Logging.finer(String.format("Not adding anchor %s to the list, user %s doesn't have the %s " +
|
||||
"permission and 'enforceaccess' is enabled!",
|
||||
anchor, p.getName(), worldPerm));
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableSet(myAnchors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified anchor.
|
||||
* @param s The name of the anchor.
|
||||
* @return True if the anchor was successfully deleted.
|
||||
*/
|
||||
public boolean deleteAnchor(String s) {
|
||||
if (this.anchors.containsKey(s)) {
|
||||
this.anchors.remove(s);
|
||||
this.anchorConfig.set("anchors." + s, null);
|
||||
return this.saveAnchors();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* this package contains the classes that are used for the anchor system.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.anchor;
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to get block/location-related information.
|
||||
*/
|
||||
@Contract
|
||||
public interface BlockSafety {
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
* @param l The {@link Location} of the block.
|
||||
* @return True if the block at that {@link Location} is above air.
|
||||
*/
|
||||
boolean isBlockAboveAir(Location l);
|
||||
|
||||
/**
|
||||
* Checks if a player can spawn safely at the given coordinates.
|
||||
* @param world The {@link World}.
|
||||
* @param x The x-coordinate.
|
||||
* @param y The y-coordinate.
|
||||
* @param z The z-coordinate.
|
||||
* @return True if a player can spawn safely at the given coordinates.
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(World world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
* This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air
|
||||
* etc. This also ensures there is enough space for a player to spawn!
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return Whether the player can spawn safely at the given {@link Location}
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(Location l);
|
||||
|
||||
/**
|
||||
* Gets a safe bed spawn location OR null if the bed is invalid.
|
||||
* @param l The location of the bead head (block with the pillow on it).
|
||||
* @return Safe location around the bed or null if no location was found.
|
||||
*/
|
||||
Location getSafeBedSpawn(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
* @return The {@link Location} of the top-block.
|
||||
*/
|
||||
Location getTopBlock(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
* @return The {@link Location} of the top-block.
|
||||
*/
|
||||
Location getBottomBlock(Location l);
|
||||
|
||||
/**
|
||||
* Checks if an entity would be on track at the specified {@link Location}.
|
||||
* @param l The {@link Location}.
|
||||
* @return True if an entity would be on tracks at the specified {@link Location}.
|
||||
*/
|
||||
boolean isEntitiyOnTrack(Location l);
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Minecart} can spawn safely.
|
||||
* @param cart The {@link Minecart}.
|
||||
* @return True if the minecart can spawn safely.
|
||||
*/
|
||||
boolean canSpawnCartSafely(Minecart cart);
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Vehicle} can spawn safely.
|
||||
* @param vehicle The {@link Vehicle}.
|
||||
* @return True if the vehicle can spawn safely.
|
||||
*/
|
||||
boolean canSpawnVehicleSafely(Vehicle vehicle);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public interface Destination<T extends DestinationInstance> {
|
||||
/**
|
||||
* Returns the identifier or prefix that is required for this destination.
|
||||
*
|
||||
* <p>Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
||||
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
||||
* Please check the wiki when adding a custom destination!</p>
|
||||
*
|
||||
* @return The identifier or prefix that is required for this destination.
|
||||
*/
|
||||
@NotNull String getIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the destination instance for the given destination parameters.
|
||||
*
|
||||
* @param destinationParams The destination parameters. ex: p:MyPortal:nw
|
||||
* @return The destination instance, or null if the destination parameters are invalid.
|
||||
*/
|
||||
@Nullable T getDestinationInstance(@Nullable String destinationParams);
|
||||
|
||||
/**
|
||||
* Returns a list of possible destinations for the given destination parameters.
|
||||
*
|
||||
* @param issuer The command issuer.
|
||||
* @param destinationParams The destination parameters. ex: p:MyPortal:nw
|
||||
* @return A list of possible destinations.
|
||||
*/
|
||||
@NotNull Collection<String> suggestDestinations(@NotNull BukkitCommandIssuer issuer, @Nullable String destinationParams);
|
||||
|
||||
/**
|
||||
* Should the Multiverse SafeTeleporter be used?
|
||||
*
|
||||
* <p>If not, MV will blindly take people to the location specified.</p>
|
||||
*
|
||||
* @return True if the SafeTeleporter will be used, false if not.
|
||||
*/
|
||||
boolean checkTeleportSafety();
|
||||
|
||||
/**
|
||||
* Returns the teleporter to use for this destination.
|
||||
*
|
||||
* <p>By default, Multiverse will automatically use SafeTeleporter. If you want to use a different teleporter, you can
|
||||
* override this method.</p>
|
||||
*
|
||||
* @return The custom teleporter to use for this destination. Return null to use the default teleporter.
|
||||
*/
|
||||
@Nullable Teleporter getTeleporter();
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface DestinationInstance {
|
||||
/**
|
||||
* Gets the exact location to teleport an entity to.
|
||||
*
|
||||
* @param teleportee The entity to teleport.
|
||||
* @return The location to teleport to.
|
||||
*/
|
||||
@Nullable Location getLocation(@NotNull Entity teleportee);
|
||||
|
||||
/**
|
||||
* Gets the velocity to apply to an entity after teleporting.
|
||||
*
|
||||
* @param teleportee The entity to teleport.
|
||||
* @return A vector representing the speed/direction the player should travel when arriving at the destination.
|
||||
*/
|
||||
@Nullable Vector getVelocity(@NotNull Entity teleportee);
|
||||
|
||||
/**
|
||||
* Gets the permission suffix to check for when teleporting to this destination.
|
||||
* This is used for finer per world/player permissions, such as "multiverse.teleport.self.worldname".
|
||||
*
|
||||
* <p>For example, if the destination is "w:world", the permission suffix is "world".</p>
|
||||
*
|
||||
* @return The permission suffix.
|
||||
*/
|
||||
@Nullable String getFinerPermissionSuffix();
|
||||
|
||||
/**
|
||||
* Serialises the destination instance to a savable string.
|
||||
*
|
||||
* <p>This is used when plugins save destinations to configuration,
|
||||
* and when the destination is displayed to the user.</p>
|
||||
*
|
||||
* @return The serialised destination instance.
|
||||
*/
|
||||
@NotNull String serialise();
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to manipulate locations.
|
||||
*/
|
||||
@Contract
|
||||
public interface LocationManipulation {
|
||||
/**
|
||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||
* <p>
|
||||
* WORLD:X,Y,Z:yaw:pitch
|
||||
* <p>
|
||||
* The corresponding String2Loc function is {@link #stringToLocation}
|
||||
*
|
||||
* @param location The Location to save.
|
||||
* @return The location as a string in this format: WORLD:x,y,z:yaw:pitch
|
||||
*/
|
||||
String locationToString(Location location);
|
||||
|
||||
/**
|
||||
* This method simply does some rounding, rather than forcing a call to the server to get the blockdata.
|
||||
*
|
||||
* @param l The location to round to the block location
|
||||
* @return A rounded location.
|
||||
*/
|
||||
Location getBlockLocation(Location l);
|
||||
|
||||
/**
|
||||
* Returns a new location from a given string. The format is as follows:
|
||||
* <p>
|
||||
* WORLD:X,Y,Z:yaw:pitch
|
||||
* <p>
|
||||
* The corresponding Location2String function is {@link #stringToLocation}
|
||||
*
|
||||
* @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch)
|
||||
* @return A new location defined by the string or null if the string was invalid.
|
||||
*/
|
||||
Location stringToLocation(String locationString);
|
||||
|
||||
/**
|
||||
* Returns a colored string with the coords.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strCoords(Location l);
|
||||
|
||||
/**
|
||||
* Converts a location to a printable readable formatted string including pitch/yaw.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strCoordsRaw(Location l);
|
||||
|
||||
/**
|
||||
* Return the NESW Direction a Location is facing.
|
||||
*
|
||||
* @param location The {@link Location}
|
||||
* @return The NESW Direction
|
||||
*/
|
||||
String getDirection(Location location);
|
||||
|
||||
/**
|
||||
* Returns the float yaw position for the given cardinal direction.
|
||||
*
|
||||
* @param orientation The cardinal direction
|
||||
* @return The yaw
|
||||
*/
|
||||
float getYaw(String orientation);
|
||||
|
||||
/**
|
||||
* Returns a speed float from a given vector.
|
||||
*
|
||||
* @param v The {@link Vector}
|
||||
* @return The speed
|
||||
*/
|
||||
float getSpeed(Vector v);
|
||||
|
||||
/**
|
||||
* Returns a translated vector from the given direction.
|
||||
*
|
||||
* @param v The old {@link Vector}
|
||||
* @param direction The new direction
|
||||
* @return The translated {@link Vector}
|
||||
*/
|
||||
Vector getTranslatedVector(Vector v, String direction);
|
||||
|
||||
/**
|
||||
* Returns the next Location that a {@link Vehicle} is traveling at.
|
||||
*
|
||||
* @param v The {@link Vehicle}
|
||||
* @return The {@link Location}
|
||||
*/
|
||||
Location getNextBlock(Vehicle v);
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders;
|
||||
import io.vavr.control.Try;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public interface MVConfig {
|
||||
|
||||
/**
|
||||
* Loads the config from disk.
|
||||
* @return True if the config was loaded successfully.
|
||||
*/
|
||||
boolean load();
|
||||
|
||||
/**
|
||||
* Whether the config has been loaded.
|
||||
* @return True if the config has been loaded.
|
||||
*/
|
||||
boolean isLoaded();
|
||||
|
||||
/**
|
||||
* Saves the config to disk.
|
||||
*/
|
||||
boolean save();
|
||||
|
||||
/**
|
||||
* Gets the nodes for the config.
|
||||
*
|
||||
* @return The nodes for the config.
|
||||
*/
|
||||
NodeGroup getNodes();
|
||||
|
||||
/**
|
||||
* Gets a property from the config.
|
||||
*
|
||||
* @param name The name of the property.
|
||||
* @return A {@link Try} with the value of the property, otherwise a {@link Try.Failure} if there is no property by
|
||||
* that name.
|
||||
*/
|
||||
Try<Object> getProperty(String name);
|
||||
|
||||
/**
|
||||
* Sets a property in the config.
|
||||
*
|
||||
* @param name The name of the property.
|
||||
* @param value The value of the property.
|
||||
* @return An empty {@link Try} if the property was set successfully, otherwise a {@link Try.Failure} with the
|
||||
* exception explaining why the property could not be set.
|
||||
*/
|
||||
Try<Void> setProperty(String name, Object value);
|
||||
|
||||
/**
|
||||
* Sets world access permissions should be enforced.
|
||||
* @param enforceAccess The new value.
|
||||
*/
|
||||
void setEnforceAccess(boolean enforceAccess);
|
||||
|
||||
/**
|
||||
* Gets enforceAccess.
|
||||
* @return enforceAccess.
|
||||
*/
|
||||
boolean getEnforceAccess();
|
||||
|
||||
/**
|
||||
* Sets whether the game mode should be enforced.
|
||||
* @param enforceGameMode The new value.
|
||||
*/
|
||||
void setEnforceGameMode(boolean enforceGameMode);
|
||||
|
||||
/**
|
||||
* Gets enforceGameMode value.
|
||||
* @return True if game mode should be enforced.
|
||||
*/
|
||||
boolean getEnforceGameMode();
|
||||
|
||||
/**
|
||||
* Sets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @param autopurge True if automatic purge should be enabled.
|
||||
*/
|
||||
void setAutoPurgeEntities(boolean autopurge);
|
||||
|
||||
/**
|
||||
* Gets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @return True if automatic purge is enabled.
|
||||
*/
|
||||
boolean isAutoPurgeEntities();
|
||||
|
||||
/**
|
||||
* Sets teleportIntercept.
|
||||
* @param teleportIntercept The new value.
|
||||
*/
|
||||
void setTeleportIntercept(boolean teleportIntercept);
|
||||
|
||||
/**
|
||||
* Gets teleportIntercept.
|
||||
* @return teleportIntercept.
|
||||
*/
|
||||
boolean getTeleportIntercept();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnOverride.
|
||||
* @param firstSpawnOverride The new value.
|
||||
*/
|
||||
void setFirstSpawnOverride(boolean firstSpawnOverride);
|
||||
|
||||
/**
|
||||
* Gets firstSpawnOverride.
|
||||
* @return firstSpawnOverride.
|
||||
*/
|
||||
boolean getFirstSpawnOverride();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnWorld.
|
||||
* @param firstSpawnWorld The new value.
|
||||
*/
|
||||
void setFirstSpawnLocation(String firstSpawnWorld);
|
||||
|
||||
/**
|
||||
* Gets firstSpawnWorld.
|
||||
* @return firstSpawnWorld.
|
||||
*/
|
||||
String getFirstSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
*
|
||||
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
|
||||
*/
|
||||
void setUseCustomPortalSearch(boolean useDefaultPortalSearch);
|
||||
|
||||
/**
|
||||
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
|
||||
*
|
||||
* @return True means Bukkit will use its own default values.
|
||||
*/
|
||||
boolean isUsingCustomPortalSearch();
|
||||
|
||||
/**
|
||||
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @param searchRadius The portal search radius.
|
||||
*/
|
||||
void setCustomPortalSearchRadius(int searchRadius);
|
||||
|
||||
/**
|
||||
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @return The portal search radius.
|
||||
*/
|
||||
int getCustomPortalSearchRadius();
|
||||
|
||||
/**
|
||||
* Sets prefixChat.
|
||||
* @param prefixChat The new value.
|
||||
*/
|
||||
void setEnablePrefixChat(boolean prefixChat);
|
||||
|
||||
/**
|
||||
* Gets prefixChat.
|
||||
* @return prefixChat.
|
||||
*/
|
||||
boolean isEnablePrefixChat();
|
||||
|
||||
/**
|
||||
* Sets prefixChatFormat.
|
||||
* @param prefixChatFormat The new value.
|
||||
*/
|
||||
void setPrefixChatFormat(String prefixChatFormat);
|
||||
|
||||
/**
|
||||
* Gets prefixChatFormat.
|
||||
* @return prefixChatFormat.
|
||||
*/
|
||||
String getPrefixChatFormat();
|
||||
|
||||
/**
|
||||
* Sets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
|
||||
* @param registerPapiHook The new value.
|
||||
*/
|
||||
void setRegisterPapiHook(boolean registerPapiHook);
|
||||
|
||||
/**
|
||||
* Gets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
|
||||
* @return registerPapiHook.
|
||||
*/
|
||||
boolean isRegisterPapiHook();
|
||||
|
||||
/**
|
||||
* Sets globalDebug.
|
||||
* @param globalDebug The new value.
|
||||
*/
|
||||
void setGlobalDebug(int globalDebug);
|
||||
|
||||
/**
|
||||
* Gets globalDebug.
|
||||
* @return globalDebug.
|
||||
*/
|
||||
int getGlobalDebug();
|
||||
|
||||
/**
|
||||
* Sets whether to suppress startup messages.
|
||||
*
|
||||
* @param silentStart true to suppress messages.
|
||||
*/
|
||||
void setSilentStart(boolean silentStart);
|
||||
|
||||
/**
|
||||
* Whether we are suppressing startup messages.
|
||||
*
|
||||
* @return true if we are suppressing startup messages.
|
||||
*/
|
||||
boolean getSilentStart();
|
||||
|
||||
/**
|
||||
* Sets whether or not the donation/patreon messages are shown.
|
||||
*
|
||||
* @param idonotwanttodonate True if donation/patreon messages should be shown.
|
||||
*/
|
||||
void setShowDonateMessage(boolean idonotwanttodonate);
|
||||
|
||||
/**
|
||||
* Gets whether or not the donation/patreon messages are shown.
|
||||
*
|
||||
* @return True if donation/patreon messages should be shown.
|
||||
*/
|
||||
boolean isShowingDonateMessage();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
/**
|
||||
* Multiverse 2 Core API
|
||||
* <p>
|
||||
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
||||
*/
|
||||
public interface MVCore extends MVPlugin {
|
||||
|
||||
/**
|
||||
* Saves all configs.
|
||||
*
|
||||
* @return Whether the config was successfully saved
|
||||
*/
|
||||
boolean saveAllConfigs();
|
||||
|
||||
/**
|
||||
* Decrements the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
void decrementPluginCount();
|
||||
|
||||
/**
|
||||
* Increments the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
void incrementPluginCount();
|
||||
|
||||
/**
|
||||
* Returns the number of plugins that have specifically hooked into core.
|
||||
*
|
||||
* @return The number if plugins that have hooked into core.
|
||||
*/
|
||||
int getPluginCount();
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* A destination API for Multiverse
|
||||
* Any plugin can add these to MV and when they are, any action that uses them (portals, MVTP, etc.) can use them!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MVDestination {
|
||||
/**
|
||||
* Returns the identifier or prefix that is required for this destination.
|
||||
* <p>
|
||||
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
||||
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
||||
* Please check the wiki when adding a custom destination!
|
||||
*
|
||||
* @return The identifier or prefix that is required for this destination.
|
||||
*/
|
||||
String getIdentifier();
|
||||
|
||||
/**
|
||||
* Allows you to determine if a Destination is valid for the type it thinks it is.
|
||||
* <p>
|
||||
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
|
||||
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
|
||||
* method
|
||||
* and does not even NEED to be called, but it's highly recommended if you're teleporting, but it's mainly for
|
||||
* Multiverse Internal use.
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*
|
||||
* @return True if the destination is valid, false if not.
|
||||
*/
|
||||
boolean isThisType(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns the location a specific entity will spawn at when being teleported to this Destination.
|
||||
* <p>
|
||||
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
||||
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
||||
* minecarts can be teleported.
|
||||
* <p>
|
||||
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
|
||||
*
|
||||
* @param entity The entity to be teleported.
|
||||
*
|
||||
* @return The location of the entity.
|
||||
*/
|
||||
Location getLocation(Entity entity);
|
||||
|
||||
/**
|
||||
* Returns the velocity vector for this destination.
|
||||
* <p>
|
||||
* Plugins wishing to fully support MVDestinations MUST implement this.
|
||||
*
|
||||
* @return A vector representing the speed/direction the player should travel when arriving
|
||||
*/
|
||||
Vector getVelocity();
|
||||
|
||||
/**
|
||||
* Sets the destination string.
|
||||
* <p>
|
||||
* This should be used when you want to tell this destination object about a change in where it should take people.
|
||||
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
|
||||
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
|
||||
* "p:HomePortal"
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*/
|
||||
void setDestination(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns true if the destination is valid and players will be taken to it.
|
||||
* <p>
|
||||
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
|
||||
* return false.
|
||||
*
|
||||
* @return True if the destination is valid; false if not.
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
/**
|
||||
* Gives you a general friendly description of the type of destination.
|
||||
* <p>
|
||||
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
|
||||
*
|
||||
* @return A friendly string description of the type of destination.
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* Gives you a specific name of the destination.
|
||||
* <p>
|
||||
* For example, the PlayerDestination sets this to The Player's Name.
|
||||
*
|
||||
* @return A friendly string stating the name of the destination.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
|
||||
* destination.
|
||||
* <p>
|
||||
* ex: e:0,0,0:50:50
|
||||
*
|
||||
* @return The savable config string.
|
||||
*/
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Returns the permissions string required to go here.
|
||||
* <p>
|
||||
* ex: multiverse.access.world
|
||||
* <p>
|
||||
* NOTE: This is NOT the permission to use the teleport command.
|
||||
*
|
||||
* @return the permissions string required to go here.
|
||||
*/
|
||||
String getRequiredPermission();
|
||||
|
||||
/**
|
||||
* Should the Multiverse SafeTeleporter be used?
|
||||
* <p>
|
||||
* If not, MV will blindly take people to the location specified.
|
||||
*
|
||||
* @return True if the SafeTeleporter will be used, false if not.
|
||||
*/
|
||||
boolean useSafeTeleporter();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
/**
|
||||
* This interface is implemented by every official Multiverse-plugin.
|
||||
*/
|
||||
public interface MVPlugin {
|
||||
/**
|
||||
* Gets the reference to MultiverseCore.
|
||||
*
|
||||
* @return A valid {@link com.onarandombox.MultiverseCore}.
|
||||
*/
|
||||
MVCore getCore();
|
||||
|
||||
/**
|
||||
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This
|
||||
* number
|
||||
* should change when something will break the code.
|
||||
*
|
||||
* @return The Integer protocol version.
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
|
||||
/**
|
||||
* Parse the Authors Array into a readable String with ',' and 'and'.
|
||||
*
|
||||
* @return The readable authors-{@link String}
|
||||
*/
|
||||
String getAuthors();
|
||||
}
|
||||
@@ -1,675 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import com.onarandombox.MultiverseCore.world.configuration.AddProperties;
|
||||
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatColor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* The API for a Multiverse Handled World.
|
||||
*/
|
||||
public interface MVWorld {
|
||||
/**
|
||||
* Returns the Bukkit world object that this world describes.
|
||||
*
|
||||
* @return A {@link World}
|
||||
*/
|
||||
World getCBWorld();
|
||||
|
||||
/**
|
||||
* Gets the name of this world. The name cannot be changed.
|
||||
* <p>
|
||||
* Note for plugin developers: Usually {@link #getAlias()}
|
||||
* is what you want to use instead of this method.
|
||||
*
|
||||
* @return The name of the world as a String.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the type of this world. As of 1.2 this will be:
|
||||
* FLAT, NORMAL or VERSION_1_1
|
||||
* <p>
|
||||
* This is <b>not</b> the generator.
|
||||
*
|
||||
* @return The Type of this world.
|
||||
*/
|
||||
WorldType getWorldType();
|
||||
|
||||
/**
|
||||
* Gets the environment of this world.
|
||||
*
|
||||
* @return A {@link org.bukkit.World.Environment}.
|
||||
*/
|
||||
World.Environment getEnvironment();
|
||||
|
||||
/**
|
||||
* Sets the environment of a world.
|
||||
* <p>
|
||||
* Note: This will ONLY take effect once the world is unloaded/reloaded.
|
||||
*
|
||||
* @param environment A {@link org.bukkit.World.Environment}.
|
||||
*/
|
||||
void setEnvironment(World.Environment environment);
|
||||
|
||||
/**
|
||||
* Gets the difficulty of this world.
|
||||
*
|
||||
* @return The difficulty of this world.
|
||||
*/
|
||||
Difficulty getDifficulty();
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns true if success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. {@code PEACEFUL}
|
||||
*
|
||||
* @param difficulty The difficulty to set the world to as a string.
|
||||
* @return True if success, false if the provided string
|
||||
* could not be translated to a difficulty.
|
||||
* @deprecated Use {@link #setDifficulty(Difficulty)} or, if you have to
|
||||
* pass a string, use {@link #setPropertyValue(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setDifficulty(String difficulty);
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns {@code true} on success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. PEACEFUL
|
||||
*
|
||||
* @param difficulty The new difficulty.
|
||||
* @return True if success, false if the operation failed... for whatever reason.
|
||||
*/
|
||||
boolean setDifficulty(Difficulty difficulty);
|
||||
|
||||
/**
|
||||
* Gets the world seed of this world.
|
||||
*
|
||||
* @return The Long version of the seed.
|
||||
*/
|
||||
long getSeed();
|
||||
|
||||
/**
|
||||
* Sets the seed of this world.
|
||||
*
|
||||
* @param seed A Long that is the seed.
|
||||
*/
|
||||
void setSeed(long seed);
|
||||
|
||||
/**
|
||||
* Gets the generator of this world.
|
||||
*
|
||||
* @return The name of the generator.
|
||||
*/
|
||||
String getGenerator();
|
||||
|
||||
/**
|
||||
* Sets the generator of this world.
|
||||
*
|
||||
* @param generator The new generator's name.
|
||||
*/
|
||||
void setGenerator(String generator);
|
||||
|
||||
/**
|
||||
* Gets the help-message for a property.
|
||||
* @param property The name of the property.
|
||||
* @return The help-message.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found.
|
||||
*/
|
||||
String getPropertyHelp(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets a property as {@link String}.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @return The string-representation of that property.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
String getPropertyValue(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Sets a property to a given value.
|
||||
*
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was set, false if not.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Adds a value to the given property. The property must be a {@link AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link AddProperties} to add a value to.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was added, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean addToVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes a value from the given property. The property must be a {@link AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link AddProperties} to remove a value
|
||||
* from.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was removed, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeFromVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes all values from the given property. The property must be a {@link AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link AddProperties} to clear.
|
||||
* @return True if it was cleared, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean clearVariable(String property);
|
||||
|
||||
/**
|
||||
* Clears a list property (sets it to []).
|
||||
*
|
||||
* @param property The property to clear.
|
||||
* @return True if success, false if fail.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean clearList(String property);
|
||||
// end of old config stuff
|
||||
|
||||
// permission stuff
|
||||
/**
|
||||
* Gets the lowercased name of the world. This method is required, since the permissables
|
||||
* lowercase all permissions when recalculating.
|
||||
* <p>
|
||||
* Note: This also means if a user has worlds named: world and WORLD, that they can both
|
||||
* exist, and both be teleported to independently, but their permissions **cannot** be
|
||||
* uniqueified at this time. See bug report #.
|
||||
*
|
||||
* @return The lowercased name of the world.
|
||||
*/
|
||||
String getPermissibleName();
|
||||
|
||||
/**
|
||||
* Gets the permission required to enter this world.
|
||||
*
|
||||
* @return The permission required to be exempt from charges to/from this world.
|
||||
*/
|
||||
Permission getAccessPermission();
|
||||
|
||||
/**
|
||||
* Gets the permission required to be exempt when entering.
|
||||
*
|
||||
* @return The permission required to be exempt when entering.
|
||||
*/
|
||||
Permission getExemptPermission();
|
||||
// end of permission stuff
|
||||
|
||||
/**
|
||||
* Gets the alias of this world.
|
||||
* <p>
|
||||
* This alias allows users to have a world named "world" but show up in the list as "FernIsland"
|
||||
*
|
||||
* @return The alias of the world as a String.
|
||||
*/
|
||||
String getAlias();
|
||||
|
||||
/**
|
||||
* Sets the alias of the world.
|
||||
*
|
||||
* @param alias A string that is the new alias.
|
||||
*/
|
||||
void setAlias(String alias);
|
||||
|
||||
/**
|
||||
* Gets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @return The color of this world.
|
||||
*/
|
||||
ChatColor getColor();
|
||||
|
||||
/**
|
||||
* Sets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @param color A valid color name.
|
||||
* @return True if the color was set, false if not.
|
||||
*/
|
||||
boolean setColor(String color);
|
||||
|
||||
/**
|
||||
* Gets the style that this world's name/alias will display as.
|
||||
*
|
||||
* @return The style of this world. {@code null} for "normal" style.
|
||||
*/
|
||||
ChatColor getStyle();
|
||||
|
||||
/**
|
||||
* Sets the style that this world's name/alias will display as.
|
||||
*
|
||||
* @param style A valid style name.
|
||||
* @return True if the style was set, false if not.
|
||||
*/
|
||||
boolean setStyle(String style);
|
||||
|
||||
/**
|
||||
* Tells you if someone entered a valid color.
|
||||
*
|
||||
* @param color A string that may translate to a color.
|
||||
* @return True if it is a color, false if not.
|
||||
*
|
||||
* @deprecated This has been moved: {@link EnglishChatColor#isValidAliasColor(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isValidAliasColor(String color);
|
||||
|
||||
/**
|
||||
* Returns a very nicely colored string (using Alias and Color if they are set).
|
||||
*
|
||||
* @return A nicely colored string.
|
||||
*/
|
||||
String getColoredWorldString();
|
||||
|
||||
// animals&monster stuff
|
||||
/**
|
||||
* Gets whether or not animals are allowed to spawn in this world.
|
||||
*
|
||||
* @return True if ANY animal can, false if no animals can spawn.
|
||||
*/
|
||||
boolean canAnimalsSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not animals can spawn.
|
||||
* If there are values in {@link #getAnimalList()} and this is false,
|
||||
* those animals become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
|
||||
*
|
||||
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
|
||||
*/
|
||||
List<String> getAnimalList();
|
||||
|
||||
/**
|
||||
* Gets whether or not monsters are allowed to spawn in this world.
|
||||
*
|
||||
* @return True if ANY monster can, false if no monsters can spawn.
|
||||
*/
|
||||
boolean canMonstersSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not monsters can spawn.
|
||||
* If there are values in {@link #getMonsterList()} and this is false,
|
||||
* those monsters become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
|
||||
*
|
||||
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
|
||||
*/
|
||||
List<String> getMonsterList();
|
||||
// end of animal&monster stuff
|
||||
|
||||
/**
|
||||
* Gets whether or not PVP is enabled in this world in some form (fake or not).
|
||||
*
|
||||
* @return True if players can take damage from other players.
|
||||
*/
|
||||
boolean isPVPEnabled();
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode.
|
||||
*
|
||||
* @param pvpMode True to enable PVP damage, false to disable it.
|
||||
*/
|
||||
void setPVPMode(boolean pvpMode);
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
|
||||
*
|
||||
* @return True if this world has fakepvp on
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean getFakePVP();
|
||||
|
||||
/**
|
||||
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
*
|
||||
* @return True if the world will be hidden, false if not.
|
||||
*/
|
||||
boolean isHidden();
|
||||
|
||||
/**
|
||||
* Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
*
|
||||
* @param hidden Set
|
||||
*/
|
||||
void setHidden(boolean hidden);
|
||||
|
||||
/**
|
||||
* Gets whether weather is enabled in this world.
|
||||
*
|
||||
* @return True if weather events will occur, false if not.
|
||||
*/
|
||||
boolean isWeatherEnabled();
|
||||
|
||||
/**
|
||||
* Sets whether or not there will be weather events in a given world.
|
||||
* If set to false, Multiverse will disable the weather in the world immediately.
|
||||
*
|
||||
* @param enableWeather True if weather events should occur in a world, false if not.
|
||||
*/
|
||||
void setEnableWeather(boolean enableWeather);
|
||||
|
||||
/**
|
||||
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
|
||||
*
|
||||
* @return True if CraftBukkit is keeping spawn chunks in memory.
|
||||
*/
|
||||
boolean isKeepingSpawnInMemory();
|
||||
|
||||
/**
|
||||
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
|
||||
* If not, CraftBukkit will attempt to free memory when players have not used that world.
|
||||
* This will not happen immediately.
|
||||
*
|
||||
* @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
|
||||
*/
|
||||
void setKeepSpawnInMemory(boolean keepSpawnInMemory);
|
||||
|
||||
/**
|
||||
* Gets the spawn location of this world.
|
||||
*
|
||||
* @return The spawn location of this world.
|
||||
*/
|
||||
Location getSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets the spawn location for a world.
|
||||
*
|
||||
* @param spawnLocation The spawn location for a world.
|
||||
*/
|
||||
void setSpawnLocation(Location spawnLocation);
|
||||
|
||||
/**
|
||||
* Gets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @return True if it will go down, false if it will remain steady.
|
||||
*/
|
||||
boolean getHunger();
|
||||
|
||||
/**
|
||||
* Sets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @param hungerEnabled True if hunger will go down, false to keep it at
|
||||
* the level they entered a world with.
|
||||
*/
|
||||
void setHunger(boolean hungerEnabled);
|
||||
|
||||
/**
|
||||
* Gets the GameMode of this world.
|
||||
*
|
||||
* @return The GameMode of this world.
|
||||
*/
|
||||
GameMode getGameMode();
|
||||
|
||||
/**
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @param gameMode A valid game mode string (either
|
||||
* an int ex. 0 or a string ex. creative).
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
* @deprecated Use {@link #setGameMode(GameMode)} instead. If you have to
|
||||
* pass a string, use {@link #setPropertyValue(String, String)}.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setGameMode(String gameMode);
|
||||
|
||||
/**
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @param gameMode The new {@link GameMode}.
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
*/
|
||||
boolean setGameMode(GameMode gameMode);
|
||||
|
||||
/**
|
||||
* Gets the amount of currency it requires to enter this world.
|
||||
*
|
||||
* @return The amount it costs to enter this world.
|
||||
*/
|
||||
double getPrice();
|
||||
|
||||
/**
|
||||
* Sets the price for entry to this world.
|
||||
* You can think of this like an amount.
|
||||
* The type can be set with {@link #setCurrency(Material)}
|
||||
*
|
||||
* @param price The Amount of money/item to enter the world.
|
||||
*/
|
||||
void setPrice(double price);
|
||||
|
||||
/**
|
||||
* Gets the type of currency that will be used when users enter this world. A value of null indicates a non-item
|
||||
* based currency is used.
|
||||
*
|
||||
* @return The type of currency that will be used when users enter this world.
|
||||
*/
|
||||
@Nullable
|
||||
Material getCurrency();
|
||||
|
||||
/**
|
||||
* Sets the type of item that will be required given the price is not 0.
|
||||
* Use a value of null to specify a non-item based currency.
|
||||
*
|
||||
* @param item The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
void setCurrency(@Nullable Material item);
|
||||
|
||||
/**
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
*
|
||||
* @return A world that exists on the server.
|
||||
*/
|
||||
World getRespawnToWorld();
|
||||
|
||||
/**
|
||||
* Sets the world players will respawn in if they die in this one.
|
||||
* Returns true upon success, false upon failure.
|
||||
*
|
||||
* @param respawnWorld The name of a world that exists on the server.
|
||||
* @return True if respawnWorld existed, false if not.
|
||||
*/
|
||||
boolean setRespawnToWorld(String respawnWorld);
|
||||
|
||||
/**
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @return This world's non-negative, non-zero scale.
|
||||
*/
|
||||
double getScaling();
|
||||
|
||||
/**
|
||||
* Sets the scale of this world. Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @param scaling A scaling value, cannot be negative or 0.
|
||||
* @return Whether the scale was set successfully.
|
||||
*/
|
||||
boolean setScaling(double scaling);
|
||||
|
||||
/**
|
||||
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @return True if the world should heal (default), false if not.
|
||||
*/
|
||||
boolean getAutoHeal();
|
||||
|
||||
/**
|
||||
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @param heal True if the world will heal.
|
||||
*/
|
||||
void setAutoHeal(boolean heal);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @return True if Multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
boolean getAdjustSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @param adjust True if multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
void setAdjustSpawn(boolean adjust);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-load this world.
|
||||
*
|
||||
* @return True if Multiverse should auto-load this world.
|
||||
*/
|
||||
boolean getAutoLoad();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-load this world.
|
||||
* <p>
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
|
||||
*/
|
||||
void setAutoLoad(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Gets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
*
|
||||
* @return True if players dying in this world should respawn at their bed.
|
||||
*/
|
||||
boolean getBedRespawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
* <p>
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if players dying in this world respawn at their bed.
|
||||
*/
|
||||
void setBedRespawn(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Sets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @param limit The new limit
|
||||
*/
|
||||
void setPlayerLimit(int limit);
|
||||
|
||||
/**
|
||||
* Gets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @return The player limit
|
||||
*/
|
||||
int getPlayerLimit();
|
||||
|
||||
/**
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
* @return The time as a short string: 12:34pm
|
||||
*/
|
||||
String getTime();
|
||||
|
||||
/**
|
||||
* Sets the current time in a world.
|
||||
* <p>
|
||||
* This method will take the following formats:
|
||||
* 11:37am
|
||||
* 4:30p
|
||||
* day(morning), night, noon, midnight
|
||||
*
|
||||
* @param timeAsString The formatted time to set the world to.
|
||||
* @return True if the time was set, false if not.
|
||||
*/
|
||||
boolean setTime(String timeAsString);
|
||||
|
||||
/**
|
||||
* Sets The types of portals that are allowed in this world.
|
||||
*
|
||||
* @param type The type of portals allowed in this world.
|
||||
*/
|
||||
void allowPortalMaking(AllowedPortalType type);
|
||||
|
||||
/**
|
||||
* Gets which type(s) of portals are allowed to be constructed in this world.
|
||||
*
|
||||
* @return The type of portals that are allowed.
|
||||
*/
|
||||
AllowedPortalType getAllowedPortals();
|
||||
|
||||
// properties that are not "getter+setter" style
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
* regardless of their access permissions.
|
||||
*
|
||||
* @return A List of world names.
|
||||
*/
|
||||
List<String> getWorldBlacklist();
|
||||
|
||||
/**
|
||||
* Gets all the names of all properties that can be SET.
|
||||
*
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
|
||||
/**
|
||||
* Whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @return True if players allowed to fly in this world.
|
||||
*/
|
||||
boolean getAllowFlight();
|
||||
|
||||
/**
|
||||
* Sets whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @param allowFlight True to allow flight in this world.
|
||||
*/
|
||||
void setAllowFlight(final boolean allowFlight);
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Multiverse 2 World Manager API
|
||||
* <p>
|
||||
* This API contains all of the world managing
|
||||
* functions that your heart desires!
|
||||
*/
|
||||
@Contract
|
||||
public interface MVWorldManager {
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generateStructures If true, this world will get NPC villages.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator);
|
||||
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generateStructures If true, this world will get NPC villages.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Make a copy of a world.
|
||||
*
|
||||
* @param oldName
|
||||
* Name of world to be copied
|
||||
* @param newName
|
||||
* Name of world to be created
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
*/
|
||||
boolean cloneWorld(String oldName, String newName);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the config and deletes
|
||||
* the folder.
|
||||
*
|
||||
* @param name
|
||||
* The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config if wanted, and deletes the folder.
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeConfig);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeFromConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
|
||||
* only the contents of the world folder will be deleted
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
boolean unloadWorld(String name);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @param unloadBukkit True if Bukkit world should be unloaded
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
boolean unloadWorld(String name, boolean unloadBukkit);
|
||||
|
||||
/**
|
||||
* Loads the world. Only use this if the world has been
|
||||
* unloaded with {@link #unloadWorld(String)}.
|
||||
*
|
||||
* @param name The name of the world to load
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean loadWorld(String name);
|
||||
|
||||
/**
|
||||
* Removes all players from the specified world.
|
||||
*
|
||||
* @param name World to remove players from.
|
||||
*/
|
||||
void removePlayersFromWorld(String name);
|
||||
|
||||
/**
|
||||
* Test if a given chunk generator is valid.
|
||||
*
|
||||
* @param generator The generator name.
|
||||
* @param generatorID The generator id.
|
||||
* @param worldName The worldName to use as the default.
|
||||
* @return A {@link ChunkGenerator} or null
|
||||
*/
|
||||
ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
|
||||
|
||||
/**
|
||||
* Returns a list of all the worlds Multiverse knows about.
|
||||
*
|
||||
* @return A list of {@link MVWorld}.
|
||||
*/
|
||||
Collection<MVWorld> getMVWorlds();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a {@link MVWorld} if it exists, and null if it does not.
|
||||
* This will search name AND alias.
|
||||
*
|
||||
* @param name The name or alias of the world to get.
|
||||
* @return A {@link MVWorld} or null.
|
||||
*/
|
||||
MVWorld getMVWorld(String name);
|
||||
|
||||
/**
|
||||
* Returns a {@link MVWorld} if the world with name given exists, and null if it does not.
|
||||
* This will search optionally for alias names.
|
||||
*
|
||||
* @param name The name or optionally the alias of the world to get.
|
||||
* @param checkAliases Indicates whether to check for world alias name.
|
||||
* @return A {@link MVWorld} or null.
|
||||
*/
|
||||
MVWorld getMVWorld(String name, boolean checkAliases);
|
||||
|
||||
/**
|
||||
* Returns a {@link MVWorld} if it exists, and null if it does not.
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
* @return A {@link MVWorld} or null.
|
||||
*/
|
||||
MVWorld getMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Checks to see if the given name is a valid {@link MVWorld}
|
||||
* Searches based on world name AND alias.
|
||||
*
|
||||
* @param name The name or alias of the world to check.
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
boolean isMVWorld(String name);
|
||||
|
||||
/**
|
||||
* Checks to see if the given name is a valid {@link MVWorld}.
|
||||
* Optionally searches by alias is specified.
|
||||
*
|
||||
* @param name The name or alias of the world to check.
|
||||
* @param checkAliases Indicates whether to check for world alias name.
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
boolean isMVWorld(String name, boolean checkAliases);
|
||||
|
||||
/**
|
||||
* Checks to see if the given world is a valid {@link MVWorld}.
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
* @return True if the world has been loaded into MV2, false if not.
|
||||
*/
|
||||
boolean isMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Load the Worlds & Settings from the configuration file.
|
||||
*
|
||||
* @param forceLoad If set to true, this will perform a total
|
||||
* reset and not just load new worlds.
|
||||
*/
|
||||
void loadWorlds(boolean forceLoad);
|
||||
|
||||
/**
|
||||
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
||||
* <p>
|
||||
* This way people will _always_ have some worlds in the list.
|
||||
*/
|
||||
void loadDefaultWorlds();
|
||||
|
||||
/**
|
||||
* Gets the world players will spawn in on first join.
|
||||
* Currently this always returns worlds.get(0) from Bukkit.
|
||||
*
|
||||
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
|
||||
*/
|
||||
MVWorld getSpawnWorld();
|
||||
|
||||
/**
|
||||
* Gets the list of worlds in the config, but unloaded.
|
||||
*
|
||||
* @return A List of worlds as strings.
|
||||
*/
|
||||
List<String> getUnloadedWorlds();
|
||||
|
||||
/**
|
||||
* This method populates an internal list and needs to be called after multiverse initialization.
|
||||
*/
|
||||
void getDefaultWorldGenerators();
|
||||
|
||||
/**
|
||||
* Load the config from a file.
|
||||
*
|
||||
* @return A loaded configuration.
|
||||
*/
|
||||
FileConfiguration loadWorldsConfig();
|
||||
|
||||
/**
|
||||
* Saves the world config to disk.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean saveWorldsConfig();
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list and from the config.
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean removeWorldFromConfig(String name);
|
||||
|
||||
/**
|
||||
* Sets the initial spawn world for new players.
|
||||
*
|
||||
* @param world The World new players should spawn in.
|
||||
*/
|
||||
void setFirstSpawnWorld(String world);
|
||||
|
||||
/**
|
||||
* Gets the world players should spawn in first.
|
||||
*
|
||||
* @return The {@link MVWorld} new players should spawn in.
|
||||
*/
|
||||
MVWorld getFirstSpawnWorld();
|
||||
|
||||
/**
|
||||
* Regenerates a world.
|
||||
*
|
||||
* @param name Name of the world to regenerate
|
||||
* @param useNewSeed If a new seed should be used
|
||||
* @param randomSeed If the new seed should be random
|
||||
* @param seed The seed of the world.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
|
||||
|
||||
/**
|
||||
* Regenerates a world.
|
||||
*
|
||||
* @param name Name of the world to regenerate
|
||||
* @param useNewSeed If a new seed should be used
|
||||
* @param randomSeed If the new seed should be random
|
||||
* @param seed The seed of the world.
|
||||
* @param keepGameRules If GameRules should be kept on world regen.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules);
|
||||
|
||||
boolean isKeepingSpawnInMemory(World world);
|
||||
|
||||
/**
|
||||
* Checks whether Multiverse knows about a provided unloaded world. This
|
||||
* method will check the parameter against the alias mappings.
|
||||
*
|
||||
* @param name The name of the unloaded world
|
||||
* @param includeLoaded The value to return if the world is loaded
|
||||
*
|
||||
* @return True if the world exists and is unloaded. False if the world
|
||||
* does not exist. {@code includeLoaded} if the world exists and is loaded.
|
||||
*/
|
||||
boolean hasUnloadedWorld(String name, boolean includeLoaded);
|
||||
|
||||
/**
|
||||
* Get all the possible worlds that Multiverse has detected to be importable.
|
||||
*
|
||||
* @return A collection of world names that are deemed importable.
|
||||
*/
|
||||
Collection<String> getPotentialWorlds();
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to safely teleport people.
|
||||
*/
|
||||
@Contract
|
||||
public interface SafeTTeleporter extends Teleporter {
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l);
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @param tolerance The tolerance.
|
||||
* @param radius The radius.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l, int tolerance, int radius);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param destination Destination to teleport them to
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
@Deprecated
|
||||
TeleportResult safelyTeleport(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param destination Destination to teleport them to
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
CompletableFuture<TeleportResult> safelyTeleportAsync(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the Location. This may perform checks to
|
||||
* see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who issued the teleport command.
|
||||
* @param teleportee Entity to teleport.
|
||||
* @param location Location to teleport them to.
|
||||
* @param safely Should the destination be checked for safety before teleport?
|
||||
* @return true for success, false for failure.
|
||||
*/
|
||||
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location,
|
||||
boolean safely);
|
||||
|
||||
/**
|
||||
* Returns a safe location for the entity to spawn at.
|
||||
*
|
||||
* @param entity The entity to spawn
|
||||
* @param destination The MVDestination to take the entity to.
|
||||
* @return A new location to spawn the entity at.
|
||||
*/
|
||||
Location getSafeLocation(Entity entity, DestinationInstance destination);
|
||||
|
||||
/**
|
||||
* Finds a portal-block next to the specified {@link Location}.
|
||||
* @param l The {@link Location}
|
||||
* @return The next portal-block's {@link Location}.
|
||||
*/
|
||||
Location findPortalBlockNextTo(Location l);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public interface Teleporter {
|
||||
/**
|
||||
* Teleport the entity to the Multiverse Destination.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param destination Destination to teleport them to
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
@Deprecated
|
||||
TeleportResult teleport(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
|
||||
|
||||
/**
|
||||
* Teleport the entity to the Multiverse Destination.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param destination Destination to teleport them to
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
CompletableFuture<TeleportResult> teleportAsync(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to remove animals from worlds that don't belong there.
|
||||
*/
|
||||
@Contract
|
||||
public interface WorldPurger {
|
||||
/**
|
||||
* Synchronizes the given worlds with their settings.
|
||||
*
|
||||
* @param worlds A list of {@link MVWorld}
|
||||
*/
|
||||
void purgeWorlds(List<MVWorld> worlds);
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #purgeWorld(MVWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
|
||||
*
|
||||
* @param world The {@link MVWorld}.
|
||||
*/
|
||||
void purgeWorld(MVWorld world);
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
*
|
||||
* @param mvworld The {@link MVWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
*/
|
||||
void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters);
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
*
|
||||
* @param mvworld The {@link MVWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
* @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
|
||||
*/
|
||||
void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters, CommandSender sender);
|
||||
|
||||
/**
|
||||
* Determines whether the specified creature should be killed.
|
||||
*
|
||||
* @param e The creature.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
* @return {@code true} if the creature should be killed, otherwise {@code false}.
|
||||
*/
|
||||
boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters);
|
||||
|
||||
/**
|
||||
* Determines whether the specified creature should be killed and automatically reads the params from a world object.
|
||||
*
|
||||
* @param w The world.
|
||||
* @param e The creature.
|
||||
* @return {@code true} if the creature should be killed, otherwise {@code false}.
|
||||
*/
|
||||
boolean shouldWeKillThisCreature(MVWorld w, Entity e);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* The Multiverse-API, containing lots of interfaces that can be quite useful for other
|
||||
* plugins when interacting with Multiverse.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class CheckCommand extends MultiverseCommand {
|
||||
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
|
||||
@Inject
|
||||
public CheckCommand(@NotNull MVCommandManager commandManager, @NotNull DestinationsProvider destinationsProvider) {
|
||||
super(commandManager);
|
||||
this.destinationsProvider = destinationsProvider;
|
||||
}
|
||||
|
||||
@Subcommand("check")
|
||||
@CommandPermission("multiverse.core.check")
|
||||
@CommandCompletion("@players @destinations|@mvworlds")
|
||||
@Syntax("<player> <destination>")
|
||||
@Description("{@@mv-core.check.description}")
|
||||
public void onCheckCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Syntax("<player>")
|
||||
@Description("{@@mv-core.check.player.description}")
|
||||
Player player,
|
||||
|
||||
@Syntax("<destination>")
|
||||
@Description("{@@mv-core.check.destination.description}")
|
||||
ParsedDestination<?> destination
|
||||
) {
|
||||
issuer.sendInfo(MVCorei18n.CHECK_CHECKING,
|
||||
"{player}", player.getName(),
|
||||
"{destination}", destination.toString());
|
||||
//TODO More detailed output on permissions required.
|
||||
this.destinationsProvider.checkTeleportPermissions(issuer, player, destination);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class CloneCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public CloneCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
}
|
||||
|
||||
@Subcommand("clone")
|
||||
@CommandPermission("multiverse.core.clone")
|
||||
@CommandCompletion("@mvworlds:scope=both @empty")
|
||||
@Syntax("<world> <new world name>")
|
||||
@Description("{@@mv-core.clone.description}")
|
||||
public void onCloneCommand(CommandIssuer issuer,
|
||||
|
||||
@Conditions("validWorldName:scope=both")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.clone.world.description}")
|
||||
String worldName,
|
||||
|
||||
@Single
|
||||
@Conditions("validWorldName:scope=new")
|
||||
@Syntax("<new world name>")
|
||||
@Description("{@@mv-core.clone.newWorld.description}")
|
||||
String newWorldName
|
||||
) {
|
||||
issuer.sendInfo(MVCorei18n.CLONE_CLONING,
|
||||
"{world}", worldName,
|
||||
"{newWorld}", newWorldName);
|
||||
|
||||
if (!this.worldManager.cloneWorld(worldName, newWorldName)) {
|
||||
issuer.sendError(MVCorei18n.CLONE_FAILED);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.CLONE_SUCCESS,
|
||||
"{world}", newWorldName);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandIssuer;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.MVConfigValue;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.exceptions.MultiverseException;
|
||||
import io.vavr.control.Option;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class ConfigCommand extends MultiverseCommand {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
|
||||
@Inject
|
||||
public ConfigCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) {
|
||||
super(commandManager);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Subcommand("config")
|
||||
@CommandPermission("multiverse.core.config")
|
||||
@CommandCompletion("@mvconfigs")
|
||||
@Syntax("<name> [new-value]")
|
||||
@Description("") //TODO
|
||||
public void onConfigCommand(MVCommandIssuer issuer,
|
||||
|
||||
@Syntax("<name>")
|
||||
@Description("") //TODO
|
||||
String name,
|
||||
|
||||
@Optional
|
||||
@Single
|
||||
@Syntax("[new-value]")
|
||||
@Description("") //TODO
|
||||
MVConfigValue value
|
||||
) {
|
||||
if (value == null) {
|
||||
showConfigValue(issuer, name);
|
||||
return;
|
||||
}
|
||||
updateConfigValue(issuer, name, value.getValue());
|
||||
}
|
||||
|
||||
private void showConfigValue(MVCommandIssuer issuer, String name) {
|
||||
config.getProperty(name)
|
||||
.onSuccess(value -> issuer.sendMessage(name + "is currently set to " + value))
|
||||
.onFailure(e -> issuer.sendMessage(e.getMessage()));
|
||||
}
|
||||
|
||||
private void updateConfigValue(MVCommandIssuer issuer, String name, Object value) {
|
||||
config.setProperty(name, value)
|
||||
.onSuccess(ignore -> {
|
||||
config.save();
|
||||
issuer.sendMessage("Successfully set " + name + " to " + value);
|
||||
})
|
||||
.onFailure(ignore -> issuer.sendMessage("Unable to set " + name + " to " + value + "."))
|
||||
.onFailure(MultiverseException.class, e -> Option.of(e.getMVMessage()).peek(issuer::sendError));
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class ConfirmCommand extends MultiverseCommand {
|
||||
|
||||
@Inject
|
||||
public ConfirmCommand(@NotNull MVCommandManager commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@Subcommand("confirm")
|
||||
@CommandPermission("multiverse.core.confirm")
|
||||
@Description("{@@mv-core.confirm.description}")
|
||||
public void onConfirmCommand(@NotNull BukkitCommandIssuer issuer) {
|
||||
this.commandManager.getCommandQueueManager().runQueuedCommand(issuer.getIssuer());
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class CreateCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public CreateCommand(
|
||||
@NotNull MVCommandManager commandManager,
|
||||
@NotNull MVWorldManager worldManager,
|
||||
@NotNull UnsafeCallWrapper unsafeCallWrapper
|
||||
) {
|
||||
super(commandManager);
|
||||
|
||||
this.worldManager = worldManager;
|
||||
|
||||
registerFlagGroup(CommandFlagGroup.builder("mvcreate")
|
||||
.add(CommandValueFlag.builder("--seed", String.class)
|
||||
.addAlias("-s")
|
||||
.completion(() -> Collections.singleton(String.valueOf(new Random().nextLong())))
|
||||
.build())
|
||||
.add(CommandValueFlag.builder("--generator", String.class)
|
||||
.addAlias("-g")
|
||||
.completion(() -> Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins())
|
||||
.filter(Plugin::isEnabled)
|
||||
.filter(genplugin -> unsafeCallWrapper.wrap(
|
||||
() -> genplugin.getDefaultWorldGenerator("world", ""),
|
||||
genplugin.getName(),
|
||||
"Get generator"
|
||||
) != null)
|
||||
.map(genplugin -> genplugin.getDescription().getName())
|
||||
.collect(Collectors.toList()))
|
||||
.build())
|
||||
.add(CommandValueFlag.builder("--world-type", WorldType.class)
|
||||
.addAlias("-t")
|
||||
.context((value) -> {
|
||||
try {
|
||||
return WorldType.valueOf(value.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new InvalidCommandArgument("Invalid world type: " + value);
|
||||
}
|
||||
})
|
||||
.completion(() -> {
|
||||
List<String> types = new ArrayList<>();
|
||||
for (WorldType type : WorldType.values()) {
|
||||
types.add(type.name().toLowerCase());
|
||||
}
|
||||
return types;
|
||||
})
|
||||
.build())
|
||||
.add(CommandFlag.builder("--adjust-spawn")
|
||||
.addAlias("-n")
|
||||
.build())
|
||||
.add(CommandFlag.builder("--no-structures")
|
||||
.addAlias("-a")
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Subcommand("create")
|
||||
@CommandPermission("multiverse.core.create")
|
||||
@CommandCompletion("@empty @flags:groupName=mvcreate")
|
||||
@Syntax("<name> <environment> --seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures")
|
||||
@Description("{@@mv-core.create.description}")
|
||||
public void onCreateCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Conditions("validWorldName:scope=new")
|
||||
@Syntax("<name>")
|
||||
@Description("{@@mv-core.create.name.description}")
|
||||
String worldName,
|
||||
|
||||
@Syntax("<environment>")
|
||||
@Description("{@@mv-core.create.environment.description}")
|
||||
World.Environment environment,
|
||||
|
||||
@Optional
|
||||
@Syntax("--seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures")
|
||||
@Description("{@@mv-core.create.flags.description}")
|
||||
String[] flags
|
||||
) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES, "{worldName}", worldName);
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ENVIRONMENT, "{environment}", environment.name());
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_SEED, "{seed}", parsedFlags.flagValue("--seed", "RANDOM", String.class));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_WORLDTYPE, "{worldType}", parsedFlags.flagValue("--world-type", WorldType.NORMAL, WorldType.class).name());
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ADJUSTSPAWN, "{adjustSpawn}", String.valueOf(parsedFlags.hasFlag("--adjust-spawn")));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_GENERATOR, "{generator}", parsedFlags.flagValue("--generator", "null", String.class));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_STRUCTURES, "{structures}", String.valueOf(!parsedFlags.hasFlag("--no-structures")));
|
||||
|
||||
issuer.sendInfo(MVCorei18n.CREATE_LOADING);
|
||||
|
||||
if (!worldManager.addWorld(
|
||||
worldName,
|
||||
environment,
|
||||
parsedFlags.flagValue("--seed", String.class),
|
||||
parsedFlags.flagValue("--world-type", WorldType.NORMAL, WorldType.class),
|
||||
parsedFlags.hasFlag("--adjust-spawn"),
|
||||
parsedFlags.flagValue("--generator", String.class),
|
||||
parsedFlags.hasFlag("--no-structures")
|
||||
)) {
|
||||
issuer.sendError(MVCorei18n.CREATE_FAILED, "{worldName}", worldName);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.CREATE_SUCCESS, "{worldName}", worldName);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class DebugCommand extends MultiverseCommand {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
|
||||
@Inject
|
||||
public DebugCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) {
|
||||
super(commandManager);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Subcommand("debug")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@Description("{@@mv-core.debug.info.description}")
|
||||
public void onShowDebugCommand(BukkitCommandIssuer issuer) {
|
||||
this.displayDebugMode(issuer);
|
||||
}
|
||||
|
||||
@Subcommand("debug")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@CommandCompletion("@range:3")
|
||||
@Syntax("<{@@mv-core.debug.change.syntax}>")
|
||||
@Description("{@@mv-core.debug.change.description}")
|
||||
public void onChangeDebugCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Syntax("<{@@mv-core.debug.change.syntax}>")
|
||||
@Description("{@@mv-core.debug.change.level.description}")
|
||||
int level) {
|
||||
|
||||
config.setGlobalDebug(level);
|
||||
config.save();
|
||||
this.displayDebugMode(issuer);
|
||||
}
|
||||
|
||||
private void displayDebugMode(BukkitCommandIssuer issuer) {
|
||||
final int debugLevel = config.getGlobalDebug();
|
||||
if (debugLevel == 0) {
|
||||
issuer.sendInfo(MVCorei18n.DEBUG_INFO_OFF);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.DEBUG_INFO_ON, "{level}", String.valueOf(debugLevel));
|
||||
Logging.fine("Multiverse Debug ENABLED.");
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.MessageType;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class DeleteCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
}
|
||||
|
||||
@Subcommand("delete")
|
||||
@CommandPermission("multiverse.core.delete")
|
||||
@CommandCompletion("@mvworlds:scope=both")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.delete.description}")
|
||||
public void onDeleteCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Single
|
||||
@Conditions("validWorldName:scope=both")
|
||||
@Syntax("<world>")
|
||||
@Description("The world you want to delete.")
|
||||
String worldName
|
||||
) {
|
||||
this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand(
|
||||
issuer.getIssuer(),
|
||||
() -> {
|
||||
issuer.sendInfo(MVCorei18n.DELETE_DELETING,
|
||||
"{world}", worldName);
|
||||
if (!this.worldManager.deleteWorld(worldName)) {
|
||||
issuer.sendError(MVCorei18n.DELETE_FAILED,
|
||||
"{world}", worldName);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.DELETE_SUCCESS,
|
||||
"{world}", worldName);
|
||||
},
|
||||
this.commandManager.formatMessage(
|
||||
issuer,
|
||||
MessageType.INFO,
|
||||
MVCorei18n.DELETE_PROMPT,
|
||||
"{world}", worldName)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleValue;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.GameRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class GameruleCommand extends MultiverseCommand {
|
||||
|
||||
@Inject
|
||||
public GameruleCommand(@NotNull MVCommandManager commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@Subcommand("gamerule")
|
||||
@CommandPermission("multiverse.core.gamerule")
|
||||
@CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*")
|
||||
@Syntax("<Gamerule> <Gamerule value> [World or *]")
|
||||
@Description("{@@mv-core.gamerule.description}")
|
||||
public void onGameruleCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Syntax("<Gamerule>")
|
||||
@Description("{@@mv-core.gamerule.gamerule.description}")
|
||||
GameRule gamerule,
|
||||
|
||||
@Syntax("<Value>")
|
||||
@Description("{@@mv-core.gamerule.value.description}")
|
||||
GameRuleValue gameRuleValue,
|
||||
|
||||
@Flags("resolve=issuerAware")
|
||||
@Syntax("[World or *]")
|
||||
@Description("{@@mv-core.gamerule.world.description}")
|
||||
MVWorld[] worlds
|
||||
) {
|
||||
Object value = gameRuleValue.getValue();
|
||||
boolean success = true;
|
||||
for(MVWorld world : worlds) {
|
||||
// Set gamerules and add false to list if it fails
|
||||
if (!world.getCBWorld().setGameRule(gamerule, value)) {
|
||||
issuer.sendError(MVCorei18n.GAMERULE_FAILED,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{value}", value.toString(),
|
||||
"{world}", world.getName(),
|
||||
"{type}", gamerule.getType().getName());
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
// Tell user if it was successful
|
||||
if (success) {
|
||||
if (worlds.length == 1) {
|
||||
issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_SINGLE,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{value}", value.toString(),
|
||||
"{world}", worlds[0].getName());
|
||||
}
|
||||
else if (worlds.length > 1) {
|
||||
issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_MULTIPLE,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{value}", value.toString(),
|
||||
"{count}", String.valueOf(worlds.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class ImportCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public ImportCommand(
|
||||
@NotNull MVCommandManager commandManager,
|
||||
@NotNull MVWorldManager worldManager,
|
||||
@NotNull UnsafeCallWrapper unsafeCallWrapper
|
||||
) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
|
||||
registerFlagGroup(CommandFlagGroup.builder("mvimport")
|
||||
.add(CommandValueFlag.builder("--generator", String.class)
|
||||
.addAlias("-g")
|
||||
.completion(() -> Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins())
|
||||
.filter(Plugin::isEnabled)
|
||||
.filter(genplugin -> unsafeCallWrapper.wrap(
|
||||
() -> genplugin.getDefaultWorldGenerator("world", ""),
|
||||
genplugin.getName(),
|
||||
"Get generator"
|
||||
) != null)
|
||||
.map(genplugin -> genplugin.getDescription().getName())
|
||||
.collect(Collectors.toList()))
|
||||
.build())
|
||||
.add(CommandFlag.builder("--adjust-spawn")
|
||||
.addAlias("-a")
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Subcommand("import")
|
||||
@CommandPermission("multiverse.core.import")
|
||||
@CommandCompletion("@mvworlds:scope=potential @flags:groupName=mvimport")
|
||||
@Syntax("<name> <env> --generator [generator[:id]] --adjust-spawn")
|
||||
@Description("{@@mv-core.import.description")
|
||||
public void onImportCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Conditions("validWorldName:scope=new")
|
||||
@Syntax("<name>")
|
||||
@Description("{@@mv-core.import.name.description}")
|
||||
String worldName,
|
||||
|
||||
@Syntax("<env>")
|
||||
@Description("{@@mv-core.import.env.description}")
|
||||
World.Environment environment,
|
||||
|
||||
@Optional
|
||||
@Syntax("--generator [generator[:id]] --adjust-spawn")
|
||||
@Description("{@@mv-core.import.other.description}")
|
||||
String[] flags) {
|
||||
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
issuer.sendInfo(MVCorei18n.IMPORT_IMPORTING,
|
||||
"{world}", worldName);
|
||||
|
||||
if (!this.worldManager.addWorld(
|
||||
worldName, environment,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
parsedFlags.flagValue("--generator", String.class),
|
||||
parsedFlags.hasFlag("--adjust-spawn"))
|
||||
) {
|
||||
issuer.sendError(MVCorei18n.IMPORT_FAILED);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class LoadCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public LoadCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
}
|
||||
|
||||
@Subcommand("load")
|
||||
@CommandPermission("multiverse.core.load")
|
||||
@CommandCompletion("@mvworlds:scope=unloaded")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.load.description}")
|
||||
public void onLoadCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Single
|
||||
@Conditions("validWorldName:scope=unloaded")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.load.world.description}")
|
||||
String worldName
|
||||
) {
|
||||
issuer.sendInfo(MVCorei18n.LOAD_LOADING,
|
||||
"{world}", worldName);
|
||||
|
||||
if (!this.worldManager.loadWorld(worldName)) {
|
||||
issuer.sendError(MVCorei18n.LOAD_FAILED,
|
||||
"{world}", worldName);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.LOAD_SUCCESS,
|
||||
"{world}", worldName);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.MessageType;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class RegenCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public RegenCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
|
||||
registerFlagGroup(CommandFlagGroup.builder("mvregen")
|
||||
.add(CommandValueFlag.builder("--seed", String.class)
|
||||
.addAlias("-s")
|
||||
.completion(() -> Collections.singleton(String.valueOf(new Random().nextLong())))
|
||||
.optional()
|
||||
.build())
|
||||
.add(CommandFlag.builder("--keep-gamerules")
|
||||
.addAlias("-k")
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Subcommand("regen")
|
||||
@CommandPermission("multiverse.core.regen")
|
||||
@CommandCompletion("@mvworlds:scope=both @flags:groupName=mvregen")
|
||||
@Syntax("<world> --seed [seed] --keep-gamerules")
|
||||
@Description("{@@mv-core.regen.description}")
|
||||
public void onRegenCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Conditions("validWorldName:scope=both")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.regen.world.description}")
|
||||
String worldName,
|
||||
|
||||
@Optional
|
||||
@Syntax("--seed [seed] --keep-gamerules")
|
||||
@Description("{@@mv-core.regen.other.description}")
|
||||
String[] flags
|
||||
) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand(
|
||||
issuer.getIssuer(),
|
||||
() -> {
|
||||
issuer.sendInfo(MVCorei18n.REGEN_REGENERATING,
|
||||
"{world}", worldName);
|
||||
if (!this.worldManager.regenWorld(
|
||||
worldName,
|
||||
parsedFlags.hasFlag("--seed"),
|
||||
!parsedFlags.hasFlagValue("--seed"),
|
||||
parsedFlags.flagValue("--seed", String.class),
|
||||
parsedFlags.hasFlag("--keep-gamerules")
|
||||
)) {
|
||||
issuer.sendError(MVCorei18n.REGEN_FAILED,
|
||||
"{world}", worldName);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.REGEN_SUCCESS,
|
||||
"{world}", worldName);
|
||||
},
|
||||
this.commandManager.formatMessage(
|
||||
issuer,
|
||||
MessageType.INFO,
|
||||
MVCorei18n.REGEN_PROMPT,
|
||||
"{world}", worldName)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.anchor.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.api.MVCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class ReloadCommand extends MultiverseCommand {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
private final AnchorManager anchorManager;
|
||||
private final MVWorldManager worldManager;
|
||||
private final PluginManager pluginManager;
|
||||
|
||||
@Inject
|
||||
public ReloadCommand(
|
||||
@NotNull MVCommandManager commandManager,
|
||||
@NotNull MVCoreConfig config,
|
||||
@NotNull AnchorManager anchorManager,
|
||||
@NotNull MVWorldManager worldManager,
|
||||
@NotNull PluginManager pluginManager
|
||||
) {
|
||||
super(commandManager);
|
||||
this.config = config;
|
||||
this.anchorManager = anchorManager;
|
||||
this.worldManager = worldManager;
|
||||
this.pluginManager = pluginManager;
|
||||
}
|
||||
|
||||
@Subcommand("reload")
|
||||
@CommandPermission("multiverse.core.reload")
|
||||
@Description("{@@mv-core.reload.description}")
|
||||
public void onReloadCommand(@NotNull BukkitCommandIssuer issuer) {
|
||||
issuer.sendInfo(MVCorei18n.RELOAD_RELOADING);
|
||||
this.config.load();
|
||||
this.worldManager.loadWorldsConfig();
|
||||
this.worldManager.loadWorlds(true);
|
||||
this.anchorManager.loadAnchors();
|
||||
|
||||
List<String> configsLoaded = new ArrayList<>();
|
||||
configsLoaded.add("Multiverse-Core - config.yml");
|
||||
configsLoaded.add("Multiverse-Core - worlds.yml");
|
||||
configsLoaded.add("Multiverse-Core - anchors.yml");
|
||||
|
||||
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
|
||||
this.pluginManager.callEvent(configReload);
|
||||
|
||||
// @TODO: replace this sendMessage and format the configsLoaded above, maybe?
|
||||
configReload.getAllConfigsLoaded().forEach(issuer::sendMessage);
|
||||
issuer.sendInfo(MVCorei18n.RELOAD_SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class RemoveCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public RemoveCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
}
|
||||
|
||||
@Subcommand("remove")
|
||||
@CommandPermission("multiverse.core.remove")
|
||||
@CommandCompletion("@mvworlds:scope=both")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.remove.description}")
|
||||
public void onRemoveCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Single
|
||||
@Conditions("mvworlds:scope=both")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.remove.world.description}")
|
||||
String worldName
|
||||
) {
|
||||
if (!this.worldManager.removeWorldFromConfig(worldName)) {
|
||||
issuer.sendError(MVCorei18n.REMOVE_FAILED);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.REMOVE_SUCCESS,
|
||||
"{world}", worldName);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
public class RootCommand extends MultiverseCommand {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
@Inject
|
||||
public RootCommand(@NotNull MVCommandManager commandManager, @NotNull MultiverseCore plugin) {
|
||||
super(commandManager);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@CommandAlias("mv")
|
||||
public void onRootCommand(CommandIssuer issuer) {
|
||||
PluginDescriptionFile description = this.plugin.getDescription();
|
||||
issuer.sendInfo(MVCorei18n.ROOT_TITLE,
|
||||
"{name}", description.getName(),
|
||||
"{version}", description.getVersion());
|
||||
issuer.sendInfo(MVCorei18n.ROOT_HELP);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
|
||||
@Inject
|
||||
public TeleportCommand(MVCommandManager commandManager, DestinationsProvider destinationsProvider) {
|
||||
super(commandManager);
|
||||
this.destinationsProvider = destinationsProvider;
|
||||
}
|
||||
|
||||
@Subcommand("teleport|tp")
|
||||
@CommandCompletion("@players|@mvworlds:playerOnly|@destinations:playerOnly @mvworlds|@destinations")
|
||||
@Syntax("[player] <destination>")
|
||||
@Description("{@@mv-core.teleport.description}")
|
||||
public void onTeleportCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Flags("resolve=issuerAware")
|
||||
@Syntax("[player]")
|
||||
@Description("{@@mv-core.teleport.player.description}")
|
||||
Player[] players,
|
||||
|
||||
@Syntax("<destination>")
|
||||
@Description("{@@mv-core.teleport.destination.description}")
|
||||
ParsedDestination<?> destination
|
||||
) {
|
||||
// TODO Add warning if teleporting too many players at once.
|
||||
|
||||
CompletableFuture.allOf(Arrays.stream(players)
|
||||
.map(player -> this.destinationsProvider.playerTeleportAsync(issuer, player, destination))
|
||||
.toArray(CompletableFuture[]::new))
|
||||
.thenRun(() -> {
|
||||
String playerName = players.length == 1
|
||||
? issuer.getPlayer() == players[0] ? "you" : players[0].getName()
|
||||
: players.length + " players";
|
||||
|
||||
issuer.sendInfo(MVCorei18n.TELEPORT_SUCCESS,
|
||||
"{player}", playerName, "{destination}", destination.toString());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandIssuer issuer) {
|
||||
return this.destinationsProvider.hasAnyTeleportPermission(issuer);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class UnloadCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public UnloadCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
super(commandManager);
|
||||
this.worldManager = worldManager;
|
||||
}
|
||||
|
||||
@Subcommand("unload")
|
||||
@CommandPermission("multiverse.core.unload")
|
||||
@CommandCompletion("@mvworlds")
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.unload.description}")
|
||||
public void onUnloadCommand(BukkitCommandIssuer issuer,
|
||||
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.unload.world.description}")
|
||||
MVWorld world
|
||||
) {
|
||||
issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING,
|
||||
"{world}", world.getColoredWorldString());
|
||||
|
||||
//TODO API: Should be able to use MVWorld object directly
|
||||
if (!this.worldManager.unloadWorld(world.getName())) {
|
||||
issuer.sendError(MVCorei18n.UNLOAD_FAILURE,
|
||||
"{world}", world.getColoredWorldString());
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.UNLOAD_SUCCESS,
|
||||
"{world}", world.getColoredWorldString());
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.CommandHelp;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.HelpCommand;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class UsageCommand extends MultiverseCommand {
|
||||
|
||||
@Inject
|
||||
public UsageCommand(@NotNull MVCommandManager commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@HelpCommand
|
||||
@Subcommand("help")
|
||||
@CommandPermission("multiverse.core.help")
|
||||
@CommandCompletion("@commands:mv")
|
||||
@Syntax("[filter] [page]")
|
||||
@Description("{@@mv-core.usage.description}")
|
||||
public void onUsageCommand(CommandHelp help) {
|
||||
if (help.getIssuer().isPlayer()) {
|
||||
// Prevent flooding the chat
|
||||
help.setPerPage(4);
|
||||
}
|
||||
this.commandManager.showUsage(help);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* This package contains all the commands for Multiverse-Core.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
@@ -1,146 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.PaperCommandCompletions;
|
||||
import co.aikar.commands.RegisteredCommand;
|
||||
import co.aikar.commands.RootCommand;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.GameRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
protected final MVCommandManager commandManager;
|
||||
private final MVWorldManager worldManager;
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
|
||||
@Inject
|
||||
public MVCommandCompletions(
|
||||
@NotNull MVCommandManager mvCommandManager,
|
||||
@NotNull MVWorldManager worldManager,
|
||||
@NotNull DestinationsProvider destinationsProvider,
|
||||
@NotNull MVCoreConfig config
|
||||
) {
|
||||
super(mvCommandManager);
|
||||
this.commandManager = mvCommandManager;
|
||||
this.worldManager = worldManager;
|
||||
this.destinationsProvider = destinationsProvider;
|
||||
|
||||
registerAsyncCompletion("commands", this::suggestCommands);
|
||||
registerAsyncCompletion("destinations", this::suggestDestinations);
|
||||
registerAsyncCompletion("flags", this::suggestFlags);
|
||||
registerStaticCompletion("gamerules", this::suggestGamerules);
|
||||
registerStaticCompletion("mvconfigs", config.getNodes().getNames());
|
||||
registerAsyncCompletion("mvworlds", this::suggestMVWorlds);
|
||||
|
||||
setDefaultCompletion("destinations", ParsedDestination.class);
|
||||
setDefaultCompletion("flags", String[].class);
|
||||
setDefaultCompletion("gamerules", GameRule.class);
|
||||
setDefaultCompletion("mvworlds", MVWorld.class);
|
||||
}
|
||||
|
||||
private Collection<String> suggestCommands(BukkitCommandCompletionContext context) {
|
||||
String rootCmdName = context.getConfig();
|
||||
if (rootCmdName == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
RootCommand rootCommand = this.commandManager.getRegisteredRootCommands().stream()
|
||||
.unordered()
|
||||
.filter(c -> c.getCommandName().equals(rootCmdName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (rootCommand == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return rootCommand.getSubCommands().entries().stream()
|
||||
.filter(entry -> checkPerms(context.getIssuer(), entry.getValue()))
|
||||
.map(Map.Entry::getKey)
|
||||
.filter(cmdName -> !cmdName.startsWith("__"))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean checkPerms(CommandIssuer issuer, RegisteredCommand<?> command) {
|
||||
return this.commandManager.hasPermission(issuer, command.getRequiredPermissions());
|
||||
}
|
||||
|
||||
private Collection<String> suggestDestinations(BukkitCommandCompletionContext context) {
|
||||
if (context.hasConfig("playerOnly") && !context.getIssuer().isPlayer()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.destinationsProvider
|
||||
.suggestDestinations((BukkitCommandIssuer)context.getIssuer(), context.getInput());
|
||||
}
|
||||
|
||||
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
|
||||
return this.commandManager.getFlagsManager().suggest(
|
||||
context.getConfig("groupName", ""), context.getContextValue(String[].class));
|
||||
}
|
||||
|
||||
private Collection<String> suggestGamerules() {
|
||||
return Arrays.stream(GameRule.values()).map(GameRule::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Collection<String> suggestMVWorlds(BukkitCommandCompletionContext context) {
|
||||
if (context.hasConfig("playerOnly") && !context.getIssuer().isPlayer()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (!context.hasConfig("multiple")) {
|
||||
return getMVWorldNames(context);
|
||||
}
|
||||
|
||||
String input = context.getInput();
|
||||
int lastComma = input.lastIndexOf(',');
|
||||
String currentWorldsString = input.substring(0, lastComma + 1);
|
||||
Set<String> currentWorlds = Sets.newHashSet(input.split(","));
|
||||
return getMVWorldNames(context).stream()
|
||||
.filter(world -> !currentWorlds.contains(world))
|
||||
.map(world -> currentWorldsString + world)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<String> getMVWorldNames(BukkitCommandCompletionContext context) {
|
||||
String scope = context.getConfig("scope", "loaded");
|
||||
List<String> worlds = new ArrayList<>();
|
||||
switch (scope) {
|
||||
case "both":
|
||||
worlds.addAll(worldManager.getUnloadedWorlds());
|
||||
case "loaded":
|
||||
worldManager.getMVWorlds()
|
||||
.stream()
|
||||
.map(MVWorld::getName)
|
||||
.forEach(worlds::add);
|
||||
break;
|
||||
case "unloaded":
|
||||
worlds.addAll(worldManager.getUnloadedWorlds());
|
||||
break;
|
||||
case "potential":
|
||||
worlds.addAll(worldManager.getPotentialWorlds());
|
||||
break;
|
||||
}
|
||||
return worlds;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.BukkitConditionContext;
|
||||
import co.aikar.commands.CommandConditions;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.world.WorldNameChecker;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MVCommandConditions {
|
||||
static void load(MVCommandManager commandManager, MVWorldManager worldManager) {
|
||||
new MVCommandConditions(commandManager, worldManager);
|
||||
}
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
private final MVCommandManager commandManager;
|
||||
|
||||
private MVCommandConditions(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
|
||||
this.worldManager = worldManager;
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void registerConditions() {
|
||||
CommandConditions<BukkitCommandIssuer, BukkitCommandExecutionContext, BukkitConditionContext> conditions
|
||||
= commandManager.getCommandConditions();
|
||||
|
||||
conditions.addCondition(String.class, "validWorldName", this::checkValidWorldName);
|
||||
}
|
||||
|
||||
private void checkValidWorldName(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext executionContext,
|
||||
String worldName
|
||||
) {
|
||||
String scope = context.getConfigValue("scope", "loaded");
|
||||
|
||||
switch (scope) {
|
||||
// Worlds that are loaded
|
||||
case "loaded":
|
||||
if (!this.worldManager.isMVWorld(worldName)) {
|
||||
throw new ConditionFailedException("World with name '" + worldName + "' does not exist or is not loaded!");
|
||||
}
|
||||
break;
|
||||
// Worlds that are unloaded
|
||||
case "unloaded":
|
||||
if (!this.worldManager.hasUnloadedWorld(worldName, false)) {
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
throw new ConditionFailedException("World with name '" + worldName + "' is loaded already!");
|
||||
}
|
||||
throw new ConditionFailedException("World with name '" + worldName + "' does not exist!");
|
||||
}
|
||||
break;
|
||||
// World that are loaded or unloaded
|
||||
case "both":
|
||||
if (!this.worldManager.hasUnloadedWorld(worldName, true)) {
|
||||
throw new ConditionFailedException("World with name '" + worldName + "' does not exist!");
|
||||
}
|
||||
break;
|
||||
// World that are does not exist
|
||||
case "new":
|
||||
if (this.worldManager.hasUnloadedWorld(worldName, true)) {
|
||||
throw new ConditionFailedException("World with name '" + worldName + "' already exists!");
|
||||
}
|
||||
switch (WorldNameChecker.checkName(worldName)) {
|
||||
case INVALID_CHARS:
|
||||
throw new ConditionFailedException("World name '" + worldName + "' contains invalid characters!");
|
||||
case BLACKLISTED:
|
||||
throw new ConditionFailedException("World name '" + worldName + "' is used for critical server operations and is blacklisted!");
|
||||
}
|
||||
break;
|
||||
// Probably a typo happened here
|
||||
default:
|
||||
throw new ConditionFailedException("Unknown scope '" + scope + "'!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,356 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.PaperCommandContexts;
|
||||
import co.aikar.commands.contexts.ContextResolver;
|
||||
import com.google.common.base.Strings;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleValue;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.MVConfigValue;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.Node;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ValueNode;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import com.onarandombox.MultiverseCore.display.filters.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.display.filters.DefaultContentFilter;
|
||||
import com.onarandombox.MultiverseCore.display.filters.RegexContentFilter;
|
||||
import com.onarandombox.MultiverseCore.utils.PlayerFinder;
|
||||
import io.vavr.control.Option;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
public class MVCommandContexts extends PaperCommandContexts {
|
||||
|
||||
private final MVCommandManager mvCommandManager;
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
private final MVWorldManager worldManager;
|
||||
private final MVCoreConfig config;
|
||||
|
||||
@Inject
|
||||
public MVCommandContexts(
|
||||
MVCommandManager mvCommandManager,
|
||||
DestinationsProvider destinationsProvider,
|
||||
MVWorldManager worldManager,
|
||||
MVCoreConfig config
|
||||
) {
|
||||
super(mvCommandManager);
|
||||
this.mvCommandManager = mvCommandManager;
|
||||
this.destinationsProvider = destinationsProvider;
|
||||
this.worldManager = worldManager;
|
||||
this.config = config;
|
||||
|
||||
registerIssuerOnlyContext(BukkitCommandIssuer.class, BukkitCommandExecutionContext::getIssuer);
|
||||
registerIssuerOnlyContext(MVCommandIssuer.class, this::parseMVCommandIssuer);
|
||||
registerOptionalContext(ContentFilter.class, this::parseContentFilter);
|
||||
registerContext(ParsedDestination.class, this::parseDestination);
|
||||
registerContext(GameRule.class, this::parseGameRule);
|
||||
registerContext(GameRuleValue.class, this::parseGameRuleValue);
|
||||
registerContext(MVConfigValue.class, this::parseMVConfigValue);
|
||||
registerIssuerAwareContext(MVWorld.class, this::parseMVWorld);
|
||||
registerIssuerAwareContext(MVWorld[].class, this::parseMVWorldArray);
|
||||
registerIssuerAwareContext(Player.class, this::parsePlayer);
|
||||
registerIssuerAwareContext(Player[].class, this::parsePlayerArray);
|
||||
}
|
||||
|
||||
private MVCommandIssuer parseMVCommandIssuer(BukkitCommandExecutionContext context) {
|
||||
if (context.getIssuer() instanceof MVCommandIssuer) {
|
||||
return (MVCommandIssuer) context.getIssuer();
|
||||
}
|
||||
return mvCommandManager.getCommandIssuer(context.getSender());
|
||||
}
|
||||
|
||||
private ContentFilter parseContentFilter(BukkitCommandExecutionContext context) {
|
||||
if (Strings.isNullOrEmpty(context.getFirstArg())) {
|
||||
return DefaultContentFilter.get();
|
||||
}
|
||||
String filterString = context.popFirstArg();
|
||||
return RegexContentFilter.fromString(filterString);
|
||||
}
|
||||
|
||||
private ParsedDestination<?> parseDestination(BukkitCommandExecutionContext context) {
|
||||
String destination = context.popFirstArg();
|
||||
if (Strings.isNullOrEmpty(destination)) {
|
||||
throw new InvalidCommandArgument("No destination specified.");
|
||||
}
|
||||
|
||||
ParsedDestination<?> parsedDestination = destinationsProvider.parseDestination(destination);
|
||||
if (parsedDestination == null) {
|
||||
throw new InvalidCommandArgument("The destination " + destination + " is not valid.");
|
||||
}
|
||||
|
||||
return parsedDestination;
|
||||
}
|
||||
|
||||
private GameRule<?> parseGameRule(BukkitCommandExecutionContext context) {
|
||||
String gameRuleName = context.popFirstArg();
|
||||
if (Strings.isNullOrEmpty(gameRuleName)) {
|
||||
throw new InvalidCommandArgument("No game rule specified.");
|
||||
}
|
||||
|
||||
GameRule<?> gameRule = GameRule.getByName(gameRuleName);
|
||||
if (gameRule == null) {
|
||||
throw new InvalidCommandArgument("The game rule " + gameRuleName + " is not valid.");
|
||||
}
|
||||
|
||||
return gameRule;
|
||||
}
|
||||
|
||||
private GameRuleValue parseGameRuleValue(BukkitCommandExecutionContext context) {
|
||||
GameRule<?> gameRule = (GameRule<?>) context.getResolvedArg(GameRule.class);
|
||||
if (gameRule == null) {
|
||||
throw new InvalidCommandArgument("No game rule specified.");
|
||||
}
|
||||
String valueString = context.getFirstArg();
|
||||
if (Strings.isNullOrEmpty(valueString)) {
|
||||
throw new InvalidCommandArgument("No game rule value specified.");
|
||||
}
|
||||
|
||||
ContextResolver<?, BukkitCommandExecutionContext> resolver = getResolver(gameRule.getType());
|
||||
if (resolver == null) {
|
||||
return new GameRuleValue(valueString);
|
||||
}
|
||||
|
||||
Object resolvedValue = resolver.getContext(context);
|
||||
if (resolvedValue == null) {
|
||||
throw new InvalidCommandArgument("The game rule value " + valueString + " is not valid for game rule " + gameRule.getName() + ".");
|
||||
}
|
||||
|
||||
return new GameRuleValue(resolvedValue);
|
||||
}
|
||||
|
||||
private MVConfigValue parseMVConfigValue(BukkitCommandExecutionContext context) {
|
||||
String configName = (String) context.getResolvedArg(String.class);
|
||||
if (Strings.isNullOrEmpty(configName)) {
|
||||
throw new InvalidCommandArgument("No config name specified.");
|
||||
}
|
||||
Option<Node> node = config.getNodes().findNode(configName);
|
||||
if (node.isEmpty()) {
|
||||
throw new InvalidCommandArgument("The config " + configName + " is not valid.");
|
||||
}
|
||||
|
||||
String valueString = context.getFirstArg();
|
||||
if (Strings.isNullOrEmpty(valueString)) {
|
||||
throw new InvalidCommandArgument("No config value specified.");
|
||||
}
|
||||
|
||||
if (!(node.get() instanceof ValueNode)) {
|
||||
context.popFirstArg();
|
||||
return new MVConfigValue(valueString);
|
||||
}
|
||||
|
||||
ContextResolver<?, BukkitCommandExecutionContext> resolver = getResolver(((ValueNode<?>) node.get()).getType());
|
||||
if (resolver == null) {
|
||||
context.popFirstArg();
|
||||
return new MVConfigValue(valueString);
|
||||
}
|
||||
|
||||
Object resolvedValue = resolver.getContext(context);
|
||||
if (resolvedValue == null) {
|
||||
throw new InvalidCommandArgument("The config value " + valueString + " is not valid for config " + configName + ".");
|
||||
}
|
||||
return new MVConfigValue(resolvedValue);
|
||||
}
|
||||
|
||||
private MVWorld parseMVWorld(BukkitCommandExecutionContext context) {
|
||||
String resolve = context.getFlagValue("resolve", "");
|
||||
|
||||
// Get world based on sender only
|
||||
if (resolve.equals("issuerOnly")) {
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
return worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld());
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("This command can only be used by a player in a Multiverse World.");
|
||||
}
|
||||
|
||||
String worldName = context.getFirstArg();
|
||||
MVWorld world = worldManager.getMVWorld(worldName);
|
||||
|
||||
// Get world based on input, fallback to sender if input is not a world
|
||||
if (resolve.equals("issuerAware")) {
|
||||
if (world != null) {
|
||||
context.popFirstArg();
|
||||
return world;
|
||||
}
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
return worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld());
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("Player is not in a Multiverse World.");
|
||||
}
|
||||
|
||||
// Get world based on input only
|
||||
if (world != null) {
|
||||
context.popFirstArg();
|
||||
return world;
|
||||
}
|
||||
if (!context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("World " + worldName + " is not a loaded multiverse world.");
|
||||
}
|
||||
|
||||
private MVWorld[] parseMVWorldArray(BukkitCommandExecutionContext context) {
|
||||
String resolve = context.getFlagValue("resolve", "");
|
||||
|
||||
MVWorld playerWorld = null;
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
playerWorld = worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld());
|
||||
}
|
||||
|
||||
// Get world based on sender only
|
||||
if (resolve.equals("issuerOnly")) {
|
||||
if (playerWorld != null) {
|
||||
return new MVWorld[]{playerWorld};
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("This command can only be used by a player in a Multiverse World.");
|
||||
}
|
||||
|
||||
String worldStrings = context.getFirstArg();
|
||||
String[] worldNames = worldStrings.split(",");
|
||||
Set<MVWorld> worlds = new HashSet<>(worldNames.length);
|
||||
for (String worldName : worldNames) {
|
||||
if ("*".equals(worldName)) {
|
||||
worlds.addAll(worldManager.getMVWorlds());
|
||||
break;
|
||||
}
|
||||
MVWorld world = worldManager.getMVWorld(worldName);
|
||||
if (world == null) {
|
||||
throw new InvalidCommandArgument("World " + worldName + " is not a loaded multiverse world.");
|
||||
}
|
||||
worlds.add(world);
|
||||
}
|
||||
|
||||
// Get world based on input, fallback to sender if input is not a world
|
||||
if (resolve.equals("issuerAware")) {
|
||||
if (!worlds.isEmpty()) {
|
||||
context.popFirstArg();
|
||||
return worlds.toArray(new MVWorld[0]);
|
||||
}
|
||||
if (playerWorld != null) {
|
||||
return new MVWorld[]{playerWorld};
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("Player is not in a Multiverse World.");
|
||||
}
|
||||
|
||||
// Get world based on input only
|
||||
if (!worlds.isEmpty()) {
|
||||
context.popFirstArg();
|
||||
return worlds.toArray(new MVWorld[0]);
|
||||
}
|
||||
if (!context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("World " + worldStrings + " is not a loaded multiverse world.");
|
||||
}
|
||||
|
||||
private Player parsePlayer(BukkitCommandExecutionContext context) {
|
||||
String resolve = context.getFlagValue("resolve", "");
|
||||
|
||||
// Get player based on sender only
|
||||
if (resolve.equals("issuerOnly")) {
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
return context.getIssuer().getPlayer();
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("This command can only be used by a player.");
|
||||
}
|
||||
|
||||
String playerIdentifier = context.getFirstArg();
|
||||
Player player = PlayerFinder.get(playerIdentifier, context.getSender());
|
||||
|
||||
// Get player based on input, fallback to sender if input is not a player
|
||||
if (resolve.equals("issuerAware")) {
|
||||
if (player != null) {
|
||||
context.popFirstArg();
|
||||
return player;
|
||||
}
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
return context.getIssuer().getPlayer();
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("Invalid player: " + playerIdentifier
|
||||
+ ". Either specify an online player or use this command as a player.");
|
||||
}
|
||||
|
||||
// Get player based on input only
|
||||
if (player != null) {
|
||||
context.popFirstArg();
|
||||
return player;
|
||||
}
|
||||
if (!context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("Player " + playerIdentifier + " not found.");
|
||||
}
|
||||
|
||||
|
||||
private Player[] parsePlayerArray(BukkitCommandExecutionContext context) {
|
||||
String resolve = context.getFlagValue("resolve", "");
|
||||
|
||||
// Get player based on sender only
|
||||
if (resolve.equals("issuerOnly")) {
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
return new Player[]{context.getIssuer().getPlayer()};
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("This command can only be used by a player.");
|
||||
}
|
||||
|
||||
String playerIdentifier = context.getFirstArg();
|
||||
Player[] players = PlayerFinder.getMulti(playerIdentifier, context.getSender()).toArray(new Player[0]);
|
||||
|
||||
// Get player based on input, fallback to sender if input is not a player
|
||||
if (resolve.equals("issuerAware")) {
|
||||
if (players.length > 0) {
|
||||
context.popFirstArg();
|
||||
return players;
|
||||
}
|
||||
if (context.getIssuer().isPlayer()) {
|
||||
return new Player[]{context.getIssuer().getPlayer()};
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("Invalid player: " + playerIdentifier
|
||||
+ ". Either specify an online player or use this command as a player.");
|
||||
}
|
||||
|
||||
// Get player based on input only
|
||||
if (players.length > 0) {
|
||||
context.popFirstArg();
|
||||
return players;
|
||||
}
|
||||
if (!context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("Player " + playerIdentifier + " not found.");
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.MessageType;
|
||||
import co.aikar.commands.OpenBukkitCommandIssuer;
|
||||
import co.aikar.locales.MessageKeyProvider;
|
||||
import com.onarandombox.MultiverseCore.utils.message.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MVCommandIssuer extends OpenBukkitCommandIssuer {
|
||||
|
||||
private final MVCommandManager commandManager;
|
||||
|
||||
MVCommandIssuer(@NotNull MVCommandManager commandManager, @NotNull CommandSender sender) {
|
||||
super(commandManager, sender);
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MVCommandManager getManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public void sendError(Message message) {
|
||||
sendMessage(MessageType.ERROR, message);
|
||||
}
|
||||
|
||||
public void sendSyntax(Message message) {
|
||||
sendMessage(MessageType.SYNTAX, message);
|
||||
}
|
||||
|
||||
public void sendInfo(Message message) {
|
||||
sendMessage(MessageType.INFO, message);
|
||||
}
|
||||
|
||||
private void sendMessage(MessageType messageType, Message message) {
|
||||
if (message instanceof MessageKeyProvider) {
|
||||
sendMessage(messageType, (MessageKeyProvider) message, message.getReplacements());
|
||||
} else {
|
||||
var formatter = getManager().getFormat(messageType);
|
||||
if (formatter != null) {
|
||||
sendMessage(formatter.format(message.formatted()));
|
||||
} else {
|
||||
sendMessage(message.formatted());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitLocales;
|
||||
import co.aikar.commands.CommandCompletions;
|
||||
import co.aikar.commands.CommandContexts;
|
||||
import co.aikar.commands.CommandHelp;
|
||||
import co.aikar.commands.HelpEntry;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Provider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Main class to manage permissions.
|
||||
*/
|
||||
@Service
|
||||
public class MVCommandManager extends PaperCommandManager {
|
||||
|
||||
private final CommandFlagsManager flagsManager;
|
||||
private final CommandQueueManager commandQueueManager;
|
||||
private final Provider<MVCommandContexts> commandContextsProvider;
|
||||
private final Provider<MVCommandCompletions> commandCompletionsProvider;
|
||||
|
||||
@Inject
|
||||
public MVCommandManager(
|
||||
@NotNull MultiverseCore plugin,
|
||||
@NotNull CommandFlagsManager flagsManager,
|
||||
@NotNull CommandQueueManager commandQueueManager,
|
||||
@NotNull Provider<MVCommandContexts> commandContextsProvider,
|
||||
@NotNull Provider<MVCommandCompletions> commandCompletionsProvider,
|
||||
@NotNull MVWorldManager worldManager
|
||||
) {
|
||||
super(plugin);
|
||||
this.flagsManager = flagsManager;
|
||||
this.commandQueueManager = commandQueueManager;
|
||||
this.commandContextsProvider = commandContextsProvider;
|
||||
this.commandCompletionsProvider = commandCompletionsProvider;
|
||||
|
||||
MVCommandConditions.load(this, worldManager);
|
||||
this.enableUnstableAPI("help");
|
||||
}
|
||||
|
||||
void loadLanguages(PluginLocales locales) {
|
||||
if (this.locales == null) {
|
||||
this.locales = locales;
|
||||
this.locales.loadLanguages();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitLocales getLocales() {
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class responsible for flag handling.
|
||||
*
|
||||
* @return A not-null {@link CommandFlagsManager}.
|
||||
*/
|
||||
public synchronized @NotNull CommandFlagsManager getFlagsManager() {
|
||||
return flagsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manager for command that requires /mv confirm before execution.
|
||||
*
|
||||
* @return A non-null {@link CommandQueueManager}.
|
||||
*/
|
||||
public synchronized @NotNull CommandQueueManager getCommandQueueManager() {
|
||||
return commandQueueManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class responsible for parsing string args into objects.
|
||||
*
|
||||
* @return A not-null {@link CommandContexts}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized @NotNull CommandContexts<BukkitCommandExecutionContext> getCommandContexts() {
|
||||
if (this.contexts == null) {
|
||||
this.contexts = commandContextsProvider.get();
|
||||
}
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class responsible for tab-completion handling.
|
||||
*
|
||||
* @return A not-null {@link CommandCompletions}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized @NotNull CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() {
|
||||
if (this.completions == null) {
|
||||
this.completions = commandCompletionsProvider.get();
|
||||
}
|
||||
return this.completions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standardise usage command formatting for all mv modules.
|
||||
*
|
||||
* @param help The target {@link CommandHelp}.
|
||||
*/
|
||||
public void showUsage(@NotNull CommandHelp help) {
|
||||
List<HelpEntry> entries = help.getHelpEntries();
|
||||
if (entries.size() == 1) {
|
||||
getHelpFormatter().showDetailedHelp(help, entries.get(0));
|
||||
return;
|
||||
}
|
||||
help.showHelp();
|
||||
}
|
||||
|
||||
public @NotNull MVCommandIssuer getConsoleCommandIssuer() {
|
||||
return getCommandIssuer(Bukkit.getConsoleSender());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull MVCommandIssuer getCommandIssuer(Object issuer) {
|
||||
if (!(issuer instanceof CommandSender)) {
|
||||
throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer.");
|
||||
} else {
|
||||
return new MVCommandIssuer(this, (CommandSender)issuer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public abstract class MultiverseCommand extends BaseCommand {
|
||||
|
||||
protected final MVCommandManager commandManager;
|
||||
private String flagGroupName;
|
||||
|
||||
protected MultiverseCommand(@NotNull MVCommandManager commandManager) {
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
protected CommandFlagsManager getFlagsManager() {
|
||||
return commandManager.getFlagsManager();
|
||||
}
|
||||
|
||||
protected void registerFlagGroup(@NotNull CommandFlagGroup flagGroup) {
|
||||
if (flagGroupName != null) {
|
||||
throw new IllegalStateException("Flag group already registered! (name: " + flagGroupName + ")");
|
||||
}
|
||||
getFlagsManager().registerFlagGroup(flagGroup);
|
||||
flagGroupName = flagGroup.getName();
|
||||
}
|
||||
|
||||
protected @NotNull ParsedCommandFlags parseFlags(@NotNull String[] flags) {
|
||||
return getFlagsManager().parse(flagGroupName, flags);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BukkitLocales;
|
||||
import com.onarandombox.MultiverseCore.utils.file.FileResClassLoader;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Locale manager with additional methods for loading locales from plugin's locales folder.
|
||||
*/
|
||||
@Service
|
||||
public class PluginLocales extends BukkitLocales {
|
||||
|
||||
private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales";
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link PluginLocales}.
|
||||
*
|
||||
* @param manager The command manager.
|
||||
*/
|
||||
@Inject
|
||||
public PluginLocales(MVCommandManager manager) {
|
||||
super(manager);
|
||||
manager.loadLanguages(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from.
|
||||
*
|
||||
* @param plugin The plugin.
|
||||
* @return True if the class loader was added successfully.
|
||||
*/
|
||||
public boolean addFileResClassLoader(@NotNull Plugin plugin) {
|
||||
return this.addBundleClassLoader(new FileResClassLoader(plugin, DEFAULT_LOCALE_FOLDER_PATH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from.
|
||||
*
|
||||
* @param plugin The plugin.
|
||||
* @param localesFolderPath The path to the folder containing the locales.
|
||||
* @return True if the class loader was added successfully.
|
||||
*/
|
||||
public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) {
|
||||
return this.addBundleClassLoader(new FileResClassLoader(plugin, localesFolderPath));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.context;
|
||||
|
||||
public class GameRuleValue {
|
||||
private final Object value;
|
||||
|
||||
public GameRuleValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.context;
|
||||
|
||||
public class MVConfigValue {
|
||||
private final Object value;
|
||||
|
||||
public MVConfigValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a flag.
|
||||
*/
|
||||
public class CommandFlag {
|
||||
/**
|
||||
* A builder for a flag.
|
||||
*
|
||||
* @param key The key for the new flag.
|
||||
* @return The builder.
|
||||
*/
|
||||
public static @NotNull Builder<?> builder(@NotNull String key){
|
||||
return new Builder<>(key);
|
||||
}
|
||||
|
||||
private final String key;
|
||||
private final List<String> aliases;
|
||||
|
||||
/**
|
||||
* Creates a new flag.
|
||||
*
|
||||
* @param builder The builder.
|
||||
*/
|
||||
protected CommandFlag(@NotNull Builder<?> builder) {
|
||||
key = builder.key;
|
||||
aliases = builder.aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key of this flag.
|
||||
*
|
||||
* @return The key of this flag.
|
||||
*/
|
||||
public @NotNull String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aliases of this flag.
|
||||
*
|
||||
* @return The aliases of this flag.
|
||||
*/
|
||||
public @NotNull List<String> getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a flag.
|
||||
*
|
||||
* @param <S> The type of the builder.
|
||||
*/
|
||||
public static class Builder<S extends Builder<?>> {
|
||||
private final String key;
|
||||
private final List<String> aliases;
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
*
|
||||
* @param key The key for the new flag.
|
||||
*/
|
||||
public Builder(@NotNull String key) {
|
||||
this.key = key;
|
||||
aliases = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one or more alias to the flag.
|
||||
*
|
||||
* @param alias The alias to add.
|
||||
* @return The builder.
|
||||
*/
|
||||
public @NotNull S addAlias(@NotNull String...alias){
|
||||
Collections.addAll(this.aliases, alias);
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the flag.
|
||||
*
|
||||
* @return The flag.
|
||||
*/
|
||||
public @NotNull CommandFlag build(){
|
||||
return new CommandFlag(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A group of flags.
|
||||
*/
|
||||
public class CommandFlagGroup {
|
||||
/**
|
||||
* A builder for a flag group.
|
||||
*
|
||||
* @param name The name of the group.
|
||||
* @return The builder.
|
||||
*/
|
||||
public static @NotNull Builder builder(@NotNull String name) {
|
||||
return new Builder(name);
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final List<String> keys;
|
||||
private final Map<String, CommandFlag> keysFlagMap;
|
||||
|
||||
/**
|
||||
* Creates a new flag group.
|
||||
*
|
||||
* @param builder The builder.
|
||||
*/
|
||||
protected CommandFlagGroup(@NotNull Builder builder) {
|
||||
name = builder.name;
|
||||
keys = builder.keys;
|
||||
keysFlagMap = builder.keysFlagMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this group.
|
||||
*
|
||||
* @return The name of this group.
|
||||
*/
|
||||
public @NotNull String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this group contains a flag with the given key. Works with alias keys.
|
||||
*
|
||||
* @param key The key to check.
|
||||
* @return True if the group contains a flag with the given key, false otherwise.
|
||||
*/
|
||||
public boolean hasKey(@Nullable String key) {
|
||||
return keysFlagMap.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remaining keys after the given flags have been removed. Works with alias keys.
|
||||
*
|
||||
* @param flags The flags to remove.
|
||||
* @return The remaining keys.
|
||||
*/
|
||||
public @NotNull Set<String> getRemainingKeys(@NotNull String[] flags) {
|
||||
Set<String> keysRemaining = new HashSet<>(this.keys);
|
||||
for (String flag : flags) {
|
||||
CommandFlag mvFlag = this.getFlagByKey(flag);
|
||||
if (mvFlag != null) {
|
||||
keysRemaining.remove(mvFlag.getKey());
|
||||
}
|
||||
}
|
||||
return keysRemaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a flag by its key. Alias keys are supported as well.
|
||||
*
|
||||
* @param key The key of the flag.
|
||||
* @return The flag if found, null otherwise.
|
||||
*/
|
||||
public @Nullable CommandFlag getFlagByKey(String key) {
|
||||
return keysFlagMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link CommandFlagGroup}.
|
||||
*/
|
||||
public static class Builder {
|
||||
private final String name;
|
||||
private final List<String> keys;
|
||||
private final Map<String, CommandFlag> keysFlagMap;
|
||||
|
||||
/**
|
||||
* Creates a new builder.
|
||||
*
|
||||
* @param name The name of the flag group.
|
||||
*/
|
||||
public Builder(@NotNull String name) {
|
||||
this.name = name;
|
||||
this.keys = new ArrayList<>();
|
||||
this.keysFlagMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a flag to the group.
|
||||
*
|
||||
* @param flag The flag to add.
|
||||
* @return The builder.
|
||||
*/
|
||||
public @NotNull Builder add(CommandFlag flag) {
|
||||
keys.add(flag.getKey());
|
||||
keysFlagMap.put(flag.getKey(), flag);
|
||||
flag.getAliases().forEach((alias) -> keysFlagMap.put(alias, flag));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the flag group.
|
||||
*
|
||||
* @return The flag group.
|
||||
*/
|
||||
public @NotNull CommandFlagGroup build() {
|
||||
return new CommandFlagGroup(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Manages all the flag groups and parsing.
|
||||
*/
|
||||
@Service
|
||||
public class CommandFlagsManager {
|
||||
private final Map<String, CommandFlagGroup> flagGroupMap;
|
||||
|
||||
/**
|
||||
* Creates a new FlagsManager.
|
||||
*/
|
||||
public CommandFlagsManager() {
|
||||
flagGroupMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a flag group.
|
||||
*
|
||||
* @param flagGroup The target flag group to register.
|
||||
*/
|
||||
public void registerFlagGroup(@NotNull CommandFlagGroup flagGroup) {
|
||||
flagGroupMap.put(flagGroup.getName(), flagGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a flag group by name.
|
||||
*
|
||||
* @param groupName The target flag group name.
|
||||
* @return The flag group if found, null otherwise.
|
||||
*/
|
||||
public @Nullable CommandFlagGroup getFlagGroup(@Nullable String groupName) {
|
||||
return this.flagGroupMap.get(groupName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Autocompletes suggestions for flags.
|
||||
*
|
||||
* @param groupName The target flag group name.
|
||||
* @param flags The current flags so far.
|
||||
* @return The list of suggestions.
|
||||
*/
|
||||
public @NotNull Collection<String> suggest(@Nullable String groupName, @NotNull String[] flags) {
|
||||
CommandFlagGroup flagGroup = this.getFlagGroup(groupName);
|
||||
if (flagGroup == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Collection<String> suggestions = new ArrayList<>();
|
||||
CommandFlag currentFlag = (flags.length <= 1) ? null : flagGroup.getFlagByKey(flags[flags.length - 2]);
|
||||
|
||||
if (currentFlag instanceof CommandValueFlag) {
|
||||
CommandValueFlag<?> valueFlag = (CommandValueFlag<?>) currentFlag;
|
||||
if (valueFlag.getCompletion() != null) {
|
||||
suggestions.addAll(valueFlag.getCompletion().get());
|
||||
}
|
||||
if (valueFlag.isOptional()) {
|
||||
suggestions.addAll(flagGroup.getRemainingKeys(flags));
|
||||
}
|
||||
} else {
|
||||
suggestions.addAll(flagGroup.getRemainingKeys(flags));
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the flags.
|
||||
*
|
||||
* @param groupName The target flag group name.
|
||||
* @param flags The flags to parse.
|
||||
* @return The parsed flags.
|
||||
*
|
||||
* @throws InvalidCommandArgument If the flags are invalid.
|
||||
*/
|
||||
public @NotNull ParsedCommandFlags parse(@Nullable String groupName, @NotNull String[] flags) {
|
||||
CommandFlagGroup flagGroup = this.getFlagGroup(groupName);
|
||||
if (flagGroup == null) {
|
||||
return ParsedCommandFlags.EMPTY;
|
||||
}
|
||||
|
||||
return new CommandFlagsParser(this.getFlagGroup(groupName), flags).parse();
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
|
||||
/**
|
||||
* Parses flags from a string array. Each parser should only be used once.
|
||||
*/
|
||||
public class CommandFlagsParser {
|
||||
private final CommandFlagGroup flagGroup;
|
||||
private final String[] flags;
|
||||
|
||||
private ParsedCommandFlags parsedFlags;
|
||||
private boolean nextArgMayBeKey;
|
||||
private boolean nextArgMayBeValue;
|
||||
private CommandFlag currentFlag;
|
||||
|
||||
/**
|
||||
* Creates a new CommandFlagsParser.
|
||||
*
|
||||
* @param flagGroup The flag group to parse flags for.
|
||||
* @param flags The flags to parse.
|
||||
*/
|
||||
public CommandFlagsParser(CommandFlagGroup flagGroup, String[] flags) {
|
||||
this.flagGroup = flagGroup;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the flags.
|
||||
*
|
||||
* @return The parsed flags.
|
||||
*/
|
||||
public ParsedCommandFlags parse() {
|
||||
parsedFlags = new ParsedCommandFlags();
|
||||
|
||||
// First argument is always a key
|
||||
this.nextArgMayBeKey = true;
|
||||
this.nextArgMayBeValue = false;
|
||||
|
||||
for (String flag : flags) {
|
||||
if (this.nextArgMayBeKey) {
|
||||
if (parseKey(flag)) continue;
|
||||
}
|
||||
if (this.nextArgMayBeValue) {
|
||||
if (parseValue(flag)) continue;
|
||||
}
|
||||
throw new InvalidCommandArgument(flag + " is not a valid flag.");
|
||||
}
|
||||
|
||||
if (!this.nextArgMayBeKey && this.nextArgMayBeValue) {
|
||||
throw new InvalidCommandArgument(currentFlag.getKey() + " requires a value!");
|
||||
}
|
||||
|
||||
return parsedFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a key.
|
||||
*
|
||||
* @param flag The flag to parse.
|
||||
* @return True if the flag was parsed as a key, false otherwise.
|
||||
*/
|
||||
private boolean parseKey(String flag) {
|
||||
CommandFlag potentialFlag = flagGroup.getFlagByKey(flag);
|
||||
if (potentialFlag == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.currentFlag = potentialFlag;
|
||||
|
||||
if (this.currentFlag instanceof CommandValueFlag) {
|
||||
CommandValueFlag<?> valueFlag = (CommandValueFlag<?>) this.currentFlag;
|
||||
|
||||
if (valueFlag.isOptional()) {
|
||||
parsedFlags.addFlagResult(valueFlag.getKey(), valueFlag.getDefaultValue());
|
||||
this.nextArgMayBeKey = true;
|
||||
this.nextArgMayBeValue = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
this.nextArgMayBeKey = false;
|
||||
this.nextArgMayBeValue = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
parsedFlags.addFlagResult(this.currentFlag.getKey(), null);
|
||||
this.nextArgMayBeKey = true;
|
||||
this.nextArgMayBeValue = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a value.
|
||||
*
|
||||
* @param flag The flag to parse.
|
||||
* @return True if the flag was parsed as a value, false otherwise.
|
||||
*/
|
||||
private boolean parseValue(String flag) {
|
||||
if (this.currentFlag == null) {
|
||||
throw new InvalidCommandArgument("Some flag logic error occurred at " + flag + "");
|
||||
}
|
||||
if (flagGroup.hasKey(flag)) {
|
||||
throw new InvalidCommandArgument(currentFlag.getKey() + " requires a value!");
|
||||
}
|
||||
|
||||
Object flagValue;
|
||||
CommandValueFlag<?> valueFlag = (CommandValueFlag<?>) this.currentFlag;
|
||||
flagValue = valueFlag.getContext() != null ? valueFlag.getContext().apply(flag) : flag;
|
||||
parsedFlags.addFlagResult(valueFlag.getKey(), flagValue);
|
||||
|
||||
// After a value, the next argument must be a key
|
||||
this.nextArgMayBeKey = true;
|
||||
this.nextArgMayBeValue = false;
|
||||
this.currentFlag = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a flag with a value.
|
||||
*
|
||||
* @param <T> The type of the value.
|
||||
*/
|
||||
public class CommandValueFlag<T> extends CommandFlag {
|
||||
/**
|
||||
* A builder for a flag.
|
||||
*
|
||||
* @param key The key for the new flag.
|
||||
* @param type The type of the value.
|
||||
* @return The builder.
|
||||
*/
|
||||
public static @NotNull <T> Builder<T, ?> builder(@NotNull String key, @NotNull Class<T> type) {
|
||||
return new Builder<>(key, type);
|
||||
}
|
||||
|
||||
private final Class<T> type;
|
||||
private final boolean optional;
|
||||
private final T defaultValue;
|
||||
private final Function<String, T> context;
|
||||
private final Supplier<Collection<String>> completion;
|
||||
|
||||
/**
|
||||
* Creates a new flag.
|
||||
*
|
||||
* @param builder The builder.
|
||||
*/
|
||||
protected CommandValueFlag(@NotNull Builder<T, ?> builder) {
|
||||
super(builder);
|
||||
type = builder.type;
|
||||
optional = builder.optional;
|
||||
defaultValue = builder.defaultValue;
|
||||
context = builder.context;
|
||||
completion = builder.completion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the value.
|
||||
*
|
||||
* @return The type of the value.
|
||||
*/
|
||||
public @NotNull Class<T> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it is optional for users to specify a value.
|
||||
*
|
||||
* @return True if the value is optional, false otherwise.
|
||||
*/
|
||||
public boolean isOptional() {
|
||||
return optional;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value. May be null.
|
||||
*
|
||||
* @return The default value.
|
||||
*/
|
||||
public @Nullable T getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context. May be null for {@link String} value type.
|
||||
*
|
||||
* @return The context.
|
||||
*/
|
||||
public @Nullable Function<String, T> getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the completion. May be null.
|
||||
*
|
||||
* @return The completion.
|
||||
*/
|
||||
public @Nullable Supplier<Collection<String>> getCompletion() {
|
||||
return completion;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a flag.
|
||||
*
|
||||
* @param <T> The type of the value.
|
||||
* @param <S> The type of the builder.
|
||||
*/
|
||||
public static class Builder<T, S extends Builder<T, S>> extends CommandFlag.Builder<S> {
|
||||
private final Class<T> type;
|
||||
private boolean optional = false;
|
||||
private T defaultValue = null;
|
||||
private Function<String, T> context = null;
|
||||
private Supplier<Collection<String>> completion = null;
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
*
|
||||
* @param key The key for the new flag.
|
||||
* @param type The type of the value.
|
||||
*/
|
||||
public Builder(@NotNull String key, @NotNull Class<T> type) {
|
||||
super(key);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the flag as optional for users to specify a value.
|
||||
*
|
||||
* @return The builder.
|
||||
*/
|
||||
public @NotNull S optional() {
|
||||
this.optional = true;
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default value. Used if optional is true and user does not specify a value.
|
||||
*
|
||||
* @param defaultValue The default value.
|
||||
* @return The builder.
|
||||
*/
|
||||
public @NotNull S defaultValue(@NotNull T defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the context callback for parsing string into value type.
|
||||
*
|
||||
* @param context The context.
|
||||
* @return The builder.
|
||||
*/
|
||||
public @NotNull S context(@NotNull Function<String, T> context) {
|
||||
this.context = context;
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the completion callback for autocomplete.
|
||||
*
|
||||
* @param completion The completion.
|
||||
* @return The builder.
|
||||
*/
|
||||
public @NotNull S completion(@NotNull Supplier<Collection<String>> completion) {
|
||||
this.completion = completion;
|
||||
return (S) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the flag.
|
||||
*
|
||||
* @return The flag.
|
||||
*/
|
||||
@Override
|
||||
public @NotNull CommandFlag build() {
|
||||
if (context == null && !String.class.equals(type)) {
|
||||
throw new IllegalStateException("Context is required for none-string value flags");
|
||||
}
|
||||
return new CommandValueFlag<>(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Object to contain the results of the flags present and its values.
|
||||
*/
|
||||
public class ParsedCommandFlags
|
||||
{
|
||||
public static final ParsedCommandFlags EMPTY = new ParsedCommandFlags();
|
||||
|
||||
private final Map<String, Object> flagValues;
|
||||
|
||||
public ParsedCommandFlags() {
|
||||
flagValues = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a flag result to the parsed flags.
|
||||
*
|
||||
* @param key The key of the flag.
|
||||
* @param value The value of the flag.
|
||||
*/
|
||||
void addFlagResult(@NotNull String key, @Nullable Object value) {
|
||||
flagValues.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a flag is present.
|
||||
*
|
||||
* @param key The key of the flag.
|
||||
* @return True if the flag is present, false otherwise.
|
||||
*/
|
||||
public boolean hasFlag(@Nullable String key) {
|
||||
return this.flagValues.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean hasFlagValue(@Nullable String key) {
|
||||
return flagValue(key, Object.class) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a flag.
|
||||
*
|
||||
* @param key The key of the flag.
|
||||
* @return The value of the flag, null if flag does not exist or no value.
|
||||
*/
|
||||
public @Nullable <T> T flagValue(@Nullable String key, @NotNull Class<T> type) {
|
||||
Object value = this.flagValues.get(key);
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public @NotNull <T> T flagValue(@Nullable String key, @NotNull T defaultValue, @NotNull Class<T> type) {
|
||||
T value = flagValue(key, type);
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* This package contains all the flags parsing classes.
|
||||
*
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commandtools.flags;
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* This package contains the classes that manages command handling.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
@@ -1,166 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools.queue;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.data.type.CommandBlock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* <p>Manages the queuing of dangerous commands that require {@code /mv confirm} before executing.</p>
|
||||
*
|
||||
* <p>Each sender can only have one command in queue at any given time. When a queued command is added
|
||||
* for a sender that already has a command in queue, it will replace the old queued command.</p>
|
||||
*/
|
||||
@Service
|
||||
public class CommandQueueManager {
|
||||
|
||||
private static final long TICKS_PER_SECOND = 20;
|
||||
private static final DummyCommandBlockSender COMMAND_BLOCK = new DummyCommandBlockSender();
|
||||
|
||||
private final Plugin plugin;
|
||||
private final Map<CommandSender, QueuedCommand> queuedCommandMap;
|
||||
|
||||
@Inject
|
||||
public CommandQueueManager(@NotNull MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.queuedCommandMap = new WeakHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link QueuedCommand} into queue.
|
||||
*
|
||||
* @param queuedCommand The queued command to add.
|
||||
*/
|
||||
public void addToQueue(QueuedCommand queuedCommand) {
|
||||
CommandSender targetSender = parseSender(queuedCommand.getSender());
|
||||
|
||||
// Since only one command is stored in queue per sender, we remove the old one.
|
||||
this.removeFromQueue(targetSender);
|
||||
|
||||
Logging.finer("Add new command to queue for sender %s.", targetSender.getName());
|
||||
this.queuedCommandMap.put(targetSender, queuedCommand);
|
||||
queuedCommand.setExpireTask(runExpireLater(queuedCommand));
|
||||
|
||||
queuedCommand.getSender().sendMessage(queuedCommand.getPrompt());
|
||||
queuedCommand.getSender().sendMessage(String.format("Run %s/mv confirm %sto continue. This will expire in %s seconds.",
|
||||
ChatColor.GREEN, ChatColor.WHITE, queuedCommand.getValidDuration()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Expire task that removes a {@link QueuedCommand} from queue after valid duration defined.
|
||||
*
|
||||
* @param queuedCommand Command to run the expire task on.
|
||||
* @return The expire {@link BukkitTask}.
|
||||
*/
|
||||
@NotNull
|
||||
private BukkitTask runExpireLater(@NotNull QueuedCommand queuedCommand) {
|
||||
return Bukkit.getScheduler().runTaskLater(
|
||||
this.plugin,
|
||||
expireRunnable(queuedCommand),
|
||||
queuedCommand.getValidDuration() * TICKS_PER_SECOND
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable responsible for expiring the queued command.
|
||||
*
|
||||
* @param queuedCommand Command to create the expire task on.
|
||||
* @return The expire runnable.
|
||||
*/
|
||||
@NotNull
|
||||
private Runnable expireRunnable(@NotNull QueuedCommand queuedCommand) {
|
||||
return () -> {
|
||||
CommandSender targetSender = parseSender(queuedCommand.getSender());
|
||||
QueuedCommand matchingQueuedCommand = this.queuedCommandMap.get(targetSender);
|
||||
if (!queuedCommand.equals(matchingQueuedCommand) || queuedCommand.getExpireTask().isCancelled()) {
|
||||
// To be safe, but this shouldn't happen since we cancel old commands before add new once.
|
||||
Logging.finer("This is an old queue command already.");
|
||||
return;
|
||||
}
|
||||
queuedCommand.getSender().sendMessage("Your queued command has expired.");
|
||||
this.queuedCommandMap.remove(queuedCommand.getSender());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the command in queue for the given sender, if any.
|
||||
*
|
||||
* @param sender {@link CommandSender} that confirmed the command.
|
||||
* @return True if queued command ran successfully, else false.
|
||||
*/
|
||||
public boolean runQueuedCommand(@NotNull CommandSender sender) {
|
||||
CommandSender targetSender = parseSender(sender);
|
||||
QueuedCommand queuedCommand = this.queuedCommandMap.get(targetSender);
|
||||
if (queuedCommand == null) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have any commands in queue.");
|
||||
return false;
|
||||
}
|
||||
Logging.finer("Running queued command...");
|
||||
queuedCommand.getAction().run();
|
||||
return removeFromQueue(targetSender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since only one command is stored in queue per sender, we remove the old one.
|
||||
*
|
||||
* @param sender The {@link CommandSender} that executed the command.
|
||||
* @return True if queue command is removed from sender successfully, else false.
|
||||
*/
|
||||
public boolean removeFromQueue(@NotNull CommandSender sender) {
|
||||
CommandSender targetSender = parseSender(sender);
|
||||
QueuedCommand previousCommand = this.queuedCommandMap.remove(targetSender);
|
||||
if (previousCommand == null) {
|
||||
Logging.finer("No queue command to remove for sender %s.", targetSender.getName());
|
||||
return false;
|
||||
}
|
||||
previousCommand.getExpireTask().cancel();
|
||||
Logging.finer("Removed queue command for sender %s.", targetSender.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* To allow all CommandBlocks to be a common sender with use of {@link DummyCommandBlockSender}.
|
||||
* So confirm command can be used for a queued command on another command block.
|
||||
*
|
||||
* @param sender The sender to parse.
|
||||
* @return The sender, or if its a command block, a {@link DummyCommandBlockSender}.
|
||||
*/
|
||||
@NotNull
|
||||
private CommandSender parseSender(@NotNull CommandSender sender) {
|
||||
Logging.finer("Sender is of class %s.", sender.getClass().getName());
|
||||
if (isCommandBlock(sender)) {
|
||||
Logging.finer("Is command block.");
|
||||
return COMMAND_BLOCK;
|
||||
}
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the sender is a command block.
|
||||
*
|
||||
* @param sender The sender to check.
|
||||
* @return True if sender is a command block, else false.
|
||||
*/
|
||||
private boolean isCommandBlock(@NotNull CommandSender sender) {
|
||||
return sender instanceof BlockCommandSender
|
||||
&& ((BlockCommandSender) sender).getBlock().getBlockData() instanceof CommandBlock;
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.queue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Used by {@link CommandQueueManager}, so different commands block can be recognised as one.
|
||||
*/
|
||||
class DummyCommandBlockSender implements CommandSender {
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull String message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull String[] messages) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@Nullable UUID uuid, @NotNull String s) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@Nullable UUID uuid, @NotNull String[] strings) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Server getServer() {
|
||||
return Bukkit.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return "DummyCommandBlockSender";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Spigot spigot() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(@NotNull String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(@NotNull Permission perm) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NotNull String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NotNull Permission perm) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(@NotNull PermissionAttachment attachment) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools.queue;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a single command used in {@link CommandQueueManager} for confirming before running potentially
|
||||
* dangerous action.
|
||||
*/
|
||||
public class QueuedCommand {
|
||||
|
||||
private static final String DEFAULT_PROMPT_MESSAGE = "The command you are trying to run is deemed dangerous.";
|
||||
private static final int DEFAULT_VALID_TIME = 10;
|
||||
|
||||
private final CommandSender sender;
|
||||
private final Runnable action;
|
||||
private final String prompt;
|
||||
private final int validDuration;
|
||||
private BukkitTask expireTask;
|
||||
|
||||
public QueuedCommand(BukkitCommandIssuer issuer, Runnable action) {
|
||||
this(issuer.getIssuer(), action, DEFAULT_PROMPT_MESSAGE, DEFAULT_VALID_TIME);
|
||||
}
|
||||
|
||||
public QueuedCommand(BukkitCommandIssuer issuer, Runnable action, String prompt) {
|
||||
this(issuer.getIssuer(), action, prompt, DEFAULT_VALID_TIME);
|
||||
}
|
||||
|
||||
public QueuedCommand(BukkitCommandIssuer issuer, Runnable action, int validDuration) {
|
||||
this(issuer.getIssuer(), action, DEFAULT_PROMPT_MESSAGE, validDuration);
|
||||
}
|
||||
|
||||
public QueuedCommand(CommandSender sender, Runnable action) {
|
||||
this(sender, action, DEFAULT_PROMPT_MESSAGE, DEFAULT_VALID_TIME);
|
||||
}
|
||||
|
||||
public QueuedCommand(CommandSender sender, Runnable action, String prompt) {
|
||||
this(sender, action, prompt, DEFAULT_VALID_TIME);
|
||||
}
|
||||
|
||||
public QueuedCommand(CommandSender sender, Runnable action, int validDuration) {
|
||||
this(sender, action, DEFAULT_PROMPT_MESSAGE, validDuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new queue command, to be registered at {@link CommandQueueManager#addToQueue(QueuedCommand)}.
|
||||
*
|
||||
* @param sender The sender that ran the command needed for confirmation.
|
||||
* @param action The logic to execute upon confirming.
|
||||
* @param prompt Question to ask sender to confirm.
|
||||
* @param validDuration Duration in which the command is valid for confirm in seconds.
|
||||
*/
|
||||
public QueuedCommand(CommandSender sender, Runnable action, String prompt, int validDuration) {
|
||||
this.sender = sender;
|
||||
this.action = action;
|
||||
this.prompt = prompt;
|
||||
this.validDuration = validDuration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
int getValidDuration() {
|
||||
return validDuration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
Runnable getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
BukkitTask getExpireTask() {
|
||||
return expireTask;
|
||||
}
|
||||
|
||||
void setExpireTask(@NotNull BukkitTask expireTask) {
|
||||
if (this.expireTask != null) {
|
||||
throw new IllegalStateException("This queue command already has an expire task. You can't register twice!");
|
||||
}
|
||||
this.expireTask = expireTask;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Manager queuing of dangerous commands in need of confirmation.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commandtools.queue;
|
||||
@@ -1,262 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVConfig;
|
||||
import com.onarandombox.MultiverseCore.configuration.handle.CommentedYamlConfigHandle;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.BooleanMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.IntegerMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.InvertBoolMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.MoveMigratorAction;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.VersionMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import io.vavr.control.Try;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
public class MVCoreConfig implements MVConfig {
|
||||
public static final String CONFIG_FILENAME = "config.yml";
|
||||
public static final double CONFIG_VERSION = 5.0;
|
||||
|
||||
private final Path configPath;
|
||||
private final MVCoreConfigNodes configNodes;
|
||||
private final CommentedYamlConfigHandle configHandle;
|
||||
|
||||
@Inject
|
||||
MVCoreConfig(@NotNull MultiverseCore core, @NotNull PluginManager pluginManager) {
|
||||
this.configPath = Path.of(core.getDataFolder().getPath(), CONFIG_FILENAME);
|
||||
this.configNodes = new MVCoreConfigNodes(pluginManager);
|
||||
this.configHandle = CommentedYamlConfigHandle.builder(configPath)
|
||||
.logger(Logging.getLogger())
|
||||
.nodes(configNodes.getNodes())
|
||||
.migrator(ConfigMigrator.builder(configNodes.VERSION)
|
||||
.addVersionMigrator(VersionMigrator.builder(5.0)
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.enforceaccess", "world.enforce-access"))
|
||||
.addAction(BooleanMigratorAction.of("world.enforce-access"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.prefixchat", "messaging.enable-chat-prefix"))
|
||||
.addAction(BooleanMigratorAction.of("messaging.enable-chat-prefix"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.prefixchatformat", "messaging.chat-prefix-format"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.teleportintercept", "world.teleport-intercept"))
|
||||
.addAction(BooleanMigratorAction.of("world.teleport-intercept"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.firstspawnoverride", "spawn.first-spawn-override"))
|
||||
.addAction(BooleanMigratorAction.of("spawn.first-spawn-override"))
|
||||
//.addAction(MoveMigratorAction.of("multiverse-configuration.displaypermerrors", ""))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.globaldebug", "misc.global-debug"))
|
||||
.addAction(IntegerMigratorAction.of("misc.global-debug"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.silentstart", "misc.silent-start"))
|
||||
.addAction(BooleanMigratorAction.of("misc.silent-start"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.firstspawnworld", "spawn.first-spawn-location"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.defaultportalsearch", "portal.use-custom-portal-search"))
|
||||
.addAction(BooleanMigratorAction.of("portal.use-custom-portal-search"))
|
||||
.addAction(InvertBoolMigratorAction.of("portal.use-custom-portal-search"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.portalsearchradius", "portal.custom-portal-search-radius"))
|
||||
.addAction(IntegerMigratorAction.of("portal.custom-portal-search-radius"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.autopurge", "world.auto-purge-entities"))
|
||||
.addAction(BooleanMigratorAction.of("world.auto-purge-entities"))
|
||||
.addAction(MoveMigratorAction.of("multiverse-configuration.idonotwanttodonate", "misc.show-donation-message"))
|
||||
.addAction(BooleanMigratorAction.of("misc.show-donation-message"))
|
||||
.addAction(InvertBoolMigratorAction.of("misc.show-donation-message"))
|
||||
.build())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
load();
|
||||
save();
|
||||
}
|
||||
|
||||
private void migrateFromOldConfigFile() {
|
||||
String content;
|
||||
try {
|
||||
content = Files.readString(configPath);
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
// Remove the old config section if it is still in the old ConfigurationSerializable.
|
||||
content = content.replace("==: com.onarandombox.MultiverseCore.MultiverseCoreConfiguration", "");
|
||||
try {
|
||||
Files.writeString(configPath, content);
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load() {
|
||||
migrateFromOldConfigFile();
|
||||
return configHandle.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return configHandle.isLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save() {
|
||||
configHandle.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeGroup getNodes() {
|
||||
return configNodes.getNodes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Try<Object> getProperty(String name) {
|
||||
return configHandle.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Try<Void> setProperty(String name, Object value) {
|
||||
return configHandle.set(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnforceAccess(boolean enforceAccess) {
|
||||
configHandle.set(configNodes.ENFORCE_ACCESS, enforceAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnforceAccess() {
|
||||
return configHandle.get(configNodes.ENFORCE_ACCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnforceGameMode(boolean enforceGameMode) {
|
||||
configHandle.set(configNodes.ENFORCE_GAMEMODE, enforceGameMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnforceGameMode() {
|
||||
return configHandle.get(configNodes.ENFORCE_GAMEMODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoPurgeEntities(boolean autopurge) {
|
||||
configHandle.set(configNodes.AUTO_PURGE_ENTITIES, autopurge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoPurgeEntities() {
|
||||
return configHandle.get(configNodes.AUTO_PURGE_ENTITIES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTeleportIntercept(boolean teleportIntercept) {
|
||||
configHandle.set(configNodes.TELEPORT_INTERCEPT, teleportIntercept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTeleportIntercept() {
|
||||
return configHandle.get(configNodes.TELEPORT_INTERCEPT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFirstSpawnOverride(boolean firstSpawnOverride) {
|
||||
configHandle.set(configNodes.FIRST_SPAWN_OVERRIDE, firstSpawnOverride);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFirstSpawnOverride() {
|
||||
return configHandle.get(configNodes.FIRST_SPAWN_OVERRIDE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFirstSpawnLocation(String firstSpawnWorld) {
|
||||
configHandle.set(configNodes.FIRST_SPAWN_LOCATION, firstSpawnWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFirstSpawnLocation() {
|
||||
return configHandle.get(configNodes.FIRST_SPAWN_LOCATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseCustomPortalSearch(boolean useDefaultPortalSearch) {
|
||||
configHandle.set(configNodes.USE_CUSTOM_PORTAL_SEARCH, useDefaultPortalSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingCustomPortalSearch() {
|
||||
return configHandle.get(configNodes.USE_CUSTOM_PORTAL_SEARCH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomPortalSearchRadius(int searchRadius) {
|
||||
configHandle.set(configNodes.CUSTOM_PORTAL_SEARCH_RADIUS, searchRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCustomPortalSearchRadius() {
|
||||
return configHandle.get(configNodes.CUSTOM_PORTAL_SEARCH_RADIUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnablePrefixChat(boolean prefixChat) {
|
||||
configHandle.set(configNodes.ENABLE_CHAT_PREFIX, prefixChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnablePrefixChat() {
|
||||
return configHandle.get(configNodes.ENABLE_CHAT_PREFIX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrefixChatFormat(String prefixChatFormat) {
|
||||
configHandle.set(configNodes.CHAT_PREFIX_FORMAT, prefixChatFormat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefixChatFormat() {
|
||||
return configHandle.get(configNodes.CHAT_PREFIX_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRegisterPapiHook(boolean registerPapiHook) {
|
||||
configHandle.set(configNodes.REGISTER_PAPI_HOOK, registerPapiHook);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegisterPapiHook() {
|
||||
return configHandle.get(configNodes.REGISTER_PAPI_HOOK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGlobalDebug(int globalDebug) {
|
||||
configHandle.set(configNodes.GLOBAL_DEBUG, globalDebug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGlobalDebug() {
|
||||
return configHandle.get(configNodes.GLOBAL_DEBUG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSilentStart(boolean silentStart) {
|
||||
configHandle.set(configNodes.SILENT_START, silentStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSilentStart() {
|
||||
return configHandle.get(configNodes.SILENT_START);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowDonateMessage(boolean showDonateMessage) {
|
||||
configHandle.set(configNodes.SHOW_DONATION_MESSAGE, showDonateMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowingDonateMessage() {
|
||||
return configHandle.get(configNodes.SHOW_DONATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.config;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ConfigHeaderNode;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ConfigNode;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.Node;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
import com.onarandombox.MultiverseCore.exceptions.MultiverseException;
|
||||
import io.github.townyadvanced.commentedconfiguration.setting.CommentedNode;
|
||||
import io.vavr.control.Try;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
class MVCoreConfigNodes {
|
||||
|
||||
private final NodeGroup nodes = new NodeGroup();
|
||||
private PluginManager pluginManager;
|
||||
|
||||
MVCoreConfigNodes(PluginManager pluginManager) {
|
||||
this.pluginManager = pluginManager;
|
||||
}
|
||||
|
||||
public NodeGroup getNodes() {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
private <N extends Node> N node(N node) {
|
||||
nodes.add(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
private final ConfigHeaderNode HEADER = node(ConfigHeaderNode.builder("world") // TODO hacky way to get the header to the top of the file
|
||||
.comment("####################################################################################################")
|
||||
.comment("# #")
|
||||
.comment("# █▀▄▀█ █░█ █░░ ▀█▀ █ █░█ █▀▀ █▀█ █▀ █▀▀ █▀▀ █▀█ █▀█ █▀▀ #")
|
||||
.comment("# █░▀░█ █▄█ █▄▄ ░█░ █ ▀▄▀ ██▄ █▀▄ ▄█ ██▄ █▄▄ █▄█ █▀▄ ██▄ #")
|
||||
.comment("# #")
|
||||
.comment("# #")
|
||||
.comment("# WIKI: https://github.com/Multiverse/Multiverse-Core/wiki #")
|
||||
.comment("# DISCORD: https://discord.gg/NZtfKky #")
|
||||
.comment("# BUG REPORTS: https://github.com/Multiverse/Multiverse-Core/issues #")
|
||||
.comment("# #")
|
||||
.comment("# #")
|
||||
.comment("# Each option in this file is documented and explained here: #")
|
||||
.comment("# ==> https://github.com/Multiverse/Multiverse-Core/wiki/config.yml #")
|
||||
.comment("# #")
|
||||
.comment("# #")
|
||||
.comment("# New options are added to this file automatically. If you manually made changes #")
|
||||
.comment("# to this file while your server is running, please run `/mv reload` command. #")
|
||||
.comment("# #")
|
||||
.comment("####################################################################################################")
|
||||
.comment("")
|
||||
.comment("")
|
||||
.build());
|
||||
|
||||
// private final ConfigHeaderNode WORLD_HEADER = node(ConfigHeaderNode.builder("world")
|
||||
// .comment("")
|
||||
// .comment("")
|
||||
// .build());
|
||||
|
||||
public final ConfigNode<Boolean> ENFORCE_ACCESS = node(ConfigNode.builder("world.enforce-access", Boolean.class)
|
||||
.comment("This setting will prevent players from entering worlds they don't have access to.")
|
||||
.comment("If this is set to false, players will be able to enter any world they want.")
|
||||
.comment("If this is set to true, players will only be able to enter worlds they have")
|
||||
.comment("the `mv.access.<worldname>` permission.")
|
||||
.defaultValue(false)
|
||||
.name("enforce-access")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> ENFORCE_GAMEMODE = node(ConfigNode.builder("world.enforce-gamemode", Boolean.class)
|
||||
.comment("")
|
||||
.comment("Sets whether Multiverse will should enforce gamemode on world change.")
|
||||
.comment("If enabled, players will be forced into the gamemode of the world they are entering, unless they have")
|
||||
.comment("the `mv.bypass.gamemode.<worldname>` permission.")
|
||||
.defaultValue(true)
|
||||
.name("enforce-gamemode")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> AUTO_PURGE_ENTITIES = node(ConfigNode.builder("world.auto-purge-entities", Boolean.class)
|
||||
.comment("")
|
||||
.comment("Sets whether Multiverse will purge mobs and entities with be automatically.")
|
||||
.defaultValue(false)
|
||||
.name("auto-purge-entities")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> TELEPORT_INTERCEPT = node(ConfigNode.builder("world.teleport-intercept", Boolean.class)
|
||||
.comment("")
|
||||
.comment("If this is set to true, Multiverse will enforce access permissions for all teleportation,")
|
||||
.comment("including teleportation from other plugins.")
|
||||
.defaultValue(true)
|
||||
.name("teleport-intercept")
|
||||
.build());
|
||||
|
||||
private final ConfigHeaderNode SPAWN_HEADER = node(ConfigHeaderNode.builder("spawn")
|
||||
.comment("")
|
||||
.comment("")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> FIRST_SPAWN_OVERRIDE = node(ConfigNode.builder("spawn.first-spawn-override", Boolean.class)
|
||||
.comment("Sets whether Multiverse will override the first spawn location of a world.")
|
||||
.comment("If enabled, Multiverse will set the first spawn location of a world to the spawn location of the world.")
|
||||
.comment("If disabled, it will default to server.properties settings.")
|
||||
.defaultValue(true)
|
||||
.name("first-spawn-override")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<String> FIRST_SPAWN_LOCATION = node(ConfigNode.builder("spawn.first-spawn-location", String.class)
|
||||
.comment("")
|
||||
.comment("Sets the world that Multiverse will use as the location for players that first join the server.")
|
||||
.comment("This only applies if first-spawn-override is set to true.")
|
||||
.defaultValue("")
|
||||
.name("first-spawn-location")
|
||||
.build());
|
||||
|
||||
private final ConfigHeaderNode PORTAL_HEADER = node(ConfigHeaderNode.builder("portal")
|
||||
.comment("")
|
||||
.comment("")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> USE_CUSTOM_PORTAL_SEARCH = node(ConfigNode.builder("portal.use-custom-portal-search", Boolean.class)
|
||||
.comment("This config option defines whether or not Multiverse should interfere with's Bukkit's default portal search radius.")
|
||||
.comment("Setting it to false would mean you want to simply let Bukkit decides the search radius itself.")
|
||||
.defaultValue(false)
|
||||
.name("use-custom-portal-search")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Integer> CUSTOM_PORTAL_SEARCH_RADIUS = node(ConfigNode.builder("portal.custom-portal-search-radius", Integer.class)
|
||||
.comment("")
|
||||
.comment("This config option defines the search radius Multiverse should use when searching for a portal.")
|
||||
.comment("This only applies if use-custom-portal-search is set to true.")
|
||||
.defaultValue(128)
|
||||
.name("custom-portal-search-radius")
|
||||
.validator(value -> value < 0
|
||||
? Try.failure(new MultiverseException("The value must be greater than or equal to 0.", null))
|
||||
: Try.success(null))
|
||||
.build());
|
||||
|
||||
private final ConfigHeaderNode MESSAGING_HEADER = node(ConfigHeaderNode.builder("messaging")
|
||||
.comment("")
|
||||
.comment("")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> ENABLE_CHAT_PREFIX = node(ConfigNode.builder("messaging.enable-chat-prefix", Boolean.class)
|
||||
.comment("This config option defines whether or not Multiverse should prefix the chat with the world name.")
|
||||
.comment("This only applies if use-custom-portal-search is set to true.")
|
||||
.defaultValue(false)
|
||||
.name("enable-chat-prefix")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<String> CHAT_PREFIX_FORMAT = node(ConfigNode.builder("messaging.chat-prefix-format", String.class)
|
||||
.comment("")
|
||||
.comment("This config option defines the format Multiverse should use when prefixing the chat with the world name.")
|
||||
.comment("This only applies if enable-chat-prefix is set to true.")
|
||||
.defaultValue("[%world%]%chat%")
|
||||
.name("chat-prefix-format")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> REGISTER_PAPI_HOOK = node(ConfigNode.builder("messaging.register-papi-hook", Boolean.class)
|
||||
.comment("")
|
||||
.comment("This config option defines whether or not Multiverse should register the PlaceholderAPI hook.")
|
||||
.comment("This only applies if PlaceholderAPI is installed.")
|
||||
.defaultValue(true)
|
||||
.name("register-papi-hook")
|
||||
.build());
|
||||
|
||||
private final ConfigHeaderNode MISC_HEADER = node(ConfigHeaderNode.builder("misc")
|
||||
.comment("")
|
||||
.comment("")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Integer> GLOBAL_DEBUG = node(ConfigNode.builder("misc.global-debug", Integer.class)
|
||||
.comment("This is our debug flag to help identify issues with Multiverse.")
|
||||
.comment("If you are having issues with Multiverse, please set this to 3 and then post your log to pastebin.com")
|
||||
.comment("Otherwise, there's no need to touch this. If not instructed by a wiki page or developer.")
|
||||
.comment(" 0 = Off, No debug messages")
|
||||
.comment(" 1 = fine")
|
||||
.comment(" 2 = finer")
|
||||
.comment(" 3 = finest")
|
||||
.defaultValue(0)
|
||||
.name("global-debug")
|
||||
.validator(value -> (value < 0 || value > 3)
|
||||
? Try.failure(new MultiverseException("Debug level must be between 0 and 3.", null))
|
||||
: Try.success(null))
|
||||
.onSetValue((oldValue, newValue) -> {
|
||||
int level = Logging.getDebugLevel();
|
||||
Logging.setDebugLevel(newValue);
|
||||
if (level != Logging.getDebugLevel()) {
|
||||
pluginManager.callEvent(new MVDebugModeEvent(level));
|
||||
}
|
||||
})
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> SILENT_START = node(ConfigNode.builder("misc.silent-start", Boolean.class)
|
||||
.comment("")
|
||||
.comment("If true, the startup console messages will no longer show.")
|
||||
.defaultValue(false)
|
||||
.name("silent-start")
|
||||
.onSetValue((oldValue, newValue) -> Logging.setShowingConfig(!newValue))
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> SHOW_DONATION_MESSAGE = node(ConfigNode.builder("misc.show-donation-message", Boolean.class)
|
||||
.comment("")
|
||||
.comment("If you don't want to donate, you can set this to false and Multiverse will stop nagging you.")
|
||||
.defaultValue(true)
|
||||
.name("show-donation-message")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Double> VERSION = node(ConfigNode.builder("version", Double.class)
|
||||
.comment("")
|
||||
.comment("")
|
||||
.comment("This just signifies the version number so we can see what version of config you have.")
|
||||
.comment("NEVER TOUCH THIS VALUE")
|
||||
.defaultValue(MVCoreConfig.CONFIG_VERSION)
|
||||
.name(null)
|
||||
.build());
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.configuration.handle;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.CommentedNode;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ValueNode;
|
||||
import io.github.townyadvanced.commentedconfiguration.CommentedConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Configuration handle for commented YAML files.
|
||||
*/
|
||||
public class CommentedYamlConfigHandle extends FileConfigHandle<CommentedConfiguration> {
|
||||
|
||||
/**
|
||||
* Creates a new builder for a {@link CommentedYamlConfigHandle}.
|
||||
*
|
||||
* @param configPath The path to the config file.
|
||||
* @return The builder.
|
||||
*/
|
||||
public static @NotNull Builder builder(@NotNull Path configPath) {
|
||||
return new Builder(configPath);
|
||||
}
|
||||
|
||||
protected CommentedYamlConfigHandle(@NotNull Path configPath, @Nullable Logger logger, @Nullable NodeGroup nodes, @Nullable ConfigMigrator migrator) {
|
||||
super(configPath, logger, nodes, migrator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected boolean loadConfigObject() {
|
||||
config = new CommentedConfiguration(configPath, logger);
|
||||
return config.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setUpNodes() {
|
||||
if (nodes == null || nodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommentedConfiguration oldConfig = config;
|
||||
this.config = new CommentedConfiguration(configPath, logger);
|
||||
|
||||
nodes.forEach(node -> {
|
||||
if (node instanceof CommentedNode typedNode) {
|
||||
if (typedNode.getComments().length > 0) {
|
||||
config.addComment(typedNode.getPath(), typedNode.getComments());
|
||||
}
|
||||
}
|
||||
if (node instanceof ValueNode valueNode) {
|
||||
set(valueNode, oldConfig.getObject(valueNode.getPath(), valueNode.getType(), valueNode.getDefaultValue())).onFailure(e -> {
|
||||
Logging.warning("Failed to set node " + valueNode.getPath() + " to " + valueNode.getDefaultValue());
|
||||
setDefault(valueNode);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean save() {
|
||||
config.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class Builder extends FileConfigHandle.Builder<CommentedConfiguration, Builder> {
|
||||
|
||||
protected Builder(@NotNull Path configPath) {
|
||||
super(configPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public @NotNull CommentedYamlConfigHandle build() {
|
||||
return new CommentedYamlConfigHandle(configPath, logger, nodes, migrator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.configuration.handle;
|
||||
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Configuration handle for a single configuration section.
|
||||
*/
|
||||
public class ConfigurationSectionHandle extends GenericConfigHandle<ConfigurationSection> {
|
||||
public static Builder<? extends Builder> builder(@NotNull ConfigurationSection configurationSection) {
|
||||
return new Builder<>(configurationSection);
|
||||
}
|
||||
|
||||
public ConfigurationSectionHandle(@NotNull ConfigurationSection configurationSection,
|
||||
@Nullable Logger logger,
|
||||
@Nullable NodeGroup nodes,
|
||||
@Nullable ConfigMigrator migrator) {
|
||||
super(logger, nodes, migrator);
|
||||
this.config = configurationSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link ConfigurationSectionHandle}.
|
||||
*
|
||||
* @param <B> The builder type.
|
||||
*/
|
||||
public static class Builder<B extends Builder<B>> extends GenericConfigHandle.Builder<ConfigurationSection, B> {
|
||||
private final ConfigurationSection configurationSection;
|
||||
|
||||
protected Builder(@NotNull ConfigurationSection configurationSection) {
|
||||
this.configurationSection = configurationSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public @NotNull ConfigurationSectionHandle build() {
|
||||
return new ConfigurationSectionHandle(configurationSection, logger, nodes, migrator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.configuration.handle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Generic configuration handle for file based configurations.
|
||||
* @param <C> The configuration type.
|
||||
*/
|
||||
abstract class FileConfigHandle<C extends FileConfiguration> extends GenericConfigHandle<C> {
|
||||
|
||||
protected final @NotNull Path configPath;
|
||||
protected final @NotNull File configFile;
|
||||
|
||||
|
||||
protected FileConfigHandle(@NotNull Path configPath, @Nullable Logger logger, @Nullable NodeGroup nodes, @Nullable ConfigMigrator migrator) {
|
||||
super(logger, nodes, migrator);
|
||||
this.configPath = configPath;
|
||||
this.configFile = configPath.toFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean load() {
|
||||
if (!createConfigFile()) {
|
||||
Logging.severe("Failed to create config file: %s", configFile.getName());
|
||||
return false;
|
||||
}
|
||||
if (!loadConfigObject()) {
|
||||
Logging.severe("Failed to load config file: %s", configFile.getName());
|
||||
return false;
|
||||
}
|
||||
migrateConfig();
|
||||
setUpNodes();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new config file if file does not exist
|
||||
*
|
||||
* @return True if file exist or created successfully, otherwise false.
|
||||
*/
|
||||
protected boolean createConfigFile() {
|
||||
if (configFile.exists()) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
if (!configFile.createNewFile()) {
|
||||
return false;
|
||||
}
|
||||
Logging.info("Created new config file: %s", configFile.getName());
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the configuration object.
|
||||
*
|
||||
* @return True if the configuration was loaded successfully, false otherwise.
|
||||
*/
|
||||
protected abstract boolean loadConfigObject();
|
||||
|
||||
/**
|
||||
* Saves the configuration.
|
||||
*/
|
||||
public abstract boolean save();
|
||||
|
||||
/**
|
||||
* Checks if the configuration is loaded.
|
||||
*
|
||||
* @return True if the configuration is loaded, false otherwise.
|
||||
*/
|
||||
public boolean isLoaded() {
|
||||
return config != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @return The configuration.
|
||||
*/
|
||||
public C getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract builder for {@link FileConfigHandle}.
|
||||
*
|
||||
* @param <C> The configuration type.
|
||||
* @param <B> The builder type.
|
||||
*/
|
||||
public static abstract class Builder<C extends FileConfiguration, B extends Builder<C, B>> extends GenericConfigHandle.Builder<C, B> {
|
||||
|
||||
protected @NotNull Path configPath;
|
||||
protected @Nullable Logger logger;
|
||||
protected @Nullable NodeGroup nodes;
|
||||
protected @Nullable ConfigMigrator migrator;
|
||||
|
||||
protected Builder(@NotNull Path configPath) {
|
||||
this.configPath = configPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the configuration handle.
|
||||
*
|
||||
* @return The configuration handle.
|
||||
*/
|
||||
public abstract @NotNull FileConfigHandle<C> build();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.configuration.handle;
|
||||
|
||||
import com.onarandombox.MultiverseCore.configuration.migration.ConfigMigrator;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ConfigNodeNotFoundException;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
|
||||
import com.onarandombox.MultiverseCore.configuration.node.ValueNode;
|
||||
import io.vavr.control.Try;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Generic configuration handle for all ConfigurationSection types.
|
||||
*/
|
||||
public abstract class GenericConfigHandle<C extends ConfigurationSection> {
|
||||
protected final @Nullable Logger logger;
|
||||
protected final @Nullable NodeGroup nodes;
|
||||
protected final @Nullable ConfigMigrator migrator;
|
||||
|
||||
protected C config;
|
||||
|
||||
public GenericConfigHandle(@Nullable Logger logger, @Nullable NodeGroup nodes, @Nullable ConfigMigrator migrator) {
|
||||
this.logger = logger;
|
||||
this.nodes = nodes;
|
||||
this.migrator = migrator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the configuration.
|
||||
*
|
||||
* @return True if the configuration was loaded successfully, false otherwise.
|
||||
*/
|
||||
public boolean load() {
|
||||
migrateConfig();
|
||||
setUpNodes();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates the configuration.
|
||||
*/
|
||||
protected void migrateConfig() {
|
||||
if (migrator != null) {
|
||||
migrator.migrate(config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the nodes.
|
||||
*/
|
||||
protected void setUpNodes() {
|
||||
if (nodes == null || nodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nodes.forEach(node -> {
|
||||
if (node instanceof ValueNode valueNode) {
|
||||
set(valueNode, config.getObject(valueNode.getPath(), valueNode.getType(), valueNode.getDefaultValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a node, if the node has a default value, it will be returned if the node is not found.
|
||||
* @param name The name of the node.
|
||||
* @return The value of the node.
|
||||
*/
|
||||
public Try<Object> get(@Nullable String name) {
|
||||
return nodes.findNode(name, ValueNode.class)
|
||||
.toTry(() -> new ConfigNodeNotFoundException(name))
|
||||
.map(node -> get((ValueNode<Object>) node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a node, if the node has a default value, it will be returned if the node is not found.
|
||||
*
|
||||
* @param node The node to get the value of.
|
||||
* @return The value of the node.
|
||||
*/
|
||||
public <T> T get(@NotNull ValueNode<T> node) {
|
||||
return config.getObject(node.getPath(), node.getType(), node.getDefaultValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of a node, if the validator is not null, it will be tested first.
|
||||
*
|
||||
* @param name The name of the node.
|
||||
* @param value The value to set.
|
||||
* @return True if the value was set, false otherwise.
|
||||
*/
|
||||
public Try<Void> set(@Nullable String name, Object value) {
|
||||
return nodes.findNode(name, ValueNode.class)
|
||||
.toTry(() -> new ConfigNodeNotFoundException(name))
|
||||
.flatMap(node -> set(node, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of a node, if the validator is not null, it will be tested first.
|
||||
*
|
||||
* @param node The node to set the value of.
|
||||
* @param value The value to set.
|
||||
* @return True if the value was set, false otherwise.
|
||||
* @param <T> The type of the node value.
|
||||
*/
|
||||
public <T> Try<Void> set(@NotNull ValueNode<T> node, T value) {
|
||||
return node.validate(value).map(ignore -> {
|
||||
T oldValue = get(node);
|
||||
config.set(node.getPath(), value);
|
||||
node.onSetValue(oldValue, get(node));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value of a node.
|
||||
*
|
||||
* @param node The node to set the default value of.
|
||||
*/
|
||||
public void setDefault(@NotNull ValueNode node) {
|
||||
config.set(node.getPath(), node.getDefaultValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract builder for {@link GenericConfigHandle}.
|
||||
*
|
||||
* @param <C> The configuration type.
|
||||
* @param <B> The builder type.
|
||||
*/
|
||||
public static abstract class Builder<C extends ConfigurationSection, B extends GenericConfigHandle.Builder<C, B>> {
|
||||
|
||||
protected @Nullable Logger logger;
|
||||
protected @Nullable NodeGroup nodes;
|
||||
protected @Nullable ConfigMigrator migrator;
|
||||
|
||||
protected Builder() {}
|
||||
|
||||
/**
|
||||
* Sets the logger.
|
||||
*
|
||||
* @param logger The logger.
|
||||
* @return The builder.
|
||||
*/
|
||||
public B logger(@Nullable Logger logger) {
|
||||
this.logger = logger;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logger.
|
||||
*
|
||||
* @param plugin The plugin to get the logger from.
|
||||
* @return The builder.
|
||||
*/
|
||||
public B logger(Plugin plugin) {
|
||||
this.logger = plugin.getLogger();
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the nodes.
|
||||
*
|
||||
* @param nodes The nodes.
|
||||
* @return The builder.
|
||||
*/
|
||||
public B nodes(@Nullable NodeGroup nodes) {
|
||||
this.nodes = nodes;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the migrator.
|
||||
*
|
||||
* @param migrator The migrator.
|
||||
* @return The builder.
|
||||
*/
|
||||
public B migrator(@Nullable ConfigMigrator migrator) {
|
||||
this.migrator = migrator;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the configuration handle.
|
||||
*
|
||||
* @return The configuration handle.
|
||||
*/
|
||||
public abstract @NotNull GenericConfigHandle<C> build();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
}
|
||||
}
|
||||