Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95ee1d731c | ||
|
|
5ed049d6b0 | ||
|
|
20b1fc3a3e | ||
|
|
0209099e15 |
No files matched your search
@@ -1,2 +0,0 @@
|
||||
github: Multiverse
|
||||
open_collective: multiverse-plugins
|
||||
@@ -1,77 +0,0 @@
|
||||
name: 🐛 Report a Bug
|
||||
description: Report a problem with Multiverse-Core.
|
||||
title: "[Bug]: "
|
||||
labels: ["Bug: Unconfirmed"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
If you are having issues with other submodules of Multiverse, please go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
|
||||
|
||||
Not sure if this is a bug with Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
|
||||
|
||||
When completing the report, please ensure all fields are filled with the correct details requested. Failure to do so will result in your issue being closed.
|
||||
- type: input
|
||||
id: multiverse-version-info
|
||||
attributes:
|
||||
label: '`/mv dumps` output'
|
||||
description: Run `/mv dumps` in the console, then copy and paste the link from the output of the command into this box. If `/mv dumps` command is not available, update multiverse to v5.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: server-logs
|
||||
attributes:
|
||||
label: Server logs
|
||||
description: >
|
||||
Include full startup log and console error (if any). upload all relevant logs to either https://pastes.dev
|
||||
or https://gist.github.com, save and the paste the link in this box.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: server-version
|
||||
attributes:
|
||||
label: Server Version
|
||||
description: Output of `/version` command.
|
||||
placeholder: server version info
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Bug Description
|
||||
description: Describe in detail what the bug is about. Include the expected behaviour and actual behaviour.
|
||||
placeholder: "Example: When running `/mv` it cause the server to crash..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce-steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Provide detailed instructions to trigger the bug.
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Start a server with only multiverse installed.
|
||||
2. Run `/mv` command.
|
||||
3. Players all get kicked with a "server closed" message.
|
||||
...
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: agreements
|
||||
attributes:
|
||||
label: Agreements
|
||||
description: Ensure you have done the following being submitting this issue.
|
||||
options:
|
||||
- label: I have searched for and ensured there isn't already an open or resolved issue(s) regarding this.
|
||||
required: true
|
||||
- label: >
|
||||
I was able to reproduce my issue on a freshly setup and up-to-date server with the latest
|
||||
version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
|
||||
required: true
|
||||
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 Multiverse Discord Server
|
||||
url: https://discord.gg/NZtfKky
|
||||
about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help!
|
||||
@@ -1,41 +0,0 @@
|
||||
name: 💡 Request a Feature
|
||||
description: Suggest a feature you want to see in Multiverse-Core!
|
||||
title: "[Idea]: "
|
||||
labels: ["Type: Idea"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to share your ideas!
|
||||
|
||||
If you are look for other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
|
||||
|
||||
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
|
||||
- type: textarea
|
||||
id: feature-description
|
||||
attributes:
|
||||
label: Describe the feature
|
||||
description: What feature are you suggesting?
|
||||
placeholder: "Example: I hope multiverse can implement random teleport feature..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: feature-reasoning
|
||||
attributes:
|
||||
label: How is the feature useful to all Multiverse users?
|
||||
description: How is the feature useful to all players, server owners and/or developers?
|
||||
placeholder: "Example: Random teleporting can be integrated into many multiverse modules such as mv-portals..."
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: agreements
|
||||
attributes:
|
||||
label: Agreements
|
||||
description: Ensure you have done the following being submitting this issue.
|
||||
options:
|
||||
- label: I have searched for and ensured there isn't already an open issue regarding this.
|
||||
required: true
|
||||
@@ -1,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,83 +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,
|
||||
"platforms": ["PAPER"]
|
||||
},
|
||||
{
|
||||
"name": "Multiverse-Portals",
|
||||
"required": false,
|
||||
"platforms": ["PAPER"]
|
||||
},
|
||||
{
|
||||
"name": "Multiverse-NetherPortals",
|
||||
"required": false,
|
||||
"platforms": ["PAPER"]
|
||||
},
|
||||
{
|
||||
"name": "Multiverse-SignPortals",
|
||||
"required": false,
|
||||
"platforms": ["PAPER"]
|
||||
}
|
||||
]}
|
||||
|
||||
target_tag: ${{ inputs.target_tag }}
|
||||
upload_modrinth: ${{ inputs.upload_modrinth }}
|
||||
upload_dbo: ${{ inputs.upload_dbo }}
|
||||
upload_hangar: ${{ inputs.upload_hangar }}
|
||||
@@ -1,39 +0,0 @@
|
||||
name: 'Dispatch: Create Release'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_type:
|
||||
description: 'Stable or pre-release'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- prerelease
|
||||
- release
|
||||
version_bump:
|
||||
description: 'Version bump type'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- major
|
||||
- minor
|
||||
- patch
|
||||
|
||||
jobs:
|
||||
github_release:
|
||||
uses: ./.github/workflows/call.github_release.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
release_mode: ${{ inputs.release_type }}
|
||||
version_bump: ${{ inputs.version_bump }}
|
||||
|
||||
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: 'false'
|
||||
upload_hangar: 'false'
|
||||
@@ -1,55 +0,0 @@
|
||||
name: 'Dispatch: Deploy Javadoc'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target_tag:
|
||||
description: 'Version to generate javadoc'
|
||||
required: true
|
||||
replace_latest:
|
||||
description: 'Replace the latest folder'
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
javadocs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.target_tag }}
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: build javadoc
|
||||
run: ./gradlew javadoc
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_VERSION: ${{ inputs.target_tag }}
|
||||
|
||||
- name: Copy javadoc to deploy folder
|
||||
run: |
|
||||
mkdir -p build/docs/javadoc-deploy/${{ inputs.target_tag }}
|
||||
cp -r build/docs/javadoc/* build/docs/javadoc-deploy/${{ inputs.target_tag }}
|
||||
|
||||
- name: Copy javadoc to latest folder
|
||||
if: inputs.replace_latest
|
||||
run: |
|
||||
mkdir -p build/docs/javadoc-deploy/latest
|
||||
cp -r build/docs/javadoc/* build/docs/javadoc-deploy/latest
|
||||
|
||||
- name: Deploy javadoc to gh pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
folder: build/docs/javadoc-deploy
|
||||
branch: javadoc
|
||||
target-folder: javadoc
|
||||
clean: false
|
||||
commit-message: Deploy javadoc for ${{ inputs.target_tag }}
|
||||
@@ -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,22 +0,0 @@
|
||||
name: 'Generic: Checkstyle'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
checkstyle:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: dbelyaev/action-checkstyle@v0.8.4
|
||||
continue-on-error: true
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
checkstyle_version: 10.12.2
|
||||
checkstyle_config: ./config/mv_checks.xml
|
||||
level: warning
|
||||
@@ -1,131 +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@v4
|
||||
with:
|
||||
ref: ${{ inputs.promote_from }}
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: Build to test
|
||||
id: test
|
||||
run: ./gradlew clean build -x assemble -x shadowJar
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
if: steps.test.outcome == 'success'
|
||||
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'
|
||||
run: >
|
||||
./gradlew publish -x test
|
||||
-PmultiverseUsername=${{ secrets.REPOSILITE_REPO_USERNAME }}
|
||||
-PmultiversePassword=${{ secrets.REPOSILITE_REPO_PASSWORD }}
|
||||
env:
|
||||
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build for upload
|
||||
id: build
|
||||
if: steps.release.outputs.release_created == 'true'
|
||||
run: ./gradlew build -x test
|
||||
env:
|
||||
GITHUB_VERSION: ${{ steps.release.outputs.tag_name }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload release artifact
|
||||
if: steps.build.outcome == 'success'
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/libs/${{ inputs.plugin_name }}-${{ steps.release.outputs.tag_name }}.jar
|
||||
asset_name: ${{ inputs.plugin_name }}-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
||||
|
||||
- name: Generate javadoc
|
||||
id: javadoc
|
||||
if: steps.build.outcome == 'success'
|
||||
run: ./gradlew javadoc -x test
|
||||
env:
|
||||
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload javadoc
|
||||
if: steps.javadoc.outcome == 'success'
|
||||
run: |
|
||||
mkdir -p build/docs/javadoc-deploy/${{ steps.release.outputs.publish_version }}
|
||||
cp -r build/docs/javadoc/* build/docs/javadoc-deploy/${{ steps.release.outputs.publish_version }}
|
||||
|
||||
- name: Override latest javadoc for stable release
|
||||
if: steps.javadoc.outcome == 'success' && steps.release.outputs.release_type == 'release'
|
||||
run: |
|
||||
mkdir -p build/docs/javadoc-deploy/latest
|
||||
cp -r build/docs/javadoc/* build/docs/javadoc-deploy/latest
|
||||
|
||||
- name: Deploy javadoc to gh pages
|
||||
if: steps.javadoc.outcome == 'success'
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
folder: build/docs/javadoc-deploy
|
||||
branch: javadoc
|
||||
target-folder: javadoc
|
||||
clean: false
|
||||
commit-message: Deploy javadoc for ${{ steps.release.outputs.tag_name }}
|
||||
@@ -1,140 +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.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2
|
||||
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.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2
|
||||
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 }}
|
||||
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.18.2-1.21.8"]}'
|
||||
plugin_dependencies: ${{ inputs.hangar_plugin_dependencies }}
|
||||
@@ -1,48 +0,0 @@
|
||||
name: 'Generic: Test'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
plugin_name:
|
||||
description: 'Plugin name'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
test-and-artifact:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: Run unit tests
|
||||
run: ./gradlew build
|
||||
env:
|
||||
GITHUB_VERSION: pr${{ github.event.pull_request.number }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Artifact output
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}
|
||||
path: build/libs/${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}.jar
|
||||
|
||||
comment-artifact:
|
||||
needs: test-and-artifact
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: benwoo1110/artifact-comment-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -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,9 +0,0 @@
|
||||
name: 'PR: Checkstyle'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
checkstyle:
|
||||
uses: ./.github/workflows/generic.checkstyle.yml
|
||||
@@ -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,11 +0,0 @@
|
||||
name: 'PR: Test'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
uses: ./.github/workflows/generic.test.yml
|
||||
with:
|
||||
plugin_name: multiverse-core
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
# maven
|
||||
/target
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
@@ -43,6 +42,3 @@ debug.log
|
||||
# Doxygen
|
||||
/docs/html
|
||||
debug.txt
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
@@ -1,6 +0,0 @@
|
||||
Copyright (c) 2011, The Multiverse Team All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -1,51 +1,15 @@
|
||||
<p align="center">
|
||||
<img src="config/multiverse-banner.png" alt="Multiverse Logo">
|
||||
</p>
|
||||
Building
|
||||
========
|
||||
Simply build the source with maven:
|
||||
|
||||
[](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/)
|
||||
$ mvn install
|
||||
|
||||
[](https://github.com/Multiverse/Multiverse-Core/releases/latest)
|
||||
[](https://github.com/Multiverse/Multiverse-Core/releases)
|
||||
[](https://discord.gg/NZtfKky)
|
||||
[](https://github.com/sponsors/Multiverse)
|
||||
[](https://opencollective.com/multiverse-plugins)
|
||||
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
||||
|
||||
# About
|
||||
License
|
||||
=======
|
||||
Copyright (c) 2011, The Multiverse Team All rights reserved.
|
||||
|
||||
[Multiverse](https://modrinth.com/plugin/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!
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Now it's time to create your very own Multiverse server, do check out our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) and [Usage Guide](https://github.com/Multiverse/Multiverse-Core/wiki/Basics) to get started. Feel free to hop onto our [Discord](https://discord.gg/NZtfKky) if you have any question or just want to have a chat with us!
|
||||
|
||||
## Amazing sub-modules available:
|
||||
|
||||
* [Multiverse-NetherPortals](https://github.com/Multiverse/Multiverse-NetherPortals) -> Have separate nether and end worlds for each of your overworlds!
|
||||
* [Multiverse-Portals](https://github.com/Multiverse/Multiverse-Portals) -> Make custom portals to go to any destination!
|
||||
* [Multiverse-Inventories](https://github.com/Multiverse/Multiverse-Inventories) -> Have separated players stats and inventories per world or per group of worlds.
|
||||
* [Multiverse-SignPortals](https://github.com/Multiverse/Multiverse-SignPortals) -> Signs as teleporters!
|
||||
|
||||
## Usage Guide
|
||||
|
||||
We have a cool new website hosting our Wiki: https://mvplugins.org
|
||||
|
||||
## Building
|
||||
Simply build the source with Gradle:
|
||||
```
|
||||
./gradlew build
|
||||
```
|
||||
|
||||
## 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-web) 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 donating to our [Github Sponsors](https://github.com/sponsors/Multiverse) or [Open Collective](https://opencollective.com/multiverse-plugins)!
|
||||
|
||||
Additionally, we would like to give a big thanks to everyone that has supported Multiverse over the years, as well as those in the years to come. Thank you!
|
||||
|
||||
## License
|
||||
Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info.
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
id 'org.mvplugins.multiverse-plugin' version '1.2.1'
|
||||
}
|
||||
|
||||
group = 'org.mvplugins.multiverse.core'
|
||||
description = 'Multiverse-Core'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'aikar repo'
|
||||
url = uri('https://repo.aikar.co/content/groups/aikar/')
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'glaremasters repo'
|
||||
url = 'https://repo.glaremasters.me/repository/towny/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "helpchatRepoReleases"
|
||||
url = uri("https://repo.helpch.at/releases/")
|
||||
}
|
||||
}
|
||||
|
||||
configure(apiDependencies) {
|
||||
serverApiVersion = '1.21.8-R0.1-SNAPSHOT'
|
||||
mockBukkitServerApiVersion = '1.21'
|
||||
mockBukkitVersion = '4.69.2'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Economy
|
||||
externalPlugin('com.github.MilkBowl:VaultAPI:1.7.1') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
|
||||
// PlaceholderAPI
|
||||
externalPlugin 'me.clip:placeholderapi:2.11.6'
|
||||
|
||||
// Command Framework
|
||||
shadowed 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
|
||||
|
||||
// Config
|
||||
shadowed('io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.1') {
|
||||
exclude group: 'org.spigotmc', module: 'spigot-api'
|
||||
}
|
||||
|
||||
// Utils
|
||||
shadowed 'io.vavr:vavr:0.10.7'
|
||||
shadowed 'org.glassfish.hk2:hk2-locator:3.1.1'
|
||||
shadowed('org.glassfish.hk2:hk2-inhabitant-generator:3.1.1') {
|
||||
exclude group: 'org.apache.maven', module: 'maven-core'
|
||||
}
|
||||
shadowed('com.dumptruckman.minecraft:Logging:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
shadowed 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
|
||||
shadowed('org.bstats:bstats-bukkit:3.1.0') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
shadowed 'net.minidev:json-smart:2.5.2'
|
||||
shadowed 'org.jetbrains:annotations:26.0.2'
|
||||
shadowed 'io.papermc:paperlib:1.0.8'
|
||||
|
||||
// Tests
|
||||
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
testImplementation("org.hamcrest:hamcrest:3.0")
|
||||
}
|
||||
|
||||
ext.bitlyAccessToken = System.getenv('BITLY_ACCESS_TOKEN') ?: 'bitly-access-token'
|
||||
|
||||
tasks.register('prepareSource', Sync) {
|
||||
inputs.property 'bitlyAccessToken', bitlyAccessToken
|
||||
from sourceSets.main.java
|
||||
into "$buildDir/src"
|
||||
filter(ReplaceTokens, tokens: [
|
||||
'bitly-access-token': bitlyAccessToken,
|
||||
])
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
relocate 'co.aikar', 'org.mvplugins.multiverse.external.acf'
|
||||
relocate 'com.dumptruckman.minecraft.util.Logging', 'org.mvplugins.multiverse.core.utils.CoreLogging'
|
||||
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'org.mvplugins.multiverse.core.utils.DebugFileLogger'
|
||||
relocate 'de.themoep.idconverter', 'org.mvplugins.multiverse.external.idconverter'
|
||||
relocate 'io.github.townyadvanced.commentedconfiguration', 'org.mvplugins.multiverse.external.commentedconfiguration'
|
||||
relocate 'org.bstats', 'org.mvplugins.multiverse.external.bstats'
|
||||
relocate 'com.sun', 'org.mvplugins.multiverse.external.sun'
|
||||
relocate 'net.minidev', 'org.mvplugins.multiverse.external.minidev'
|
||||
relocate 'org.objectweb', 'org.mvplugins.multiverse.external.objectweb'
|
||||
relocate 'io.vavr', 'org.mvplugins.multiverse.external.vavr'
|
||||
relocate 'jakarta', 'org.mvplugins.multiverse.external.jakarta'
|
||||
relocate 'javassist', 'org.mvplugins.multiverse.external.javassist'
|
||||
relocate 'org.aopalliance', 'org.mvplugins.multiverse.external.aopalliance'
|
||||
relocate 'org.glassfish', 'org.mvplugins.multiverse.external.glassfish'
|
||||
relocate 'org.jvnet', 'org.mvplugins.multiverse.external.jvnet'
|
||||
relocate 'org.intellij', 'org.mvplugins.multiverse.external.intellij'
|
||||
relocate 'org.jetbrains', 'org.mvplugins.multiverse.external.jetbrains'
|
||||
relocate 'io.papermc.lib', 'org.mvplugins.multiverse.external.paperlib'
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Core"
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
out.txt
|
||||
@@ -1,20 +0,0 @@
|
||||
filepath = "../src/main/resources/multiverse-core_en.properties"
|
||||
|
||||
enumList = []
|
||||
|
||||
with open(filepath) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if len(line) == 0:
|
||||
enumList.append("")
|
||||
elif line.startswith("#"):
|
||||
enumList.append(line.replace("#", "//"))
|
||||
else:
|
||||
parts = line.split("=")
|
||||
if (len(parts) < 2):
|
||||
continue
|
||||
parts = parts[0].split(".")[1:]
|
||||
enumList.append("_".join([p.upper() for p in parts]) + ",")
|
||||
|
||||
with open("out.txt", "w") as f:
|
||||
f.write("\n".join(enumList))
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 166 KiB |
+92
-614
@@ -6,660 +6,138 @@
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<!-- Future reference: valid severity values are 'ignore', 'info', 'warning', 'error' -->
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<property name="severity" value="warning"/>
|
||||
|
||||
<!-- Javadoc Comments -->
|
||||
<module name="JavadocPackage"/><!-- require package-info.java file -->
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<module name="JavadocPackage">
|
||||
<property name="allowLegacy" value="true"/>
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile" />
|
||||
<module name="OrderedProperties"/>
|
||||
<module name="Translation"/>
|
||||
<module name="UniqueProperties"/>
|
||||
|
||||
<!-- Regexp -->
|
||||
<module name="FileLength"/>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
<property name="format" value="\s+$"/>
|
||||
</module>
|
||||
|
||||
<!-- Size Violations -->
|
||||
<module name="FileLength">
|
||||
<property name="max" value="2000"/>
|
||||
<module name="SuppressWithNearbyCommentFilter">
|
||||
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="max" value="120"/>
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- Make suppression possible -->
|
||||
<module name="SuppressWithNearbyCommentFilter">
|
||||
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
</module>
|
||||
|
||||
<module name="FileContentsHolder"/>
|
||||
<!-- Actual checks -->
|
||||
|
||||
<!-- Annotations -->
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationMostCases"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, PACKAGE_DEF, ENUM_CONSTANT_DEF,
|
||||
ENUM_DEF, METHOD_DEF, CTOR_DEF, RECORD_DEF, COMPACT_CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationVariables"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation"/>
|
||||
<module name="AnnotationUseStyle"/>
|
||||
<module name="MissingDeprecated"/>
|
||||
<module name="MissingOverride"/>
|
||||
|
||||
<!-- Block Checks -->
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="tokens"
|
||||
value="LITERAL_WHILE, LITERAL_TRY, LITERAL_FINALLY, LITERAL_DO, LITERAL_IF,
|
||||
LITERAL_ELSE, LITERAL_FOR, INSTANCE_INIT, STATIC_INIT, LITERAL_SWITCH,
|
||||
LITERAL_SYNCHRONIZED"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="(ignore|expect)"/>
|
||||
</module>
|
||||
<module name="LeftCurly">
|
||||
<property name="ignoreEnums" value="false"/>
|
||||
<property name="tokens"
|
||||
value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, ENUM_DEF,
|
||||
INTERFACE_DEF, LAMBDA, LITERAL_CASE, LITERAL_CATCH, LITERAL_DEFAULT,
|
||||
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF,
|
||||
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, METHOD_DEF,
|
||||
OBJBLOCK, STATIC_INIT, RECORD_DEF, COMPACT_CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="NeedBraces">
|
||||
<property name="id" value="SingleLineIf"/>
|
||||
<property name="tokens" value="LITERAL_IF"/>
|
||||
<property name="allowSingleLineStatement" value="true"/>
|
||||
</module>
|
||||
<module name="NeedBraces">
|
||||
<property name="id" value="NoSingleLineControl"/>
|
||||
<property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlySame"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
|
||||
LITERAL_DO"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlyAlone"/>
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
|
||||
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF,
|
||||
COMPACT_CTOR_DEF, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
|
||||
<!-- Class Design -->
|
||||
<module name="DesignForExtension">
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="FinalClass"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InnerTypeLast"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="MutableException"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="ThrowsCount">
|
||||
<property name="max" value="2"/>
|
||||
</module>
|
||||
<module name="VisibilityModifier">
|
||||
<property name="protectedAllowed" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Coding -->
|
||||
<module name="ArrayTrailingComma"/>
|
||||
<module name="AvoidDoubleBraceInitialization"/>
|
||||
<module name="AvoidNoArgumentSuperConstructorCall"/>
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="DeclarationOrder">
|
||||
<!-- Doesn't respect static methods at top -->
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
<module name="DefaultComesLast"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsAvoidNull"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="FallThrough">
|
||||
<property name="checkLastCaseGroup" value="true"/>
|
||||
</module>
|
||||
<module name="HiddenField">
|
||||
<property name="ignoreConstructorParameter" value="true"/>
|
||||
<property name="ignoreSetter" value="true"/>
|
||||
<property name="setterCanReturnItsClass" value="true"/>
|
||||
<property name="ignoreAbstractMethods" value="true"/>
|
||||
<!-- Not smart enough -->
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
<module name="IllegalCatch"/>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="IllegalToken"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format"
|
||||
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message"
|
||||
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||
</module>
|
||||
<module name="IllegalType"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MagicNumber">
|
||||
<property name="ignoreHashCodeMethod" value="true"/>
|
||||
<property name="ignoreAnnotationElementDefaults" value="true"/>
|
||||
</module>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="ModifiedControlVariable"/>
|
||||
<module name="MultipleStringLiterals">
|
||||
|
||||
</module>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="NestedForDepth">
|
||||
<module name="LineLength">
|
||||
<property name="max" value="160"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
<module name="NestedIfDepth"/>
|
||||
<module name="NestedTryDepth"/>
|
||||
<module name="NoClone"/>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="PackageDeclaration"/>
|
||||
<module name="ParameterAssignment"/>
|
||||
<module name="RequireThis"/>
|
||||
<module name="ReturnCount">
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="SuperClone"/>
|
||||
<module name="SuperFinalize"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="UnnecessarySemicolonAfterOuterTypeDeclaration"/>
|
||||
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration"/>
|
||||
<module name="UnnecessarySemicolonInEnumeration"/>
|
||||
<module name="UnnecessarySemicolonInTryWithResources"/>
|
||||
<module name="UnusedLocalVariable"/>
|
||||
<module name="VariableDeclarationUsageDistance">
|
||||
<property name="allowedDistance" value="3"/>
|
||||
<property name="validateBetweenScopes" value="false"/>
|
||||
</module>
|
||||
<module name="VariableDeclarationUsageDistance">
|
||||
<property name="allowedDistance" value="5"/>
|
||||
<property name="validateBetweenScopes" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Imports -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport">
|
||||
<property name="illegalPkgs" value="sun"/>
|
||||
</module>
|
||||
<module name="ImportOrder">
|
||||
<property name="option" value="bottom"/>
|
||||
<property name="ordered" value="true"/>
|
||||
<property name="separated" value="true"/>
|
||||
<property name="separatedStaticGroups" value="true"/>
|
||||
<property name="caseSensitive" value="true"/>
|
||||
<property name="sortStaticImportsAlphabetically" value="true"/>
|
||||
<property name="groups"
|
||||
value="java,javax,*,org.mvplugins"/>
|
||||
<property name="staticGroups"
|
||||
value="/^.*$/"/>
|
||||
</module>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
|
||||
<!-- Javadoc Comments -->
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target"
|
||||
value="CLASS_DEF, COMPACT_CTOR_DEF, CTOR_DEF, ENUM_DEF,
|
||||
INTERFACE_DEF, METHOD_DEF, RECORD_DEF, VARIABLE_DEF"/>
|
||||
</module>
|
||||
<module name="InvalidJavadocPosition"/>
|
||||
<module name="JavadocBlockTagLocation"/>
|
||||
<module name="JavadocContentLocationCheck"/>
|
||||
<module name="JavadocMethod">
|
||||
<property name="accessModifiers" value="public"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF, COMPACT_CTOR_DEF"/>
|
||||
<property name="scope" value="package"/><!-- We don't need javadoc for private methods -->
|
||||
<property name="tokens" value="METHOD_DEF"/><!-- We don't need javadoc for constructors -->
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="accessModifiers" value="public"/>
|
||||
</module>
|
||||
<module name="JavadocMissingLeadingAsterisk"/>
|
||||
<module name="JavadocMissingWhitespaceAfterAsterisk"/>
|
||||
<module name="JavadocParagraph">
|
||||
<property name="allowNewlineParagraph" value="true"/>
|
||||
</module>
|
||||
<module name="JavadocStyle">
|
||||
<property name="scope" value="package"/>
|
||||
</module>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="JavadocType"/>
|
||||
<module name="JavadocVariable">
|
||||
<property name="scope" value="package"/>
|
||||
</module>
|
||||
<module name="MissingJavadocMethod">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowMissingPropertyJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="MissingJavadocMethod">
|
||||
<property name="scope" value="protected"/>
|
||||
<property name="excludeScope" value="public"/>
|
||||
<property name="allowMissingPropertyJavadoc" value="true"/>
|
||||
<property name="minLineCount" value="2"/>
|
||||
</module>
|
||||
<module name="MissingJavadocType">
|
||||
<property name="scope" value="protected"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
|
||||
RECORD_DEF, ANNOTATION_DEF"/>
|
||||
<property name="excludeScope" value="nothing"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="RequireEmptyLineBeforeBlockTagGroup"/>
|
||||
<module name="SingleLineJavadoc"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments"
|
||||
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
<property name="scope" value="package"/><!-- We don't need javadoc for private variables -->
|
||||
</module>
|
||||
<module name="JavadocStyle"/>
|
||||
<module name="WriteTag">
|
||||
<property name="tag" value="@author"/>
|
||||
<property name="tagFormat" value="\S"/>
|
||||
<property name="severity" value="ignore"/>
|
||||
<property name="tagSeverity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<!-- Metrics -->
|
||||
<module name="BooleanExpressionComplexity"/>
|
||||
<module name="ClassDataAbstractionCoupling">
|
||||
<property name="max" value="7"/>
|
||||
<property name="excludedClasses"
|
||||
value="ArrayIndexOutOfBoundsException, ArrayList, Boolean, Byte, Character,
|
||||
Class, Collection, Deprecated, Deque, Double, DoubleStream, EnumSet, Exception,
|
||||
Float, FunctionalInterface, HashMap, HashSet, IllegalArgumentException,
|
||||
IllegalStateException, IndexOutOfBoundsException, IntStream, Integer,
|
||||
LinkedHashMap, LinkedHashSet, LinkedList, List, Long, LongStream, Map,
|
||||
NullPointerException, Object, Optional, OptionalDouble, OptionalInt,
|
||||
OptionalLong, Override, Queue, RuntimeException, SafeVarargs, SecurityException,
|
||||
Set, Short, SortedMap, SortedSet, Stream, String, StringBuffer, StringBuilder,
|
||||
SuppressWarnings, Throwable, TreeMap, TreeSet, UnsupportedOperationException,
|
||||
Void, boolean, byte, char, double, float, int, long, short, var, void"/>
|
||||
</module>
|
||||
<module name="ClassFanOutComplexity">
|
||||
<property name="id" value="FanOutComplexityGettingTooHigh"/>
|
||||
<property name="max" value="20"/>
|
||||
<property name="excludedClasses"
|
||||
value="ArrayIndexOutOfBoundsException, ArrayList, Boolean, Byte, Character,
|
||||
Class, Collection, Deprecated, Deque, Double, DoubleStream, EnumSet, Exception,
|
||||
Float, FunctionalInterface, HashMap, HashSet, IllegalArgumentException,
|
||||
IllegalStateException, IndexOutOfBoundsException, IntStream, Integer,
|
||||
LinkedHashMap, LinkedHashSet, LinkedList, List, Long, LongStream, Map,
|
||||
NullPointerException, Object, Optional, OptionalDouble, OptionalInt,
|
||||
OptionalLong, Override, Queue, RuntimeException, SafeVarargs, SecurityException,
|
||||
Set, Short, SortedMap, SortedSet, Stream, String, StringBuffer, StringBuilder,
|
||||
SuppressWarnings, Throwable, TreeMap, TreeSet, UnsupportedOperationException,
|
||||
Void, boolean, byte, char, double, float, int, long, short, var, void"/>
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="ClassFanOutComplexity">
|
||||
<property name="id" value="FanOutComplexityProbablyTooHigh"/>
|
||||
<property name="max" value="35"/>
|
||||
<property name="excludedClasses"
|
||||
value="ArrayIndexOutOfBoundsException, ArrayList, Boolean, Byte, Character,
|
||||
Class, Collection, Deprecated, Deque, Double, DoubleStream, EnumSet, Exception,
|
||||
Float, FunctionalInterface, HashMap, HashSet, IllegalArgumentException,
|
||||
IllegalStateException, IndexOutOfBoundsException, IntStream, Integer,
|
||||
LinkedHashMap, LinkedHashSet, LinkedList, List, Long, LongStream, Map,
|
||||
NullPointerException, Object, Optional, OptionalDouble, OptionalInt,
|
||||
OptionalLong, Override, Queue, RuntimeException, SafeVarargs, SecurityException,
|
||||
Set, Short, SortedMap, SortedSet, Stream, String, StringBuffer, StringBuilder,
|
||||
SuppressWarnings, Throwable, TreeMap, TreeSet, UnsupportedOperationException,
|
||||
Void, boolean, byte, char, double, float, int, long, short, var, void"/>
|
||||
</module>
|
||||
<module name="CyclomaticComplexity">
|
||||
<property name="max" value="7"/>
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
<module name="AvoidStarImport">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="excludes" value="com.onarandombox.MultiverseCore.utils,com.onarandombox.MultiverseCore.configuration,com.onarandombox.MultiverseCore.commands,com.onarandombox.MultiverseCore.destination"/>
|
||||
</module>
|
||||
<module name="JavaNCSS">
|
||||
<property name="methodMaximum" value="50"/>
|
||||
<property name="classMaximum" value="1500"/>
|
||||
<property name="fileMaximum" value="2000"/>
|
||||
<property name="recordMaximum" value="150"/>
|
||||
</module>
|
||||
<module name="NPathComplexity">
|
||||
<property name="max" value="200"/>
|
||||
</module>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="AvoidEscapedUnicodeCharacters">
|
||||
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||
<property name="allowNonPrintableEscapes" value="true"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation">
|
||||
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="braceAdjustment" value="4"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="throwsIndent" value="8"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
<property name="forceStrictCondition" value="false"/>
|
||||
</module>
|
||||
<module name="NoCodeInFile"/>
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="TodoComment">
|
||||
<property name="format" value="TODO"/>
|
||||
<!-- TODO change back to warning after MV5 -->
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="TrailingComment">
|
||||
<property name="legalComment" value="^\sSUPPRESS CHECKSTYLE:"/>
|
||||
</module>
|
||||
<module name="UncommentedMain"/>
|
||||
<module name="UpperEll"/>
|
||||
|
||||
<!-- Modifiers -->
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
<!-- Naming Conventions -->
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
<property name="allowedAbbreviationLength" value="0"/>
|
||||
<property name="allowedAbbreviations" value="MV"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
|
||||
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF,
|
||||
RECORD_COMPONENT_DEF"/>
|
||||
</module>
|
||||
<module name="AbstractClassName">
|
||||
<property name="ignoreName" value="true"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Abstract class name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="CatchParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="^[A-Z]{1,3}$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ConstantName">
|
||||
<message key="name.invalidPattern"
|
||||
value="Constant name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="^[A-Z]{1,3}$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LambdaParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalFinalVariableName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Local final variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$|^[A-Z][A-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<message key="name.invalidPattern"
|
||||
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="^[A-Z]{1,3}$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="severity" value="info"/>
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="PatternVariableName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Pattern variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="RecordComponentName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Record component name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="RecordTypeParameterName">
|
||||
<property name="format" value="^[A-Z]{1,3}$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Record type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="StaticVariableName">
|
||||
<message key="name.invalidPattern"
|
||||
value="Static variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
|
||||
ANNOTATION_DEF, RECORD_DEF"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
|
||||
<!-- Size Violations -->
|
||||
<module name="AnonInnerLength">
|
||||
<property name="max" value="20"/>
|
||||
</module>
|
||||
<module name="ExecutableStatementCount">
|
||||
<property name="max" value="30"/>
|
||||
</module>
|
||||
<module name="LambdaBodyLength">
|
||||
<property name="id" value="LambdaGettingTooLong"/>
|
||||
<property name="max" value="10"/>
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="LambdaBodyLength">
|
||||
<property name="id" value="LambdaProbablyTooLong"/>
|
||||
<property name="max" value="25"/>
|
||||
</module>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="100"/>
|
||||
<property name="maxPrivate" value="100"/>
|
||||
<property name="maxPackage" value="100"/>
|
||||
<property name="maxProtected" value="100"/>
|
||||
<property name="maxPublic" value="100"/>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="MethodLength">
|
||||
<property name="max" value="50"/>
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="countEmpty" value="false"/>
|
||||
</module>
|
||||
<module name="OuterTypeNumber">
|
||||
<property name="max" value="1"/>
|
||||
</module>
|
||||
<module name="ParameterNumber">
|
||||
<property name="id" value="ConsiderLessMethodParameters"/>
|
||||
<property name="max" value="4"/>
|
||||
<property name="ignoreOverriddenMethods" value="true"/>
|
||||
<property name="severity" value="info"/>
|
||||
<property name="tokens" value="METHOD_DEF"/>
|
||||
</module>
|
||||
<module name="ParameterNumber">
|
||||
<property name="id" value="ProbablyTooManyMethodParameters"/>
|
||||
<property name="max" value="10"/>
|
||||
<property name="ignoreOverriddenMethods" value="true"/>
|
||||
<property name="tokens" value="METHOD_DEF"/>
|
||||
</module>
|
||||
<module name="ParameterNumber">
|
||||
<property name="id" value="ConsiderLessConstructorParameters"/>
|
||||
<property name="max" value="7"/>
|
||||
<property name="ignoreOverriddenMethods" value="true"/>
|
||||
<property name="severity" value="info"/>
|
||||
<property name="tokens" value="CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="ParameterNumber">
|
||||
<property name="id" value="ProbablyTooManyConstructorParameters"/>
|
||||
<property name="max" value="12"/>
|
||||
<property name="ignoreOverriddenMethods" value="true"/>
|
||||
<property name="tokens" value="CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="RecordComponentNumber">
|
||||
<property name="max" value="8"/>
|
||||
</module>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<module name="EmptyForInitializerPad"/>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
<property name="allowMultipleEmptyLines" value="false"/>
|
||||
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
|
||||
<property name="tokens"
|
||||
value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
|
||||
STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF,
|
||||
COMPACT_CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.followed"
|
||||
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded"
|
||||
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow"
|
||||
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
<message key="ws.notPreceded"
|
||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="MethodParamPad">
|
||||
<property name="tokens"
|
||||
value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF,
|
||||
SUPER_CTOR_CALL, ENUM_CONSTANT_DEF, RECORD_DEF"/>
|
||||
</module>
|
||||
<module name="NoLineWrap">
|
||||
<property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/>
|
||||
</module>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="tokens"
|
||||
value="AT, INC, DEC, UNARY_MINUS,UNARY_PLUS,BNOT,LNOT,DOT,ARRAY_DECLARATOR,INDEX_OP,LITERAL_SYNCHRONIZED,METHOD_REF"/>
|
||||
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="id" value="AllowedWhitespaceBeforeWithoutLinebreak"/>
|
||||
<property name="tokens"
|
||||
value="COMMA, SEMI, POST_INC, POST_DEC, ELLIPSIS, LABELED_STAT"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="id" value="AllowedWhitespaceBeforeWithLinebreak"/>
|
||||
<property name="tokens" value="DOT, METHOD_REF"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="tokens"
|
||||
value="QUESTION, COLON, EQUAL, NOT_EQUAL, DIV, PLUS, MINUS, STAR, MOD,
|
||||
SR, BSR, GE, GT, SL, LE, LT, BXOR, BOR, LOR, BAND, LAND, LITERAL_INSTANCEOF,
|
||||
TYPE_EXTENSION_AND, ASSIGN, DIV_ASSIGN, PLUS_ASSIGN, MINUS_ASSIGN,
|
||||
STAR_ASSIGN, MOD_ASSIGN, SR_ASSIGN, BSR_ASSIGN, SL_ASSIGN, BXOR_ASSIGN,
|
||||
BOR_ASSIGN, BAND_ASSIGN, METHOD_REF"/>
|
||||
</module>
|
||||
<module name="ParenPad">
|
||||
<property name="tokens"
|
||||
value="ANNOTATION, ANNOTATION_FIELD_DEF, CTOR_CALL, CTOR_DEF, DOT, ENUM_CONSTANT_DEF,
|
||||
EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW,
|
||||
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL,
|
||||
METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA,
|
||||
RECORD_DEF"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapNl"/>
|
||||
<property name="option" value="nl"/>
|
||||
<property name="tokens" value="DOT, AT, METHOD_REF"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapEol"/>
|
||||
<property name="option" value="eol"/>
|
||||
<property name="tokens"
|
||||
value="COMMA, SEMI, ELLIPSIS, RPAREN, ARRAY_DECLARATOR, RBRACK"/>
|
||||
</module>
|
||||
<module name="SingleSpaceSeparator"/>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter">
|
||||
<property name="tokens"
|
||||
value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_RETURN,
|
||||
LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_FINALLY, DO_WHILE, ELLIPSIS,
|
||||
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CATCH, LAMBDA,
|
||||
LITERAL_YIELD, LITERAL_CASE"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyLambdas" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<property name="ignoreEnhancedForColon" value="false"/>
|
||||
<property name="tokens"
|
||||
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR,
|
||||
BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND,
|
||||
LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY,
|
||||
LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED,
|
||||
LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN,
|
||||
NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR,
|
||||
SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
|
||||
<message key="ws.notFollowed"
|
||||
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks
|
||||
may only be represented as '{}' when not part of a multi-block statement"/>
|
||||
<message key="ws.notPreceded"
|
||||
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_FOR,LITERAL_TRY,LITERAL_WHILE,INSTANCE_INIT,STATIC_INIT"/>
|
||||
</module>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="DoubleCheckedLocking"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="HiddenField">
|
||||
<property name="tokens" value="VARIABLE_DEF"/><!-- We don't care if parameters hide fields. -->
|
||||
</module>
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MagicNumber">
|
||||
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
|
||||
</module>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="RedundantThrows"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<!-- Don't like errors for `final` missing
|
||||
<module name="DesignForExtension"/>
|
||||
<module name="FinalClass"/>
|
||||
-->
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="VisibilityModifier">
|
||||
<property name="protectedAllowed" value="true"/>
|
||||
</module>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<!-- Don't like errors for `final` missing
|
||||
<module name="FinalParameters"/>
|
||||
-->
|
||||
<module name="TodoComment">
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="UpperEll"/>
|
||||
<module name="Indentation"/>
|
||||
<module name="MissingDeprecated"/>
|
||||
<module name="MissingOverride"/>
|
||||
</module>
|
||||
</module>
|
||||
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-8.10.2-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,370 @@
|
||||
<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>2.5</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>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Bukkit Official</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/public</url>
|
||||
</repository>
|
||||
<!-- I've been told they'll have a repo this weekend :D
|
||||
<repository>
|
||||
<id>DynMap</id>
|
||||
<url>TBD</url>
|
||||
</repository> -->
|
||||
<!-- Required for Metrics -->
|
||||
<repository>
|
||||
<id>mcstats</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<!-- Required for Vault -->
|
||||
<repository>
|
||||
<id>herocraft</id>
|
||||
<url>http://ci.herocraftonline.com/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>doodleproject-repo</id>
|
||||
<name>DoodleProject Maven 2 Repository</name>
|
||||
<url>http://doodleproject.sourceforge.net/maven2/release</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://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>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<!-- Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>maven-replacer-plugin</artifactId>
|
||||
<version>1.3.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>target/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-b${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Jar Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.11</version>
|
||||
<configuration>
|
||||
<parallel>methods</parallel>
|
||||
<threadCount>10</threadCount>
|
||||
<excludes>
|
||||
<exclude>**/TestCommandSender.java</exclude>
|
||||
<exclude>**/TestInstanceCreator.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit47</artifactId>
|
||||
<version>2.11</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.8</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>2.1.2</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.8.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc-jar</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.main__.util:SerializationConfig</include>
|
||||
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
|
||||
<include>com.dumptruckman.minecraft:buscript</include>
|
||||
<include>org.mcstats:metrics</include>
|
||||
<include>com.dumptruckman.minecraft:Logging</include>
|
||||
<include>com.fernferret.allpay:AllPay</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.fernferret.allpay</pattern>
|
||||
<shadedPattern>com.fernferret.allpay.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.main__.util</pattern>
|
||||
<shadedPattern>me.main__.util.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.pneumaticraft.commandhandler</pattern>
|
||||
<shadedPattern>com.pneumaticraft.commandhandler.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>buscript</pattern>
|
||||
<shadedPattern>buscript.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>org.mcstats.multiverse</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>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- Bukkit Dependency -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.3.2-R2.1-SNAPSHOT</version>
|
||||
<!-- If you want the lates, use this -->
|
||||
<!-- <version>LATEST</version> -->
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Bukkit Dependency -->
|
||||
<!-- Start of Spout (disabled because we aren't using it)
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
</dependency>
|
||||
End of Spout -->
|
||||
<!-- SerializationConfig Dependency -->
|
||||
<dependency>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.6b</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of SerializationConfig Dependency -->
|
||||
<!-- Start of Economy Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.fernferret.allpay</groupId>
|
||||
<artifactId>AllPay</artifactId>
|
||||
<version>10</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.2.19-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependency -->
|
||||
<!-- Start of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.pneumaticraft.commandhandler</groupId>
|
||||
<artifactId>CommandHandler</artifactId>
|
||||
<version>7</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of CommandHandler Dependency -->
|
||||
<!-- Start DynMap Dependency -->
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>DynmapCoreAPI</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End DynMap Dependency -->
|
||||
<!-- Start of Buscript Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>buscript</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Buscript Dependency -->
|
||||
<!-- Start of Metrics Dependency -->
|
||||
<dependency>
|
||||
<groupId>org.mcstats</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Metrics Dependency -->
|
||||
<!-- Start of Logging Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>Logging</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Logging Dependency -->
|
||||
<!-- Start of Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>1.4.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
<version>1.4.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<version>1.4.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>3.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- End of Test Dependencies -->
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>OnARandomBox</id>
|
||||
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url = uri('https://repo.onarandombox.com/multiverse-releases')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'multiverse-core'
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,278 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
*/
|
||||
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
|
||||
private static MultiverseCoreConfiguration instance;
|
||||
|
||||
/**
|
||||
* Sets the statically saved instance.
|
||||
* @param instance The new instance.
|
||||
*/
|
||||
public static void setInstance(MultiverseCoreConfiguration instance) {
|
||||
MultiverseCoreConfiguration.instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the static instance of config is set.
|
||||
*/
|
||||
public static boolean isSet() {
|
||||
return instance != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statically saved instance.
|
||||
* @return The statically saved instance.
|
||||
*/
|
||||
public static MultiverseCoreConfiguration getInstance() {
|
||||
if (instance == null)
|
||||
throw new IllegalStateException("The instance wasn't set!");
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Property
|
||||
private volatile boolean enforceaccess;
|
||||
@Property
|
||||
private volatile boolean prefixchat;
|
||||
@Property
|
||||
private volatile boolean useasyncchat;
|
||||
@Property
|
||||
private volatile boolean teleportintercept;
|
||||
@Property
|
||||
private volatile boolean firstspawnoverride;
|
||||
@Property
|
||||
private volatile boolean displaypermerrors;
|
||||
@Property
|
||||
private volatile int globaldebug;
|
||||
@Property
|
||||
private volatile int messagecooldown;
|
||||
@Property
|
||||
private volatile double version;
|
||||
@Property
|
||||
private volatile String firstspawnworld;
|
||||
@Property
|
||||
private volatile int teleportcooldown;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
MultiverseCoreConfiguration.setInstance(this);
|
||||
}
|
||||
|
||||
public MultiverseCoreConfiguration(Map<String, Object> values) {
|
||||
super(values);
|
||||
MultiverseCoreConfiguration.setInstance(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
enforceaccess = false;
|
||||
useasyncchat = true;
|
||||
prefixchat = true;
|
||||
teleportintercept = true;
|
||||
firstspawnoverride = true;
|
||||
displaypermerrors = true;
|
||||
globaldebug = 0;
|
||||
messagecooldown = 5000;
|
||||
teleportcooldown = 1000;
|
||||
this.version = 2.9;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setConfigProperty(String property, String value) {
|
||||
try {
|
||||
return this.setProperty(property, value, true);
|
||||
} catch (NoSuchPropertyException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// And here we go:
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getEnforceAccess() {
|
||||
return this.enforceaccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setEnforceAccess(boolean enforceAccess) {
|
||||
this.enforceaccess = enforceAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getPrefixChat() {
|
||||
return this.prefixchat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setPrefixChat(boolean prefixChat) {
|
||||
this.prefixchat = prefixChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getTeleportIntercept() {
|
||||
return this.teleportintercept;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setTeleportIntercept(boolean teleportIntercept) {
|
||||
this.teleportintercept = teleportIntercept;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getFirstSpawnOverride() {
|
||||
return this.firstspawnoverride;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setFirstSpawnOverride(boolean firstSpawnOverride) {
|
||||
this.firstspawnoverride = firstSpawnOverride;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getDisplayPermErrors() {
|
||||
return this.displaypermerrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDisplayPermErrors(boolean displayPermErrors) {
|
||||
this.displaypermerrors = displayPermErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getGlobalDebug() {
|
||||
return this.globaldebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setGlobalDebug(int globalDebug) {
|
||||
this.globaldebug = globalDebug;
|
||||
Logging.setDebugLevel(globalDebug);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getMessageCooldown() {
|
||||
return this.messagecooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setMessageCooldown(int messageCooldown) {
|
||||
this.messagecooldown = messageCooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public double getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getFirstSpawnWorld() {
|
||||
return this.firstspawnworld;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setFirstSpawnWorld(String firstSpawnWorld) {
|
||||
this.firstspawnworld = firstSpawnWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getTeleportCooldown() {
|
||||
return this.teleportcooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setTeleportCooldown(int teleportCooldown) {
|
||||
this.teleportcooldown = teleportCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseAsyncChat(boolean useAsyncChat) {
|
||||
this.useasyncchat = useAsyncChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseAsyncChat() {
|
||||
return this.useasyncchat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
/**
|
||||
* Used to get block/location-related information.
|
||||
*/
|
||||
public interface BlockSafety {
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
* @param l The {@link Location} of the block.
|
||||
* @return True if the block at that {@link Location} is above air.
|
||||
*/
|
||||
boolean isBlockAboveAir(Location l);
|
||||
|
||||
/**
|
||||
* Checks if a player can spawn safely at the given coordinates.
|
||||
* @param world The {@link World}.
|
||||
* @param x The x-coordinate.
|
||||
* @param y The y-coordinate.
|
||||
* @param z The z-coordinate.
|
||||
* @return True if a player can spawn safely at the given coordinates.
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(World world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
* This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air
|
||||
* etc. This also ensures there is enough space for a player to spawn!
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return Whether the player can spawn safely at the given {@link Location}
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(Location l);
|
||||
|
||||
/**
|
||||
* Gets a safe bed spawn location OR null if the bed is invalid.
|
||||
* @param l The location of the bead head (block with the pillow on it).
|
||||
* @return Safe location around the bed or null if no location was found.
|
||||
*/
|
||||
Location getSafeBedSpawn(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
* @return The {@link Location} of the top-block.
|
||||
*/
|
||||
Location getTopBlock(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
* @return The {@link Location} of the top-block.
|
||||
*/
|
||||
Location getBottomBlock(Location l);
|
||||
|
||||
/**
|
||||
* Checks if an entity would be on track at the specified {@link Location}.
|
||||
* @param l The {@link Location}.
|
||||
* @return True if an entity would be on tracks at the specified {@link Location}.
|
||||
*/
|
||||
boolean isEntitiyOnTrack(Location l);
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Minecart} can spawn safely.
|
||||
* @param cart The {@link Minecart}.
|
||||
* @return True if the minecart can spawn safely.
|
||||
*/
|
||||
boolean canSpawnCartSafely(Minecart cart);
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Vehicle} can spawn safely.
|
||||
* @param vehicle The {@link Vehicle}.
|
||||
* @return True if the vehicle can spawn safely.
|
||||
*/
|
||||
boolean canSpawnVehicleSafely(Vehicle vehicle);
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
/******************************************************************************
|
||||
* 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 buscript.Buscript;
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Multiverse 2 Core API
|
||||
* <p>
|
||||
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
||||
*/
|
||||
public interface Core {
|
||||
|
||||
/**
|
||||
* Gets the Multiverse config file.
|
||||
*
|
||||
* @return The Multiverse config file.
|
||||
* @deprecated Don't modify the config-file manually!
|
||||
*/
|
||||
@Deprecated
|
||||
FileConfiguration getMVConfiguration();
|
||||
|
||||
/**
|
||||
* Gets the Banking system that Multiverse-Core has hooked into.
|
||||
*
|
||||
* @return A {@link GenericBank} that can be used for payments.
|
||||
* @deprecated Now using vault, see {@link #getVaultEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
GenericBank getBank();
|
||||
|
||||
/**
|
||||
* Returns the Vault economy system if Vault is present and has an economy system enabled.
|
||||
*
|
||||
* @return The vault economy system or null if not configured.
|
||||
*/
|
||||
Economy getVaultEconomy();
|
||||
|
||||
/**
|
||||
* Reloads the Multiverse Configuration files:
|
||||
* worlds.yml and config.yml.
|
||||
*/
|
||||
void loadConfigs();
|
||||
|
||||
/**
|
||||
* Gets the Multiverse message system. This allows you to send messages
|
||||
* to users at specified intervals.
|
||||
*
|
||||
* @return The loaded {@link MultiverseMessaging}.
|
||||
*/
|
||||
MultiverseMessaging getMessaging();
|
||||
|
||||
/**
|
||||
* Gets the {@link MVPlayerSession} for the given player.
|
||||
* This will also create a player session if one does not exist
|
||||
* for a player.
|
||||
*
|
||||
* @param player The player's session to grab.
|
||||
*
|
||||
* @return The corresponding {@link MVPlayerSession}.
|
||||
*/
|
||||
MVPlayerSession getPlayerSession(Player player);
|
||||
|
||||
/**
|
||||
* Gets the instantiated Safe-T-Teleporter for performing
|
||||
* safe teleports.
|
||||
*
|
||||
* @return A non-null {@link SafeTTeleporter}.
|
||||
*
|
||||
* @deprecated Use {@link #getSafeTTeleporter()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter();
|
||||
|
||||
/**
|
||||
* Multiverse uses an advanced permissions setup, this object
|
||||
* simplifies getting/setting permissions.
|
||||
*
|
||||
* @return A non-null {@link MVPermissions}.
|
||||
*/
|
||||
MVPermissions getMVPerms();
|
||||
|
||||
/**
|
||||
* Multiverse uses {@link CommandHandler} to make adding and using commands
|
||||
* a piece of cake.
|
||||
*
|
||||
* @return A non-null {@link CommandHandler}.
|
||||
*/
|
||||
CommandHandler getCommandHandler();
|
||||
|
||||
/**
|
||||
* Gets the factory class responsible for loading many different destinations
|
||||
* on demand.
|
||||
*
|
||||
* @return A valid {@link DestinationFactory}.
|
||||
*/
|
||||
DestinationFactory getDestFactory();
|
||||
|
||||
/**
|
||||
* Gets the primary class responsible for managing Multiverse Worlds.
|
||||
*
|
||||
* @return {@link WorldManager}.
|
||||
*/
|
||||
MVWorldManager getMVWorldManager();
|
||||
|
||||
/**
|
||||
* Saves all configs.
|
||||
*
|
||||
* @return Whether the config was successfully saved
|
||||
*/
|
||||
boolean saveMVConfigs();
|
||||
|
||||
/**
|
||||
* Gets the {@link AnchorManager}.
|
||||
*
|
||||
* @return The {@link AnchorManager}
|
||||
*/
|
||||
AnchorManager getAnchorManager();
|
||||
|
||||
/**
|
||||
* Used by queued commands to regenerate a world on a delay.
|
||||
*
|
||||
* @param name Name of the world to regenerate
|
||||
* @param useNewSeed If a new seed should be used
|
||||
* @param randomSeed IF the new seed should be random
|
||||
* @param seed The seed of the world.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*
|
||||
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
|
||||
|
||||
/**
|
||||
* Sets the {@link GenericBank}-Bank AllPay is using.
|
||||
*
|
||||
* @param bank The new {@link GenericBank}
|
||||
* @deprecated Now using vault, see {@link #getVaultEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
void setBank(GenericBank bank);
|
||||
|
||||
/**
|
||||
* Gets this plugin's {@link AllPay}-Banker.
|
||||
*
|
||||
* @return An {@link AllPay}-Banker
|
||||
* @deprecated Now using vault, see {@link #getVaultEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
AllPay getBanker();
|
||||
|
||||
/**
|
||||
* Decrements the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
void decrementPluginCount();
|
||||
|
||||
/**
|
||||
* Increments the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
void incrementPluginCount();
|
||||
|
||||
/**
|
||||
* Returns the number of plugins that have specifically hooked into core.
|
||||
*
|
||||
* @return The number if plugins that have hooked into core.
|
||||
*/
|
||||
int getPluginCount();
|
||||
|
||||
/**
|
||||
* Parse the Authors Array into a readable String with ',' and 'and'.
|
||||
*
|
||||
* @return The readable authors-{@link String}
|
||||
*/
|
||||
String getAuthors();
|
||||
|
||||
/**
|
||||
* Gets the {@link BlockSafety} this {@link Core} is using.
|
||||
* @return The {@link BlockSafety} this {@link Core} is using.
|
||||
* @see BlockSafety
|
||||
* @see SimpleBlockSafety
|
||||
*/
|
||||
BlockSafety getBlockSafety();
|
||||
|
||||
/**
|
||||
* Sets the {@link BlockSafety} this {@link Core} is using.
|
||||
* @param blockSafety The new {@link BlockSafety}.
|
||||
* @see BlockSafety
|
||||
* @see SimpleBlockSafety
|
||||
*/
|
||||
void setBlockSafety(BlockSafety blockSafety);
|
||||
|
||||
/**
|
||||
* Gets the {@link LocationManipulation} this {@link Core} is using.
|
||||
* @return The {@link LocationManipulation} this {@link Core} is using.
|
||||
* @see LocationManipulation
|
||||
* @see SimpleLocationManipulation
|
||||
*/
|
||||
LocationManipulation getLocationManipulation();
|
||||
|
||||
/**
|
||||
* Sets the {@link LocationManipulation} this {@link Core} is using.
|
||||
* @param locationManipulation The new {@link LocationManipulation}.
|
||||
* @see LocationManipulation
|
||||
* @see SimpleLocationManipulation
|
||||
*/
|
||||
void setLocationManipulation(LocationManipulation locationManipulation);
|
||||
|
||||
/**
|
||||
* Gets the {@link SafeTTeleporter} this {@link Core} is using.
|
||||
* @return The {@link SafeTTeleporter} this {@link Core} is using.
|
||||
* @see SafeTTeleporter
|
||||
* @see SimpleSafeTTeleporter
|
||||
*/
|
||||
SafeTTeleporter getSafeTTeleporter();
|
||||
|
||||
/**
|
||||
* Sets the {@link SafeTTeleporter} this {@link Core} is using.
|
||||
* @param safeTTeleporter The new {@link SafeTTeleporter}.
|
||||
* @see SafeTTeleporter
|
||||
* @see SimpleSafeTTeleporter
|
||||
*/
|
||||
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
||||
|
||||
/**
|
||||
* Gets the {@link MultiverseCoreConfig}.
|
||||
* @return The configuration.
|
||||
*/
|
||||
MultiverseCoreConfig getMVConfig();
|
||||
|
||||
/**
|
||||
* Gets the buscript object for Multiverse. This is what handles Javascript processing.
|
||||
*
|
||||
* @return The Multiverse buscript object.
|
||||
*/
|
||||
Buscript getScriptAPI();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/******************************************************************************
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A fancy text.
|
||||
*/
|
||||
public interface FancyText {
|
||||
/**
|
||||
* Gets the {@link String}-representation of this {@link FancyText}.
|
||||
*
|
||||
* @return The {@link String}-representation of this {@link FancyText}.
|
||||
*/
|
||||
String getFancyText();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Used to manipulate locations.
|
||||
*/
|
||||
public interface LocationManipulation {
|
||||
/**
|
||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||
* <p>
|
||||
* WORLD:X,Y,Z:yaw:pitch
|
||||
* <p>
|
||||
* The corresponding String2Loc function is {@link #stringToLocation}
|
||||
*
|
||||
* @param location The Location to save.
|
||||
* @return The location as a string in this format: WORLD:x,y,z:yaw:pitch
|
||||
*/
|
||||
String locationToString(Location location);
|
||||
|
||||
/**
|
||||
* This method simply does some rounding, rather than forcing a call to the server to get the blockdata.
|
||||
*
|
||||
* @param l The location to round to the block location
|
||||
* @return A rounded location.
|
||||
*/
|
||||
Location getBlockLocation(Location l);
|
||||
|
||||
/**
|
||||
* Returns a new location from a given string. The format is as follows:
|
||||
* <p>
|
||||
* WORLD:X,Y,Z:yaw:pitch
|
||||
* <p>
|
||||
* The corresponding Location2String function is {@link #stringToLocation}
|
||||
*
|
||||
* @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch)
|
||||
* @return A new location defined by the string or null if the string was invalid.
|
||||
*/
|
||||
Location stringToLocation(String locationString);
|
||||
|
||||
/**
|
||||
* Returns a colored string with the coords.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strCoords(Location l);
|
||||
|
||||
/**
|
||||
* Converts a location to a printable readable formatted string including pitch/yaw.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strCoordsRaw(Location l);
|
||||
|
||||
/**
|
||||
* Return the NESW Direction a Location is facing.
|
||||
*
|
||||
* @param location The {@link Location}
|
||||
* @return The NESW Direction
|
||||
*/
|
||||
String getDirection(Location location);
|
||||
|
||||
/**
|
||||
* Returns the float yaw position for the given cardinal direction.
|
||||
*
|
||||
* @param orientation The cardinal direction
|
||||
* @return The yaw
|
||||
*/
|
||||
float getYaw(String orientation);
|
||||
|
||||
/**
|
||||
* Returns a speed float from a given vector.
|
||||
*
|
||||
* @param v The {@link Vector}
|
||||
* @return The speed
|
||||
*/
|
||||
float getSpeed(Vector v);
|
||||
|
||||
/**
|
||||
* Returns a translated vector from the given direction.
|
||||
*
|
||||
* @param v The old {@link Vector}
|
||||
* @param direction The new direction
|
||||
* @return The translated {@link Vector}
|
||||
*/
|
||||
Vector getTranslatedVector(Vector v, String direction);
|
||||
|
||||
/**
|
||||
* Returns the next Location that a {@link Vehicle} is traveling at.
|
||||
*
|
||||
* @param v The {@link Vehicle}
|
||||
* @return The {@link Location}
|
||||
*/
|
||||
Location getNextBlock(Vehicle v);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/** A simple API to require plugins to have a log method. */
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* A destination API for Multiverse
|
||||
* Any plugin can add these to MV and when they are, any action that uses them (portals, MVTP, etc.) can use them!
|
||||
*/
|
||||
public interface MVDestination {
|
||||
/**
|
||||
* Returns the identifier or prefix that is required for this destination.
|
||||
* <p>
|
||||
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
||||
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
||||
* Please check the wiki when adding a custom destination!
|
||||
*
|
||||
* @return The identifier or prefix that is required for this destination.
|
||||
*/
|
||||
String getIdentifier();
|
||||
|
||||
/**
|
||||
* Allows you to determine if a Destination is valid for the type it thinks it is.
|
||||
* <p>
|
||||
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
|
||||
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
|
||||
* method
|
||||
* and does not even NEED to be called, but it's highly recommended if you're teleporting, but it's mainly for
|
||||
* Multiverse Internal use.
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*
|
||||
* @return True if the destination is valid, false if not.
|
||||
*/
|
||||
boolean isThisType(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns the location a specific entity will spawn at when being teleported to this Destination.
|
||||
* <p>
|
||||
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
||||
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
||||
* minecarts can be teleported.
|
||||
* <p>
|
||||
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
|
||||
*
|
||||
* @param entity The entity to be teleported.
|
||||
*
|
||||
* @return The location of the entity.
|
||||
*/
|
||||
Location getLocation(Entity entity);
|
||||
|
||||
/**
|
||||
* Returns the velocity vector for this destination.
|
||||
* <p>
|
||||
* Plugins wishing to fully support MVDestinations MUST implement this.
|
||||
*
|
||||
* @return A vector representing the speed/direction the player should travel when arriving
|
||||
*/
|
||||
Vector getVelocity();
|
||||
|
||||
/**
|
||||
* Sets the destination string.
|
||||
* <p>
|
||||
* This should be used when you want to tell this destination object about a change in where it should take people.
|
||||
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
|
||||
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
|
||||
* "p:HomePortal"
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*/
|
||||
void setDestination(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns true if the destination is valid and players will be taken to it.
|
||||
* <p>
|
||||
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
|
||||
* return false.
|
||||
*
|
||||
* @return True if the destination is valid; false if not.
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
/**
|
||||
* Gives you a general friendly description of the type of destination.
|
||||
* <p>
|
||||
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
|
||||
*
|
||||
* @return A friendly string description of the type of destination.
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* Gives you a specific name of the destination.
|
||||
* <p>
|
||||
* For example, the PlayerDestination sets this to The Player's Name.
|
||||
*
|
||||
* @return A friendly string stating the name of the destination.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
|
||||
* destination.
|
||||
* <p>
|
||||
* ex: e:0,0,0:50:50
|
||||
*
|
||||
* @return The savable config string.
|
||||
*/
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Returns the permissions string required to go here.
|
||||
* <p>
|
||||
* ex: multiverse.access.world
|
||||
* <p>
|
||||
* NOTE: This is NOT the permission to use the teleport command.
|
||||
*
|
||||
* @return the permissions string required to go here.
|
||||
*/
|
||||
String getRequiredPermission();
|
||||
|
||||
/**
|
||||
* Should the Multiverse SafeTeleporter be used?
|
||||
* <p>
|
||||
* If not, MV will blindly take people to the location specified.
|
||||
*
|
||||
* @return True if the SafeTeleporter will be used, false if not.
|
||||
*/
|
||||
boolean useSafeTeleporter();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
* 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.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
|
||||
/**
|
||||
* This interface is implemented by every official Multiverse-plugin.
|
||||
*/
|
||||
public interface MVPlugin extends LoggablePlugin {
|
||||
/**
|
||||
* Adds This plugin's version information to the buffer and returns the new string.
|
||||
*
|
||||
* @param buffer The string that contains Core and all other MV plugins' versions.
|
||||
*
|
||||
* @return A modified buffer that contains this MVPlugin's version information.
|
||||
*
|
||||
* @deprecated This is now deprecated, nobody needs it any longer.
|
||||
* All version info-dumping is now done with {@link MVVersionEvent}.
|
||||
*/
|
||||
@Deprecated
|
||||
String dumpVersionInfo(String buffer);
|
||||
|
||||
/**
|
||||
* Gets the reference to MultiverseCore.
|
||||
*
|
||||
* @return A valid {@link MultiverseCore}.
|
||||
*/
|
||||
MultiverseCore getCore();
|
||||
|
||||
/**
|
||||
* Sets the reference to MultiverseCore.
|
||||
*
|
||||
* @param core A valid {@link MultiverseCore}.
|
||||
*/
|
||||
void setCore(MultiverseCore core);
|
||||
|
||||
/**
|
||||
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This
|
||||
* number
|
||||
* should change when something will break the code.
|
||||
*
|
||||
* @return The Integer protocol version.
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
/******************************************************************************
|
||||
* 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.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Multiverse 2 World Manager API
|
||||
* <p>
|
||||
* This API contains all of the world managing
|
||||
* functions that your heart desires!
|
||||
*/
|
||||
public interface MVWorldManager {
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generateStructures If true, this world will get NPC villages.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator);
|
||||
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generateStructures If true, this world will get NPC villages.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Make a copy of a world.
|
||||
*
|
||||
* @param oldName Name of world to be copied
|
||||
* @param newName Name of world to be created
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
*/
|
||||
boolean cloneWorld(String oldName, String newName, String generator);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config and deletes the folder.
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config if wanted, and deletes the folder.
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeConfig);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
boolean unloadWorld(String name);
|
||||
|
||||
/**
|
||||
* Loads the world. Only use this if the world has been
|
||||
* unloaded with {@link #unloadWorld(String)}.
|
||||
*
|
||||
* @param name The name of the world to load
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean loadWorld(String name);
|
||||
|
||||
/**
|
||||
* Removes all players from the specified world.
|
||||
*
|
||||
* @param name World to remove players from.
|
||||
*/
|
||||
void removePlayersFromWorld(String name);
|
||||
|
||||
/**
|
||||
* Test if a given chunk generator is valid.
|
||||
*
|
||||
* @param generator The generator name.
|
||||
* @param generatorID The generator id.
|
||||
* @param worldName The worldName to use as the default.
|
||||
* @return A {@link ChunkGenerator} or null
|
||||
*/
|
||||
ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
|
||||
|
||||
/**
|
||||
* Returns a list of all the worlds Multiverse knows about.
|
||||
*
|
||||
* @return A list of {@link MultiverseWorld}.
|
||||
*/
|
||||
Collection<MultiverseWorld> getMVWorlds();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
|
||||
* This will search name AND alias.
|
||||
*
|
||||
* @param name The name or alias of the world to get.
|
||||
* @return A {@link MultiverseWorld} or null.
|
||||
*/
|
||||
MultiverseWorld getMVWorld(String name);
|
||||
|
||||
/**
|
||||
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
* @return A {@link MultiverseWorld} or null.
|
||||
*/
|
||||
MultiverseWorld getMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Checks to see if the given name is a valid {@link MultiverseWorld}.
|
||||
*
|
||||
* @param name The name or alias of the world to check.
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
boolean isMVWorld(String name);
|
||||
|
||||
/**
|
||||
* Checks to see if the given world is a valid {@link MultiverseWorld}.
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
* @return True if the world has been loaded into MV2, false if not.
|
||||
*/
|
||||
boolean isMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Load the Worlds & Settings from the configuration file.
|
||||
*
|
||||
* @param forceLoad If set to true, this will perform a total
|
||||
* reset and not just load new worlds.
|
||||
*/
|
||||
void loadWorlds(boolean forceLoad);
|
||||
|
||||
/**
|
||||
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
||||
* <p>
|
||||
* This way people will _always_ have some worlds in the list.
|
||||
*/
|
||||
void loadDefaultWorlds();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
WorldPurger getTheWorldPurger();
|
||||
|
||||
/**
|
||||
* Gets the world players will spawn in on first join.
|
||||
* Currently this always returns worlds.get(0) from Bukkit.
|
||||
*
|
||||
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
|
||||
*/
|
||||
MultiverseWorld getSpawnWorld();
|
||||
|
||||
/**
|
||||
* Gets the list of worlds in the config, but unloaded.
|
||||
*
|
||||
* @return A List of worlds as strings.
|
||||
*/
|
||||
List<String> getUnloadedWorlds();
|
||||
|
||||
/**
|
||||
* This method populates an internal list and needs to be called after multiverse initialization.
|
||||
*/
|
||||
void getDefaultWorldGenerators();
|
||||
|
||||
/**
|
||||
* Load the config from a file.
|
||||
*
|
||||
* @param file The file to load.
|
||||
* @return A loaded configuration.
|
||||
*/
|
||||
FileConfiguration loadWorldConfig(File file);
|
||||
|
||||
/**
|
||||
* Saves the world config to disk.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean saveWorldsConfig();
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list and from the config.
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean removeWorldFromConfig(String name);
|
||||
|
||||
/**
|
||||
* Sets the initial spawn world for new players.
|
||||
*
|
||||
* @param world The World new players should spawn in.
|
||||
*/
|
||||
void setFirstSpawnWorld(String world);
|
||||
|
||||
/**
|
||||
* Gets the world players should spawn in first.
|
||||
*
|
||||
* @return The {@link MultiverseWorld} new players should spawn in.
|
||||
*/
|
||||
MultiverseWorld getFirstSpawnWorld();
|
||||
|
||||
/**
|
||||
* Regenerates a world.
|
||||
*
|
||||
* @param name Name of the world to regenerate
|
||||
* @param useNewSeed If a new seed should be used
|
||||
* @param randomSeed IF the new seed should be random
|
||||
* @param seed The seed of the world.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
||||
/**
|
||||
* The configuration of MultiverseCore.
|
||||
*/
|
||||
public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
/**
|
||||
* Sets a property using a {@link String}.
|
||||
* @param property The name of the property.
|
||||
* @param value The value.
|
||||
* @return True on success, false if the operation failed.
|
||||
*/
|
||||
boolean setConfigProperty(String property, String value);
|
||||
|
||||
/**
|
||||
* Sets portalCooldown.
|
||||
* @param portalCooldown The new value.
|
||||
*/
|
||||
void setTeleportCooldown(int portalCooldown);
|
||||
|
||||
/**
|
||||
* Gets portalCooldown.
|
||||
* @return portalCooldown.
|
||||
*/
|
||||
int getTeleportCooldown();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnWorld.
|
||||
* @param firstSpawnWorld The new value.
|
||||
*/
|
||||
void setFirstSpawnWorld(String firstSpawnWorld);
|
||||
|
||||
/**
|
||||
* Gets firstSpawnWorld.
|
||||
* @return firstSpawnWorld.
|
||||
*/
|
||||
String getFirstSpawnWorld();
|
||||
|
||||
/**
|
||||
* Sets version.
|
||||
* @param version The new value.
|
||||
*/
|
||||
void setVersion(int version);
|
||||
|
||||
/**
|
||||
* Gets version.
|
||||
* @return version.
|
||||
*/
|
||||
double getVersion();
|
||||
|
||||
/**
|
||||
* Sets messageCooldown.
|
||||
* @param messageCooldown The new value.
|
||||
*/
|
||||
void setMessageCooldown(int messageCooldown);
|
||||
|
||||
/**
|
||||
* Gets messageCooldown.
|
||||
* @return messageCooldown.
|
||||
*/
|
||||
int getMessageCooldown();
|
||||
|
||||
/**
|
||||
* Sets globalDebug.
|
||||
* @param globalDebug The new value.
|
||||
*/
|
||||
void setGlobalDebug(int globalDebug);
|
||||
|
||||
/**
|
||||
* Gets globalDebug.
|
||||
* @return globalDebug.
|
||||
*/
|
||||
int getGlobalDebug();
|
||||
|
||||
/**
|
||||
* Sets displayPermErrors.
|
||||
* @param displayPermErrors The new value.
|
||||
*/
|
||||
void setDisplayPermErrors(boolean displayPermErrors);
|
||||
|
||||
/**
|
||||
* Gets displayPermErrors.
|
||||
* @return displayPermErrors.
|
||||
*/
|
||||
boolean getDisplayPermErrors();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnOverride.
|
||||
* @param firstSpawnOverride The new value.
|
||||
*/
|
||||
void setFirstSpawnOverride(boolean firstSpawnOverride);
|
||||
|
||||
/**
|
||||
* Gets firstSpawnOverride.
|
||||
* @return firstSpawnOverride.
|
||||
*/
|
||||
boolean getFirstSpawnOverride();
|
||||
|
||||
/**
|
||||
* Sets teleportIntercept.
|
||||
* @param teleportIntercept The new value.
|
||||
*/
|
||||
void setTeleportIntercept(boolean teleportIntercept);
|
||||
|
||||
/**
|
||||
* Gets teleportIntercept.
|
||||
* @return teleportIntercept.
|
||||
*/
|
||||
boolean getTeleportIntercept();
|
||||
|
||||
/**
|
||||
* Sets prefixChat.
|
||||
* @param prefixChat The new value.
|
||||
*/
|
||||
void setPrefixChat(boolean prefixChat);
|
||||
|
||||
/**
|
||||
* Gets prefixChat.
|
||||
* @return prefixChat.
|
||||
*/
|
||||
boolean getPrefixChat();
|
||||
|
||||
/**
|
||||
* Sets enforceAccess.
|
||||
* @param enforceAccess The new value.
|
||||
*/
|
||||
void setEnforceAccess(boolean enforceAccess);
|
||||
|
||||
/**
|
||||
* Gets enforceAccess.
|
||||
* @return enforceAccess.
|
||||
*/
|
||||
boolean getEnforceAccess();
|
||||
|
||||
/**
|
||||
* Sets useasyncchat.
|
||||
* @param useAsyncChat The new value.
|
||||
*/
|
||||
void setUseAsyncChat(boolean useAsyncChat);
|
||||
|
||||
/**
|
||||
* Gets useasyncchat.
|
||||
* @return useasyncchat.
|
||||
*/
|
||||
boolean getUseAsyncChat();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Multiverse-messaging.
|
||||
*/
|
||||
public interface MultiverseMessaging {
|
||||
/**
|
||||
* Sets the message-cooldown.
|
||||
* @param milliseconds The new message-cooldown in milliseconds.
|
||||
*/
|
||||
void setCooldown(int milliseconds);
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param message The message to send.
|
||||
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown);
|
||||
|
||||
/**
|
||||
* Sends a group of messages to the specified sender if the cooldown has passed.
|
||||
* This method is needed, since sending many messages in quick succession would violate
|
||||
* the cooldown.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param messages The messages to send.
|
||||
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown);
|
||||
|
||||
/**
|
||||
* Sends a group of messages to the specified sender if the cooldown has passed.
|
||||
* This method is needed, since sending many messages in quick succession would violate
|
||||
* the cooldown.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param messages The messages to send.
|
||||
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessages(CommandSender sender, Collection<String> messages, boolean ignoreCooldown);
|
||||
|
||||
/**
|
||||
* Gets the message-cooldown.
|
||||
* @return The message-cooldown.
|
||||
*/
|
||||
int getCooldown();
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.DebugLog;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
|
||||
/**
|
||||
* Make things easier for MV-Plugins!
|
||||
*/
|
||||
public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
|
||||
private MultiverseCore core;
|
||||
/**
|
||||
* Prefix for standard log entrys.
|
||||
*/
|
||||
protected String logTag;
|
||||
private DebugLog debugLog;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Note: You can't override this, use {@link #onPluginEnable()} instead!
|
||||
* @see #onPluginEnable()
|
||||
*/
|
||||
@Override
|
||||
public final void onEnable() {
|
||||
MultiverseCore theCore = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
|
||||
if (theCore == null) {
|
||||
this.getLogger().severe("Core not found! The plugin dev needs to add a dependency!");
|
||||
this.getLogger().severe("Disabling!");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
if (theCore.getProtocolVersion() < this.getProtocolVersion()) {
|
||||
this.getLogger().severe("You need a newer version of Multiverse-Core!");
|
||||
this.getLogger().severe("Disabling!");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
this.setCore(theCore);
|
||||
|
||||
this.getServer().getLogger().info(String.format("%s - Version %s enabled - By %s",
|
||||
this.getDescription().getName(), this.getDescription().getVersion(), getAuthors()));
|
||||
getDataFolder().mkdirs();
|
||||
File debugLogFile = new File(getDataFolder(), "debug.log");
|
||||
try {
|
||||
debugLogFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
debugLog = new DebugLog(this.getDescription().getName(), getDataFolder() + File.separator + "debug.log");
|
||||
debugLog.setTag(String.format("[%s-Debug]", this.getDescription().getName()));
|
||||
|
||||
this.onPluginEnable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the Authors Array into a readable String with ',' and 'and'.
|
||||
*
|
||||
* @return The readable authors-{@link String}
|
||||
*/
|
||||
protected String getAuthors() {
|
||||
String authors = "";
|
||||
List<String> auths = this.getDescription().getAuthors();
|
||||
if (auths.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (auths.size() == 1) {
|
||||
return auths.get(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < auths.size(); i++) {
|
||||
if (i == this.getDescription().getAuthors().size() - 1) {
|
||||
authors += " and " + this.getDescription().getAuthors().get(i);
|
||||
} else {
|
||||
authors += ", " + this.getDescription().getAuthors().get(i);
|
||||
}
|
||||
}
|
||||
return authors.substring(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the plugin is enabled.
|
||||
* @see #onEnable()
|
||||
*/
|
||||
protected abstract void onPluginEnable();
|
||||
|
||||
/**
|
||||
* You can register commands here.
|
||||
* @param handler The CommandHandler.
|
||||
*/
|
||||
protected abstract void registerCommands(CommandHandler handler);
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!this.isEnabled()) {
|
||||
sender.sendMessage("This plugin is Disabled!");
|
||||
return true;
|
||||
}
|
||||
|
||||
ArrayList<String> allArgs = new ArrayList<String>(args.length + 1);
|
||||
allArgs.add(command.getName());
|
||||
allArgs.addAll(Arrays.asList(args));
|
||||
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.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final MultiverseCore getCore() {
|
||||
if (this.core == null)
|
||||
throw new IllegalStateException("Core is null!");
|
||||
return this.core;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setCore(MultiverseCore core) {
|
||||
this.core = core;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,672 @@
|
||||
/******************************************************************************
|
||||
* 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.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The API for a Multiverse Handled World.
|
||||
*/
|
||||
public interface MultiverseWorld {
|
||||
/**
|
||||
* Returns the Bukkit world object that this world describes.
|
||||
*
|
||||
* @return A {@link World}
|
||||
*/
|
||||
World getCBWorld();
|
||||
|
||||
/**
|
||||
* Gets the name of this world. The name cannot be changed.
|
||||
* <p>
|
||||
* Note for plugin developers: Usually {@link #getAlias()}
|
||||
* is what you want to use instead of this method.
|
||||
*
|
||||
* @return The name of the world as a String.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the type of this world. As of 1.2 this will be:
|
||||
* FLAT, NORMAL or VERSION_1_1
|
||||
* <p>
|
||||
* This is <b>not</b> the generator.
|
||||
*
|
||||
* @return The Type of this world.
|
||||
*/
|
||||
WorldType getWorldType();
|
||||
|
||||
/**
|
||||
* Gets the environment of this world.
|
||||
*
|
||||
* @return A {@link org.bukkit.World.Environment}.
|
||||
*/
|
||||
World.Environment getEnvironment();
|
||||
|
||||
/**
|
||||
* Sets the environment of a world.
|
||||
* <p>
|
||||
* Note: This will ONLY take effect once the world is unloaded/reloaded.
|
||||
*
|
||||
* @param environment A {@link org.bukkit.World.Environment}.
|
||||
*/
|
||||
void setEnvironment(World.Environment environment);
|
||||
|
||||
/**
|
||||
* Gets the difficulty of this world.
|
||||
*
|
||||
* @return The difficulty of this world.
|
||||
*/
|
||||
Difficulty getDifficulty();
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns true if success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. {@code PEACEFUL}
|
||||
*
|
||||
* @param difficulty The difficulty to set the world to as a string.
|
||||
* @return True if success, false if the provided string
|
||||
* could not be translated to a difficulty.
|
||||
* @deprecated Use {@link #setDifficulty(Difficulty)} or, if you have to
|
||||
* pass a string, use {@link #setPropertyValue(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setDifficulty(String difficulty);
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns {@code true} on success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. PEACEFUL
|
||||
*
|
||||
* @param difficulty The new difficulty.
|
||||
* @return True if success, false if the operation failed... for whatever reason.
|
||||
*/
|
||||
boolean setDifficulty(Difficulty difficulty);
|
||||
|
||||
/**
|
||||
* Gets the world seed of this world.
|
||||
*
|
||||
* @return The Long version of the seed.
|
||||
*/
|
||||
long getSeed();
|
||||
|
||||
/**
|
||||
* Sets the seed of this world.
|
||||
*
|
||||
* @param seed A Long that is the seed.
|
||||
*/
|
||||
void setSeed(long seed);
|
||||
|
||||
/**
|
||||
* Gets the generator of this world.
|
||||
*
|
||||
* @return The name of the generator.
|
||||
*/
|
||||
String getGenerator();
|
||||
|
||||
/**
|
||||
* Sets the generator of this world.
|
||||
*
|
||||
* @param generator The new generator's name.
|
||||
*/
|
||||
void setGenerator(String generator);
|
||||
|
||||
/**
|
||||
* Gets the help-message for a property.
|
||||
* @param property The name of the property.
|
||||
* @return The help-message.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found.
|
||||
*/
|
||||
String getPropertyHelp(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets a property as {@link String}.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @return The string-representation of that property.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
String getPropertyValue(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Sets a property to a given value.
|
||||
*
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was set, false if not.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets the actual MVConfigProperty from this world.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
|
||||
* @param <T> The type of the expected property.
|
||||
*
|
||||
* @return A valid MVWorldProperty.
|
||||
*
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
* @deprecated We don't use {@link com.onarandombox.MultiverseCore.configuration.MVConfigProperty} any longer!
|
||||
*/
|
||||
@Deprecated
|
||||
<T> com.onarandombox.MultiverseCore.configuration.MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
|
||||
|
||||
// old config
|
||||
/**
|
||||
* Adds the property to the given value.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @param sender The sender who wants this value to be set.
|
||||
* @return True if the value was set, false if not.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
* @deprecated Use {@link #setPropertyValue(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was added, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean addToVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
|
||||
* from.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was removed, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeFromVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
|
||||
* @return True if it was cleared, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean clearVariable(String property);
|
||||
|
||||
/**
|
||||
* Clears a list property (sets it to []).
|
||||
*
|
||||
* @param property The property to clear.
|
||||
* @return True if success, false if fail.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean clearList(String property);
|
||||
// end of old config stuff
|
||||
|
||||
// permission stuff
|
||||
/**
|
||||
* Gets the lowercased name of the world. This method is required, since the permissables
|
||||
* lowercase all permissions when recalculating.
|
||||
* <p>
|
||||
* Note: This also means if a user has worlds named: world and WORLD, that they can both
|
||||
* exist, and both be teleported to independently, but their permissions **cannot** be
|
||||
* uniqueified at this time. See bug report #.
|
||||
*
|
||||
* @return The lowercased name of the world.
|
||||
*/
|
||||
String getPermissibleName();
|
||||
|
||||
/**
|
||||
* Gets the permission required to enter this world.
|
||||
*
|
||||
* @return The permission required to be exempt from charges to/from this world.
|
||||
*/
|
||||
Permission getAccessPermission();
|
||||
|
||||
/**
|
||||
* Gets the permission required to be exempt when entering.
|
||||
*
|
||||
* @return The permission required to be exempt when entering.
|
||||
*/
|
||||
Permission getExemptPermission();
|
||||
// end of permission stuff
|
||||
|
||||
/**
|
||||
* Gets the alias of this world.
|
||||
* <p>
|
||||
* This alias allows users to have a world named "world" but show up in the list as "FernIsland"
|
||||
*
|
||||
* @return The alias of the world as a String.
|
||||
*/
|
||||
String getAlias();
|
||||
|
||||
/**
|
||||
* Sets the alias of the world.
|
||||
*
|
||||
* @param alias A string that is the new alias.
|
||||
*/
|
||||
void setAlias(String alias);
|
||||
|
||||
/**
|
||||
* Gets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @return The color of this world.
|
||||
*/
|
||||
ChatColor getColor();
|
||||
|
||||
/**
|
||||
* Sets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @param color A valid color name.
|
||||
* @return True if the color was set, false if not.
|
||||
*/
|
||||
boolean setColor(String color);
|
||||
|
||||
/**
|
||||
* Gets the style that this world's name/alias will display as.
|
||||
*
|
||||
* @return The style of this world. {@code null} for "normal" style.
|
||||
*/
|
||||
ChatColor getStyle();
|
||||
|
||||
/**
|
||||
* Sets the style that this world's name/alias will display as.
|
||||
*
|
||||
* @param style A valid style name.
|
||||
* @return True if the style was set, false if not.
|
||||
*/
|
||||
boolean setStyle(String style);
|
||||
|
||||
/**
|
||||
* Tells you if someone entered a valid color.
|
||||
*
|
||||
* @param color A string that may translate to a color.
|
||||
* @return True if it is a color, false if not.
|
||||
*
|
||||
* @deprecated This has been moved: {@link com.onarandombox.MultiverseCore.enums.EnglishChatColor#isValidAliasColor(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isValidAliasColor(String color);
|
||||
|
||||
/**
|
||||
* Returns a very nicely colored string (using Alias and Color if they are set).
|
||||
*
|
||||
* @return A nicely colored string.
|
||||
*/
|
||||
String getColoredWorldString();
|
||||
|
||||
// animals&monster stuff
|
||||
/**
|
||||
* Gets whether or not animals are allowed to spawn in this world.
|
||||
*
|
||||
* @return True if ANY animal can, false if no animals can spawn.
|
||||
*/
|
||||
boolean canAnimalsSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not animals can spawn.
|
||||
* If there are values in {@link #getAnimalList()} and this is false,
|
||||
* those animals become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
|
||||
*
|
||||
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
|
||||
*/
|
||||
List<String> getAnimalList();
|
||||
|
||||
/**
|
||||
* Gets whether or not monsters are allowed to spawn in this world.
|
||||
*
|
||||
* @return True if ANY monster can, false if no monsters can spawn.
|
||||
*/
|
||||
boolean canMonstersSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not monsters can spawn.
|
||||
* If there are values in {@link #getMonsterList()} and this is false,
|
||||
* those monsters become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
|
||||
*
|
||||
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
|
||||
*/
|
||||
List<String> getMonsterList();
|
||||
// end of animal&monster stuff
|
||||
|
||||
/**
|
||||
* Gets whether or not PVP is enabled in this world in some form (fake or not).
|
||||
*
|
||||
* @return True if players can take damage from other players.
|
||||
*/
|
||||
boolean isPVPEnabled();
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode.
|
||||
*
|
||||
* @param pvpMode True to enable PVP damage, false to disable it.
|
||||
*/
|
||||
void setPVPMode(boolean pvpMode);
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
|
||||
*
|
||||
* @return True if this world has fakepvp on
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean getFakePVP();
|
||||
|
||||
/**
|
||||
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
*
|
||||
* @return True if the world will be hidden, false if not.
|
||||
*/
|
||||
boolean isHidden();
|
||||
|
||||
/**
|
||||
* Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
*
|
||||
* @param hidden Set
|
||||
*/
|
||||
void setHidden(boolean hidden);
|
||||
|
||||
/**
|
||||
* Gets whether weather is enabled in this world.
|
||||
*
|
||||
* @return True if weather events will occur, false if not.
|
||||
*/
|
||||
boolean isWeatherEnabled();
|
||||
|
||||
/**
|
||||
* Sets whether or not there will be weather events in a given world.
|
||||
* If set to false, Multiverse will disable the weather in the world immediately.
|
||||
*
|
||||
* @param enableWeather True if weather events should occur in a world, false if not.
|
||||
*/
|
||||
void setEnableWeather(boolean enableWeather);
|
||||
|
||||
/**
|
||||
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
|
||||
*
|
||||
* @return True if CraftBukkit is keeping spawn chunks in memory.
|
||||
*/
|
||||
boolean isKeepingSpawnInMemory();
|
||||
|
||||
/**
|
||||
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
|
||||
* If not, CraftBukkit will attempt to free memory when players have not used that world.
|
||||
* This will not happen immediately.
|
||||
*
|
||||
* @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
|
||||
*/
|
||||
void setKeepSpawnInMemory(boolean keepSpawnInMemory);
|
||||
|
||||
/**
|
||||
* Gets the spawn location of this world.
|
||||
*
|
||||
* @return The spawn location of this world.
|
||||
*/
|
||||
Location getSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets the spawn location for a world.
|
||||
*
|
||||
* @param spawnLocation The spawn location for a world.
|
||||
*/
|
||||
void setSpawnLocation(Location spawnLocation);
|
||||
|
||||
/**
|
||||
* Gets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @return True if it will go down, false if it will remain steady.
|
||||
*/
|
||||
boolean getHunger();
|
||||
|
||||
/**
|
||||
* Sets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @param hungerEnabled True if hunger will go down, false to keep it at
|
||||
* the level they entered a world with.
|
||||
*/
|
||||
void setHunger(boolean hungerEnabled);
|
||||
|
||||
/**
|
||||
* Gets the GameMode of this world.
|
||||
*
|
||||
* @return The GameMode of this world.
|
||||
*/
|
||||
GameMode getGameMode();
|
||||
|
||||
/**
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @param gameMode A valid game mode string (either
|
||||
* an int ex. 0 or a string ex. creative).
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
* @deprecated Use {@link #setGameMode(GameMode)} instead. If you have to
|
||||
* pass a string, use {@link #setPropertyValue(String, String)}.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setGameMode(String gameMode);
|
||||
|
||||
/**
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @param gameMode The new {@link GameMode}.
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
*/
|
||||
boolean setGameMode(GameMode gameMode);
|
||||
|
||||
/**
|
||||
* Gets the amount of currency it requires to enter this world.
|
||||
*
|
||||
* @return The amount it costs to enter this world.
|
||||
*/
|
||||
double getPrice();
|
||||
|
||||
/**
|
||||
* Sets the price for entry to this world.
|
||||
* You can think of this like an amount.
|
||||
* The type can be set with {@link #setCurrency(int)}
|
||||
*
|
||||
* @param price The Amount of money/item to enter the world.
|
||||
*/
|
||||
void setPrice(double price);
|
||||
|
||||
/**
|
||||
* Gets the Type of currency that will be used when users enter this world.
|
||||
*
|
||||
* @return The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
int getCurrency();
|
||||
|
||||
/**
|
||||
* Sets the type of item that will be required given the price is not 0.
|
||||
* Use -1 to use an AllPay economy, or any valid itemid
|
||||
*
|
||||
* @param item The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
void setCurrency(int item);
|
||||
|
||||
/**
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
*
|
||||
* @return A world that exists on the server.
|
||||
*/
|
||||
World getRespawnToWorld();
|
||||
|
||||
/**
|
||||
* Sets the world players will respawn in if they die in this one.
|
||||
* Returns true upon success, false upon failure.
|
||||
*
|
||||
* @param respawnWorld The name of a world that exists on the server.
|
||||
* @return True if respawnWorld existed, false if not.
|
||||
*/
|
||||
boolean setRespawnToWorld(String respawnWorld);
|
||||
|
||||
/**
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @return This world's non-negative, non-zero scale.
|
||||
*/
|
||||
double getScaling();
|
||||
|
||||
/**
|
||||
* Sets the scale of this world. Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @param scaling A scaling value, cannot be negative or 0.
|
||||
* @return Whether the scale was set successfully.
|
||||
*/
|
||||
boolean setScaling(double scaling);
|
||||
|
||||
/**
|
||||
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @return True if the world should heal (default), false if not.
|
||||
*/
|
||||
boolean getAutoHeal();
|
||||
|
||||
/**
|
||||
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @param heal True if the world will heal.
|
||||
*/
|
||||
void setAutoHeal(boolean heal);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @return True if Multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
boolean getAdjustSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @param adjust True if multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
void setAdjustSpawn(boolean adjust);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-load this world.
|
||||
*
|
||||
* @return True if Multiverse should auto-load this world.
|
||||
*/
|
||||
boolean getAutoLoad();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-load this world.
|
||||
* <p>
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
|
||||
*/
|
||||
void setAutoLoad(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Gets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
*
|
||||
* @return True if players dying in this world should respawn at their bed.
|
||||
*/
|
||||
boolean getBedRespawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
* <p>
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if players dying in this world respawn at their bed.
|
||||
*/
|
||||
void setBedRespawn(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
* @return The time as a short string: 12:34pm
|
||||
*/
|
||||
String getTime();
|
||||
|
||||
/**
|
||||
* Sets the current time in a world.
|
||||
* <p>
|
||||
* This method will take the following formats:
|
||||
* 11:37am
|
||||
* 4:30p
|
||||
* day(morning), night, noon, midnight
|
||||
*
|
||||
* @param timeAsString The formatted time to set the world to.
|
||||
* @return True if the time was set, false if not.
|
||||
*/
|
||||
boolean setTime(String timeAsString);
|
||||
|
||||
/**
|
||||
* Sets The types of portals that are allowed in this world.
|
||||
*
|
||||
* @param type The type of portals allowed in this world.
|
||||
*/
|
||||
void allowPortalMaking(AllowedPortalType type);
|
||||
|
||||
/**
|
||||
* Gets which type(s) of portals are allowed to be constructed in this world.
|
||||
*
|
||||
* @return The type of portals that are allowed.
|
||||
*/
|
||||
AllowedPortalType getAllowedPortals();
|
||||
|
||||
// properties that are not "getter+setter" style
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
* regardless of their access permissions.
|
||||
*
|
||||
* @return A List of world names.
|
||||
*/
|
||||
List<String> getWorldBlacklist();
|
||||
|
||||
/**
|
||||
* Gets all the names of all properties that can be SET.
|
||||
*
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
|
||||
/**
|
||||
* Used to safely teleport people.
|
||||
*/
|
||||
public interface SafeTTeleporter {
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l);
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @param tolerance The tolerance.
|
||||
* @param radius The radius.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l, int tolerance, int radius);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param d Destination to teleport them to
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the Location. This may perform checks to
|
||||
* see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who issued the teleport command.
|
||||
* @param teleportee Entity to teleport.
|
||||
* @param location Location to teleport them to.
|
||||
* @param safely Should the destination be checked for safety before teleport?
|
||||
* @return true for success, false for failure.
|
||||
*/
|
||||
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location,
|
||||
boolean safely);
|
||||
|
||||
/**
|
||||
* Returns a safe location for the entity to spawn at.
|
||||
*
|
||||
* @param e The entity to spawn
|
||||
* @param d The MVDestination to take the entity to.
|
||||
* @return A new location to spawn the entity at.
|
||||
*/
|
||||
Location getSafeLocation(Entity e, MVDestination d);
|
||||
|
||||
/**
|
||||
* Finds a portal-block next to the specified {@link Location}.
|
||||
* @param l The {@link Location}
|
||||
* @return The next portal-block's {@link Location}.
|
||||
*/
|
||||
Location findPortalBlockNextTo(Location l);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
/**
|
||||
* Used to remove animals from worlds that don't belong there.
|
||||
*/
|
||||
public interface WorldPurger {
|
||||
/**
|
||||
* Synchronizes the given worlds with their settings.
|
||||
*
|
||||
* @param worlds A list of {@link MultiverseWorld}
|
||||
*/
|
||||
void purgeWorlds(List<MultiverseWorld> worlds);
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #purgeWorld(CommandSender, MultiverseWorld, List, boolean, boolean)} that takes the settings from the world-config.
|
||||
*
|
||||
* @param world The {@link MultiverseWorld}.
|
||||
*/
|
||||
void purgeWorld(MultiverseWorld world);
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
*
|
||||
* @param mvworld The {@link MultiverseWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
*/
|
||||
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters);
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
*
|
||||
* @param mvworld The {@link MultiverseWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
* @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
|
||||
*/
|
||||
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters, CommandSender sender);
|
||||
|
||||
/**
|
||||
* Determines whether the specified creature should be killed.
|
||||
*
|
||||
* @param e The creature.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
* @return {@code true} if the creature should be killed, otherwise {@code false}.
|
||||
*/
|
||||
boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters);
|
||||
|
||||
/**
|
||||
* Determines whether the specified creature should be killed and automatically reads the params from a world object.
|
||||
*
|
||||
* @param w The world.
|
||||
* @param e The creature.
|
||||
* @return {@code true} if the creature should be killed, otherwise {@code false}.
|
||||
*/
|
||||
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* The Multiverse-API, containing lots of interfaces that can be quite useful for other
|
||||
* plugins when interacting with Multiverse.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
@@ -0,0 +1,162 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Allows management of Anchor Destinations.
|
||||
*/
|
||||
public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
|
||||
public AnchorCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Create, Delete and Manage Anchor Destinations.");
|
||||
this.setCommandUsage("/mv anchor " + ChatColor.GREEN + "{name}" + ChatColor.GOLD + " [-d]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mv anchor");
|
||||
this.addKey("mv anchors");
|
||||
this.addKey("mvanchor");
|
||||
this.addKey("mvanchors");
|
||||
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething");
|
||||
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
|
||||
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
|
||||
this.addCommandExample("/mv anchors ");
|
||||
this.setPermission("multiverse.core.anchor.list", "Allows a player to list all anchors.", PermissionDefault.OP);
|
||||
this.addAdditonalPermission(new Permission("multiverse.core.anchor.create",
|
||||
"Allows a player to create anchors.", PermissionDefault.OP));
|
||||
this.addAdditonalPermission(new Permission("multiverse.core.anchor.delete",
|
||||
"Allows a player to delete anchors.", PermissionDefault.OP));
|
||||
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
private List<String> getFancyAnchorList(Player p) {
|
||||
List<String> anchorList = new ArrayList<String>();
|
||||
ChatColor color = ChatColor.GREEN;
|
||||
for (String anchor : this.plugin.getAnchorManager().getAnchors(p)) {
|
||||
anchorList.add(color + anchor);
|
||||
color = (color == ChatColor.GREEN) ? ChatColor.GOLD : ChatColor.GREEN;
|
||||
}
|
||||
return anchorList;
|
||||
}
|
||||
|
||||
private void showList(CommandSender sender, List<String> args) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.list", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to list anchors!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
|
||||
FilterObject filterObject = this.getPageAndFilter(args);
|
||||
|
||||
List<String> availableAnchors = new ArrayList<String>(this.getFancyAnchorList(p));
|
||||
if (filterObject.getFilter().length() > 0) {
|
||||
availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
|
||||
if (availableAnchors.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
|
||||
+ "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (availableAnchors.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors were defined.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
for (String c : availableAnchors) {
|
||||
sender.sendMessage(c);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int totalPages = (int) Math.ceil(availableAnchors.size() / (this.itemsPerPage + 0.0));
|
||||
|
||||
if (filterObject.getPage() > totalPages) {
|
||||
filterObject.setPage(totalPages);
|
||||
} else if (filterObject.getPage() < 1) {
|
||||
filterObject.setPage(1);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
|
||||
|
||||
this.showPage(filterObject.getPage(), sender, availableAnchors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 0) {
|
||||
this.showList(sender, args);
|
||||
return;
|
||||
}
|
||||
if (args.size() == 1 && (this.getPageAndFilter(args).getPage() != 1 || args.get(0).equals("1"))) {
|
||||
this.showList(sender, args);
|
||||
return;
|
||||
}
|
||||
if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!");
|
||||
} else {
|
||||
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
|
||||
} else {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You must be a player to create Anchors.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!");
|
||||
} else {
|
||||
Player player = (Player) sender;
|
||||
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
|
||||
} else {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
|
||||
List<String> filtered = new ArrayList<String>();
|
||||
for (String s : availableItems) {
|
||||
if (s.matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(s);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getItemText(String item) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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 com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* Checks to see if a player can go to a destination.
|
||||
*/
|
||||
public class CheckCommand extends MultiverseCommand {
|
||||
|
||||
public CheckCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Help you validate your multiverse settings");
|
||||
this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}");
|
||||
this.setArgRange(2, 2);
|
||||
this.addKey("mv check");
|
||||
this.addKey("mvcheck");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
|
||||
this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player p = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (p == null) {
|
||||
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
|
||||
sender.sendMessage("Are they online?");
|
||||
return;
|
||||
}
|
||||
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
|
||||
if (dest instanceof InvalidDestination) {
|
||||
sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,",
|
||||
args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE));
|
||||
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
|
||||
return;
|
||||
}
|
||||
|
||||
MVPermissions perms = this.plugin.getMVPerms();
|
||||
perms.tellMeWhyICantDoThis(sender, p, dest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a clone of a world.
|
||||
*/
|
||||
public class CloneCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public CloneCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Clone World");
|
||||
this.setCommandUsage("/mv clone" + ChatColor.GREEN + " {TARGET} {NAME}" + ChatColor.GOLD + " -g [GENERATOR[:ID]]");
|
||||
this.setArgRange(2, 4); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvclone");
|
||||
this.addKey("mvcl");
|
||||
this.addKey("mv cl");
|
||||
this.addKey("mv clone");
|
||||
this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup");
|
||||
this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock");
|
||||
this.addCommandExample("To clone a world that uses a generator:");
|
||||
this.addCommandExample("/mv clone " + ChatColor.GOLD + "CleanRoom"
|
||||
+ ChatColor.GREEN + " CleanRoomCopy" + ChatColor.DARK_AQUA + " -g CleanRoomGenerator");
|
||||
this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Class<?>[] paramTypes = {String.class, String.class, String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>();
|
||||
objectArgs.add(args.get(0));
|
||||
objectArgs.add(args.get(1));
|
||||
objectArgs.add(CommandHandler.getFlag("-g", args));
|
||||
if (!this.worldManager.isMVWorld(args.get(0))) {
|
||||
// If no world was found, we can't clone.
|
||||
sender.sendMessage("Sorry, Multiverse doesn't know about world " + args.get(0) + ", so we can't clone it!");
|
||||
sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed.");
|
||||
return;
|
||||
}
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvclone", "cloneWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World Cloned!", ChatColor.RED + "World could NOT be cloned!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows you to set Global MV Variables.
|
||||
*/
|
||||
public class ConfigCommand extends MultiverseCommand {
|
||||
public ConfigCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Configuration");
|
||||
this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mv config");
|
||||
this.addKey("mvconfig");
|
||||
this.addKey("mv conf");
|
||||
this.addKey("mvconf");
|
||||
this.addCommandExample("/mv config show");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
||||
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() <= 1) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Map<String, Object> serializedConfig = this.plugin.getMVConfig().serialize();
|
||||
for (Map.Entry<String, Object> entry : serializedConfig.entrySet()) {
|
||||
builder.append(ChatColor.GREEN);
|
||||
builder.append(entry.getKey());
|
||||
builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
|
||||
builder.append(entry.getValue().toString());
|
||||
builder.append(ChatColor.WHITE).append(", ");
|
||||
}
|
||||
String message = builder.toString();
|
||||
message = message.substring(0, message.length() - 2);
|
||||
sender.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
if (!this.plugin.getMVConfig().setConfigProperty(args.get(0).toLowerCase(), args.get(1))) {
|
||||
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
|
||||
return;
|
||||
}
|
||||
|
||||
// special rule
|
||||
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
|
||||
// Don't forget to set the world!
|
||||
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
|
||||
}
|
||||
|
||||
if (this.plugin.saveMVConfigs()) {
|
||||
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
||||
this.plugin.loadConfigs();
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Confirms actions.
|
||||
*/
|
||||
public class ConfirmCommand extends MultiverseCommand {
|
||||
|
||||
public ConfirmCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
// Any command that is dangerous should require op
|
||||
this.setName("Confirms a command that could destroy life, the universe and everything.");
|
||||
this.setCommandUsage("/mv confirm");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvconfirm");
|
||||
this.addKey("mv confirm");
|
||||
this.addCommandExample("/mv confirm");
|
||||
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/******************************************************************************
|
||||
* 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.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;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Returns detailed information on the Players where abouts.
|
||||
*/
|
||||
public class CoordCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public CoordCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Coordinates");
|
||||
this.setCommandUsage("/mv coord");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv coord");
|
||||
this.addKey("mvcoord");
|
||||
this.addKey("mvco");
|
||||
this.addCommandExample("/mv coord");
|
||||
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
World world = p.getWorld();
|
||||
|
||||
if (!this.worldManager.isMVWorld(world.getName())) {
|
||||
this.plugin.showNotMVWorldMessage(sender, world.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
|
||||
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
|
||||
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
|
||||
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
|
||||
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a new world and loads it.
|
||||
*/
|
||||
public class CreateCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Create World");
|
||||
this.setCommandUsage(String.format("/mv create %s{NAME} {ENV} %s-s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n] -a [true|false]",
|
||||
ChatColor.GREEN, ChatColor.GOLD));
|
||||
this.setArgRange(2, 11); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvcreate");
|
||||
this.addKey("mvc");
|
||||
this.addKey("mv create");
|
||||
this.setPermission("multiverse.core.create", "Creates a new world and loads it.", PermissionDefault.OP);
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "world" + ChatColor.GREEN + " normal");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "lavaland" + ChatColor.RED + " nether");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "starwars" + ChatColor.AQUA + " end");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -s gargamel");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "moonworld" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -g BukkitFullOfMoon");
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
String worldName = args.get(0);
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
String env = args.get(1);
|
||||
String seed = CommandHandler.getFlag("-s", args);
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
boolean allowStructures = true;
|
||||
String structureString = CommandHandler.getFlag("-a", args);
|
||||
if (structureString != null) {
|
||||
allowStructures = Boolean.parseBoolean(structureString);
|
||||
}
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase("-n")) {
|
||||
useSpawnAdjust = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "Multiverse cannot create " + ChatColor.GOLD +ChatColor.UNDERLINE + "another" + ChatColor.RESET + ChatColor.RED + " world named " + worldName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldFile.exists()) {
|
||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||
return;
|
||||
}
|
||||
|
||||
Environment environment = EnvironmentCommand.getEnvFromString(env);
|
||||
if (environment == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// If they didn't specify a type, default to NORMAL
|
||||
if (typeString == null) {
|
||||
typeString = "NORMAL";
|
||||
}
|
||||
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
return;
|
||||
}
|
||||
// Determine if the generator is valid. #918
|
||||
if (generator != null) {
|
||||
List<String> genarray = new ArrayList<String>(Arrays.asList(generator.split(":")));
|
||||
if (genarray.size() < 2) {
|
||||
// If there was only one arg specified, pad with another empty one.
|
||||
genarray.add("");
|
||||
}
|
||||
if (this.worldManager.getChunkGenerator(genarray.get(0), genarray.get(1), "test") == null) {
|
||||
// We have an invalid generator.
|
||||
sender.sendMessage("Invalid generator! '" + generator + "'. " + ChatColor.RED + "Aborting world creation.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, "FAILED.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* 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]");
|
||||
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) {
|
||||
if (plugin.getMVConfig().getGlobalDebug() == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
|
||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Deletes worlds.
|
||||
*/
|
||||
public class DeleteCommand extends MultiverseCommand {
|
||||
|
||||
public DeleteCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Delete World");
|
||||
this.setCommandUsage("/mv delete" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvdelete");
|
||||
this.addKey("mv delete");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "MyWorld");
|
||||
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Class<?>[] paramTypes = {String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>(args);
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Lists valid known environments.
|
||||
*/
|
||||
public class EnvironmentCommand extends MultiverseCommand {
|
||||
|
||||
public EnvironmentCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("List Environments");
|
||||
this.setCommandUsage("/mv env");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvenv");
|
||||
this.addKey("mv env");
|
||||
this.addKey("mv type");
|
||||
this.addKey("mv environment");
|
||||
this.addKey("mv environments");
|
||||
this.addCommandExample("/mv env");
|
||||
this.setPermission("multiverse.core.list.environments", "Lists valid known environments/world types.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows all valid known environments to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
public static void showEnvironments(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
|
||||
sender.sendMessage(ChatColor.GREEN + "NORMAL");
|
||||
sender.sendMessage(ChatColor.RED + "NETHER");
|
||||
sender.sendMessage(ChatColor.AQUA + "END");
|
||||
}
|
||||
/**
|
||||
* Shows all valid known world types to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
public static void showWorldTypes(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT, %sLARGEBIOMES %sor %sVERSION_1_1",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link String} into a {@link WorldType}.
|
||||
*
|
||||
* @param type The WorldType as a {@link String}
|
||||
* @return The WorldType as a {@link WorldType}
|
||||
*/
|
||||
public static WorldType getWorldTypeFromString(String type) {
|
||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||
if (type.equalsIgnoreCase("normal"))
|
||||
type = "NORMAL";
|
||||
if (type.equalsIgnoreCase("flat"))
|
||||
type = "FLAT";
|
||||
if (type.equalsIgnoreCase("largebiomes")) {
|
||||
type = "LARGE_BIOMES";
|
||||
}
|
||||
try {
|
||||
// Now that we've converted a potentially unfriendly value
|
||||
// to a friendly one, get it from the ENUM!
|
||||
return WorldType.valueOf(type);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link String} into an {@link org.bukkit.World.Environment}.
|
||||
*
|
||||
* @param env The environment as {@link String}
|
||||
* @return The environment as {@link org.bukkit.World.Environment}
|
||||
*/
|
||||
public static World.Environment getEnvFromString(String env) {
|
||||
env = env.toUpperCase();
|
||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
||||
env = "NETHER";
|
||||
|
||||
if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS"))
|
||||
env = "THE_END";
|
||||
|
||||
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
|
||||
env = "NORMAL";
|
||||
|
||||
try {
|
||||
// Now that we've converted a potentially unfriendly value
|
||||
// to a friendly one, get it from the ENUM!
|
||||
return World.Environment.valueOf(env);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Returns a list of loaded generator plugins.
|
||||
*/
|
||||
public class GeneratorCommand extends MultiverseCommand {
|
||||
|
||||
public GeneratorCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Information");
|
||||
this.setCommandUsage("/mv generators");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv generators");
|
||||
this.addKey("mvgenerators");
|
||||
this.addKey("mv gens");
|
||||
this.addKey("mvgens");
|
||||
this.addCommandExample("/mv generators");
|
||||
this.setPermission("multiverse.core.generator", "Returns a list of Loaded Generator Plugins.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
|
||||
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
|
||||
List<String> generators = new ArrayList<String>();
|
||||
for (Plugin p : plugins) {
|
||||
if (p.isEnabled() && p.getDefaultWorldGenerator("world", "") != null) {
|
||||
generators.add(p.getDescription().getName());
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---");
|
||||
String loadedGens = "";
|
||||
boolean altColor = false;
|
||||
for (String s : generators) {
|
||||
loadedGens += (altColor ? ChatColor.YELLOW : ChatColor.WHITE) + s + " ";
|
||||
altColor = !altColor;
|
||||
}
|
||||
if (loadedGens.length() == 0) {
|
||||
loadedGens = ChatColor.RED + "No Generator Plugins found.";
|
||||
}
|
||||
sender.sendMessage(loadedGens);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/******************************************************************************
|
||||
* 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.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays a nice help menu.
|
||||
*/
|
||||
public class HelpCommand extends PaginatedCoreCommand<Command> {
|
||||
|
||||
public HelpCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Get Help with Multiverse");
|
||||
this.setCommandUsage("/mv " + ChatColor.GOLD + "[FILTER] [PAGE #]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mv");
|
||||
this.addKey("mvh");
|
||||
this.addKey("mvhelp");
|
||||
this.addKey("mv help");
|
||||
this.addKey("mvsearch");
|
||||
this.addKey("mv search");
|
||||
this.addCommandExample("/mv help ?");
|
||||
this.setPermission("multiverse.help", "Displays a nice help menu.", PermissionDefault.TRUE);
|
||||
this.setItemsPerPage(7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Command> getFilteredItems(List<Command> availableItems, String filter) {
|
||||
List<Command> filtered = new ArrayList<Command>();
|
||||
|
||||
for (Command c : availableItems) {
|
||||
if (stitchThisString(c.getKeyStrings()).matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
} else if (c.getCommandName().matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
} else if (c.getCommandDesc().matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
} else if (c.getCommandUsage().matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
} else {
|
||||
for (String example : c.getCommandExamples()) {
|
||||
if (example.matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getItemText(Command item) {
|
||||
return ChatColor.AQUA + item.getCommandUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
sender.sendMessage(ChatColor.AQUA + "====[ Multiverse Help ]====");
|
||||
|
||||
FilterObject filterObject = this.getPageAndFilter(args);
|
||||
|
||||
List<Command> availableCommands = new ArrayList<Command>(this.plugin.getCommandHandler().getCommands(sender));
|
||||
if (filterObject.getFilter().length() > 0) {
|
||||
availableCommands = this.getFilteredItems(availableCommands, filterObject.getFilter());
|
||||
if (availableCommands.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
|
||||
+ "No commands matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.AQUA + " Add a '" + ChatColor.DARK_PURPLE + "?" + ChatColor.AQUA + "' after a command to see more about it.");
|
||||
for (Command c : availableCommands) {
|
||||
sender.sendMessage(ChatColor.AQUA + c.getCommandUsage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int totalPages = (int) Math.ceil(availableCommands.size() / (this.itemsPerPage + 0.0));
|
||||
|
||||
if (filterObject.getPage() > totalPages) {
|
||||
filterObject.setPage(totalPages);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
|
||||
sender.sendMessage(ChatColor.AQUA + " Add a '" + ChatColor.DARK_PURPLE + "?" + ChatColor.AQUA + "' after a command to see more about it.");
|
||||
|
||||
this.showPage(filterObject.getPage(), sender, availableCommands);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Imports a new world of the specified type.
|
||||
*/
|
||||
public class ImportCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ImportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Import World");
|
||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n]");
|
||||
this.setArgRange(1, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvimport");
|
||||
this.addKey("mvim");
|
||||
this.addKey("mv import");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "hell_world" + ChatColor.GREEN + " nether");
|
||||
this.addCommandExample("To import a world that uses a generator, you'll need the generator:");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " CleanRoomGenerator");
|
||||
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* A very basic check to see if a folder has a level.dat file.
|
||||
* If it does, we can safely assume it's a world folder.
|
||||
*
|
||||
* @param worldFolder The File that may be a world.
|
||||
* @return True if it looks like a world, false if not.
|
||||
*/
|
||||
private static boolean checkIfIsWorld(File worldFolder) {
|
||||
if (worldFolder.isDirectory()) {
|
||||
File[] files = worldFolder.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return name.equalsIgnoreCase("level.dat");
|
||||
}
|
||||
});
|
||||
if (files != null && files.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getPotentialWorlds() {
|
||||
File worldFolder = this.plugin.getServer().getWorldContainer();
|
||||
if (worldFolder == null) {
|
||||
return "";
|
||||
}
|
||||
File[] files = worldFolder.listFiles();
|
||||
String worldList = "";
|
||||
Collection<MultiverseWorld> worlds = this.worldManager.getMVWorlds();
|
||||
List<String> worldStrings = new ArrayList<String>();
|
||||
for (MultiverseWorld world : worlds) {
|
||||
worldStrings.add(world.getName());
|
||||
}
|
||||
for (String world : this.worldManager.getUnloadedWorlds()) {
|
||||
worldStrings.add(world);
|
||||
}
|
||||
ChatColor currColor = ChatColor.WHITE;
|
||||
for (File file : files) {
|
||||
if (file.isDirectory() && checkIfIsWorld(file) && !worldStrings.contains(file.getName())) {
|
||||
worldList += currColor + file.getName() + " ";
|
||||
if (currColor == ChatColor.WHITE) {
|
||||
currColor = ChatColor.YELLOW;
|
||||
} else {
|
||||
currColor = ChatColor.WHITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return worldList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
String worldName = args.get(0);
|
||||
|
||||
if (worldName.toLowerCase().equals("--list") || worldName.toLowerCase().equals("-l")) {
|
||||
String worldList = this.getPotentialWorlds();
|
||||
if (worldList.length() > 2) {
|
||||
sender.sendMessage(ChatColor.AQUA + "====[ These look like worlds ]====");
|
||||
sender.sendMessage(worldList);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No potential worlds found. Sorry!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Since we made an exception for the list, we have to make sure they have at least 2 params:
|
||||
// Note the exception is --list, which is covered above.
|
||||
if (args.size() == 1) {
|
||||
this.showHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we don't already know about this world.
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Multiverse" + ChatColor.WHITE
|
||||
+ " already knows about '" + ChatColor.AQUA + worldName + ChatColor.WHITE + "'!");
|
||||
return;
|
||||
}
|
||||
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase("-n")) {
|
||||
useSpawnAdjust = false;
|
||||
}
|
||||
}
|
||||
|
||||
String env = args.get(1);
|
||||
Environment environment = EnvironmentCommand.getEnvFromString(env);
|
||||
if (environment == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldFile.exists() && env != null) {
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
|
||||
if (this.worldManager.addWorld(worldName, environment, null, null, null, generator, useSpawnAdjust))
|
||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
|
||||
else
|
||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
|
||||
} else if (env == null) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
sender.sendMessage("That world environment did not exist.");
|
||||
sender.sendMessage("For a list of available world types, type: " + ChatColor.AQUA + "/mvenv");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
String worldList = this.getPotentialWorlds();
|
||||
sender.sendMessage("That world folder does not exist. These look like worlds to me:");
|
||||
sender.sendMessage(worldList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/******************************************************************************
|
||||
* 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.FancyText;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyHeader;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// Will use when we can compile with JDK 6
|
||||
//import com.sun.xml.internal.ws.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Returns detailed information about a world.
|
||||
*/
|
||||
public class InfoCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public InfoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Information");
|
||||
this.setCommandUsage("/mv info" + ChatColor.GOLD + " [WORLD] [PAGE]");
|
||||
this.setArgRange(0, 2);
|
||||
this.addKey("mvinfo");
|
||||
this.addKey("mvi");
|
||||
this.addKey("mv info");
|
||||
this.addCommandExample("/mv info " + ChatColor.GOLD + "1");
|
||||
this.addCommandExample("/mv info " + ChatColor.GOLD + "3");
|
||||
this.setPermission("multiverse.core.info", "Returns detailed information on the world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
String worldName = "";
|
||||
int pageNum = 0;
|
||||
|
||||
if (args.size() == 0) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
worldName = p.getWorld().getName();
|
||||
} else {
|
||||
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
|
||||
return;
|
||||
}
|
||||
} else if (args.size() == 1) {
|
||||
if (this.worldManager.isMVWorld(args.get(0))) {
|
||||
// then we have a world!
|
||||
worldName = args.get(0);
|
||||
} else if (this.worldManager.getUnloadedWorlds().contains(args.get(0))) {
|
||||
sender.sendMessage("That world exists, but it is unloaded!");
|
||||
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, args.get(0)));
|
||||
return;
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
worldName = p.getWorld().getName();
|
||||
try {
|
||||
pageNum = Integer.parseInt(args.get(0)) - 1;
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("That world does not exist.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (args.size() == 2) {
|
||||
worldName = args.get(0);
|
||||
try {
|
||||
pageNum = Integer.parseInt(args.get(1)) - 1;
|
||||
} catch (NumberFormatException e) {
|
||||
pageNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
|
||||
} else if (this.worldManager.getUnloadedWorlds().contains(worldName)) {
|
||||
sender.sendMessage("That world exists, but it is unloaded!");
|
||||
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, worldName));
|
||||
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
||||
sender.sendMessage("That world exists, but Multiverse does not know about it!");
|
||||
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
|
||||
}
|
||||
}
|
||||
|
||||
private List<List<FancyText>> buildEntireCommand(MultiverseWorld world, Player p) {
|
||||
List<FancyText> message = new ArrayList<FancyText>();
|
||||
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
|
||||
// Page 1
|
||||
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
|
||||
message.add(new FancyHeader("General Info", colors));
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
|
||||
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
|
||||
Location spawn = world.getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
|
||||
if (world.getPrice() > 0) {
|
||||
final String formattedAmount;
|
||||
if (world.getCurrency() <= 0 && plugin.getVaultEconomy() != null) {
|
||||
formattedAmount = plugin.getVaultEconomy().format(world.getPrice());
|
||||
} else {
|
||||
formattedAmount = this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency());
|
||||
}
|
||||
message.add(new FancyMessage("Price to enter this world: ", formattedAmount, colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
|
||||
}
|
||||
|
||||
if (world.getRespawnToWorld() != null) {
|
||||
MultiverseWorld respawn = this.worldManager.getMVWorld(world.getRespawnToWorld());
|
||||
if (respawn != null) {
|
||||
message.add(new FancyMessage("Players will respawn in: ", respawn.getColoredWorldString(), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Players will respawn in: ", ChatColor.RED + "!!INVALID!!", colors));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
worldInfo.add(message);
|
||||
// Page 2
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("More World Settings", colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
|
||||
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
|
||||
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
|
||||
message.add(new FancyHeader("PVP Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.isPVPEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
|
||||
worldInfo.add(message);
|
||||
// Page 3
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("Monster Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.canMonstersSpawn() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowMonsters() + "", colors));
|
||||
if (world.getMonsterList().size() > 0) {
|
||||
if (world.canMonstersSpawn()) {
|
||||
message.add(new FancyMessage("Monsters that" + ChatColor.RED + " CAN NOT "
|
||||
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getMonsterList()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Monsters that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getMonsterList()), colors));
|
||||
}
|
||||
} else {
|
||||
message.add(new FancyMessage("Monsters that CAN spawn: ", world.canMonstersSpawn() ? "ALL" : "NONE", colors));
|
||||
}
|
||||
worldInfo.add(message);
|
||||
|
||||
// Page 4
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("Animal Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.canAnimalsSpawn() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowAnimals() + "", colors));
|
||||
if (world.getMonsterList().size() > 0) {
|
||||
if (world.canMonstersSpawn()) {
|
||||
message.add(new FancyMessage("Animals that" + ChatColor.RED + " CAN NOT "
|
||||
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getAnimalList()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Animals that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getAnimalList()), colors));
|
||||
}
|
||||
} else {
|
||||
message.add(new FancyMessage("Animals that CAN spawn: ", world.canAnimalsSpawn() ? "ALL" : "NONE", colors));
|
||||
}
|
||||
worldInfo.add(message);
|
||||
|
||||
return worldInfo;
|
||||
}
|
||||
|
||||
private static String toCommaSeperated(List<String> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
}
|
||||
String result = list.get(0);
|
||||
|
||||
for (int i = 1; i < list.size() - 1; i++) {
|
||||
result += ", " + list.get(i);
|
||||
}
|
||||
result += " and " + list.get(list.size() - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a "positive" or "negative" {@link ChatColor}.
|
||||
*
|
||||
* @param positive Whether this {@link ChatColor} should be "positive".
|
||||
* @return The {@link ChatColor}.
|
||||
*/
|
||||
protected ChatColor getChatColor(boolean positive) {
|
||||
return positive ? ChatColor.GREEN : ChatColor.RED;
|
||||
}
|
||||
|
||||
private static void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
|
||||
page = page < 0 ? 0 : page;
|
||||
page = page > doc.size() - 1 ? doc.size() - 1 : page;
|
||||
boolean altColor = false;
|
||||
boolean appendedPageNum = false;
|
||||
if (sender instanceof Player) {
|
||||
List<FancyText> list = doc.get(page);
|
||||
for (FancyText fancyT : list) {
|
||||
if (fancyT instanceof FancyMessage) {
|
||||
FancyMessage text = (FancyMessage) fancyT;
|
||||
text.setAltColor(altColor);
|
||||
altColor = !altColor;
|
||||
sender.sendMessage(text.getFancyText());
|
||||
} else if (fancyT instanceof FancyHeader) {
|
||||
FancyHeader text = (FancyHeader) fancyT;
|
||||
if (!appendedPageNum) {
|
||||
text.appendText(ChatColor.DARK_PURPLE + " [ Page " + (page + 1) + " of " + doc.size() + " ]");
|
||||
appendedPageNum = true;
|
||||
}
|
||||
sender.sendMessage(text.getFancyText());
|
||||
altColor = false;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for (List<FancyText> list : doc) {
|
||||
for (FancyText fancyT : list) {
|
||||
if (fancyT instanceof FancyMessage) {
|
||||
FancyMessage text = (FancyMessage) fancyT;
|
||||
text.setAltColor(altColor);
|
||||
altColor = !altColor;
|
||||
sender.sendMessage(text.getFancyText());
|
||||
} else {
|
||||
FancyText text = fancyT;
|
||||
if (appendedPageNum) {
|
||||
sender.sendMessage(" ");
|
||||
} else {
|
||||
appendedPageNum = true;
|
||||
}
|
||||
sender.sendMessage(text.getFancyText());
|
||||
altColor = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays a listing of all worlds that a player can enter.
|
||||
*/
|
||||
public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
|
||||
public ListCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Listing");
|
||||
this.setCommandUsage("/mv list");
|
||||
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);
|
||||
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
private List<String> getFancyWorldList(Player p) {
|
||||
List<String> worldList = new ArrayList<String>();
|
||||
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
|
||||
|
||||
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ChatColor color = ChatColor.GOLD;
|
||||
Environment env = world.getEnvironment();
|
||||
if (env == Environment.NETHER) {
|
||||
color = ChatColor.RED;
|
||||
} else if (env == Environment.NORMAL) {
|
||||
color = ChatColor.GREEN;
|
||||
} else if (env == Environment.THE_END) {
|
||||
color = ChatColor.AQUA;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(world.getColoredWorldString()).append(ChatColor.WHITE);
|
||||
builder.append(" - ").append(color).append(world.getEnvironment());
|
||||
if (world.isHidden()) {
|
||||
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) {
|
||||
// Prefix hidden worlds with an "[H]"
|
||||
worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
|
||||
}
|
||||
} else {
|
||||
worldList.add(builder.toString());
|
||||
}
|
||||
}
|
||||
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
||||
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
|
||||
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
|
||||
}
|
||||
}
|
||||
return worldList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
|
||||
List<String> filtered = new ArrayList<String>();
|
||||
|
||||
for (String s : availableItems) {
|
||||
if (s.matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(s);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getItemText(String item) {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse World List ]====");
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
|
||||
FilterObject filterObject = this.getPageAndFilter(args);
|
||||
|
||||
List<String> availableWorlds = new ArrayList<String>(this.getFancyWorldList(p));
|
||||
if (filterObject.getFilter().length() > 0) {
|
||||
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
|
||||
if (availableWorlds.size() == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
|
||||
+ "No worlds matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
for (String c : availableWorlds) {
|
||||
sender.sendMessage(c);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int totalPages = (int) Math.ceil(availableWorlds.size() / (this.itemsPerPage + 0.0));
|
||||
|
||||
if (filterObject.getPage() > totalPages) {
|
||||
filterObject.setPage(totalPages);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
|
||||
|
||||
this.showPage(filterObject.getPage(), sender, availableWorlds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Loads a world into Multiverse.
|
||||
*/
|
||||
public class LoadCommand extends MultiverseCommand {
|
||||
|
||||
public LoadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Load World");
|
||||
this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvload");
|
||||
this.addKey("mv load");
|
||||
this.addCommandExample("/mv load " + ChatColor.GREEN + "MyUnloadedWorld");
|
||||
this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) {
|
||||
Command.broadcastCommandMessage(sender, "Loaded world '" + args.get(0) + "'!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to load world '" + args.get(0) + "'!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// This will contain all the properties that support the ADD/REMOVE
|
||||
// Anything not in here will only support the SET action
|
||||
|
||||
/**
|
||||
* Used to modify various aspects of worlds.
|
||||
*/
|
||||
public class ModifyAddCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifyAddCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Modify a World (Add a value)");
|
||||
this.setCommandUsage("/mv modify " + ChatColor.GREEN + "add {VALUE} {PROPERTY}" + ChatColor.GOLD + " [WORLD] ");
|
||||
this.setArgRange(2, 3);
|
||||
this.addKey("mvm add");
|
||||
this.addKey("mvmadd");
|
||||
this.addKey("mv modify add");
|
||||
this.addKey("mvmodify add");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
|
||||
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// We NEED a world from the command line
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
if (args.size() == 2 && p == null) {
|
||||
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
|
||||
sender.sendMessage(this.getCommandDesc());
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
sender.sendMessage("Nothing changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld world;
|
||||
String value = args.get(0);
|
||||
String property = args.get(1);
|
||||
|
||||
if (args.size() == 2) {
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.worldManager.getMVWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage("That world does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ModifyCommand.validateAction(Action.Add, property)) {
|
||||
sender.sendMessage("Sorry, you can't ADD to " + property);
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO fix this
|
||||
if (world.addToVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA
|
||||
+ value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(value + " could not be added to " + property);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Removes all values from a world-property.
|
||||
*/
|
||||
public class ModifyClearCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifyClearCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Modify a World (Clear a property)");
|
||||
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " clear {PROPERTY}" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvm clear");
|
||||
this.addKey("mvmclear");
|
||||
this.addKey("mv modify clear");
|
||||
this.addKey("mvmodify clear");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.clear",
|
||||
"Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// We NEED a world from the command line
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
if (args.size() == 1 && p == null) {
|
||||
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
|
||||
sender.sendMessage(this.getCommandDesc());
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
sender.sendMessage("Nothing changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld world;
|
||||
String property = args.get(0);
|
||||
|
||||
if (args.size() == 1) {
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.worldManager.getMVWorld(args.get(1));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage("That world does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ModifyCommand.validateAction(Action.Clear, property)) {
|
||||
sender.sendMessage("Sorry, you can't use CLEAR with " + property);
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
|
||||
return;
|
||||
}
|
||||
// TODO fix this
|
||||
if (world.clearList(property)) {
|
||||
sender.sendMessage(property + " was cleared. It contains 0 values now.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was "
|
||||
+ ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property
|
||||
+ ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/******************************************************************************
|
||||
* 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.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.enums.AddProperties;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Used to modify various aspects of worlds.
|
||||
*/
|
||||
public class ModifyCommand extends MultiverseCommand {
|
||||
|
||||
public ModifyCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Modify a World");
|
||||
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " {set|add|remove|clear} ...");
|
||||
this.setArgRange(2, 3);
|
||||
this.addKey("mvm");
|
||||
this.addKey("mvmodify");
|
||||
this.addKey("mv modify");
|
||||
Map<String, Boolean> children = new HashMap<String, Boolean>();
|
||||
children.put("multiverse.core.modify.add", true);
|
||||
children.put("multiverse.core.modify.modify", true);
|
||||
children.put("multiverse.core.modify.clear", true);
|
||||
children.put("multiverse.core.modify.remove", true);
|
||||
Permission modify = new Permission("multiverse.core.modify",
|
||||
"Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children);
|
||||
this.addCommandExample(ChatColor.AQUA + "/mv modify set ?");
|
||||
this.addCommandExample(ChatColor.GREEN + "/mv modify add ?");
|
||||
this.addCommandExample(ChatColor.BLUE + "/mv modify clear ?");
|
||||
this.addCommandExample(ChatColor.RED + "/mv modify remove ?");
|
||||
this.setPermission(modify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the specified action.
|
||||
*
|
||||
* @param action The {@link Action}.
|
||||
* @param property The property.
|
||||
* @return Whether this action is valid.
|
||||
*/
|
||||
protected static boolean validateAction(Action action, String property) {
|
||||
if (action != Action.Set) {
|
||||
try {
|
||||
AddProperties.valueOf(property);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// This is just a place holder. The real commands are in:
|
||||
// ModifyAddCommand
|
||||
// ModifyRemoveCommand
|
||||
// ModifySetCommand
|
||||
// ModifyClearCommand
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Removes values from a world-property.
|
||||
*/
|
||||
public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifyRemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Modify a World (Remove a value)");
|
||||
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " remove {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(2, 3);
|
||||
this.addKey("mvm remove");
|
||||
this.addKey("mvmremove");
|
||||
this.addKey("mv modify remove");
|
||||
this.addKey("mvmodify remove");
|
||||
this.addKey("mvm delete");
|
||||
this.addKey("mvmdelete");
|
||||
this.addKey("mv modify delete");
|
||||
this.addKey("mvmodify delete");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
|
||||
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// We NEED a world from the command line
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
if (args.size() == 2 && p == null) {
|
||||
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
|
||||
sender.sendMessage(this.getCommandDesc());
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
sender.sendMessage("Nothing changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld world;
|
||||
String value = args.get(0);
|
||||
String property = args.get(1);
|
||||
|
||||
if (args.size() == 2) {
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.worldManager.getMVWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage("That world does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ModifyCommand.validateAction(Action.Remove, property)) {
|
||||
sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||
return;
|
||||
}
|
||||
// TODO fix this
|
||||
if (world.removeFromVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE
|
||||
+ " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY
|
||||
+ value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Used to set world-properties.
|
||||
*/
|
||||
public class ModifySetCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifySetCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
this.setName("Modify a World (Set a value)");
|
||||
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(1, 3);
|
||||
this.addKey("mvm set");
|
||||
this.addKey("mvmset");
|
||||
this.addKey("mv modify set");
|
||||
this.addKey("mvmodify set");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "mode " + ChatColor.RED + "creative");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "animals " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "monsters " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "alias " + ChatColor.RED + "MyWorld");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "color " + ChatColor.RED + "green");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "curr " + ChatColor.RED + "3");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "price " + ChatColor.RED + "5");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "scale " + ChatColor.RED + "1.2");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "memory " + ChatColor.RED + "true");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "diff " + ChatColor.RED + "hard");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hunger " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hidden " + ChatColor.RED + "true");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "pvp " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "heal " + ChatColor.RED + "true");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "adjustspawn " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "spawn");
|
||||
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
|
||||
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Special case for spawn:
|
||||
if (args.size() == 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You must be a player to set the" + ChatColor.GREEN + " spawn");
|
||||
return;
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("spawn")) {
|
||||
SetSpawnCommand c = new SetSpawnCommand(this.plugin);
|
||||
c.setWorldSpawn(sender);
|
||||
|
||||
} else {
|
||||
sender.sendMessage("Spawn is the only param with no" + ChatColor.GREEN + " VALUE");
|
||||
sender.sendMessage("Type " + ChatColor.GREEN + "/mv modify ?" + ChatColor.WHITE + " For help.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// We NEED a world from the command line
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
if (args.size() == 2 && p == null) {
|
||||
sender.sendMessage("From the command line, WORLD is required.");
|
||||
sender.sendMessage(this.getCommandDesc());
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
sender.sendMessage("Nothing changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld world;
|
||||
String value = args.get(1);
|
||||
String property = args.get(0);
|
||||
|
||||
if (args.size() == 2) {
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.worldManager.getMVWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage("That world does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !EnglishChatColor.isValidAliasColor(value)) {
|
||||
sender.sendMessage(value + " is not a valid color. Please pick one of the following:");
|
||||
sender.sendMessage(EnglishChatColor.getAllColors());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (world.setPropertyValue(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + world.getPropertyHelp(property));
|
||||
}
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
|
||||
sender.sendMessage("Valid world-properties: " + world.getAllPropertyNames());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.commands;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/******************************************************************************
|
||||
* 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.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A generic paginated command.
|
||||
* @param <T> The type of items on the page.
|
||||
*/
|
||||
public abstract class PaginatedCommand<T> extends Command {
|
||||
private static final int DEFAULT_ITEMS_PER_PAGE = 9;
|
||||
/**
|
||||
* The number of items per page.
|
||||
*/
|
||||
protected int itemsPerPage = DEFAULT_ITEMS_PER_PAGE;
|
||||
|
||||
public PaginatedCommand(JavaPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of items per page.
|
||||
*
|
||||
* @param items The new number of items per page.
|
||||
*/
|
||||
protected void setItemsPerPage(int items) {
|
||||
itemsPerPage = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets filtered items.
|
||||
* @param availableItems All available items.
|
||||
* @param filter The filter-{@link String}.
|
||||
* @return A list of items that match the filter.
|
||||
*/
|
||||
protected abstract List<T> getFilteredItems(List<T> availableItems, String filter);
|
||||
|
||||
/**
|
||||
* Constructs a single string from a list of strings.
|
||||
*
|
||||
* @param list The {@link List} of strings.
|
||||
* @return A single {@link String}.
|
||||
*/
|
||||
protected String stitchThisString(List<String> list) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String s : list) {
|
||||
builder.append(s);
|
||||
builder.append(' ');
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a page.
|
||||
*
|
||||
* @param page The number of the page to show.
|
||||
* @param sender The {@link CommandSender} that wants to see the page.
|
||||
* @param cmds The items that should be displayed on the page.
|
||||
*/
|
||||
protected void showPage(int page, CommandSender sender, List<T> cmds) {
|
||||
// Ensure the page is at least 1.
|
||||
page = (page <= 0) ? 1 : page;
|
||||
int start = (page - 1) * itemsPerPage;
|
||||
int end = start + itemsPerPage;
|
||||
|
||||
for (int i = start; i < end; i++) {
|
||||
// For consistancy, print some extra lines if it's a player:
|
||||
if (i < cmds.size()) {
|
||||
sender.sendMessage(this.getItemText(cmds.get(i)));
|
||||
} else if (sender instanceof Player) {
|
||||
sender.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an item into a string.
|
||||
*
|
||||
* @param item The item.
|
||||
* @return A {@link String}.
|
||||
*/
|
||||
protected abstract String getItemText(T item);
|
||||
|
||||
/**
|
||||
* Constructs a {@link FilterObject} from a {@link List} of arguments.
|
||||
*
|
||||
* @param args The {@link List} of arguments.
|
||||
* @return The {@link FilterObject}.
|
||||
*/
|
||||
protected FilterObject getPageAndFilter(List<String> args) {
|
||||
int page = 1;
|
||||
|
||||
String filter = "";
|
||||
|
||||
if (args.size() == 0) {
|
||||
filter = "";
|
||||
page = 1;
|
||||
} else if (args.size() == 1) {
|
||||
try {
|
||||
page = Integer.parseInt(args.get(0));
|
||||
} catch (NumberFormatException ex) {
|
||||
filter = args.get(0);
|
||||
page = 1;
|
||||
}
|
||||
} else if (args.size() == 2) {
|
||||
filter = args.get(0);
|
||||
try {
|
||||
page = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ex) {
|
||||
page = 1;
|
||||
}
|
||||
}
|
||||
return new FilterObject(page, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Key-Object" containing information about the page and the filter that were requested.
|
||||
*/
|
||||
protected class FilterObject {
|
||||
private Integer page;
|
||||
private String filter;
|
||||
|
||||
public FilterObject(Integer page, String filter) {
|
||||
this.page = page;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page.
|
||||
* @return The page.
|
||||
*/
|
||||
public Integer getPage() {
|
||||
return this.page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the page.
|
||||
*
|
||||
* @param page The new page.
|
||||
*/
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filter.
|
||||
* @return The filter.
|
||||
*/
|
||||
public String getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/******************************************************************************
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A generic paginated Multiverse-command.
|
||||
* @param <T> The type of items on the page.
|
||||
*/
|
||||
public abstract class PaginatedCoreCommand<T> extends PaginatedCommand<T> {
|
||||
/**
|
||||
* The reference to the core.
|
||||
*/
|
||||
protected MultiverseCore plugin;
|
||||
|
||||
public PaginatedCoreCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Removes a type of mob from a world.
|
||||
*/
|
||||
public class PurgeCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public PurgeCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Purge World of Creatures");
|
||||
this.setCommandUsage("/mv purge" + ChatColor.GOLD + " [WORLD|all] " + ChatColor.GREEN + "{all|animals|monsters|MOBNAME}");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvpurge");
|
||||
this.addKey("mv purge");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GREEN + "all");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "all");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GREEN + "monsters");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "animals");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld " + ChatColor.GREEN + "squid");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld_nether " + ChatColor.GREEN + "ghast");
|
||||
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
if (args.size() == 1 && p == null) {
|
||||
sender.sendMessage("This command requires a WORLD when being run from the console!");
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
return;
|
||||
}
|
||||
String worldName = null;
|
||||
String deathName = null;
|
||||
if (args.size() == 1) {
|
||||
worldName = p.getWorld().getName();
|
||||
deathName = args.get(0);
|
||||
} else {
|
||||
worldName = args.get(0);
|
||||
deathName = args.get(1);
|
||||
}
|
||||
|
||||
if (!worldName.equalsIgnoreCase("all") && !this.worldManager.isMVWorld(worldName)) {
|
||||
this.plugin.showNotMVWorldMessage(sender, worldName);
|
||||
sender.sendMessage("It cannot be purged.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<MultiverseWorld> worldsToRemoveEntitiesFrom = new ArrayList<MultiverseWorld>();
|
||||
// Handle all case any user who names a world "all" should know better...
|
||||
if (worldName.equalsIgnoreCase("all")) {
|
||||
worldsToRemoveEntitiesFrom.addAll(this.worldManager.getMVWorlds());
|
||||
} else {
|
||||
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
|
||||
}
|
||||
|
||||
WorldPurger purger = this.worldManager.getTheWorldPurger();
|
||||
ArrayList<String> thingsToKill = new ArrayList<String>();
|
||||
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
|
||||
thingsToKill.add(deathName.toUpperCase());
|
||||
} else {
|
||||
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
|
||||
}
|
||||
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
|
||||
purger.purgeWorld(w, thingsToKill, false, false, sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Regenerates a world.
|
||||
*/
|
||||
public class RegenCommand extends MultiverseCommand {
|
||||
|
||||
public RegenCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Regenerates a World");
|
||||
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]]");
|
||||
this.setArgRange(1, 3);
|
||||
this.addKey("mvregen");
|
||||
this.addKey("mv regen");
|
||||
this.addCommandExample("You can use the -s with no args to get a new seed:");
|
||||
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s");
|
||||
this.addCommandExample("or specifiy a seed to get that one:");
|
||||
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s" + ChatColor.AQUA + " gargamel");
|
||||
this.setPermission("multiverse.core.regen", "Regenerates a world on your server. The previous state will be lost "
|
||||
+ ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Boolean useseed = (!(args.size() == 1));
|
||||
Boolean randomseed = (args.size() == 2 && args.get(1).equalsIgnoreCase("-s"));
|
||||
String seed = (args.size() == 3) ? args.get(2) : "";
|
||||
|
||||
Class<?>[] paramTypes = {String.class, Boolean.class, Boolean.class, String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>();
|
||||
objectArgs.add(args.get(0));
|
||||
objectArgs.add(useseed);
|
||||
objectArgs.add(randomseed);
|
||||
objectArgs.add(seed);
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvregen", "regenWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World Regenerated!", ChatColor.RED + "World could NOT be regenerated!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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 com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Reloads worlds.yml and config.yml.
|
||||
*/
|
||||
public class ReloadCommand extends MultiverseCommand {
|
||||
|
||||
public ReloadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Reload Configs");
|
||||
this.setCommandUsage("/mv reload");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvreload");
|
||||
this.addKey("mv reload");
|
||||
this.addCommandExample("/mv reload");
|
||||
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
|
||||
this.plugin.loadConfigs();
|
||||
this.plugin.getAnchorManager().loadAnchors();
|
||||
this.plugin.getMVWorldManager().loadWorlds(true);
|
||||
|
||||
List<String> configsLoaded = new ArrayList<String>();
|
||||
configsLoaded.add("Multiverse-Core - config.yml");
|
||||
configsLoaded.add("Multiverse-Core - worlds.yml");
|
||||
configsLoaded.add("Multiverse-Core - anchors.yml");
|
||||
// Create the event
|
||||
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
|
||||
// Fire it off
|
||||
this.plugin.getServer().getPluginManager().callEvent(configReload);
|
||||
for (String s : configReload.getAllConfigsLoaded()) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Reload Complete!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Unloads a world and removes it from the config.
|
||||
*/
|
||||
public class RemoveCommand extends MultiverseCommand {
|
||||
|
||||
public RemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Remove World");
|
||||
this.setCommandUsage("/mv remove" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvremove");
|
||||
this.addKey("mv remove");
|
||||
this.addCommandExample("/mv remove " + ChatColor.GREEN + "MyWorld");
|
||||
this.setPermission("multiverse.core.remove",
|
||||
"Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (this.plugin.getMVWorldManager().removeWorldFromConfig(args.get(0))) {
|
||||
sender.sendMessage("World removed from config!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to remove world from config!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* States who is in what world.
|
||||
*/
|
||||
public class ScriptCommand extends MultiverseCommand {
|
||||
|
||||
public ScriptCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Runs a script.");
|
||||
this.setCommandUsage("/mv script" + ChatColor.GOLD + " {script} [target]");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mv script");
|
||||
this.addKey("mvscript");
|
||||
this.addCommandExample(String.format("/mv script %sscript.txt", ChatColor.GOLD));
|
||||
this.addCommandExample(String.format("/mv script %stest.txt %ssomeplayer", ChatColor.GOLD, ChatColor.GREEN));
|
||||
this.setPermission("multiverse.core.script", "Runs a script.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
File file = new File(plugin.getScriptAPI().getScriptFolder(), args.get(0));
|
||||
if (!file.exists()) {
|
||||
sender.sendMessage("That script file does not exist in the Multiverse-Core scripts directory!");
|
||||
return;
|
||||
}
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
String target = null;
|
||||
if (args.size() == 2) {
|
||||
target = args.get(1);
|
||||
}
|
||||
plugin.getScriptAPI().executeScript(file, target, player);
|
||||
sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/******************************************************************************
|
||||
* 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.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sets the spawn for a world.
|
||||
*/
|
||||
public class SetSpawnCommand extends MultiverseCommand {
|
||||
public SetSpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Set World Spawn");
|
||||
this.setCommandUsage("/mv setspawn");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvsetspawn");
|
||||
this.addKey("mvss");
|
||||
this.addKey("mv set spawn");
|
||||
this.addKey("mv setspawn");
|
||||
this.addKey("mvset spawn");
|
||||
this.addCommandExample("/mv set spawn");
|
||||
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
setWorldSpawn(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual spawn-setting-work.
|
||||
*
|
||||
* @param sender The {@link CommandSender} that's setting the spawn.
|
||||
*/
|
||||
protected void setWorldSpawn(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
Location l = p.getLocation();
|
||||
World w = p.getWorld();
|
||||
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
|
||||
if (foundWorld != null) {
|
||||
foundWorld.setSpawnLocation(p.getLocation());
|
||||
BlockSafety bs = this.plugin.getBlockSafety();
|
||||
if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) {
|
||||
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
|
||||
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
|
||||
sender.sendMessage("If you want this turned back on just do:");
|
||||
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
|
||||
foundWorld.setAdjustSpawn(false);
|
||||
}
|
||||
sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
} else {
|
||||
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage("You cannot use this command from the console.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Takes the player to the latest bed he's slept in.
|
||||
*/
|
||||
public class SleepCommand extends MultiverseCommand {
|
||||
|
||||
public SleepCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Go to Sleep");
|
||||
this.setCommandUsage("/mv sleep");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv sleep");
|
||||
this.setPermission("multiverse.core.sleep", "Takes you the latest bed you've slept in (Currently BROKEN).", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Teleports a player to the spawn.
|
||||
*/
|
||||
public class SpawnCommand extends MultiverseCommand {
|
||||
|
||||
public SpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
Permission otherPerm = new Permission("multiverse.core.spawn.other",
|
||||
"Teleports another player to the spawn of the world they are in.", PermissionDefault.OP);
|
||||
this.setName("Spawn");
|
||||
this.setCommandUsage("/mv spawn" + ChatColor.GOLD + " [PLAYER]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mvspawn");
|
||||
this.addKey("mv spawn");
|
||||
this.addKey("mvs");
|
||||
this.setPermission("multiverse.core.spawn.self", "Teleports you to the Spawn Point of the world you are in.", PermissionDefault.OP);
|
||||
this.addAdditonalPermission(otherPerm);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
// If a persons name was passed in, you must be A. the console, or B have permissions
|
||||
if (args.size() == 1) {
|
||||
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.other", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.core.spawn.other)");
|
||||
return;
|
||||
}
|
||||
Player target = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (target != null) {
|
||||
target.sendMessage("Teleporting to this world's spawn...");
|
||||
spawnAccurately(target);
|
||||
|
||||
if (player != null) {
|
||||
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
|
||||
} else {
|
||||
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(args.get(0) + " is not logged on right now!");
|
||||
}
|
||||
} else {
|
||||
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.self", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.core.spawn.self)");
|
||||
return;
|
||||
}
|
||||
if (player != null) {
|
||||
player.sendMessage("Teleporting to this world's spawn...");
|
||||
spawnAccurately(player);
|
||||
} else {
|
||||
sender.sendMessage("From the console, you must provide a PLAYER.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnAccurately(Player player) {
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName());
|
||||
Location spawnLocation;
|
||||
if (world != null) {
|
||||
spawnLocation = world.getSpawnLocation();
|
||||
} else {
|
||||
spawnLocation = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false);
|
||||
}
|
||||
}
|
||||
@@ -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.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.PopupScreen;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Edit a world with spout.
|
||||
* /
|
||||
public class SpoutCommand extends MultiverseCommand {
|
||||
|
||||
public SpoutCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Edit World with Spout");
|
||||
this.setCommandUsage("/mv spout");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv spout");
|
||||
this.setPermission("multiverse.core.spout", "Edit a world with spout.", PermissionDefault.OP);
|
||||
this.addCommandExample("/mv spout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command must be run as a player!");
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpout() == null) {
|
||||
sender.sendMessage(ChatColor.RED + "You need spout installed on this server to use it with Multiverse!");
|
||||
return;
|
||||
}
|
||||
SpoutPlayer p = (SpoutPlayer) sender;
|
||||
if (!p.isSpoutCraftEnabled()) {
|
||||
sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!");
|
||||
return;
|
||||
}
|
||||
PopupScreen pop = new GenericPopup();
|
||||
GenericButton button = new GenericButton("Fish");
|
||||
// TO-DO maybe use constants for these
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
button.setX(50);
|
||||
button.setY(50);
|
||||
button.setWidth(100);
|
||||
button.setHeight(40);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
pop.attachWidget(this.plugin, button);
|
||||
sender.sendMessage(ChatColor.GREEN + "YAY!");
|
||||
p.getMainScreen().attachPopupScreen(pop);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,203 @@
|
||||
/******************************************************************************
|
||||
* 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.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Used to teleport players.
|
||||
*/
|
||||
public class TeleportCommand extends MultiverseCommand {
|
||||
private SafeTTeleporter playerTeleporter;
|
||||
|
||||
public TeleportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
|
||||
|
||||
this.setName("Teleport");
|
||||
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvtp");
|
||||
this.addKey("mv tp");
|
||||
this.playerTeleporter = this.plugin.getSafeTTeleporter();
|
||||
this.setPermission(menu);
|
||||
}
|
||||
|
||||
private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 15;
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
CommandSender teleporter = sender;
|
||||
Player teleportee = null;
|
||||
|
||||
String destinationName;
|
||||
|
||||
if (args.size() == 2) {
|
||||
teleportee = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (teleportee == null) {
|
||||
this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s",
|
||||
ChatColor.GOLD, args.get(0)), false);
|
||||
return;
|
||||
}
|
||||
destinationName = args.get(1);
|
||||
|
||||
} else {
|
||||
destinationName = args.get(0);
|
||||
if (!(sender instanceof Player)) {
|
||||
this.messaging.sendMessage(sender, String.format("From the console, you must specify a player to teleport"), false);
|
||||
return;
|
||||
}
|
||||
teleportee = (Player) sender;
|
||||
}
|
||||
// Special case for cannons:
|
||||
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
|
||||
String[] cannonSpeed = destinationName.split("-");
|
||||
try {
|
||||
double speed = Double.parseDouble(cannonSpeed[1]);
|
||||
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX()
|
||||
+ "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":"
|
||||
+ teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
|
||||
} catch (Exception e) {
|
||||
destinationName = "i:invalid";
|
||||
}
|
||||
|
||||
}
|
||||
DestinationFactory df = this.plugin.getDestFactory();
|
||||
MVDestination d = df.getDestination(destinationName);
|
||||
|
||||
|
||||
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
|
||||
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
|
||||
if (teleportEvent.isCancelled()) {
|
||||
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (d != null && d instanceof InvalidDestination) {
|
||||
this.messaging.sendMessage(sender, String.format("Multiverse does not know how to take you to %s%s",
|
||||
ChatColor.RED, destinationName), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||
} else {
|
||||
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD
|
||||
+ teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
|
||||
}
|
||||
return;
|
||||
} else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...",
|
||||
ChatColor.GREEN, d.toString(), ChatColor.WHITE), false);
|
||||
} else {
|
||||
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
|
||||
ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED), false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Special check to verify if players are tryint to teleport to the same
|
||||
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
|
||||
|
||||
if (d instanceof WorldDestination) {
|
||||
World w = d.getLocation(teleportee).getWorld();
|
||||
if (teleportee.getWorld().equals(w)) {
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
|
||||
this.messaging.sendMessages(teleporter, new String[]{
|
||||
String.format("Sorry you don't have permission to go to the world spawn!"),
|
||||
String.format("%s (multiverse.core.spawn.self)",
|
||||
ChatColor.RED) }, false);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
|
||||
this.messaging.sendMessages(teleporter, new String[]{
|
||||
String.format("Sorry you don't have permission to send %s to the world spawn!",
|
||||
teleportee.getDisplayName()),
|
||||
String.format("%s (multiverse.core.spawn.other)",
|
||||
ChatColor.RED) }, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (d.getLocation(teleportee) == null) {
|
||||
this.messaging.sendMessage(teleporter, "Sorry Boss, I tried everything, but just couldn't teleport ya there!", false);
|
||||
return;
|
||||
}
|
||||
TeleportResult result = this.playerTeleporter.safelyTeleport(teleporter, teleportee, d);
|
||||
if (result == TeleportResult.FAIL_UNSAFE) {
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName()
|
||||
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
|
||||
this.plugin.log(Level.FINE, "Queueing Command");
|
||||
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
|
||||
List<Object> items = new ArrayList<Object>();
|
||||
items.add(teleporter);
|
||||
items.add(teleportee);
|
||||
items.add(d.getLocation(teleportee));
|
||||
String player = "you";
|
||||
if (!teleportee.equals(teleporter)) {
|
||||
player = teleportee.getName();
|
||||
}
|
||||
String message = String.format("%sMultiverse %sdid not teleport %s%s%sto %s%s%sbecause it was unsafe.",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
|
||||
paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
|
||||
}
|
||||
// else: Player was teleported successfully (or the tp event was fired I should say)
|
||||
}
|
||||
|
||||
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
|
||||
this.messaging.sendMessages(teleporter, new String[]{
|
||||
String.format("%sYou don't have permission to teleport %syourself %sto a %s%s %sDestination",
|
||||
ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, destination.getType(), ChatColor.WHITE),
|
||||
String.format("%s (multiverse.teleport.self.%s)",
|
||||
ChatColor.RED, destination.getIdentifier()) }, false);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
|
||||
this.messaging.sendMessages(teleporter, new String[]{
|
||||
String.format("You don't have permission to teleport another player to a %s%s Destination.",
|
||||
ChatColor.GREEN, destination.getType()),
|
||||
String.format("%s(multiverse.teleport.other.%s)",
|
||||
ChatColor.RED, destination.getIdentifier()) }, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/******************************************************************************
|
||||
* 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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Unloads worlds from Multiverse.
|
||||
*/
|
||||
public class UnloadCommand extends MultiverseCommand {
|
||||
|
||||
public UnloadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Unload World");
|
||||
this.setCommandUsage("/mv unload" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvunload");
|
||||
this.addKey("mv unload");
|
||||
this.setPermission("multiverse.core.unload",
|
||||
"Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (this.plugin.getMVWorldManager().unloadWorld(args.get(0))) {
|
||||
Command.broadcastCommandMessage(sender, "Unloaded world '" + args.get(0) + "'!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to unload world '" + args.get(0) + "'!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/******************************************************************************
|
||||
* 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.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.BitlyURLShortener;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteFailedException;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteService;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortener;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Dumps version info to the console.
|
||||
*/
|
||||
public class VersionCommand extends MultiverseCommand {
|
||||
private static final URLShortener SHORTENER = new BitlyURLShortener();
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Multiverse Version");
|
||||
this.setCommandUsage("/mv version " + ChatColor.GOLD + "-[pb]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv version");
|
||||
this.addKey("mvv");
|
||||
this.addKey("mvversion");
|
||||
this.setPermission("multiverse.core.version",
|
||||
"Dumps version info to the console, optionally to pastie.org with -p or pastebin.com with a -b.", PermissionDefault.TRUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(final CommandSender sender, final List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage("Version info dumped to console. Please check your server logs.");
|
||||
}
|
||||
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("[Multiverse-Core] Multiverse-Core Version: ").append(this.plugin.getDescription().getVersion()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n');
|
||||
final boolean usingVault = this.plugin.getVaultEconomy() != null;
|
||||
buffer.append("[Multiverse-Core] Using Vault: ").append(usingVault).append('\n');
|
||||
if (usingVault) {
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getVaultEconomy().getName()).append('\n');
|
||||
} else {
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
||||
}
|
||||
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
|
||||
.append(this.plugin.getMVConfig().getVersion()).append(")").append('\n');
|
||||
buffer.append("[Multiverse-Core] messagecooldown: ").append(plugin.getMessaging().getCooldown()).append('\n');
|
||||
buffer.append("[Multiverse-Core] teleportcooldown: ").append(plugin.getMVConfig().getTeleportCooldown()).append('\n');
|
||||
buffer.append("[Multiverse-Core] worldnameprefix: ").append(plugin.getMVConfig().getPrefixChat()).append('\n');
|
||||
buffer.append("[Multiverse-Core] enforceaccess: ").append(plugin.getMVConfig().getEnforceAccess()).append('\n');
|
||||
buffer.append("[Multiverse-Core] displaypermerrors: ").append(plugin.getMVConfig().getDisplayPermErrors()).append('\n');
|
||||
buffer.append("[Multiverse-Core] teleportintercept: ").append(plugin.getMVConfig().getTeleportIntercept()).append('\n');
|
||||
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(plugin.getMVConfig().getFirstSpawnOverride()).append('\n');
|
||||
buffer.append("[Multiverse-Core] firstspawnworld: ").append(plugin.getMVConfig().getFirstSpawnWorld()).append('\n');
|
||||
buffer.append("[Multiverse-Core] debug: ").append(plugin.getMVConfig().getGlobalDebug()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
||||
|
||||
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
|
||||
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
|
||||
|
||||
// log to console
|
||||
final String data = versionEvent.getVersionInfo();
|
||||
String[] lines = data.split("\n");
|
||||
for (String line : lines) {
|
||||
this.plugin.log(Level.INFO, line);
|
||||
}
|
||||
|
||||
this.plugin.getServer().getScheduler().scheduleAsyncDelayedTask(this.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.size() == 1) {
|
||||
String pasteUrl;
|
||||
if (args.get(0).equalsIgnoreCase("-p")) {
|
||||
pasteUrl = postToService(PasteServiceType.PASTIE, true, data); // private post to pastie
|
||||
} else if (args.get(0).equalsIgnoreCase("-b")) {
|
||||
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, data); // private post to pastie
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
|
||||
plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the current contents of this.pasteBinBuffer to a web service.
|
||||
*
|
||||
* @param type Service type to send to
|
||||
* @param isPrivate Should the paste be marked as private.
|
||||
* @return URL of visible paste
|
||||
*/
|
||||
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData) {
|
||||
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
|
||||
try {
|
||||
return SHORTENER.shorten(ps.postData(ps.encodeData(pasteData), ps.getPostURL()));
|
||||
} catch (PasteFailedException e) {
|
||||
System.out.print(e);
|
||||
return "Error posting to service";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/******************************************************************************
|
||||
* 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.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* States who is in what world.
|
||||
*/
|
||||
public class WhoCommand extends MultiverseCommand {
|
||||
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Who?");
|
||||
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [WORLD|--all]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv who");
|
||||
this.addKey("mvw");
|
||||
this.addKey("mvwho");
|
||||
this.addCommandExample("/mv who");
|
||||
this.addCommandExample(String.format("/mv who %s--all", ChatColor.GREEN));
|
||||
this.addCommandExample(String.format("/mv who %smyworld", ChatColor.GOLD));
|
||||
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// If this command was sent from a Player then we need to check Permissions
|
||||
Player p = null;
|
||||
// By default, show all from the console
|
||||
boolean showAll = true;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
showAll = false;
|
||||
}
|
||||
|
||||
final Player[] onlinePlayers = plugin.getServer().getOnlinePlayers();
|
||||
final Collection<Player> visiblePlayers = new HashSet<Player>(onlinePlayers.length);
|
||||
for (final Player player : onlinePlayers) {
|
||||
if (p == null || p.canSee(player)) {
|
||||
visiblePlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
|
||||
showAll = true;
|
||||
} else {
|
||||
// single world mode
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
|
||||
if (world == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That world does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().canEnterWorld(p, world)) {
|
||||
sender.sendMessage(ChatColor.RED + "You aren't allowed to access to this world!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%s--- Players in %s%s ---", ChatColor.AQUA,
|
||||
world.getColoredWorldString(), ChatColor.AQUA));
|
||||
sender.sendMessage(this.buildPlayerString(world, p, visiblePlayers));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// multiworld mode
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Worlds and their players --- "
|
||||
+ visiblePlayers.size() + "/" + plugin.getServer().getMaxPlayers());
|
||||
boolean shownOne = false;
|
||||
for (MultiverseWorld world : this.worldManager.getMVWorlds()) {
|
||||
if (this.plugin.getMVPerms().canEnterWorld(p, world)) { // only show world if the player can access it
|
||||
if (showAll || !world.getCBWorld().getPlayers().isEmpty()) { // either show all or show if the world is not empty
|
||||
sender.sendMessage(String.format("%s%s - %s", world.getColoredWorldString(), ChatColor.WHITE, buildPlayerString(world, p, visiblePlayers)));
|
||||
shownOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!shownOne) {
|
||||
sender.sendMessage("No worlds found.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private static String buildPlayerString(MultiverseWorld world, Player viewer, final Collection<Player> visiblePlayers) {
|
||||
// Retrieve the players in this world
|
||||
List<Player> players = world.getCBWorld().getPlayers();
|
||||
StringBuilder playerBuilder = new StringBuilder();
|
||||
for (Player player : players) {
|
||||
// If the viewer is the console or the viewier is allowed to see the player, show them.
|
||||
// Make sure we're also ONLY showing online players.
|
||||
// Since we already checked visible players, we'll just make sure who we're about to show is in that.
|
||||
if (visiblePlayers.contains(player))
|
||||
playerBuilder.append(player.getDisplayName()).append(", ");
|
||||
}
|
||||
String bString = playerBuilder.toString();
|
||||
return (bString.length() == 0) ? "No players found." : bString.substring(0, bString.length() - 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This package contains all Commands.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* Entryfee-settings.
|
||||
*/
|
||||
@SerializableAs("MVEntryFee")
|
||||
public class EntryFee extends SerializationConfig {
|
||||
@Property
|
||||
private double amount;
|
||||
@Property
|
||||
private int currency;
|
||||
|
||||
public EntryFee() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EntryFee(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
amount = 0D;
|
||||
currency = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the currency
|
||||
*/
|
||||
public int getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount.
|
||||
* @param amount The new value.
|
||||
*/
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currency.
|
||||
* @param currency The new value.
|
||||
*/
|
||||
public void setCurrency(int currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
|
||||
* 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.configuration;
|
||||
|
||||
/**
|
||||
* An "active" {@link MVConfigProperty} that uses the specified method to be "actually" set.
|
||||
* @param <T> The type of the config-property.
|
||||
* @deprecated This is deprecated.
|
||||
* @see MVConfigProperty
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MVActiveConfigProperty<T> extends MVConfigProperty<T> {
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
*
|
||||
* @return The name of the method in MVWorld to be called.
|
||||
*/
|
||||
String getMethod();
|
||||
|
||||
/**
|
||||
* Sets the method that will be executed.
|
||||
*
|
||||
* @param methodName The name of the method in MVWorld to be called.
|
||||
*/
|
||||
void setMethod(String methodName);
|
||||
|
||||
/**
|
||||
* Returns the class of the object we're looking at.
|
||||
* @return the class of the object we're looking at.
|
||||
*/
|
||||
Class<?> getPropertyClass();
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/******************************************************************************
|
||||
* 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.configuration;
|
||||
|
||||
/**
|
||||
* A generic config-property.
|
||||
*
|
||||
* @param <T> The type of the config-property.
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MVConfigProperty<T> {
|
||||
/**
|
||||
* Gets the name of this property.
|
||||
*
|
||||
* @return The name of this property.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the value of this property.
|
||||
*
|
||||
* @return The value of this property.
|
||||
*/
|
||||
T getValue();
|
||||
|
||||
/**
|
||||
* Gets the string representation of this value.
|
||||
*
|
||||
* @return The value of this property as a string.
|
||||
*/
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Gets the help string for this.
|
||||
*
|
||||
* @return The value of this property as a string.
|
||||
*/
|
||||
String getHelp();
|
||||
|
||||
/**
|
||||
* Sets the value of this property.
|
||||
*
|
||||
* @param value The T representation of this value.
|
||||
* @return True the value was successfully set.
|
||||
*/
|
||||
boolean setValue(T value);
|
||||
|
||||
/**
|
||||
* This parseValue should be used with strings.
|
||||
*
|
||||
* @param value The string representation of the value to set.
|
||||
*
|
||||
* @return True if the value was set, false if not.
|
||||
*/
|
||||
boolean parseValue(String value);
|
||||
|
||||
/**
|
||||
* Gets the name of the config-node that this {@link MVConfigProperty} is saved as.
|
||||
*
|
||||
* @return The name of the config-node that this {@link MVConfigProperty} is saved as.
|
||||
*/
|
||||
String getConfigNode();
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Just like a regular {@link Location}, however {@code world} is usually {@code null}
|
||||
* or just a weak reference and it implements {@link ConfigurationSerializable}.
|
||||
*/
|
||||
@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(double x, double y, double z, float yaw, float pitch) {
|
||||
super(null, 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> serialized = new HashMap<String, Object>(5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
serialized.put("x", this.getX());
|
||||
serialized.put("y", this.getY());
|
||||
serialized.put("z", this.getZ());
|
||||
serialized.put("pitch", this.getPitch());
|
||||
serialized.put("yaw", this.getYaw());
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let Bukkit be able to deserialize this.
|
||||
* @param args The map.
|
||||
* @return The deserialized object.
|
||||
*/
|
||||
public static SpawnLocation deserialize(Map<String, Object> args) {
|
||||
double x = ((Number) args.get("x")).doubleValue();
|
||||
double y = ((Number) args.get("y")).doubleValue();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* Spawning-Settings.
|
||||
*/
|
||||
@SerializableAs("MVSpawnSettings")
|
||||
public class SpawnSettings extends SerializationConfig {
|
||||
@Property
|
||||
private SubSpawnSettings animals;
|
||||
@Property
|
||||
private SubSpawnSettings monsters;
|
||||
|
||||
public SpawnSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SpawnSettings(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
animals = new SubSpawnSettings();
|
||||
monsters = new SubSpawnSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the animal-settings
|
||||
*/
|
||||
public SubSpawnSettings getAnimalSettings() {
|
||||
return animals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the monster-settings
|
||||
*/
|
||||
public SubSpawnSettings getMonsterSettings() {
|
||||
return monsters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* SpawnSubSettings.
|
||||
*/
|
||||
@SerializableAs("MVSpawnSubSettings")
|
||||
public class SubSpawnSettings extends SerializationConfig {
|
||||
@Property
|
||||
private boolean spawn;
|
||||
@Property
|
||||
private List<String> exceptions;
|
||||
|
||||
public SubSpawnSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SubSpawnSettings(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
spawn = true;
|
||||
exceptions = new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return spawn
|
||||
*/
|
||||
public boolean doSpawn() {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param spawn The new value.
|
||||
*/
|
||||
public void setSpawn(boolean spawn) {
|
||||
this.spawn = spawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the exceptions
|
||||
*/
|
||||
public List<String> getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
|
||||
|
||||
import me.main__.util.SerializationConfig.ChangeDeniedException;
|
||||
import me.main__.util.SerializationConfig.ObjectUsingValidator;
|
||||
|
||||
/**
|
||||
* Validates world-property-changes.
|
||||
* @param <T> The type of the property that should be validated.
|
||||
*/
|
||||
public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, MVWorld> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException {
|
||||
MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
throw new ChangeDeniedException();
|
||||
return event.getTheNewValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This package contains the Multiverse-configuration.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
@@ -0,0 +1,148 @@
|
||||
/******************************************************************************
|
||||
* 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.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An anchor-{@link MVDestination}.
|
||||
*/
|
||||
public class AnchorDestination implements MVDestination {
|
||||
private boolean isValid;
|
||||
private Location location;
|
||||
private MultiverseCore plugin;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "a";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return false;
|
||||
}
|
||||
this.plugin = (MultiverseCore) plugin;
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
// Need at least: a:name
|
||||
if (!(parsed.size() == 2)) {
|
||||
return false;
|
||||
}
|
||||
// If it's not an Anchor type
|
||||
return parsed.get(0).equalsIgnoreCase("a");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return;
|
||||
}
|
||||
this.plugin = (MultiverseCore) plugin;
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
// Need at least: e:world:x,y,z
|
||||
// OR e:world:x,y,z:pitch:yaw
|
||||
// so basically 3 or 5
|
||||
if (!(parsed.size() == 2)) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
this.name = parsed.get(1);
|
||||
this.location = this.plugin.getAnchorManager().getAnchorLocation(parsed.get(1));
|
||||
if (this.location == null) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
|
||||
this.isValid = false;
|
||||
}
|
||||
this.isValid = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return "Anchor";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Anchor: " + this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isValid) {
|
||||
return "a:" + this.name;
|
||||
}
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
// This is an ANCHOR destination, don't safely teleport here.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/******************************************************************************
|
||||
* 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.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* A bed-{@link MVDestination}.
|
||||
*/
|
||||
public class BedDestination implements MVDestination {
|
||||
|
||||
private boolean isValid;
|
||||
private Location knownBedLoc;
|
||||
private MultiverseCore plugin;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "b";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] split = destination.split(":");
|
||||
this.isValid = split.length >= 1 && split.length <= 2 && split[0].equals(this.getIdentifier());
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
this.knownBedLoc = this.plugin.getBlockSafety().getSafeBedSpawn(((Player) entity).getBedSpawnLocation());
|
||||
if (this.knownBedLoc == null) {
|
||||
((Player) entity).sendMessage("Your bed was " + ChatColor.RED + "invalid or blocked" + ChatColor.RESET + ". Sorry.");
|
||||
}
|
||||
return this.knownBedLoc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return new Vector();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
this.plugin = (MultiverseCore) plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return "Bed";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Bed";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
if (knownBedLoc != null) {
|
||||
return "multiverse.access." + knownBedLoc.getWorld().getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
// Bukkit should have already checked this.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "b:playerbed";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
/******************************************************************************
|
||||
* 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.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A cannon-{@link MVDestination}.
|
||||
*/
|
||||
public class CannonDestination implements MVDestination {
|
||||
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
|
||||
private boolean isValid;
|
||||
private Location location;
|
||||
private double speed;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
double pitchRadians = Math.toRadians(location.getPitch());
|
||||
double yawRadians = Math.toRadians(location.getYaw());
|
||||
double x = Math.sin(yawRadians) * speed * -1;
|
||||
double y = Math.sin(pitchRadians) * speed * -1;
|
||||
double z = Math.cos(yawRadians) * speed;
|
||||
// Account for the angle they were pointed, and take away velocity
|
||||
x = Math.cos(pitchRadians) * x;
|
||||
z = Math.cos(pitchRadians) * z;
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "ca";
|
||||
}
|
||||
|
||||
// NEED ca:world:x,y,z:pitch:yaw:speed
|
||||
// so basically 6
|
||||
private static final int SPLIT_SIZE = 6;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return false;
|
||||
}
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
if (parsed.size() != SPLIT_SIZE) {
|
||||
return false;
|
||||
}
|
||||
// If it's not an Cannon type
|
||||
if (!parsed.get(0).equalsIgnoreCase("ca")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it's not a MV world
|
||||
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
|
||||
return false;
|
||||
}
|
||||
// Verify X,Y,Z are numbers
|
||||
if (!parsed.get(2).matches(coordRegex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
Float.parseFloat(parsed.get(3));
|
||||
Float.parseFloat(parsed.get(4));
|
||||
Float.parseFloat(parsed.get(5));
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return;
|
||||
}
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
|
||||
if (parsed.size() != SPLIT_SIZE) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.location = new Location(((MultiverseCore) plugin).getMVWorldManager().getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
|
||||
if (!parsed.get(2).matches(this.coordRegex)) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
double[] coords = new double[3];
|
||||
String[] coordString = parsed.get(2).split(",");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
coords[i] = Double.parseDouble(coordString[i]);
|
||||
} catch (NumberFormatException e) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.location.setX(coords[0]);
|
||||
this.location.setY(coords[1]);
|
||||
this.location.setZ(coords[2]);
|
||||
|
||||
try {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
this.location.setPitch(Float.parseFloat(parsed.get(3)));
|
||||
this.location.setYaw(Float.parseFloat(parsed.get(4)));
|
||||
this.speed = Math.abs(Float.parseFloat(parsed.get(5)));
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
} catch (NumberFormatException e) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.isValid = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return "Cannon!";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Cannon (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ":"
|
||||
+ this.location.getPitch() + ":" + this.location.getYaw() + ":" + this.speed + ")";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this {@link CannonDestination}.
|
||||
*
|
||||
* @param location The {@link Location}.
|
||||
* @param speed The speed.
|
||||
*/
|
||||
public void setDestination(Location location, double speed) {
|
||||
if (location != null) {
|
||||
this.location = location;
|
||||
this.speed = Math.abs(speed);
|
||||
this.isValid = true;
|
||||
}
|
||||
this.isValid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isValid) {
|
||||
return "ca:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY()
|
||||
+ "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw() + ":" + this.speed;
|
||||
}
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/******************************************************************************
|
||||
* 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.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** A factory class that will create destinations from specific strings. */
|
||||
public class DestinationFactory {
|
||||
private MultiverseCore plugin;
|
||||
private Map<String, Class<? extends MVDestination>> destList;
|
||||
private Command teleportCommand;
|
||||
|
||||
public DestinationFactory(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.destList = new HashMap<String, Class<? extends MVDestination>>();
|
||||
List<Command> cmds = this.plugin.getCommandHandler().getAllCommands();
|
||||
for (Command c : cmds) {
|
||||
if (c instanceof TeleportCommand) {
|
||||
this.teleportCommand = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a new destination from a string.
|
||||
* Returns a new InvalidDestination if the string could not be parsed.
|
||||
*
|
||||
* @param destination The destination in string format.
|
||||
*
|
||||
* @return A non-null MVDestination
|
||||
*/
|
||||
public MVDestination getDestination(String destination) {
|
||||
String idenChar = "";
|
||||
if (destination.split(":").length > 1) {
|
||||
idenChar = destination.split(":")[0];
|
||||
}
|
||||
|
||||
if (this.destList.containsKey(idenChar)) {
|
||||
Class<? extends MVDestination> myClass = this.destList.get(idenChar);
|
||||
try {
|
||||
MVDestination mydest = myClass.newInstance();
|
||||
if (!mydest.isThisType(this.plugin, destination)) {
|
||||
return new InvalidDestination();
|
||||
}
|
||||
mydest.setDestination(this.plugin, destination);
|
||||
return mydest;
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
return new InvalidDestination();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link MVDestination}.
|
||||
*
|
||||
* @param c The {@link Class} of the {@link MVDestination} to register.
|
||||
* @param identifier The {@link String}-identifier.
|
||||
* @return True if the class was successfully registered.
|
||||
*/
|
||||
public boolean registerDestinationType(Class<? extends MVDestination> c, String identifier) {
|
||||
if (this.destList.containsKey(identifier)) {
|
||||
return false;
|
||||
}
|
||||
this.destList.put(identifier, c);
|
||||
// Special case for world defaults:
|
||||
if (identifier.equals("")) {
|
||||
identifier = "w";
|
||||
}
|
||||
Permission self = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.self." + identifier);
|
||||
Permission other = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.other." + identifier);
|
||||
PermissionTools pt = new PermissionTools(this.plugin);
|
||||
if (self == null) {
|
||||
self = new Permission("multiverse.teleport.self." + identifier,
|
||||
"Permission to teleport yourself for the " + identifier + " destination.", PermissionDefault.OP);
|
||||
this.plugin.getServer().getPluginManager().addPermission(self);
|
||||
pt.addToParentPerms("multiverse.teleport.self." + identifier);
|
||||
}
|
||||
if (other == null) {
|
||||
other = new Permission("multiverse.teleport.other." + identifier,
|
||||
"Permission to teleport others for the " + identifier + " destination.", PermissionDefault.OP);
|
||||
this.plugin.getServer().getPluginManager().addPermission(other);
|
||||
pt.addToParentPerms("multiverse.teleport.other." + identifier);
|
||||
}
|
||||
this.teleportCommand.addAdditonalPermission(self);
|
||||
this.teleportCommand.addAdditonalPermission(other);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 563 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user