Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
981b682aff | ||
|
|
3377c1dbe5 | ||
|
|
3ec22fc578 | ||
|
|
17351e66c1 | ||
|
|
0166b8d139 | ||
|
|
2acca7f330 | ||
|
|
4ad6c53ba9 | ||
|
|
0117159159 | ||
|
|
ccf802e32f | ||
|
|
83f5a4a701 | ||
|
|
a034eaa555 | ||
|
|
3fb99bc156 | ||
|
|
9d34e5d75c | ||
|
|
27c2f7b9e9 | ||
|
|
697fee8c4c | ||
|
|
6882660286 |
No files matched your search
@@ -0,0 +1,22 @@
|
||||
name: Maven CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
@@ -1,34 +0,0 @@
|
||||
name: 'Call: GitHub Release'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
release_mode:
|
||||
description: 'Release mode'
|
||||
required: true
|
||||
type: string
|
||||
version_bump:
|
||||
description: 'Version bump'
|
||||
required: false
|
||||
type: string
|
||||
promote_from:
|
||||
description: 'Promote from'
|
||||
required: false
|
||||
type: string
|
||||
outputs:
|
||||
release_created:
|
||||
description: 'Release created'
|
||||
value: ${{ jobs.github_release.outputs.release_created }}
|
||||
tag_name:
|
||||
description: 'Tag name'
|
||||
value: ${{ jobs.github_release.outputs.tag_name }}
|
||||
|
||||
jobs:
|
||||
github_release:
|
||||
uses: ./.github/workflows/generic.github_release.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
plugin_name: multiverse-core
|
||||
release_mode: ${{ inputs.release_mode }}
|
||||
version_bump: ${{ inputs.version_bump }}
|
||||
promote_from: ${{ inputs.promote_from }}
|
||||
@@ -1,95 +0,0 @@
|
||||
name: 'Call: Platform Uploads'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
target_tag:
|
||||
description: 'Version to upload'
|
||||
required: true
|
||||
type: string
|
||||
upload_modrinth:
|
||||
description: 'Upload to modrinth.com'
|
||||
required: true
|
||||
type: string
|
||||
upload_dbo:
|
||||
description: 'Upload to dev.bukkit.org'
|
||||
required: true
|
||||
type: string
|
||||
upload_hangar:
|
||||
description: 'Upload to hangar.papermc.io'
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
MODRINTH_TOKEN:
|
||||
required: true
|
||||
DBO_UPLOAD_API_TOKEN:
|
||||
required: true
|
||||
HANGAR_UPLOAD_TOKEN:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
platform_uploads:
|
||||
uses: ./.github/workflows/generic.platform_uploads.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
plugin_name: multiverse-core
|
||||
modrinth_project_id: 3wmN97b8
|
||||
modrinth_dependencies: >
|
||||
[
|
||||
{"project_id": "qvdtDX3s", "dependency_type": "optional"},
|
||||
{"project_id": "8VMk6P0I", "dependency_type": "optional"},
|
||||
{"project_id": "vtawPsTo", "dependency_type": "optional"},
|
||||
{"project_id": "WuErDeI1", "dependency_type": "optional"}
|
||||
]
|
||||
|
||||
dbo_project_id: 30765
|
||||
dbo_project_relations: >
|
||||
[
|
||||
{"slug": "multiverse-inventories", "type": "optionalDependency"},
|
||||
{"slug": "multiverse-portals", "type": "optionalDependency"},
|
||||
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
|
||||
{"slug": "multiverse-signportals", "type": "optionalDependency"},
|
||||
{"slug": "vault", "type": "optionalDependency"}
|
||||
]
|
||||
|
||||
hangar_slug: Multiverse-Core
|
||||
hangar_plugin_dependencies: >
|
||||
{ "PAPER": [
|
||||
{
|
||||
"name": "Multiverse-Inventories",
|
||||
"required": false,
|
||||
"namespace": {
|
||||
"owner": "Multiverse",
|
||||
"slug": "Multiverse-Inventories"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Multiverse-Portals",
|
||||
"required": false,
|
||||
"namespace": {
|
||||
"owner": "Multiverse",
|
||||
"slug": "Multiverse-Portals"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Multiverse-NetherPortals",
|
||||
"required": false,
|
||||
"namespace": {
|
||||
"owner": "Multiverse",
|
||||
"slug": "Multiverse-NetherPortals"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Multiverse-SignPortals",
|
||||
"required": false,
|
||||
"namespace": {
|
||||
"owner": "Multiverse",
|
||||
"slug": "Multiverse-SignPortals"
|
||||
}
|
||||
}
|
||||
]}
|
||||
|
||||
target_tag: ${{ inputs.target_tag }}
|
||||
upload_modrinth: ${{ inputs.upload_modrinth }}
|
||||
upload_dbo: ${{ inputs.upload_dbo }}
|
||||
upload_hangar: ${{ inputs.upload_hangar }}
|
||||
@@ -1,31 +0,0 @@
|
||||
name: 'Dispatch: Platform Uploads'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target_tag:
|
||||
description: 'Version to upload'
|
||||
required: true
|
||||
type: string
|
||||
upload_modrinth:
|
||||
description: 'Upload to modrinth.com'
|
||||
required: true
|
||||
type: boolean
|
||||
upload_dbo:
|
||||
description: 'Upload to dev.bukkit.org'
|
||||
required: true
|
||||
type: boolean
|
||||
upload_hangar:
|
||||
description: 'Upload to hangar.papermc.io'
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
dispatch_platform_uploads:
|
||||
uses: ./.github/workflows/call.platform_uploads.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
target_tag: ${{ github.event.inputs.target_tag }}
|
||||
upload_modrinth: ${{ github.event.inputs.upload_modrinth }}
|
||||
upload_dbo: ${{ github.event.inputs.upload_dbo }}
|
||||
upload_hangar: ${{ github.event.inputs.upload_hangar }}
|
||||
@@ -1,38 +0,0 @@
|
||||
name: 'Dispatch: Promote Release'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target_tag:
|
||||
description: 'Version to promote'
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
check_version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Verify input version is prerelease
|
||||
run: |
|
||||
if [[ "${{ github.event.inputs.target_tag }}" != *"pre"* ]]; then
|
||||
echo "Version must be a prerelease"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
github_release:
|
||||
needs: check_version
|
||||
uses: ./.github/workflows/call.github_release.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
release_mode: promote
|
||||
promote_from: ${{ github.event.inputs.target_tag }}
|
||||
|
||||
platform_uploads:
|
||||
needs: github_release
|
||||
if: needs.github_release.outputs.release_created == 'true'
|
||||
uses: ./.github/workflows/call.platform_uploads.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
target_tag: ${{ needs.github_release.outputs.tag_name }}
|
||||
upload_modrinth: 'true'
|
||||
upload_dbo: 'true'
|
||||
upload_hangar: 'true'
|
||||
@@ -1,91 +0,0 @@
|
||||
name: 'Generic: GitHub Release'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
# Plugin specific
|
||||
plugin_name:
|
||||
description: 'Plugin name'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
# Common params
|
||||
release_mode:
|
||||
description: 'Release mode'
|
||||
required: true
|
||||
type: string
|
||||
version_bump:
|
||||
description: 'Version bump'
|
||||
required: false
|
||||
type: string
|
||||
promote_from:
|
||||
description: 'Promote from'
|
||||
required: false
|
||||
type: string
|
||||
outputs:
|
||||
release_created:
|
||||
description: 'Release created'
|
||||
value: ${{ jobs.github_release.outputs.release_created }}
|
||||
tag_name:
|
||||
description: 'Tag name'
|
||||
value: ${{ jobs.github_release.outputs.tag_name }}
|
||||
|
||||
jobs:
|
||||
github_release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_created: ${{ steps.release.outputs.release_created }}
|
||||
tag_name: ${{ steps.release.outputs.tag_name }}
|
||||
steps:
|
||||
- name: Echo inputs
|
||||
run: |
|
||||
echo "release_mode: ${{ inputs.release_mode }}"
|
||||
echo "version_bump: ${{ inputs.version_bump }}"
|
||||
echo "promote_from: ${{ inputs.promote_from }}"
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.promote_from }}
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Build and test
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: clean build -x assemble -x shadowJar -x checkStyleMain -x checkStyleTest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
uses: benwoo1110/semantic-release-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
release_mode: ${{ inputs.release_mode }}
|
||||
version_bump: ${{ inputs.version_bump }}
|
||||
promote_from: ${{ inputs.promote_from }}
|
||||
|
||||
- name: Publish package
|
||||
if: steps.release.outputs.release_created == 'true'
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: publish -x checkStyleMain -x checkStyleTest -x test
|
||||
env:
|
||||
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload release artifact
|
||||
if: steps.release.outputs.release_created == 'true'
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/libs/${{ inputs.plugin_name }}-${{ steps.release.outputs.publish_version }}.jar
|
||||
asset_name: ${{ inputs.plugin_name }}-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
||||
@@ -1,141 +0,0 @@
|
||||
name: 'Generic: Platform Uploads'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
# Plugin specific params
|
||||
plugin_name:
|
||||
description: 'Plugin name'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
modrinth_project_id:
|
||||
description: 'modrinth.com project ID'
|
||||
required: true
|
||||
type: string
|
||||
modrinth_dependencies:
|
||||
description: 'modrinth.com project dependencies'
|
||||
required: false
|
||||
type: string
|
||||
default: '[]'
|
||||
|
||||
dbo_project_id:
|
||||
description: 'dev.bukkit.org project ID'
|
||||
required: true
|
||||
type: string
|
||||
dbo_project_relations:
|
||||
description: 'dev.bukkit.org project relations'
|
||||
required: false
|
||||
type: string
|
||||
default: '[]'
|
||||
|
||||
hangar_slug:
|
||||
description: 'hangar.papermc.io project slug'
|
||||
required: true
|
||||
type: string
|
||||
hangar_plugin_dependencies:
|
||||
description: 'hangar.papermc.io project dependencies'
|
||||
required: false
|
||||
type: string
|
||||
default: '{}'
|
||||
|
||||
# Common params
|
||||
target_tag:
|
||||
description: 'Version to upload'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
upload_modrinth:
|
||||
description: 'Upload to modrinth.com'
|
||||
required: true
|
||||
type: string
|
||||
upload_dbo:
|
||||
description: 'Upload to dev.bukkit.org'
|
||||
required: true
|
||||
type: string
|
||||
upload_hangar:
|
||||
description: 'Upload to hangar.papermc.io'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
secrets:
|
||||
MODRINTH_TOKEN:
|
||||
required: true
|
||||
DBO_UPLOAD_API_TOKEN:
|
||||
required: true
|
||||
HANGAR_UPLOAD_TOKEN:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
platform_uploads:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get release info
|
||||
id: release-info
|
||||
uses: cardinalby/git-get-release-action@1.2.4
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag: ${{ inputs.target_tag }}
|
||||
|
||||
- name: Download release artifact
|
||||
id: release-artifact
|
||||
uses: dsaltares/fetch-gh-release-asset@1.1.1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: tags/${{ steps.release-info.outputs.tag_name }}
|
||||
file: ${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar
|
||||
|
||||
- name: Parse release type
|
||||
id: parse-release-type
|
||||
run: |
|
||||
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
|
||||
echo Setting release_type to Beta
|
||||
echo "release_type=Beta" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo Setting release_type to Release
|
||||
echo "release_type=Release" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Upload to Modrinth
|
||||
if: ${{ !cancelled() && inputs.upload_modrinth == 'true' }}
|
||||
uses: benwoo1110/modrinth-upload-action@v1
|
||||
with:
|
||||
api_token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
project_id: ${{ inputs.modrinth_project_id }}
|
||||
version_number: ${{ steps.release-info.outputs.tag_name }}
|
||||
files: '["${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar"]'
|
||||
name: ${{ steps.release-info.outputs.tag_name }}
|
||||
changelog: ${{ steps.release-artifact.outputs.body }}
|
||||
game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13
|
||||
version_type: ${{ steps.parse-release-type.outputs.release_type }}
|
||||
loaders: bukkit, spigot, paper
|
||||
dependencies: ${{ inputs.modrinth_dependencies }}
|
||||
|
||||
- name: Upload to DBO
|
||||
if: ${{ !cancelled() && inputs.upload_dbo == 'true' }}
|
||||
uses: benwoo1110/dbo-upload-action@v1
|
||||
with:
|
||||
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
|
||||
project_id: ${{ inputs.dbo_project_id }}
|
||||
changelog: ${{ steps.release-artifact.outputs.body }}
|
||||
changelog_type: markdown
|
||||
display_name: ${{ steps.release-info.outputs.tag_name }}
|
||||
game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17, 1.16, 1.15, 1.14, 1.13
|
||||
release_type: ${{ steps.parse-release-type.outputs.release_type }}
|
||||
project_relations: ${{ inputs.dbo_project_relations }}
|
||||
file_path: ${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar
|
||||
|
||||
- name: Upload to Hangar
|
||||
if: ${{ !cancelled() && inputs.upload_hangar == 'true' }}
|
||||
uses: benwoo1110/hangar-upload-action@v1
|
||||
with:
|
||||
api_token: ${{ secrets.HANGAR_UPLOAD_TOKEN }}
|
||||
author: Multiverse
|
||||
slug: ${{ inputs.hangar_slug }}
|
||||
version: ${{ steps.release-info.outputs.tag_name }}
|
||||
channel: ${{ steps.parse-release-type.outputs.release_type }}
|
||||
files: '[{"path": "${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar", "platforms": ["PAPER"]}]'
|
||||
description: ${{ steps.release-artifact.outputs.body }}
|
||||
platform_dependencies: '{"PAPER": ["1.13-1.20.1"]}'
|
||||
plugin_dependencies: ${{ inputs.hangar_plugin_dependencies }}
|
||||
@@ -1,24 +0,0 @@
|
||||
name: 'Main: Prerelease'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
github_release_on_push:
|
||||
uses: ./.github/workflows/call.github_release.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
release_mode: prerelease
|
||||
version_bump: prlabel
|
||||
|
||||
platform_uploads_on_push:
|
||||
needs: github_release_on_push
|
||||
if: needs.github_release_on_push.outputs.release_created == 'true'
|
||||
uses: ./.github/workflows/call.platform_uploads.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
target_tag: ${{ needs.github_release_on_push.outputs.tag_name }}
|
||||
upload_modrinth: 'true'
|
||||
upload_dbo: 'false'
|
||||
upload_hangar: 'false'
|
||||
@@ -1,18 +0,0 @@
|
||||
name: 'PR: Require Label'
|
||||
|
||||
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 release"
|
||||
@@ -1,36 +0,0 @@
|
||||
name: 'PR: Test'
|
||||
|
||||
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: '11'
|
||||
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
|
||||
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
|
||||
@@ -43,6 +43,3 @@ debug.log
|
||||
# Doxygen
|
||||
/docs/html
|
||||
debug.txt
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
@@ -1,50 +1,44 @@
|
||||
<p align="center">
|
||||
<img src="config/multiverse2-long.png" alt="Multiverse Logo">
|
||||
</p>
|
||||
|
||||
[](https://modrinth.com/plugin/multiverse-core)
|
||||
[](https://hangar.papermc.io/Multiverse/Multiverse-Core)
|
||||
[](https://dev.bukkit.org/projects/multiverse-core)
|
||||
[](https://www.spigotmc.org/resources/multiverse-core.390/)
|
||||

|
||||
|
||||
[](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)
|
||||
[](https://patreon.com/dumptruckman)
|
||||
[](LICENSE.md)
|
||||
|
||||
|
||||
# About
|
||||
|
||||
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:
|
||||
|
||||
### 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 teleporters!
|
||||
* [Multiverse-SignPortals](https://github.com/Multiverse/Multiverse-SignPortals) -> Signs as teleprompters!
|
||||
|
||||
## Building
|
||||
Simply build the source with Gradle:
|
||||
Building
|
||||
========
|
||||
Simply build the source with maven:
|
||||
```
|
||||
./gradlew build
|
||||
$ mvn install
|
||||
```
|
||||
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
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)!
|
||||
* 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
|
||||
License
|
||||
=======
|
||||
Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info.
|
||||
-207
@@ -1,207 +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 "com.modrinth.minotaur" version "2.+"
|
||||
}
|
||||
|
||||
version = System.getenv('GITHUB_VERSION') ?: 'local'
|
||||
group = 'com.onarandombox.multiversecore'
|
||||
description = 'Multiverse-Core'
|
||||
|
||||
java.sourceCompatibility = JavaVersion.VERSION_11
|
||||
|
||||
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/')
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT'
|
||||
|
||||
implementation('com.github.MilkBowl:VaultAPI:1.7') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
|
||||
compileOnly('me.main__.util:SerializationConfig:1.7') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
compileOnly('com.pneumaticraft.commandhandler:CommandHandler:11') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
compileOnly 'com.dumptruckman.minecraft:buscript:2.0-SNAPSHOT'
|
||||
compileOnly 'org.bstats:bstats-bukkit:2.2.1'
|
||||
compileOnly('com.dumptruckman.minecraft:Logging:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
compileOnly 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
|
||||
compileOnly 'org.jetbrains:annotations:16.0.2'
|
||||
|
||||
testImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
|
||||
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:3.11.2'
|
||||
testImplementation 'commons-io:commons-io:2.4'
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
testCompileOnly.extendsFrom compileOnly
|
||||
testRuntimeOnly.extendsFrom testCompileOnly
|
||||
|
||||
shadowed.extendsFrom compileOnly {
|
||||
canBeResolved = true
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
|
||||
pom.withXml {
|
||||
asNode().dependencies.'*'.findAll() {
|
||||
it.scope.text() == 'runtime' && project.configurations.implementation.allDependencies.find { dep ->
|
||||
dep.name == it.artifactId.text()
|
||||
}
|
||||
}.each() {
|
||||
it.scope*.value = 'provided'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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 'me.main__.util', 'com.onarandombox.serializationconfig'
|
||||
relocate 'com.pneumaticraft.commandhandler', 'com.onarandombox.commandhandler'
|
||||
relocate 'buscript', 'com.onarandombox.buscript'
|
||||
relocate 'org.bstats', 'com.onarandombox.bstats'
|
||||
relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.MultiverseCore.utils.CoreLogging'
|
||||
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.MultiverseCore.utils.DebugFileLogger'
|
||||
relocate 'org.codehaus.jettison', 'com.onarandombox.jettison'
|
||||
relocate 'de.themoep.idconverter', 'com.onarandombox.idconverter'
|
||||
|
||||
configurations = [project.configurations.shadowed]
|
||||
|
||||
archiveFileName = "$baseName-$version.$extension"
|
||||
classifier = ''
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar
|
||||
jar.enabled = false
|
||||
|
||||
modrinth {
|
||||
token = System.getenv("MODRINTH_TOKEN")
|
||||
projectId = "multiverse-core"
|
||||
versionNumber = System.getenv("VERSION_NUMBER")
|
||||
versionType = System.getenv("VERSION_TYPE")
|
||||
uploadFile = jar
|
||||
gameVersions = ["1.20.1", "1.20", "1.19.4", "1.19.3", "1.19.2", "1.19.1", "1.19", "1.18.2", "1.18.1", "1.18", "1.17.1", "1.17", "1.16.5", "1.16.4", "1.16.3", "1.16.2", "1.16.1", "1.16", "1.15.2", "1.15.1", "1.15", "1.14.4", "1.14.3", "1.14.2", "1.14.1", "1.14", "1.13.2", "1.13.1", "1.13"]
|
||||
loaders = ["bukkit", "spigot", "paper"]
|
||||
changelog = System.getenv("CHANGELOG")
|
||||
}
|
||||
@@ -69,7 +69,7 @@
|
||||
<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.commands,com.onarandombox.MultiverseCore.destination"/>
|
||||
<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"/>
|
||||
|
||||
Vendored
BIN
Binary file not shown.
-6
@@ -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" "$@"
|
||||
Vendored
-92
@@ -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
|
||||
@@ -0,0 +1,395 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<name>Multiverse-Core</name>
|
||||
<description>World Management Plugin</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.number>UNKNOWN</project.build.number>
|
||||
<project.bitly-access-token>bitly-access-token</project.bitly-access-token>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<!-- Spigot -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<url>https://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minebench-repo</id>
|
||||
<url>https://repo.minebench.de/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>doodleproject-repo</id>
|
||||
<name>DoodleProject Maven 2 Repository</name>
|
||||
<url>https://doodleproject.sourceforge.net/maven2/release</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>https://ci.onarandombox.com</url>
|
||||
</ciManagement>
|
||||
|
||||
<!-- Profiles are used to detect whether this is a local or Jenkins build
|
||||
and adjust the build number accordingly -->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jenkins</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.BUILD_NUMBER</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>bitly</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.BITLY_ACCESS_TOKEN</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<project.bitly-access-token>${env.BITLY_ACCESS_TOKEN}</project.bitly-access-token>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<!-- Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>maven-replacer-plugin</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>replace-bitly-access-token</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.sourceDirectory}</basedir>
|
||||
<includes>
|
||||
<include>com/onarandombox/MultiverseCore/utils/webpaste/BitlyURLShortener.java</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>bitly-access-token</token>
|
||||
<value>${project.bitly-access-token}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>replace-maven-version-number</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.directory}/classes</basedir>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-b${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Jar Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M3</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
<excludes>
|
||||
<exclude>**/TestCommandSender.java</exclude>
|
||||
<exclude>**/TestInstanceCreator.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit47</artifactId>
|
||||
<version>3.0.0-M3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<configuration>
|
||||
<enableRulesSummary>true</enableRulesSummary>
|
||||
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc-jar</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>me.main__.util</pattern>
|
||||
<shadedPattern>com.onarandombox.serializationconfig</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.pneumaticraft.commandhandler</pattern>
|
||||
<shadedPattern>com.onarandombox.commandhandler</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>buscript</pattern>
|
||||
<shadedPattern>com.onarandombox.buscript</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.onarandombox.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.codehaus.jettison</pattern>
|
||||
<shadedPattern>com.onarandombox.jettison</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>de.themoep.idconverter</pattern>
|
||||
<shadedPattern>com.onarandombox.idconverter</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>com.onarandombox.acf</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.locales</pattern>
|
||||
<shadedPattern>com.onarandombox.locales</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>se.eris</groupId>
|
||||
<artifactId>notnull-instrumenter-maven-plugin</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>instrument</goal>
|
||||
<goal>tests-instrument</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<notNull>
|
||||
<param>org.jetbrains.annotations.NotNull</param>
|
||||
<param>javax.validation.constraints.NotNull</param>
|
||||
</notNull>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- SerializationConfig Dependency -->
|
||||
<dependency>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- End of SerializationConfig Dependency -->
|
||||
<!-- Start of Economy Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependency -->
|
||||
<!-- Start of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pneumaticraft.commandhandler</groupId>
|
||||
<artifactId>CommandHandler</artifactId>
|
||||
<version>11</version>
|
||||
</dependency>
|
||||
<!-- End of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>net.minidev</groupId>
|
||||
<artifactId>json-smart</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>buscript</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>Logging</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.themoep.idconverter</groupId>
|
||||
<artifactId>mappings</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Start of Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.11.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>OnARandomBox</id>
|
||||
<url>https://repo.onarandombox.com/content/repositories/multiverse</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>OnARandomBox</id>
|
||||
<url>https://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'multiverse-core'
|
||||
@@ -28,7 +28,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@@ -346,7 +345,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
@SerializableAs("MVNullLocation (It's a bug if you see this in your config file)")
|
||||
public static final class NullLocation extends SpawnLocation {
|
||||
public NullLocation() {
|
||||
super(0, -1, 0);
|
||||
super(null, 0, -1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,21 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import buscript.Buscript;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
|
||||
@@ -33,41 +18,42 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.commands.AnchorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CheckCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CloneCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfigCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.DebugCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GameruleCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GamerulesCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ImportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.InfoCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.LoadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ModifyAddCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ModifyClearCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ModifyCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ModifyRemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ModifySetCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.PurgeCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RegenCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ScriptCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SilentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.VersionCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.WhoCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.AnchorCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.CheckCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.CloneCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ConfigCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ConfirmCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.DeleteCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.GameruleCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.GamerulesCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.GeneratorCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ImportCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.InfoCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.LoadCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ModifyAddCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ModifyClearCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ModifyCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ModifyRemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ModifySetCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.PurgeCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.RegenCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ReloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.ScriptCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.SilentCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.UnloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.VersionCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.WhoCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
|
||||
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.BedDestination;
|
||||
@@ -78,31 +64,27 @@ import com.onarandombox.MultiverseCore.destination.PlayerDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVMapListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.CompatibilityLayer;
|
||||
import com.onarandombox.MultiverseCore.utils.MVEconomist;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.MaterialConverter;
|
||||
import com.onarandombox.MultiverseCore.utils.TestingMode;
|
||||
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.TestingMode;
|
||||
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
@@ -123,6 +105,20 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The implementation of the Multiverse-{@link Core}.
|
||||
*/
|
||||
@@ -205,6 +201,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
// Setup our Map for our Commands using the CommandHandler.
|
||||
private CommandHandler commandHandler;
|
||||
private MVCommandManager commandManager;
|
||||
private CommandQueueManager commandQueueManager;
|
||||
|
||||
private static final String LOG_TAG = "[Multiverse-Core]";
|
||||
@@ -257,8 +254,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Setup our SafeTTeleporter
|
||||
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
|
||||
this.unsafeCallWrapper = new UnsafeCallWrapper(this);
|
||||
// Setup our CompatibilityLayer
|
||||
CompatibilityLayer.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +285,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
// Setup the command manager
|
||||
this.commandHandler = new CommandHandler(this, this.ph);
|
||||
this.commandManager = new MVCommandManager(this);
|
||||
this.commandQueueManager = new CommandQueueManager(this);
|
||||
// Call the Function to assign all the Commands to their Class.
|
||||
this.registerCommands();
|
||||
@@ -324,17 +320,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// A test that had no worlds loaded was being run. This should never happen in production
|
||||
}
|
||||
this.saveMVConfig();
|
||||
// Register async or sync player chat according to config
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.AsyncPlayerChatEvent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getMVConfig().setUseAsyncChat(false);
|
||||
}
|
||||
if (getMVConfig().getUseAsyncChat()) {
|
||||
this.chatListener = new MVAsyncPlayerChatListener(this, this.playerListener);
|
||||
} else {
|
||||
this.chatListener = new MVPlayerChatListener(this, this.playerListener);
|
||||
}
|
||||
|
||||
this.chatListener = new MVChatListener(this, this.playerListener);
|
||||
getServer().getPluginManager().registerEvents(this.chatListener, this);
|
||||
|
||||
this.initializeBuscript();
|
||||
@@ -394,9 +381,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
pm.registerEvents(this.entityListener, this);
|
||||
pm.registerEvents(this.weatherListener, this);
|
||||
pm.registerEvents(this.portalListener, this);
|
||||
Logging.info(ChatColor.GREEN + "We are aware of the warning about the deprecated event. There is no alternative that allows us to do what we need to do and performance impact is negligible. It is safe to ignore.");
|
||||
pm.registerEvents(this.worldListener, this);
|
||||
pm.registerEvents(new MVMapListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -785,13 +770,16 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.commandHandler.registerCommand(new AnchorCommand(this));
|
||||
// Misc Commands
|
||||
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
||||
this.commandHandler.registerCommand(new DebugCommand(this));
|
||||
// this.commandHandler.registerCommand(new DebugCommand(this));
|
||||
this.commandHandler.registerCommand(new SilentCommand(this));
|
||||
this.commandHandler.registerCommand(new GeneratorCommand(this));
|
||||
this.commandHandler.registerCommand(new CheckCommand(this));
|
||||
this.commandHandler.registerCommand(new ScriptCommand(this));
|
||||
this.commandHandler.registerCommand(new GameruleCommand(this));
|
||||
this.commandHandler.registerCommand(new GamerulesCommand(this));
|
||||
|
||||
//**NEW ACF COMMAND HANDLER**
|
||||
this.commandManager.registerCommand(new DebugCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -848,47 +836,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated This is now deprecated, nobody needs it any longer.
|
||||
* All logging is now done with {@link Logging}.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void log(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
*
|
||||
* @param level The Log-{@link Level}.
|
||||
* @param msg The message to log.
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
|
||||
* messages will appear to originate from Multiverse-Core.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void staticLog(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print messages to the Debug Log, if the servers in Debug Mode then we also want to print the messages to the
|
||||
* standard Server Console.
|
||||
*
|
||||
* @param level The Log-{@link Level}
|
||||
* @param msg The message
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
|
||||
* messages will appear to originate from Multiverse-Core.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void staticDebugLog(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -926,19 +873,17 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public CommandQueueManager getCommandQueueManager() {
|
||||
return commandQueueManager;
|
||||
public MVCommandManager getCommandManager() {
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log-tag.
|
||||
*
|
||||
* @return The log-tag
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
// TODO this should be static!
|
||||
public String getTag() {
|
||||
return MultiverseCore.LOG_TAG;
|
||||
@Override
|
||||
@Deprecated
|
||||
public CommandQueueManager getCommandQueueManager() {
|
||||
return commandQueueManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1126,7 +1071,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
public Boolean cloneWorld(String oldName, String newName, String generator) {
|
||||
return this.worldManager.cloneWorld(oldName, newName, generator);
|
||||
return this.worldManager.cloneWorld(oldName, newName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1216,17 +1161,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is currently used by other plugins.
|
||||
* It will be removed in 2.4
|
||||
* @return The Multiverse config.
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public static MultiverseCoreConfiguration getStaticConfig() {
|
||||
return MultiverseCoreConfiguration.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buscript getScriptAPI() {
|
||||
return buscript;
|
||||
|
||||
@@ -48,8 +48,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
@Property
|
||||
private volatile String prefixchatformat;
|
||||
@Property
|
||||
private volatile boolean useasyncchat;
|
||||
@Property
|
||||
private volatile boolean teleportintercept;
|
||||
@Property
|
||||
private volatile boolean firstspawnoverride;
|
||||
@@ -95,7 +93,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
protected void setDefaults() {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
enforceaccess = false;
|
||||
useasyncchat = true;
|
||||
prefixchat = false;
|
||||
prefixchatformat = "[%world%]%chat%";
|
||||
teleportintercept = true;
|
||||
@@ -322,16 +319,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
this.teleportcooldown = teleportCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseAsyncChat(boolean useAsyncChat) {
|
||||
this.useasyncchat = useAsyncChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseAsyncChat() {
|
||||
return this.useasyncchat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSilentStart(boolean silentStart) {
|
||||
Logging.setShowingConfig(!silentStart);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import buscript.Buscript;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
@@ -87,6 +88,14 @@ public interface Core {
|
||||
*/
|
||||
CommandHandler getCommandHandler();
|
||||
|
||||
/**
|
||||
* Multiverse uses {@link MVCommandManager} to make adding and using commands
|
||||
* a piece of cake.
|
||||
*
|
||||
* @return A non-null {@link MVCommandManager}.
|
||||
*/
|
||||
MVCommandManager getCommandManager();
|
||||
|
||||
/**
|
||||
* Manager for command that requires /mv confirm before execution.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* A simple API to require plugins to have a log method.
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}.
|
||||
* */
|
||||
@Deprecated
|
||||
public interface LoggablePlugin {
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
*
|
||||
* @param level The Log-{@link Level}.
|
||||
* @param msg The message to log.
|
||||
*/
|
||||
void log(Level level, String msg);
|
||||
|
||||
/**
|
||||
* Gets the server instance that this plugin is attached to.
|
||||
*
|
||||
* @return A {@link Server} instance.
|
||||
*/
|
||||
Server getServer();
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
/**
|
||||
* This interface is implemented by every official Multiverse-plugin.
|
||||
*/
|
||||
public interface MVPlugin extends LoggablePlugin {
|
||||
public interface MVPlugin {
|
||||
/**
|
||||
* Adds This plugin's version information to the buffer and returns the new string.
|
||||
*
|
||||
|
||||
@@ -59,18 +59,6 @@ public interface MVWorldManager {
|
||||
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
|
||||
* @param generator The Custom generator plugin to use. Ignored.
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
* @deprecated Use {@link #cloneWorld(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean cloneWorld(String oldName, String newName, String generator);
|
||||
|
||||
/**
|
||||
* Make a copy of a world.
|
||||
*
|
||||
@@ -234,19 +222,9 @@ public interface MVWorldManager {
|
||||
*/
|
||||
void loadDefaultWorlds();
|
||||
|
||||
/**
|
||||
* Return the World Purger.
|
||||
*
|
||||
* @return A valid {@link PurgeWorlds}.
|
||||
* @deprecated {@link PurgeWorlds} is deprecated!
|
||||
*/
|
||||
@Deprecated
|
||||
PurgeWorlds getWorldPurger();
|
||||
|
||||
/**
|
||||
* Gets the {@link WorldPurger}.
|
||||
* <p>
|
||||
* TODO: Remove {@link #getWorldPurger()} and replace it with this method.
|
||||
* @return The {@link WorldPurger} this {@link MVWorldManager} is using.
|
||||
* @see WorldPurger
|
||||
* @see SimpleWorldPurger
|
||||
|
||||
@@ -158,18 +158,6 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
*/
|
||||
boolean getEnforceAccess();
|
||||
|
||||
/**
|
||||
* Sets useasyncchat.
|
||||
* @param useAsyncChat The new value.
|
||||
*/
|
||||
void setUseAsyncChat(boolean useAsyncChat);
|
||||
|
||||
/**
|
||||
* Gets useasyncchat.
|
||||
* @return useasyncchat.
|
||||
*/
|
||||
boolean getUseAsyncChat();
|
||||
|
||||
/**
|
||||
* Sets whether to suppress startup messages.
|
||||
*
|
||||
|
||||
@@ -115,33 +115,6 @@ public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
|
||||
return this.getCore().getCommandHandler().locateAndRunCommand(sender, allArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
int debugLevel = this.getCore().getMVConfig().getGlobalDebug();
|
||||
if ((level == Level.FINE && debugLevel >= 1) || (level == Level.FINER && debugLevel >= 2)
|
||||
|| (level == Level.FINEST && debugLevel >= 3)) {
|
||||
debugLog.log(level, msg);
|
||||
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
||||
String message = new StringBuilder(getLogTag()).append(msg).toString();
|
||||
this.getServer().getLogger().log(level, message);
|
||||
debugLog.log(level, message);
|
||||
}
|
||||
}
|
||||
|
||||
private String getLogTag() {
|
||||
if (logTag == null)
|
||||
logTag = String.format("[%s]", this.getDescription().getName());
|
||||
return logTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug log-tag.
|
||||
* @param tag The new tag.
|
||||
*/
|
||||
protected final void setDebugLogTag(String tag) {
|
||||
this.debugLog.setTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String dumpVersionInfo(String buffer) {
|
||||
throw new UnsupportedOperationException("This is gone.");
|
||||
|
||||
@@ -1,67 +1,57 @@
|
||||
/******************************************************************************
|
||||
* 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.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.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import com.onarandombox.MultiverseCore.locale.MVCorei18n;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Enables debug-information.
|
||||
*/
|
||||
@CommandAlias("mv")
|
||||
public class DebugCommand extends MultiverseCommand {
|
||||
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn Debug on/off?");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv debug");
|
||||
this.addKey("mv d");
|
||||
this.addKey("mvdebug");
|
||||
this.addCommandExample("/mv debug " + ChatColor.GOLD + "2");
|
||||
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("off")) {
|
||||
plugin.getMVConfig().setGlobalDebug(0);
|
||||
} else {
|
||||
try {
|
||||
int debugLevel = Integer.parseInt(args.get(0));
|
||||
if (debugLevel > 3 || debugLevel < 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
plugin.getMVConfig().setGlobalDebug(debugLevel);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
||||
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||
}
|
||||
}
|
||||
plugin.saveMVConfigs();
|
||||
}
|
||||
this.displayDebugMode(sender);
|
||||
@Subcommand("debug")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@Description("{@@mv-core.debug_info_description}")
|
||||
public void onShowDebugCommand(@NotNull CommandIssuer issuer) {
|
||||
this.displayDebugMode(issuer);
|
||||
}
|
||||
|
||||
private void displayDebugMode(CommandSender sender) {
|
||||
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
|
||||
|
||||
@Subcommand("debug")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@Syntax("<{@@mv-core.debug_change_syntax}>")
|
||||
@CommandCompletion("@range:3")
|
||||
@Description("{@@mv-core.debug_change_description}")
|
||||
public void onChangeDebugCommand(@NotNull CommandIssuer issuer,
|
||||
|
||||
@Conditions("debuglevel")
|
||||
@Syntax("<{@@mv-core.debug_change_syntax}>")
|
||||
@Description("{@@mv-core.debug_change_level_description}")
|
||||
int level) {
|
||||
|
||||
this.plugin.getMVConfig().setGlobalDebug(level);
|
||||
this.plugin.saveMVConfigs();
|
||||
this.displayDebugMode(issuer);
|
||||
}
|
||||
|
||||
private void displayDebugMode(@NotNull CommandIssuer issuer) {
|
||||
final int debugLevel = this.plugin.getMVConfig().getGlobalDebug();
|
||||
if (debugLevel == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
|
||||
Logging.fine("Multiverse Debug ENABLED");
|
||||
issuer.sendInfo(MVCorei18n.DEBUG_INFO_OFF);
|
||||
return;
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.DEBUG_INFO_ON, "{level}", String.valueOf(debugLevel));
|
||||
Logging.fine("Multiverse Debug ENABLED.");
|
||||
}
|
||||
}
|
||||
@@ -1,119 +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.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.display.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.display.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Displays a listing of all worlds that a player can enter.
|
||||
*/
|
||||
public class ListCommand extends MultiverseCommand {
|
||||
|
||||
public ListCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Listing");
|
||||
this.setCommandUsage("/mv list [filter] [page]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mvlist");
|
||||
this.addKey("mvl");
|
||||
this.addKey("mv list");
|
||||
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
ContentFilter filter = ContentFilter.DEFAULT;
|
||||
int page = 1;
|
||||
|
||||
// Either page or filter.
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
page = Integer.parseInt(args.get(0));
|
||||
} catch (NumberFormatException ignore) {
|
||||
filter = new ContentFilter(args.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
// Filter then page.
|
||||
if (args.size() == 2) {
|
||||
filter = new ContentFilter(args.get(0));
|
||||
try {
|
||||
page = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ignore) {
|
||||
sender.sendMessage(ChatColor.RED + args.get(1) + " is not valid number!");
|
||||
}
|
||||
}
|
||||
|
||||
ContentDisplay.forContent(getListContents(sender))
|
||||
.header("%s====[ Multiverse World List ]====", ChatColor.GOLD)
|
||||
.displayHandler(DisplayHandlers.PAGE_LIST)
|
||||
.colorTool(ColorAlternator.with(ChatColor.AQUA, ChatColor.GOLD))
|
||||
.filter(filter)
|
||||
.setting(PagedDisplaySettings.SHOW_PAGE, page)
|
||||
.show(sender);
|
||||
}
|
||||
|
||||
private Collection<String> getListContents(@NotNull CommandSender sender) {
|
||||
Player player = (sender instanceof Player) ? (Player) sender : null;
|
||||
|
||||
List<String> worldList = this.plugin.getMVWorldManager().getMVWorlds().stream()
|
||||
.filter(world -> player == null || plugin.getMVPerms().canEnterWorld(player, world))
|
||||
.filter(world -> canSeeWorld(player, world))
|
||||
.map(world -> hiddenText(world) + world.getColoredWorldString() + " - " + parseColouredEnvironment(world.getEnvironment()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
this.plugin.getMVWorldManager().getUnloadedWorlds().stream()
|
||||
.filter(world -> plugin.getMVPerms().hasPermission(sender, "multiverse.access." + world, true))
|
||||
.map(world -> ChatColor.GRAY + world + " - UNLOADED")
|
||||
.forEach(worldList::add);
|
||||
|
||||
return worldList;
|
||||
}
|
||||
|
||||
private boolean canSeeWorld(Player player, MultiverseWorld world) {
|
||||
return !world.isHidden()
|
||||
|| player == null
|
||||
|| this.plugin.getMVPerms().hasPermission(player, "multiverse.core.modify", true);
|
||||
}
|
||||
|
||||
private String hiddenText(MultiverseWorld world) {
|
||||
return (world.isHidden()) ? String.format("%s[H] ", ChatColor.GRAY) : "";
|
||||
}
|
||||
|
||||
private String parseColouredEnvironment(World.Environment env) {
|
||||
ChatColor color = ChatColor.GOLD;
|
||||
switch (env) {
|
||||
case NETHER:
|
||||
color = ChatColor.RED;
|
||||
break;
|
||||
case NORMAL:
|
||||
color = ChatColor.GREEN;
|
||||
break;
|
||||
case THE_END:
|
||||
color = ChatColor.AQUA;
|
||||
break;
|
||||
}
|
||||
return color + env.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 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.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
public class MultiverseCommand extends BaseCommand {
|
||||
|
||||
/**
|
||||
* A generic Multiverse-command.
|
||||
*/
|
||||
public abstract class MultiverseCommand extends Command {
|
||||
protected final MultiverseCore plugin;
|
||||
|
||||
/**
|
||||
* The reference to the core.
|
||||
*/
|
||||
protected MultiverseCore plugin;
|
||||
/**
|
||||
* The reference to {@link MultiverseMessaging}.
|
||||
*/
|
||||
protected MultiverseMessaging messaging;
|
||||
|
||||
public MultiverseCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
protected MultiverseCommand(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.messaging = this.plugin.getMessaging();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void runCommand(CommandSender sender, List<String> args);
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* This package contains all Commands.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+1
-2
@@ -5,13 +5,12 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
@@ -0,0 +1,66 @@
|
||||
/******************************************************************************
|
||||
* 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.commandsold;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Enables debug-information.
|
||||
*/
|
||||
public class DebugCommand extends MultiverseCommand {
|
||||
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn Debug on/off?");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv debug");
|
||||
this.addKey("mv d");
|
||||
this.addKey("mvdebug");
|
||||
this.addCommandExample("/mv debug " + ChatColor.GOLD + "2");
|
||||
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("off")) {
|
||||
plugin.getMVConfig().setGlobalDebug(0);
|
||||
} else {
|
||||
try {
|
||||
int debugLevel = Integer.parseInt(args.get(0));
|
||||
if (debugLevel > 3 || debugLevel < 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
plugin.getMVConfig().setGlobalDebug(debugLevel);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
||||
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||
}
|
||||
}
|
||||
plugin.saveMVConfigs();
|
||||
}
|
||||
this.displayDebugMode(sender);
|
||||
}
|
||||
|
||||
private void displayDebugMode(CommandSender sender) {
|
||||
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
|
||||
if (debugLevel == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
|
||||
Logging.fine("Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
@@ -14,7 +14,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Bukkit;
|
||||
+33
-17
@@ -5,12 +5,15 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.display.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
|
||||
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.display.handlers.InlineSendHandler;
|
||||
import com.onarandombox.MultiverseCore.display.parsers.MapContentParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
@@ -31,8 +34,8 @@ public class GamerulesCommand extends MultiverseCommand {
|
||||
public GamerulesCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("List the Minecraft Game Rules for a World.");
|
||||
this.setCommandUsage("/mv gamerules" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(0, 1);
|
||||
this.setCommandUsage("/mv gamerules" + ChatColor.GOLD + " [WORLD] [FILTER]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mv gamerules");
|
||||
this.addKey("mv rules");
|
||||
this.addKey("mvgamerules");
|
||||
@@ -42,11 +45,13 @@ public class GamerulesCommand extends MultiverseCommand {
|
||||
this.setPermission("multiverse.core.gamerule.list", "Allows a player to list gamerules.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// We NEED a world from the command line
|
||||
final Player p;
|
||||
Player p;
|
||||
World world;
|
||||
ContentFilter filter = DefaultContentFilter.getInstance();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
} else {
|
||||
@@ -61,9 +66,20 @@ public class GamerulesCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final World world;
|
||||
// Not the best way, need to fix with ACF soon...
|
||||
if (args.size() == 0) {
|
||||
world = p.getWorld();
|
||||
} else if (args.size() == 1) {
|
||||
world = Bukkit.getWorld(args.get(0));
|
||||
if (world == null) {
|
||||
if (p == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " World " + ChatColor.AQUA + args.get(0)
|
||||
+ ChatColor.WHITE + " does not exist.");
|
||||
return;
|
||||
}
|
||||
world = p.getWorld();
|
||||
filter = RegexContentFilter.fromString(args.get(0));
|
||||
}
|
||||
} else {
|
||||
world = Bukkit.getWorld(args.get(0));
|
||||
if (world == null) {
|
||||
@@ -71,23 +87,23 @@ public class GamerulesCommand extends MultiverseCommand {
|
||||
+ ChatColor.WHITE + " does not exist.");
|
||||
return;
|
||||
}
|
||||
filter = RegexContentFilter.fromString(args.get(1));
|
||||
}
|
||||
|
||||
ContentDisplay.forContent(getGameRuleMap(world))
|
||||
.header("=== Gamerules for %s%s%s ===", ChatColor.AQUA, world.getName(), ChatColor.WHITE)
|
||||
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
|
||||
.setting(MapDisplaySettings.OPERATOR, ": ")
|
||||
.show(sender);
|
||||
ContentDisplay.create()
|
||||
.addContentParser(MapContentParser.forContent(getGameRuleMap(world))
|
||||
.withKeyColor(ChatColor.GREEN)
|
||||
.withValueColor(ChatColor.YELLOW))
|
||||
.withSendHandler(InlineSendHandler.create()
|
||||
.withHeader("====[ Gamerules for %s%s%s ]====", ChatColor.AQUA, world.getName(), ChatColor.WHITE)
|
||||
.withFilter(filter))
|
||||
.send(sender);
|
||||
}
|
||||
|
||||
private Map<String, Object> getGameRuleMap(World world) {
|
||||
Map<String, Object> gameRuleMap = new HashMap<>();
|
||||
for (GameRule<?> rule : GameRule.values()) {
|
||||
Object value = world.getGameRuleValue(rule);
|
||||
if (value == null) {
|
||||
gameRuleMap.put(rule.getName(), "null");
|
||||
continue;
|
||||
}
|
||||
gameRuleMap.put(rule.getName(), value);
|
||||
}
|
||||
return gameRuleMap;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.FancyText;
|
||||
@@ -0,0 +1,120 @@
|
||||
/******************************************************************************
|
||||
* 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.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
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.display.handlers.PagedSendHandler;
|
||||
import com.onarandombox.MultiverseCore.display.parsers.ContentParser;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays a listing of all worlds that a player can enter.
|
||||
*/
|
||||
public class ListCommand extends MultiverseCommand {
|
||||
|
||||
public ListCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Listing");
|
||||
this.setCommandUsage("/mv list [filter] [page]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mvlist");
|
||||
this.addKey("mvl");
|
||||
this.addKey("mv list");
|
||||
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
ContentFilter filter = DefaultContentFilter.getInstance();
|
||||
int page = 1;
|
||||
|
||||
// Either page or filter.
|
||||
if (args.size() == 1) {
|
||||
try {
|
||||
page = Integer.parseInt(args.get(0));
|
||||
} catch (NumberFormatException ignore) {
|
||||
filter = RegexContentFilter.fromString(args.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
// Filter then page.
|
||||
if (args.size() == 2) {
|
||||
filter = RegexContentFilter.fromString(args.get(0));
|
||||
try {
|
||||
page = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ignore) {
|
||||
sender.sendMessage(ChatColor.RED + args.get(1) + " is not valid number!");
|
||||
}
|
||||
}
|
||||
|
||||
ContentDisplay.create()
|
||||
.addContentParser(new WorldListContentParser())
|
||||
.withSendHandler(PagedSendHandler.create()
|
||||
.withHeader("%s====[ Multiverse World List ]====", ChatColor.GOLD)
|
||||
.withFilter(filter)
|
||||
.withTargetPage(page))
|
||||
.send(sender);
|
||||
}
|
||||
|
||||
private class WorldListContentParser implements ContentParser {
|
||||
|
||||
@Override
|
||||
public void parse(@NotNull CommandSender sender, @NotNull List<String> content) {
|
||||
Player player = (sender instanceof Player) ? (Player) sender : null;
|
||||
|
||||
plugin.getMVWorldManager().getMVWorlds().stream()
|
||||
.filter(world -> player == null || plugin.getMVPerms().canEnterWorld(player, world))
|
||||
.filter(world -> canSeeWorld(player, world))
|
||||
.map(world -> hiddenText(world) + world.getColoredWorldString() + " - " + parseColouredEnvironment(world.getEnvironment()))
|
||||
.forEach(content::add);
|
||||
|
||||
plugin.getMVWorldManager().getUnloadedWorlds().stream()
|
||||
.filter(world -> plugin.getMVPerms().hasPermission(sender, "multiverse.access." + world, true))
|
||||
.map(world -> ChatColor.GRAY + world + " - UNLOADED")
|
||||
.forEach(content::add);
|
||||
}
|
||||
|
||||
private boolean canSeeWorld(Player player, MultiverseWorld world) {
|
||||
return !world.isHidden()
|
||||
|| player == null
|
||||
|| plugin.getMVPerms().hasPermission(player, "multiverse.core.modify", true);
|
||||
}
|
||||
|
||||
private String hiddenText(MultiverseWorld world) {
|
||||
return (world.isHidden()) ? String.format("%s[H] ", ChatColor.GRAY) : "";
|
||||
}
|
||||
|
||||
private String parseColouredEnvironment(World.Environment env) {
|
||||
ChatColor color = ChatColor.GOLD;
|
||||
switch (env) {
|
||||
case NETHER:
|
||||
color = ChatColor.RED;
|
||||
break;
|
||||
case NORMAL:
|
||||
color = ChatColor.GREEN;
|
||||
break;
|
||||
case THE_END:
|
||||
color = ChatColor.AQUA;
|
||||
break;
|
||||
}
|
||||
return color + env.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
@@ -0,0 +1,40 @@
|
||||
/******************************************************************************
|
||||
* 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.commandsold;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* A generic Multiverse-command.
|
||||
*/
|
||||
public abstract class MultiverseCommand extends Command {
|
||||
|
||||
/**
|
||||
* The reference to the core.
|
||||
*/
|
||||
protected MultiverseCore plugin;
|
||||
/**
|
||||
* The reference to {@link MultiverseMessaging}.
|
||||
*/
|
||||
protected MultiverseMessaging messaging;
|
||||
|
||||
public MultiverseCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
this.messaging = this.plugin.getMessaging();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void runCommand(CommandSender sender, List<String> args);
|
||||
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
+4
-7
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
@@ -40,13 +40,10 @@ public class RegenCommand extends MultiverseCommand {
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
String worldName = args.get(0);
|
||||
boolean useseed = CommandHandler.hasFlag("-s", args);
|
||||
String seedflag = CommandHandler.getFlag("-s", args);
|
||||
boolean useseed = (!(args.size() == 1));
|
||||
boolean randomseed = (args.size() == 2 && args.get(1).equalsIgnoreCase("-s"));
|
||||
String seed = (args.size() == 3) ? args.get(2) : "";
|
||||
boolean keepGamerules = CommandHandler.hasFlag("--keep-gamerules", args);
|
||||
|
||||
boolean randomseed = seedflag == null || seedflag.isEmpty() || seedflag.equalsIgnoreCase("--keep-gamerules");
|
||||
String seed = randomseed ? "" : seedflag;
|
||||
|
||||
this.plugin.getCommandQueueManager().addToQueue(new QueuedCommand(
|
||||
sender,
|
||||
doWorldRegen(sender, worldName, useseed, randomseed, seed, keepGamerules),
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
+1
-2
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@@ -28,7 +28,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
+5
-6
@@ -5,7 +5,11 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@@ -26,10 +30,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Dumps version info to the console.
|
||||
*/
|
||||
@@ -63,7 +63,6 @@ public class VersionCommand extends MultiverseCommand {
|
||||
+ "[Multiverse-Core] enforceaccess: " + plugin.getMVConfig().getEnforceAccess() + '\n'
|
||||
+ "[Multiverse-Core] prefixchat: " + plugin.getMVConfig().getPrefixChat() + '\n'
|
||||
+ "[Multiverse-Core] prefixchatformat: " + plugin.getMVConfig().getPrefixChatFormat() + '\n'
|
||||
+ "[Multiverse-Core] useasyncchat: " + plugin.getMVConfig().getUseAsyncChat() + '\n'
|
||||
+ "[Multiverse-Core] teleportintercept: " + plugin.getMVConfig().getTeleportIntercept() + '\n'
|
||||
+ "[Multiverse-Core] firstspawnoverride: " + plugin.getMVConfig().getFirstSpawnOverride() + '\n'
|
||||
+ "[Multiverse-Core] displaypermerrors: " + plugin.getMVConfig().getDisplayPermErrors() + '\n'
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This package contains all Commands.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commandsold;
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.PaperCommandCompletions;
|
||||
|
||||
public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
public MVCommandCompletions(MVCommandManager mvCommandManager) {
|
||||
super(mvCommandManager);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.PaperCommandContexts;
|
||||
|
||||
public class MVCommandContexts extends PaperCommandContexts {
|
||||
public MVCommandContexts(MVCommandManager mvCommandManager) {
|
||||
super(mvCommandManager);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.CommandCompletions;
|
||||
import co.aikar.commands.CommandContexts;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
/**
|
||||
* Main class to manage permissions.
|
||||
*/
|
||||
public class MVCommandManager extends PaperCommandManager {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
|
||||
public MVCommandManager(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
|
||||
// Setup locale
|
||||
this.addSupportedLanguage(Locale.ENGLISH);
|
||||
this.locales.addMessageBundles("multiverse-core");
|
||||
this.locales.loadLanguages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class responsible for parsing string args into objects.
|
||||
*
|
||||
* @return A not-null {@link CommandContexts}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized CommandContexts<BukkitCommandExecutionContext> getCommandContexts() {
|
||||
if (this.contexts == null) {
|
||||
this.contexts = new MVCommandContexts(this);
|
||||
}
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class responsible for tab-completion handling.
|
||||
*
|
||||
* @return A not-null {@link CommandCompletions}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() {
|
||||
if (this.completions == null) {
|
||||
this.completions = new MVCommandCompletions(this);
|
||||
}
|
||||
return this.completions;
|
||||
}
|
||||
}
|
||||
+17
@@ -11,6 +11,7 @@ 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.
|
||||
@@ -27,6 +28,16 @@ class DummyCommandBlockSender implements CommandSender {
|
||||
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();
|
||||
@@ -37,6 +48,12 @@ class DummyCommandBlockSender implements CommandSender {
|
||||
return "DummyCommandBlockSender";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Spigot spigot() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(@NotNull String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
@@ -18,54 +14,16 @@ import org.bukkit.configuration.serialization.SerializableAs;
|
||||
*/
|
||||
@SerializableAs("MVSpawnLocation")
|
||||
public class SpawnLocation extends Location implements ConfigurationSerializable {
|
||||
private Reference<World> worldRef;
|
||||
|
||||
public SpawnLocation(double x, double y, double z) {
|
||||
super(null, x, y, z);
|
||||
public SpawnLocation(World world, double x, double y, double z) {
|
||||
super(world, x, y, z);
|
||||
}
|
||||
|
||||
public SpawnLocation(double x, double y, double z, float yaw, float pitch) {
|
||||
super(null, x, y, z, yaw, pitch);
|
||||
public SpawnLocation(World world, double x, double y, double z, float yaw, float pitch) {
|
||||
super(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public SpawnLocation(Location loc) {
|
||||
this(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return (this.worldRef != null) ? this.worldRef.get() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setWorld(World world) {
|
||||
this.worldRef = new WeakReference<World>(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
if ((this.worldRef != null) && (this.worldRef.get() != null))
|
||||
return this.worldRef.get().getChunkAt(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
if ((this.worldRef != null) && (this.worldRef.get() != null))
|
||||
return this.worldRef.get().getBlockAt(this);
|
||||
return null;
|
||||
super(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +51,6 @@ public class SpawnLocation extends Location implements ConfigurationSerializable
|
||||
double z = ((Number) args.get("z")).doubleValue();
|
||||
float pitch = ((Number) args.get("pitch")).floatValue();
|
||||
float yaw = ((Number) args.get("yaw")).floatValue();
|
||||
return new SpawnLocation(x, y, z, yaw, pitch);
|
||||
return new SpawnLocation(null, x, y, z, yaw, pitch);
|
||||
}
|
||||
}
|
||||
@@ -9,17 +9,15 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commandsold.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import com.onarandombox.MultiverseCore.utils.PlayerFinder;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Helper class to switch between 2 {@link ChatColor}.
|
||||
*/
|
||||
public class ColorAlternator implements ColorTool {
|
||||
|
||||
/**
|
||||
* Creates a new {@link ColorAlternator} with 2 {@link ChatColor}s.
|
||||
*
|
||||
* @param colorThis The first color.
|
||||
* @param colorThat The second color.
|
||||
* @return The {@link ColorAlternator} created for you.
|
||||
*/
|
||||
public static ColorAlternator with(@NotNull ChatColor colorThis,
|
||||
@NotNull ChatColor colorThat) {
|
||||
|
||||
return new ColorAlternator(colorThis, colorThat);
|
||||
}
|
||||
|
||||
private boolean switcher;
|
||||
private final ChatColor thisColor;
|
||||
private final ChatColor thatColor;
|
||||
|
||||
/**
|
||||
* @param colorThis The first color.
|
||||
* @param colorThat The second color.
|
||||
*/
|
||||
public ColorAlternator(@NotNull ChatColor colorThis,
|
||||
@NotNull ChatColor colorThat) {
|
||||
|
||||
this.thisColor = colorThis;
|
||||
this.thatColor = colorThat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color. Everytime this method is called, it swaps the color that it returns.
|
||||
*
|
||||
* @return The color.
|
||||
*/
|
||||
@Override
|
||||
public ChatColor get() {
|
||||
return (this.switcher ^= true) ? this.thisColor : this.thatColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The first color.
|
||||
*/
|
||||
public ChatColor getThisColor() {
|
||||
return thisColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The second color.
|
||||
*/
|
||||
public ChatColor getThatColor() {
|
||||
return thatColor;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Tools to allow customisation.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ColorTool {
|
||||
|
||||
/**
|
||||
* Gets a chat color.
|
||||
*
|
||||
* @return The color.
|
||||
*/
|
||||
ChatColor get();
|
||||
|
||||
/**
|
||||
* Default implementation of this interface. Returns a default white color.
|
||||
*/
|
||||
ColorTool DEFAULT = () -> ChatColor.WHITE;
|
||||
}
|
||||
@@ -1,268 +1,69 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
import com.onarandombox.MultiverseCore.display.settings.DisplaySetting;
|
||||
import org.bukkit.ChatColor;
|
||||
import com.onarandombox.MultiverseCore.display.handlers.DefaultSendHandler;
|
||||
import com.onarandombox.MultiverseCore.display.handlers.SendHandler;
|
||||
import com.onarandombox.MultiverseCore.display.parsers.ContentParser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* Helps to display contents such as list and maps in a nicely formatted fashion.
|
||||
*
|
||||
* @param <T> Type of content to display.
|
||||
*/
|
||||
public class ContentDisplay<T> {
|
||||
|
||||
public static final String LINE_BREAK = "%br%";
|
||||
public class ContentDisplay {
|
||||
|
||||
/**
|
||||
* Creates a ContentDisplay.Builder for the given content.
|
||||
* Makes a new {@link ContentDisplay} instance to use.
|
||||
*
|
||||
* @param content The content to be displayed.
|
||||
* @param <T> The type of the content which can be inferred.
|
||||
* @return A new Builder.
|
||||
*/
|
||||
public static <T> Builder<T> forContent(T content) {
|
||||
return new Builder<>(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ContentDisplay.Builder for the given collection of content.
|
||||
*
|
||||
* @param content The content to be displayed.
|
||||
* @return A new Builder.
|
||||
*/
|
||||
public static Builder<Collection<String>> forContent(Collection<String> content) {
|
||||
return new Builder<>(content).displayHandler(DisplayHandlers.LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ContentDisplay.Builder for the given map of content.
|
||||
*
|
||||
* @param content The content to be displayed.
|
||||
* @return A new Builder.
|
||||
*/
|
||||
public static Builder<Map<String, Object>> forContent(Map<String, Object> content) {
|
||||
return new Builder<>(content).displayHandler(DisplayHandlers.INLINE_MAP);
|
||||
}
|
||||
|
||||
private final T contents;
|
||||
|
||||
private String header;
|
||||
private String emptyMessage = "No matching content to display.";
|
||||
private DisplayHandler<T> displayHandler;
|
||||
private ColorTool colorTool = ColorTool.DEFAULT;
|
||||
private ContentFilter filter = ContentFilter.DEFAULT;
|
||||
private final Map<DisplaySetting<?>, Object> settingsMap = new WeakHashMap<>();
|
||||
|
||||
private ContentDisplay(T contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual displaying of contents to the sender.
|
||||
*
|
||||
* @param sender The CommandSender to show the display to.
|
||||
*/
|
||||
public void show(@NotNull CommandSender sender) {
|
||||
Collection<String> formattedContent;
|
||||
try {
|
||||
formattedContent = (this.contents == null) ? null : this.displayHandler.format(sender, this);
|
||||
} catch (DisplayFormatException e) {
|
||||
sender.sendMessage(String.format("%sError: %s", ChatColor.RED, e.getMessage()));
|
||||
return;
|
||||
}
|
||||
this.displayHandler.sendHeader(sender, this);
|
||||
this.displayHandler.sendSubHeader(sender, this);
|
||||
this.displayHandler.sendBody(sender, this, formattedContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the header to display.
|
||||
*/
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the header text.
|
||||
*/
|
||||
public void setHeader(@NotNull String header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the contents to display.
|
||||
*/
|
||||
public T getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the message to display when no content is shown.
|
||||
* @return New {@link ContentDisplay} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public String getEmptyMessage() {
|
||||
return emptyMessage;
|
||||
public static ContentDisplay create() {
|
||||
return new ContentDisplay();
|
||||
}
|
||||
|
||||
private final List<ContentParser> contentParsers = new ArrayList<>();
|
||||
private SendHandler sendHandler = DefaultSendHandler.getInstance();
|
||||
|
||||
public ContentDisplay() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the display handler that formats and sends content to sender.
|
||||
* Adds content to be displayed.
|
||||
*
|
||||
* @param parser The content parser to add.
|
||||
* @return Same {@link ContentDisplay} for method chaining.
|
||||
*/
|
||||
@NotNull
|
||||
public DisplayHandler<T> getDisplayHandler() {
|
||||
return displayHandler;
|
||||
public ContentDisplay addContentParser(@NotNull ContentParser parser) {
|
||||
contentParsers.add(parser);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the color tool used.
|
||||
* Sets the handler for displaying the message to command sender.
|
||||
*
|
||||
* @param handler The send handler to use.
|
||||
* @return Same {@link ContentDisplay} for method chaining.
|
||||
*/
|
||||
@NotNull
|
||||
public ColorTool getColorTool() {
|
||||
return colorTool;
|
||||
public ContentDisplay withSendHandler(@NotNull SendHandler handler) {
|
||||
sendHandler = handler;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the filter used.
|
||||
*/
|
||||
@NotNull
|
||||
public ContentFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value for a given setting option.
|
||||
* Format and display the message to command sender.
|
||||
*
|
||||
* @param setting The setting option.
|
||||
* @param <S> The setting type.
|
||||
* @return Value set for the given setting.
|
||||
* @param sender The target command sender to show the display to.
|
||||
*/
|
||||
public <S> S getSetting(@NotNull DisplaySetting<S> setting) {
|
||||
return (S) settingsMap.getOrDefault(setting, setting.defaultValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets other specific settings that may be used by the {@link DisplayHandler}.
|
||||
*
|
||||
* @param setting The settings option.
|
||||
* @param value The value to set.
|
||||
* @param <S> The type of setting.
|
||||
*/
|
||||
public <S> void setSetting(@NotNull DisplaySetting<S> setting, S value) {
|
||||
this.settingsMap.put(setting, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link ContentDisplay}.
|
||||
*
|
||||
* @param <T> Type of content to display.
|
||||
*/
|
||||
public static class Builder<T> {
|
||||
|
||||
private final ContentDisplay<T> display;
|
||||
|
||||
private Builder(T content) {
|
||||
this.display = new ContentDisplay<>(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets header to be displayed.
|
||||
*
|
||||
* @param header The header text.
|
||||
* @param replacements String formatting replacements.
|
||||
* @return The builder.
|
||||
*/
|
||||
@NotNull
|
||||
public Builder<T> header(@NotNull String header, Object...replacements) {
|
||||
this.display.header = String.format(header, replacements);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message to show when no content is available for display.
|
||||
*
|
||||
* @param emptyMessage The message text.
|
||||
* @param replacements String formatting replacements.
|
||||
* @return The builder.
|
||||
*/
|
||||
@NotNull
|
||||
public Builder<T> emptyMessage(@NotNull String emptyMessage, Object...replacements) {
|
||||
this.display.emptyMessage = String.format(emptyMessage, replacements);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display handler that does the formatting and sending of content. <b>Required.</b>
|
||||
*
|
||||
* @param displayHandler The display handler for the given content type.
|
||||
* @return The builder.
|
||||
*/
|
||||
@NotNull
|
||||
public Builder<T> displayHandler(@NotNull DisplayHandler<T> displayHandler) {
|
||||
this.display.displayHandler = displayHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color tool used to make messages more colourful.
|
||||
*
|
||||
* @param colorTool The color tool to use.
|
||||
* @return The builder.
|
||||
*/
|
||||
@NotNull
|
||||
public Builder<T> colorTool(@NotNull ColorTool colorTool) {
|
||||
this.display.colorTool = colorTool;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets content filter used to match specific content to be displayed.
|
||||
*
|
||||
* @param filter The filter to use.
|
||||
* @return The builder.
|
||||
*/
|
||||
@NotNull
|
||||
public Builder<T> filter(@NotNull ContentFilter filter) {
|
||||
this.display.filter = filter;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets other specific settings that may be used by the {@link DisplayHandler}.
|
||||
*
|
||||
* @param setting The settings option.
|
||||
* @param value The value to set.
|
||||
* @param <S> The type of setting.
|
||||
* @return The builder.
|
||||
*/
|
||||
@NotNull
|
||||
public <S> Builder<T> setting(@NotNull DisplaySetting<S> setting, S value) {
|
||||
this.display.settingsMap.put(setting, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and build the content display.
|
||||
*
|
||||
* @return The content display.
|
||||
*/
|
||||
@NotNull
|
||||
public ContentDisplay<T> build() {
|
||||
Objects.requireNonNull(this.display.displayHandler);
|
||||
return this.display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and show the content to the sender.
|
||||
*
|
||||
* @param sender The CommandSender to show the display to.
|
||||
*/
|
||||
public void show(CommandSender sender) {
|
||||
this.build().show(sender);
|
||||
}
|
||||
public void send(@NotNull CommandSender sender) {
|
||||
Objects.requireNonNull(sendHandler, "No send handler set for content display");
|
||||
List<String> parsedContent = new ArrayList<>();
|
||||
contentParsers.forEach(parser -> parser.parse(sender, parsedContent));
|
||||
sendHandler.send(sender, parsedContent);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/**
|
||||
* <p>Filter content and text based on regex matching.</p>
|
||||
*
|
||||
* <p>Compile regex pattern based on {@link ContentFilter#filterString}. When prefixed with 'r=',
|
||||
* use {@link ContentFilter#filterString} as the full regex pattern. Else, set to any match that
|
||||
* contains the {@link ContentFilter#filterString}.<p>
|
||||
*/
|
||||
public class ContentFilter {
|
||||
|
||||
public static final ContentFilter DEFAULT = new ContentFilter();
|
||||
private static final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
|
||||
|
||||
private String filterString;
|
||||
private Pattern filterPattern;
|
||||
private boolean exactMatch;
|
||||
|
||||
private ContentFilter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filterString The text to do matching, either plaintext or regex.
|
||||
*/
|
||||
public ContentFilter(@NotNull String filterString) {
|
||||
this(filterString, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filterString The text to do matching, else plaintext or regex.
|
||||
* @param exactMatch Should check for exact match when doing regex matching.
|
||||
*/
|
||||
public ContentFilter(@NotNull String filterString,
|
||||
boolean exactMatch) {
|
||||
|
||||
this.filterString = filterString;
|
||||
this.exactMatch = exactMatch;
|
||||
parseFilter();
|
||||
}
|
||||
|
||||
private void parseFilter() {
|
||||
if (filterString == null) {
|
||||
return;
|
||||
}
|
||||
if (filterString.startsWith("r=")) {
|
||||
convertToMatcher(filterString.substring(2));
|
||||
return;
|
||||
}
|
||||
String cleanedFilter = REGEX_SPECIAL_CHARS.matcher(filterString.toLowerCase()).replaceAll("\\\\$0");
|
||||
convertToMatcher("(?i).*" + cleanedFilter + ".*");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile and store the regex into a {@link Pattern}.
|
||||
*
|
||||
* @param regex The regex text.
|
||||
*/
|
||||
private void convertToMatcher(@NotNull String regex) {
|
||||
try {
|
||||
this.filterPattern = Pattern.compile(regex);
|
||||
Logging.finest("Parsed regex pattern: %s", this.filterPattern.toString());
|
||||
}
|
||||
catch (PatternSyntaxException ignored) {
|
||||
Logging.warning("Error parsing regex: %s", filterString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do regex matching.
|
||||
*
|
||||
* @param text String to check regex on.
|
||||
* @return True of matches regex pattern, false otherwise.
|
||||
*/
|
||||
public boolean checkMatch(@Nullable Object text) {
|
||||
if (!hasFilter()) {
|
||||
return true;
|
||||
}
|
||||
if (text == null || !hasValidPattern()) {
|
||||
return false;
|
||||
}
|
||||
text = ChatColor.stripColor(String.valueOf(text));
|
||||
return (exactMatch)
|
||||
? filterPattern.matcher((CharSequence) text).matches()
|
||||
: filterPattern.matcher((CharSequence) text).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a filter string is present.
|
||||
*
|
||||
* @return True if there is a filter string, else false.
|
||||
*/
|
||||
public boolean hasFilter() {
|
||||
return filterString != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if regex pattern syntax is valid.
|
||||
*
|
||||
* @return True if valid, else false.
|
||||
*/
|
||||
public boolean hasValidPattern() {
|
||||
return filterPattern != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The filter string.
|
||||
*/
|
||||
@Nullable
|
||||
public String getString() {
|
||||
return filterString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The regex pattern.
|
||||
*/
|
||||
@Nullable
|
||||
public Pattern getPattern() {
|
||||
return filterPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if filter is set to do exact matching, else false.
|
||||
*/
|
||||
public boolean isExactMatch() {
|
||||
return exactMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nicely format the filter string to be used for showing the sender.
|
||||
*
|
||||
* @return The formatted filter string.
|
||||
*/
|
||||
public @NotNull String getFormattedString() {
|
||||
return String.format("%sFilter: '%s'", ChatColor.ITALIC, filterString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ContentFilter{" +
|
||||
"filterString='" + filterString + '\'' +
|
||||
", filterPattern=" + filterPattern +
|
||||
", exactMatch=" + exactMatch +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
/**
|
||||
* Thrown when an issue occur while formatting content.
|
||||
*/
|
||||
public class DisplayFormatException extends Exception {
|
||||
public DisplayFormatException() {
|
||||
}
|
||||
|
||||
public DisplayFormatException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DisplayFormatException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DisplayFormatException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public DisplayFormatException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Handles the formatting and sending of all content by the {@link ContentDisplay}.
|
||||
*
|
||||
* @param <T> Type of content to display.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface DisplayHandler<T> {
|
||||
|
||||
/**
|
||||
* Formats the raw content into a {@link Collection} for displaying to the given sender.
|
||||
*
|
||||
* @param sender The {@link CommandSender} who will the content will be displayed to.
|
||||
* @param display The responsible {@link ContentDisplay}.
|
||||
* @return The formatted content.
|
||||
* @throws DisplayFormatException Issue occurred while formatting content. E.g. invalid page.
|
||||
*/
|
||||
Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display)
|
||||
throws DisplayFormatException;
|
||||
|
||||
/**
|
||||
* Sends the header.
|
||||
*
|
||||
* @param sender The {@link CommandSender} who will the header will be displayed to.
|
||||
* @param display The responsible {@link ContentDisplay}.
|
||||
*/
|
||||
default void sendHeader(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display) {
|
||||
if (!Strings.isNullOrEmpty(display.getHeader())) {
|
||||
sender.sendMessage(display.getHeader());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends info such as filter and page.
|
||||
*
|
||||
* @param sender The {@link CommandSender} who will the sub header will be displayed to.
|
||||
* @param display The responsible {@link ContentDisplay}.
|
||||
*/
|
||||
default void sendSubHeader(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display) {
|
||||
if (display.getFilter().hasFilter()) {
|
||||
sender.sendMessage(String.format("%s[ %s ]", ChatColor.GRAY, display.getFilter().getFormattedString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the content.
|
||||
*
|
||||
* @param sender The {@link CommandSender} who will the body will be displayed to.
|
||||
* @param display The responsible {@link ContentDisplay}.
|
||||
* @param formattedContent The content after being formatted by {@link #format(CommandSender, ContentDisplay)}
|
||||
*/
|
||||
default void sendBody(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display,
|
||||
Collection<String> formattedContent) {
|
||||
if (formattedContent == null || formattedContent.size() == 0) {
|
||||
sender.sendMessage(display.getEmptyMessage());
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(formattedContent.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display;
|
||||
|
||||
import com.onarandombox.MultiverseCore.display.handlers.InlineListDisplayHandler;
|
||||
import com.onarandombox.MultiverseCore.display.handlers.InlineMapDisplayHandler;
|
||||
import com.onarandombox.MultiverseCore.display.handlers.ListDisplayHandler;
|
||||
import com.onarandombox.MultiverseCore.display.handlers.PagedListDisplayHandler;
|
||||
import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
|
||||
import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
|
||||
import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Various implementations of {@link DisplayHandler}.
|
||||
*/
|
||||
public class DisplayHandlers {
|
||||
|
||||
/**
|
||||
* Standard list display.
|
||||
*
|
||||
* Supported settings: none.
|
||||
*/
|
||||
public static final DisplayHandler<Collection<String>> LIST = new ListDisplayHandler();
|
||||
|
||||
/**
|
||||
* List display with paging.
|
||||
*
|
||||
* Supported settings: {@link PagedDisplaySettings#SHOW_PAGE}, {@link PagedDisplaySettings#LINES_PER_PAGE},
|
||||
* {@link PagedDisplaySettings#PAGE_IN_CONSOLE}, {@link PagedDisplaySettings#DO_END_PADDING}.
|
||||
*/
|
||||
public static final DisplayHandler<Collection<String>> PAGE_LIST = new PagedListDisplayHandler();
|
||||
|
||||
/**
|
||||
* Display a list inline.
|
||||
*
|
||||
* Supported settings: {@link InlineDisplaySettings#SEPARATOR}.
|
||||
*/
|
||||
public static final DisplayHandler<Collection<String>> INLINE_LIST = new InlineListDisplayHandler();
|
||||
|
||||
/**
|
||||
* Display key value pair inline.
|
||||
*
|
||||
* Supported settings: {@link InlineDisplaySettings#SEPARATOR}, {@link MapDisplaySettings#OPERATOR}.
|
||||
*/
|
||||
public static final DisplayHandler<Map<String, Object>> INLINE_MAP = new InlineMapDisplayHandler();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.onarandombox.MultiverseCore.display.filters;
|
||||
|
||||
/**
|
||||
* Filter display content for it show only certain string.
|
||||
*/
|
||||
public interface ContentFilter {
|
||||
/**
|
||||
* Checks if a particular string should be displayed.
|
||||
*
|
||||
* @param value String to check on.
|
||||
* @return True if should be display, false otherwise.
|
||||
*/
|
||||
boolean checkMatch(String value);
|
||||
|
||||
/**
|
||||
* Gets whether content needs to be filtered by this filter.
|
||||
*
|
||||
* @return True if content should be filtered, false otherwise.
|
||||
*/
|
||||
boolean needToFilter();
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.onarandombox.MultiverseCore.display.filters;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link ContentFilter} that doesn't filter anything.
|
||||
*/
|
||||
public class DefaultContentFilter implements ContentFilter {
|
||||
|
||||
public static DefaultContentFilter instance;
|
||||
|
||||
public static DefaultContentFilter getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DefaultContentFilter();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private DefaultContentFilter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMatch(String value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean needToFilter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.onarandombox.MultiverseCore.display.filters;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.google.common.base.Strings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/**
|
||||
* Filter content and text based on regex matching.
|
||||
*/
|
||||
public class RegexContentFilter implements ContentFilter {
|
||||
|
||||
private static final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
|
||||
|
||||
/**
|
||||
* Compile regex pattern to create a regex filter.
|
||||
*
|
||||
* When prefixed with 'r=', filter string is used as the full regex pattern.
|
||||
* Else, set to regex that contains the filterString.
|
||||
*
|
||||
* @param filterString The target string to create filter.
|
||||
* @return A new instance of {@link RegexContentFilter} with filter applied.
|
||||
*/
|
||||
@NotNull
|
||||
public static RegexContentFilter fromString(@Nullable String filterString) {
|
||||
if (filterString == null) {
|
||||
return new RegexContentFilter(null);
|
||||
}
|
||||
if (filterString.startsWith("r=")) {
|
||||
return new RegexContentFilter(filterString.substring(2));
|
||||
}
|
||||
String cleanedFilter = REGEX_SPECIAL_CHARS.matcher(filterString.toLowerCase()).replaceAll("\\\\$0");
|
||||
return new RegexContentFilter("(?i).*" + cleanedFilter + ".*");
|
||||
}
|
||||
|
||||
private final String regexString;
|
||||
private Pattern regexPattern;
|
||||
|
||||
public RegexContentFilter(@Nullable String regexString) {
|
||||
this.regexString = regexString;
|
||||
convertToPattern();
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to compile and store the regex into a {@link Pattern}.
|
||||
*/
|
||||
private void convertToPattern() {
|
||||
if (Strings.isNullOrEmpty(regexString)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
regexPattern = Pattern.compile(regexString);
|
||||
} catch (PatternSyntaxException ignored) {
|
||||
regexPattern = null;
|
||||
Logging.fine("Error parsing regex: %s", regexString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMatch(String value) {
|
||||
if (!hasValidRegex()) {
|
||||
return false;
|
||||
}
|
||||
String text = ChatColor.stripColor(String.valueOf(value));
|
||||
return regexPattern.matcher(text).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean needToFilter() {
|
||||
return hasValidRegex();
|
||||
}
|
||||
|
||||
public boolean hasValidRegex() {
|
||||
return regexPattern != null;
|
||||
}
|
||||
|
||||
public String getRegexString() {
|
||||
return regexString;
|
||||
}
|
||||
|
||||
public Pattern getRegexPattern() {
|
||||
return regexPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return regexString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.onarandombox.MultiverseCore.display.filters.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.display.filters.DefaultContentFilter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Base implementation of {@link SendHandler} with some common parameters.
|
||||
*
|
||||
* @param <T> The subclass that inherited this baseclass.
|
||||
*/
|
||||
public abstract class BaseSendHandler<T extends BaseSendHandler<?>> implements SendHandler {
|
||||
|
||||
protected String header = "";
|
||||
protected ContentFilter filter = DefaultContentFilter.getInstance();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void send(@NotNull CommandSender sender, @NotNull List<String> content) {
|
||||
sendHeader(sender);
|
||||
List<String> filteredContent = filterContent(content);
|
||||
if (filteredContent.isEmpty()) {
|
||||
sender.sendMessage(String.format("%sThere is no content to display.", ChatColor.RED));
|
||||
return;
|
||||
}
|
||||
sendContent(sender, filteredContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the header if header is present.
|
||||
*
|
||||
* @param sender The target which the header will be displayed to.
|
||||
*/
|
||||
protected void sendHeader(CommandSender sender) {
|
||||
if (!Strings.isNullOrEmpty(header)) {
|
||||
sender.sendMessage(header);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter to keep only contents that matches the filter.
|
||||
*
|
||||
* @param content The content to filter on.
|
||||
* @return The filtered list of content.
|
||||
*/
|
||||
protected List<String> filterContent(@NotNull List<String> content) {
|
||||
if (filter.needToFilter()) {
|
||||
return content.stream().filter(filter::checkMatch).collect(Collectors.toList());
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the contents.
|
||||
*
|
||||
* @param sender The target which the content will be displayed to.
|
||||
* @param content The content to display.
|
||||
*/
|
||||
protected abstract void sendContent(@NotNull CommandSender sender, @NotNull List<String> content);
|
||||
|
||||
/**
|
||||
* Sets header to be displayed.
|
||||
*
|
||||
* @param header The header text.
|
||||
* @param replacements String formatting replacements.
|
||||
* @return Same {@link T} for method chaining.
|
||||
*/
|
||||
public T withHeader(@NotNull String header, @NotNull Object...replacements) {
|
||||
this.header = String.format(header, replacements);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets content filter used to match specific content to be displayed.
|
||||
*
|
||||
* @param filter The filter to use.
|
||||
* @return Same {@link T} for method chaining.
|
||||
*/
|
||||
public T withFilter(@NotNull ContentFilter filter) {
|
||||
this.filter = filter;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public ContentFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultSendHandler implements SendHandler {
|
||||
|
||||
private static DefaultSendHandler instance;
|
||||
|
||||
public static DefaultSendHandler getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DefaultSendHandler();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private DefaultSendHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void send(@NotNull CommandSender sender, @NotNull List<String> content) {
|
||||
sender.sendMessage(content.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayHandler;
|
||||
import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class InlineListDisplayHandler implements DisplayHandler<Collection<String>> {
|
||||
|
||||
@Override
|
||||
public Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display)
|
||||
throws DisplayFormatException {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String separator = display.getSetting(InlineDisplaySettings.SEPARATOR);
|
||||
|
||||
for (Iterator<String> iterator = display.getContents().iterator(); iterator.hasNext(); ) {
|
||||
String content = iterator.next();
|
||||
if (!display.getFilter().checkMatch(content)) {
|
||||
continue;
|
||||
}
|
||||
builder.append(display.getColorTool().get()).append(content);
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(separator);
|
||||
}
|
||||
}
|
||||
return (builder.length() == 0)
|
||||
? Collections.singletonList(display.getEmptyMessage())
|
||||
: Collections.singleton(builder.toString());
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayHandler;
|
||||
import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
|
||||
import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class InlineMapDisplayHandler implements DisplayHandler<Map<String, Object>> {
|
||||
|
||||
@Override
|
||||
public Collection<String> format(@NotNull CommandSender sender,
|
||||
@NotNull ContentDisplay<Map<String, Object>> display)
|
||||
throws DisplayFormatException {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String separator = display.getSetting(InlineDisplaySettings.SEPARATOR);
|
||||
String operator = display.getSetting(MapDisplaySettings.OPERATOR);
|
||||
|
||||
for (Iterator<Map.Entry<String, Object>> iterator = display.getContents().entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Map.Entry<String, Object> entry = iterator.next();
|
||||
if (!display.getFilter().checkMatch(entry.getKey()) && !display.getFilter().checkMatch(entry.getValue())) {
|
||||
continue;
|
||||
}
|
||||
builder.append(display.getColorTool().get())
|
||||
.append(entry.getKey())
|
||||
.append(operator)
|
||||
.append(display.getColorTool().get())
|
||||
.append(entry.getValue());
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(separator);
|
||||
}
|
||||
}
|
||||
return (builder.length() == 0)
|
||||
? Collections.singletonList(display.getEmptyMessage())
|
||||
: Collections.singleton(builder.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Display the contents in a single line.
|
||||
*/
|
||||
public class InlineSendHandler extends BaseSendHandler<InlineSendHandler> {
|
||||
|
||||
/**
|
||||
* Makes a new {@link InlineSendHandler} instance to use.
|
||||
*
|
||||
* @return New {@link InlineSendHandler} instance.
|
||||
*/
|
||||
public static InlineSendHandler create() {
|
||||
return new InlineSendHandler();
|
||||
}
|
||||
|
||||
private String delimiter = ChatColor.WHITE + ", ";
|
||||
|
||||
public InlineSendHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void sendContent(@NotNull CommandSender sender, @NotNull List<String> content) {
|
||||
if (filter.needToFilter()) {
|
||||
sender.sendMessage(String.format("%s[Filter '%s']", ChatColor.GRAY, filter));
|
||||
}
|
||||
sender.sendMessage(String.join(delimiter, content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the delimiter. A sequence of characters that is used to separate each of the elements in content.
|
||||
*
|
||||
* @param delimiter The delimiter to use.
|
||||
* @return Same {@link InlineSendHandler} for method chaining.
|
||||
*/
|
||||
public InlineSendHandler withDelimiter(String delimiter) {
|
||||
this.delimiter = delimiter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDelimiter() {
|
||||
return delimiter;
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayHandler;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListDisplayHandler implements DisplayHandler<Collection<String>> {
|
||||
|
||||
@Override
|
||||
public Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display)
|
||||
throws DisplayFormatException {
|
||||
return display.getContents().stream()
|
||||
.filter(display.getFilter()::checkMatch)
|
||||
.map(s -> (ContentDisplay.LINE_BREAK.equals(s)) ? "" : display.getColorTool().get() + s)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import com.onarandombox.MultiverseCore.display.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
|
||||
import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class PagedListDisplayHandler extends ListDisplayHandler {
|
||||
|
||||
@Override
|
||||
public Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display)
|
||||
throws DisplayFormatException {
|
||||
if (dontNeedPaging(sender, display)) {
|
||||
return super.format(sender, display);
|
||||
}
|
||||
|
||||
int pages = 1;
|
||||
int currentLength = 0;
|
||||
int targetPage = display.getSetting(PagedDisplaySettings.SHOW_PAGE);
|
||||
int linesPerPage = display.getSetting(PagedDisplaySettings.LINES_PER_PAGE);
|
||||
List<String> content = new ArrayList<>(linesPerPage);
|
||||
|
||||
// Calculate the paging.
|
||||
for (String line : display.getContents()) {
|
||||
if (!display.getFilter().checkMatch(line)) {
|
||||
continue;
|
||||
}
|
||||
// When it's the next page.
|
||||
boolean isLineBreak = ContentDisplay.LINE_BREAK.equals(line);
|
||||
if (isLineBreak || ++currentLength > linesPerPage) {
|
||||
pages++;
|
||||
currentLength = 0;
|
||||
if (isLineBreak) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (pages == targetPage) {
|
||||
// Let first line be the header when no header is defined.
|
||||
if (display.getHeader() == null) {
|
||||
display.setHeader(line);
|
||||
currentLength--;
|
||||
continue;
|
||||
}
|
||||
content.add(display.getColorTool().get() + line);
|
||||
}
|
||||
}
|
||||
|
||||
// Page out of range.
|
||||
if (targetPage < 1 || targetPage > pages) {
|
||||
if (pages == 1) {
|
||||
throw new DisplayFormatException("There is only 1 page!");
|
||||
}
|
||||
throw new DisplayFormatException("Please enter a page from 1 to " + pages + ".");
|
||||
}
|
||||
|
||||
// No content
|
||||
if (content.size() == 0) {
|
||||
content.add(display.getEmptyMessage());
|
||||
}
|
||||
|
||||
// Add empty lines to make output length consistent.
|
||||
if (display.getSetting(PagedDisplaySettings.DO_END_PADDING)) {
|
||||
IntStream.range(0, linesPerPage - content.size()).forEach(i -> content.add(""));
|
||||
}
|
||||
display.setSetting(PagedDisplaySettings.TOTAL_PAGE, pages);
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSubHeader(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display) {
|
||||
if (dontNeedPaging(sender, display)) {
|
||||
super.sendSubHeader(sender, display);
|
||||
return;
|
||||
}
|
||||
|
||||
if (display.getFilter().hasFilter()) {
|
||||
sender.sendMessage(String.format("%s[ Page %s of %s, %s ]",
|
||||
ChatColor.GRAY,
|
||||
display.getSetting(PagedDisplaySettings.SHOW_PAGE),
|
||||
display.getSetting(PagedDisplaySettings.TOTAL_PAGE),
|
||||
display.getFilter().getFormattedString())
|
||||
);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(String.format("%s[ Page %s of %s ]",
|
||||
ChatColor.GRAY,
|
||||
display.getSetting(PagedDisplaySettings.SHOW_PAGE),
|
||||
display.getSetting(PagedDisplaySettings.TOTAL_PAGE))
|
||||
);
|
||||
}
|
||||
|
||||
private boolean dontNeedPaging(CommandSender sender, ContentDisplay<Collection<String>> display) {
|
||||
return sender instanceof ConsoleCommandSender
|
||||
&& !display.getSetting(PagedDisplaySettings.PAGE_IN_CONSOLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Display content as a list with optional pagination.
|
||||
*/
|
||||
public class PagedSendHandler extends BaseSendHandler<PagedSendHandler> {
|
||||
|
||||
/**
|
||||
* Makes a new {@link PagedSendHandler} instance to use.
|
||||
*
|
||||
* @return New {@link PagedSendHandler} instance.
|
||||
*/
|
||||
public static PagedSendHandler create() {
|
||||
return new PagedSendHandler();
|
||||
}
|
||||
|
||||
private boolean paginate = true;
|
||||
private boolean paginateInConsole = false;
|
||||
private boolean padEnd = true;
|
||||
private int linesPerPage = 8;
|
||||
private int targetPage = 1;
|
||||
|
||||
public PagedSendHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void sendContent(@NotNull CommandSender sender,
|
||||
@NotNull List<String> content) {
|
||||
|
||||
if (!paginate || (sender instanceof ConsoleCommandSender && !paginateInConsole)) {
|
||||
sendNormal(sender, content);
|
||||
return;
|
||||
}
|
||||
sendPaged(sender, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send content list without pagination.
|
||||
*
|
||||
* @param sender The target which the content will be displayed to.
|
||||
* @param content The content to display.
|
||||
*/
|
||||
private void sendNormal(@NotNull CommandSender sender,
|
||||
@NotNull List<String> content) {
|
||||
|
||||
if (filter.needToFilter()) {
|
||||
sender.sendMessage(String.format("%s[Filter '%s']", ChatColor.GRAY, filter));
|
||||
}
|
||||
sender.sendMessage(content.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send content list with pagination.
|
||||
*
|
||||
* @param sender The target which the content will be displayed to.
|
||||
* @param content The content to display.
|
||||
*/
|
||||
private void sendPaged(@NotNull CommandSender sender,
|
||||
@NotNull List<String> content) {
|
||||
|
||||
int totalPages = (content.size() + linesPerPage - 1) / linesPerPage; // Basically just divide round up
|
||||
if (targetPage < 1 || targetPage > totalPages) {
|
||||
sender.sendMessage(String.format("%sInvalid page number. Please enter a page number between 1 and %s", ChatColor.RED, totalPages));
|
||||
return;
|
||||
}
|
||||
|
||||
if (filter.needToFilter()) {
|
||||
sender.sendMessage(String.format("%s[Page %s of %s] [Filter '%s']", ChatColor.GRAY, targetPage, totalPages, filter));
|
||||
} else {
|
||||
sender.sendMessage(String.format("%s[Page %s of %s]", ChatColor.GRAY, targetPage, totalPages));
|
||||
}
|
||||
|
||||
int startIndex = (targetPage - 1) * linesPerPage;
|
||||
int pageEndIndex = startIndex + linesPerPage;
|
||||
int endIndex = Math.min(pageEndIndex, content.size());
|
||||
List<String> pageContent = content.subList(startIndex, endIndex);
|
||||
if (padEnd) {
|
||||
for (int i = 0; i < (pageEndIndex - endIndex); i++) {
|
||||
pageContent.add("");
|
||||
}
|
||||
}
|
||||
sender.sendMessage(pageContent.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether display output should be paginated.
|
||||
*
|
||||
* @param paginate State of doing pagination.
|
||||
* @return Same {@link PagedSendHandler} for method chaining.
|
||||
*/
|
||||
public PagedSendHandler doPagination(boolean paginate) {
|
||||
this.paginate = paginate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether display output should be paginated if is for console output.
|
||||
* This option will be useless of {@link PagedSendHandler#paginate} is set to false.
|
||||
*
|
||||
* @param paginateInConsole State of doing pagination in console.
|
||||
* @return Same {@link PagedSendHandler} for method chaining.
|
||||
*/
|
||||
public PagedSendHandler doPaginationInConsole(boolean paginateInConsole) {
|
||||
this.paginateInConsole = paginateInConsole;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether empty lines should be added if content lines shown is less that {@link PagedSendHandler#linesPerPage}.
|
||||
*
|
||||
* @param padEnd State of doing end padding.
|
||||
* @return Same {@link PagedSendHandler} for method chaining.
|
||||
*/
|
||||
public PagedSendHandler doEndPadding(boolean padEnd) {
|
||||
this.padEnd = padEnd;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max number of lines per page. This excludes header.
|
||||
*
|
||||
* @param linesPerPage The number of lines per page.
|
||||
* @return Same {@link PagedSendHandler} for method chaining.
|
||||
*/
|
||||
public PagedSendHandler withLinesPerPage(int linesPerPage) {
|
||||
this.linesPerPage = linesPerPage;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the page number to display.
|
||||
*
|
||||
* @param targetPage The target page number to display.
|
||||
* @return Same {@link PagedSendHandler} for method chaining.
|
||||
*/
|
||||
public PagedSendHandler withTargetPage(int targetPage) {
|
||||
this.targetPage = targetPage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPaginate() {
|
||||
return paginate;
|
||||
}
|
||||
|
||||
public boolean isPaginateInConsole() {
|
||||
return paginateInConsole;
|
||||
}
|
||||
|
||||
public boolean isPadEnd() {
|
||||
return padEnd;
|
||||
}
|
||||
|
||||
public int getLinesPerPage() {
|
||||
return linesPerPage;
|
||||
}
|
||||
|
||||
public int getTargetPage() {
|
||||
return targetPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.onarandombox.MultiverseCore.display.handlers;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles the sending of all content to the command sender.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SendHandler {
|
||||
/**
|
||||
* Sends all the content to the given command sender.
|
||||
*
|
||||
* @param sender The target which the content will be displayed to.
|
||||
* @param content The content to display.
|
||||
*/
|
||||
void send(@NotNull CommandSender sender, @NotNull List<String> content);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.onarandombox.MultiverseCore.display.parsers;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parse objects into string or list of strings.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ContentParser {
|
||||
/**
|
||||
* Parse the object to string(s) and add it to the content.
|
||||
*
|
||||
* @param sender The target which the content will be displayed to.
|
||||
* @param content The content to display.
|
||||
*/
|
||||
void parse(@NotNull CommandSender sender, @NotNull List<String> content);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.onarandombox.MultiverseCore.display.parsers;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Simple parser for list object.
|
||||
*
|
||||
* @param <T> List element type.
|
||||
*/
|
||||
public class ListContentParser<T> implements ContentParser {
|
||||
|
||||
/**
|
||||
* New list content parser for the given list.
|
||||
*
|
||||
* @param list The list object to parse.
|
||||
* @param <T> List element type.
|
||||
* @return New {@link MapContentParser} instance.
|
||||
*/
|
||||
public static <T> ListContentParser<T> forContent(List<T> list) {
|
||||
return new ListContentParser<>(list);
|
||||
}
|
||||
|
||||
private final List<T> list;
|
||||
|
||||
private String format = "%s";
|
||||
|
||||
public ListContentParser(List<T> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void parse(@NotNull CommandSender sender, @NotNull List<String> content) {
|
||||
list.forEach(element -> content.add(String.format(format, element)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the format that will be used to parse each list entry. Uses java string format pattern.
|
||||
*
|
||||
* @param format The format to use.
|
||||
* @return Same {@link ListContentParser} for method chaining.
|
||||
*/
|
||||
public ListContentParser<T> withFormat(String format) {
|
||||
this.format = format;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 125 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user