Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74b04070ab | ||
|
|
1c1245a711 | ||
|
|
ddcd325c21 | ||
|
|
198abf55ea | ||
|
|
139ddd1bb2 | ||
|
|
c10cd5c45a | ||
|
|
7d80b89b02 | ||
|
|
e25e12737a | ||
|
|
e80d3909e0 | ||
|
|
85aa931ae3 | ||
|
|
b7baeb4d3e | ||
|
|
8f4f89b804 | ||
|
|
a478fac019 | ||
|
|
1f87175716 | ||
|
|
650f2022b9 | ||
|
|
51c642b71c | ||
|
|
77faf2bddc | ||
|
|
826fe08cfc | ||
|
|
7a86227a94 | ||
|
|
a6d4e21b85 | ||
|
|
55cf19b1d8 | ||
|
|
2fc6f3dc26 | ||
|
|
8f250011b7 | ||
|
|
b8a0729715 | ||
|
|
40b260feb5 | ||
|
|
b3b8a5ed73 | ||
|
|
03d1b3682d | ||
|
|
2c9d2d0fe7 | ||
|
|
2c98fc7d90 | ||
|
|
035f3644ad | ||
|
|
e1bcff732f | ||
|
|
4a90a6a1c7 | ||
|
|
4a4a2505e7 | ||
|
|
e2bf1a2bbe | ||
|
|
835ca69b78 | ||
|
|
2eb4ce6807 | ||
|
|
197764622c | ||
|
|
cde7ab961f | ||
|
|
0f23deeca1 | ||
|
|
6b7089eec0 | ||
|
|
e90f1bb986 | ||
|
|
16878f002a | ||
|
|
8ec08fd26a | ||
|
|
c9cf25c4e3 | ||
|
|
bfffc8c94e | ||
|
|
6e7328a407 | ||
|
|
617b0b5900 | ||
|
|
e7bcdbe64b | ||
|
|
cdfe317517 | ||
|
|
6987208241 | ||
|
|
e1dc90b65d | ||
|
|
fd10eec765 | ||
|
|
54a2e270a8 | ||
|
|
73d1035f84 | ||
|
|
c874a98bac | ||
|
|
b73a4e552f | ||
|
|
cd5a4c69f9 | ||
|
|
9dd9444248 | ||
|
|
942555f380 | ||
|
|
21d775d8a2 | ||
|
|
fd5e9485e9 | ||
|
|
ebe420be15 | ||
|
|
7b3e6ee07d | ||
|
|
808c4ce704 | ||
|
|
04802f2fda | ||
|
|
1ffa1ece2d | ||
|
|
95cce25453 | ||
|
|
d0c280506c | ||
|
|
3b9f1849d7 | ||
|
|
b3517ad9ce | ||
|
|
d0f6434592 | ||
|
|
36e0d34695 | ||
|
|
6771bb6c44 | ||
|
|
3962f23691 | ||
|
|
ef073b0403 | ||
|
|
c8432b9b57 | ||
|
|
3f8e514f51 | ||
|
|
942f8a99ab | ||
|
|
81f6014e94 | ||
|
|
fee822a2fe | ||
|
|
161478f05a | ||
|
|
e9ec1275fe | ||
|
|
fc6415af8c | ||
|
|
e88828f420 | ||
|
|
22afd094b2 | ||
|
|
8f99d2c560 | ||
|
|
6b47164726 | ||
|
|
455b04ce8c | ||
|
|
cf05044b13 | ||
|
|
44cbdc3baf | ||
|
|
114400e77b | ||
|
|
ff5498313b | ||
|
|
7198a5a421 | ||
|
|
793bbe3858 | ||
|
|
90937d6322 | ||
|
|
8c18caf30b | ||
|
|
39e4b5c528 | ||
|
|
ee2e7d3a70 | ||
|
|
5efcda37a5 | ||
|
|
17d5313981 | ||
|
|
31494e2876 | ||
|
|
8304e7a4ef | ||
|
|
2dedffa353 | ||
|
|
3e1d3e776b | ||
|
|
538cdb1a69 | ||
|
|
611af12ba6 | ||
|
|
b5b9e19cff | ||
|
|
20b492fa3c | ||
|
|
e4a6e8a9ec | ||
|
|
b0cbd5b840 | ||
|
|
4b45779cd1 | ||
|
|
cee6f68439 | ||
|
|
b953f1a011 | ||
|
|
29dcef5330 | ||
|
|
b0c4d72828 | ||
|
|
10c1040ead | ||
|
|
b6a784dc1b | ||
|
|
5fad1e0623 | ||
|
|
052194ca64 | ||
|
|
dcadf23677 | ||
|
|
0c61dfff3a | ||
|
|
026dd2f444 | ||
|
|
305cf50c9c | ||
|
|
8292af84b9 | ||
|
|
904e29ed1b | ||
|
|
a76c61301e | ||
|
|
a05d4581f6 | ||
|
|
a783f773b3 | ||
|
|
620203fbb7 | ||
|
|
56b881dcda | ||
|
|
408a66c4b1 | ||
|
|
5f37bb629b | ||
|
|
a7921a9074 | ||
|
|
f99d083347 | ||
|
|
096bcde439 | ||
|
|
b6fbcf9e40 | ||
|
|
ff5f9e0691 | ||
|
|
65c332f93d | ||
|
|
94c8189d2e | ||
|
|
a66e804f05 | ||
|
|
8e00ba11ac | ||
|
|
3ca9de69f0 | ||
|
|
1302a1efb8 | ||
|
|
013c39fd53 | ||
|
|
4720bfe308 | ||
|
|
45e7db7abd | ||
|
|
14fc5c85a7 | ||
|
|
42f0965eca | ||
|
|
532469145d | ||
|
|
c0b36fefd8 | ||
|
|
c6baeea5f9 | ||
|
|
dce2cf5601 | ||
|
|
52c210f755 | ||
|
|
23241572df | ||
|
|
fbe0138fa2 | ||
|
|
4b4474b1a9 | ||
|
|
28304baa6e | ||
|
|
7b2a14c31f | ||
|
|
da6d6d64c2 | ||
|
|
bb92aa57a8 | ||
|
|
5709278722 | ||
|
|
e4f043216e | ||
|
|
3809f47a54 | ||
|
|
0641099055 | ||
|
|
1b65a91de4 | ||
|
|
ad40caecef | ||
|
|
e518ea4e47 | ||
|
|
519e449a54 | ||
|
|
23ed7cb6ed | ||
|
|
391ba7b4fa | ||
|
|
5413b92ce2 | ||
|
|
a77ad6d7ab | ||
|
|
7493ce5dd8 | ||
|
|
07bfa44ecc | ||
|
|
c8d1aa467d | ||
|
|
d494017186 | ||
|
|
5483988276 | ||
|
|
6f12290a01 | ||
|
|
df3c9574aa | ||
|
|
9cda6556c9 | ||
|
|
1cda2a18a5 | ||
|
|
15810c9404 | ||
|
|
d8ff083418 | ||
|
|
f41337f8a8 |
No files matched your search
@@ -1,77 +0,0 @@
|
||||
name: 🐛 Report a Bug
|
||||
description: Report a problem with Multiverse-Core.
|
||||
title: "[Bug]: "
|
||||
labels: ["Bug: Unconfirmed"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
If you are having issues with other submodules of Multiverse, please go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
|
||||
|
||||
Not sure if this is a bug with Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
|
||||
|
||||
When completing the report, please ensure all fields are filled with the correct details requested. Failure to do so will result in your issue being closed.
|
||||
- type: input
|
||||
id: mutliverse-version-info
|
||||
attributes:
|
||||
label: '`/mv version -p` output'
|
||||
description: Run `/mv version -p` in the console, then copy and paste the link from the output of the command into this box.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: server-logs
|
||||
attributes:
|
||||
label: Server logs
|
||||
description: >
|
||||
Include full startup log and console error (if any). upload all relevant logs to either https://paste.gg
|
||||
or https://gist.github.com, save and the paste the link in this box.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: server-version
|
||||
attributes:
|
||||
label: Server Version
|
||||
description: Output of `/version` command.
|
||||
placeholder: server version info
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Bug Description
|
||||
description: Describe in detail what the bug is about. Include the expected behaviour and actual behaviour.
|
||||
placeholder: "Example: When running `/mv` it cause the server to crash..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce-steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Provide detailed intructions to trigger the bug.
|
||||
placeholder: |
|
||||
Example:
|
||||
1. Start a server with only multiverse installed.
|
||||
2. Run `/mv` command.
|
||||
3. Players all get kicked with a "server closed" message.
|
||||
...
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: agreements
|
||||
attributes:
|
||||
label: Agreements
|
||||
description: Ensure you have done the following being submitting this issue.
|
||||
options:
|
||||
- label: I have searched for and ensured there isn't already an open or resolved issue(s) regarding this.
|
||||
required: true
|
||||
- label: >
|
||||
I was able to reproduce my issue on a freshly setup and up-to-date server with the latest
|
||||
version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
|
||||
required: true
|
||||
@@ -1,5 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 Multiverse Discord Server
|
||||
- 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
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
name: ❓ Help!
|
||||
about: Encountered a problem with Multiverse-Core? Not sure how to fix it?
|
||||
title: ''
|
||||
labels: 'Type: Assistance'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Multiverse-Core help guide
|
||||
|
||||
Don't write inside the arrows as they will be hidden when you post your issue.
|
||||
|
||||
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
|
||||
|
||||
If you need help other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
|
||||
|
||||
Or come join our Discord server to get help sooner: https://discord.gg/NZtfKky
|
||||
|
||||
If you're happy to wait (or you were sent here from Discord), read on:
|
||||
|
||||
1. Check the Usage and FAQ pages to see if it answers your queries:
|
||||
https://github.com/Multiverse/Multiverse-Core/wiki/Basics
|
||||
https://github.com/Multiverse/Multiverse-Core/wiki/FAQ
|
||||
|
||||
2. Fill out the template.
|
||||
This will help us understand what problem you've encountered and help us
|
||||
find a solution.
|
||||
|
||||
3. When linking files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/ or other similar service.
|
||||
|
||||
4. Delete this line and all above lines before posting your issue! -->
|
||||
|
||||
### Information
|
||||
|
||||
* **Server version:** <!-- Insert output of `/version` command -->
|
||||
|
||||
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
|
||||
|
||||
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
|
||||
|
||||
### Help request
|
||||
|
||||
**Problem**
|
||||
<!-- What problem did you encounter? -->
|
||||
|
||||
**What I have tried**
|
||||
<!-- What have you tried so far? -->
|
||||
|
||||
**Screenshots**
|
||||
<!-- If relevant, include any screenshots here. -->
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
name: 🐛 Report a Bug
|
||||
about: Report a Multiverse-Core bug. Only use this if you're 100% sure it's something wrong with Multiverse-Core - otherwise, try "Help!".
|
||||
title: ''
|
||||
labels: 'Bug: Unconfirmed'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Multiverse-Core bug reporting guide
|
||||
|
||||
Don't put anything inside this block, as it won't be included in the issue.
|
||||
|
||||
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
|
||||
|
||||
If you are having issues with other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
|
||||
|
||||
If you are reporting a bug, please follow the following steps:
|
||||
|
||||
1. Fill out the template in full.
|
||||
Run the commands in the console. Don't just put "latest" as a version,
|
||||
or we will ignore it.
|
||||
|
||||
2. When linking files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/, then paste a
|
||||
link to them in the relevant parts of the template.
|
||||
**DO NOT drag files into this box!**
|
||||
|
||||
3. Make sure not to write between the arrows, as anything there will be
|
||||
hidden.
|
||||
|
||||
4. Delete this line and all above lines before posting your issue! -->
|
||||
|
||||
### Information
|
||||
|
||||
* **Server version:** <!-- Insert output of `/version` command -->
|
||||
|
||||
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
|
||||
|
||||
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
|
||||
|
||||
### Details
|
||||
I was **`<able / not 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.
|
||||
|
||||
**Description**
|
||||
<!-- Replace this with a brief summary of the bug. -->
|
||||
|
||||
**Steps to reproduce**
|
||||
<!-- Replace this with exactly what you did to cause the bug. -->
|
||||
|
||||
**Expected behavior**
|
||||
<!-- Replace this with what you expected to happen. -->
|
||||
|
||||
**Screenshots**
|
||||
<!-- Replace this with screenshots, if necessary. -->
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
name: 💡 Request a Feature
|
||||
about: Suggest a feature you want to see in Multiverse-Core!
|
||||
title: ''
|
||||
labels: 'Type: Idea'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Multiverse-Core feature request guide
|
||||
|
||||
Fill out the template. Don't write inside the arrows as they will be hidden
|
||||
when you post your issue.
|
||||
|
||||
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
|
||||
|
||||
If you are look for other submodules of Multiverse, go to their respective git repo:
|
||||
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
|
||||
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
|
||||
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
|
||||
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
|
||||
|
||||
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord
|
||||
server: https://discord.gg/NZtfKky
|
||||
|
||||
If you have a feature suggestion for Multiverse-Core, read the following tips:
|
||||
|
||||
1. Fill out the template.
|
||||
This will help us understand what you're requesting and why you want us
|
||||
to add it.
|
||||
|
||||
2. Keep it simple.
|
||||
Make sure it's easy to understand what you're requesting. A good way is
|
||||
to keep it to one request per GitHub issue, as we can then easily track
|
||||
feature requests.
|
||||
|
||||
3. Check whether it has already been asked or added.
|
||||
You can search the issue tracker to see if your feature has already been
|
||||
requested at https://github.com/Multiverse/Multiverse-Core/issues.
|
||||
|
||||
4. Ask yourself: "Does this belong in Multiverse-Core?"
|
||||
There are lots of features that we reject because most servers won't
|
||||
need or use them. If your feature is very specific or already exists in
|
||||
another plugin, it might not be a good fit for Multiverse-Core.
|
||||
|
||||
5. Delete this line and all above lines before posting your issue! -->
|
||||
|
||||
### Feature request
|
||||
|
||||
**Feature description**
|
||||
<!-- What feature are you suggesting? -->
|
||||
|
||||
**How the feature is useful**
|
||||
<!-- How is the feature useful to players, server owners and/or developers? -->
|
||||
@@ -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,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,91 +0,0 @@
|
||||
name: 'Generic: GitHub Release'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
# Plugin specific
|
||||
plugin_name:
|
||||
description: 'Plugin name'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
# Common params
|
||||
release_mode:
|
||||
description: 'Release mode'
|
||||
required: true
|
||||
type: string
|
||||
version_bump:
|
||||
description: 'Version bump'
|
||||
required: false
|
||||
type: string
|
||||
promote_from:
|
||||
description: 'Promote from'
|
||||
required: false
|
||||
type: string
|
||||
outputs:
|
||||
release_created:
|
||||
description: 'Release created'
|
||||
value: ${{ jobs.github_release.outputs.release_created }}
|
||||
tag_name:
|
||||
description: 'Tag name'
|
||||
value: ${{ jobs.github_release.outputs.tag_name }}
|
||||
|
||||
jobs:
|
||||
github_release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_created: ${{ steps.release.outputs.release_created }}
|
||||
tag_name: ${{ steps.release.outputs.tag_name }}
|
||||
steps:
|
||||
- name: Echo inputs
|
||||
run: |
|
||||
echo "release_mode: ${{ inputs.release_mode }}"
|
||||
echo "version_bump: ${{ inputs.version_bump }}"
|
||||
echo "promote_from: ${{ inputs.promote_from }}"
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.promote_from }}
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Build and test
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: clean build -x assemble -x shadowJar
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create release
|
||||
id: release
|
||||
uses: benwoo1110/semantic-release-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
release_mode: ${{ inputs.release_mode }}
|
||||
version_bump: ${{ inputs.version_bump }}
|
||||
promote_from: ${{ inputs.promote_from }}
|
||||
|
||||
- name: Publish package
|
||||
if: steps.release.outputs.release_created == 'true'
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: publish -x test
|
||||
env:
|
||||
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload release artifact
|
||||
if: steps.release.outputs.release_created == 'true'
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/libs/${{ inputs.plugin_name }}-${{ steps.release.outputs.publish_version }}.jar
|
||||
asset_name: ${{ inputs.plugin_name }}-${{ steps.release.outputs.tag_name }}.jar
|
||||
tag: ${{ steps.release.outputs.tag_name }}
|
||||
@@ -1,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.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13
|
||||
version_type: ${{ steps.parse-release-type.outputs.release_type }}
|
||||
loaders: bukkit, spigot, paper
|
||||
dependencies: ${{ inputs.modrinth_dependencies }}
|
||||
|
||||
- name: Upload to DBO
|
||||
if: ${{ !cancelled() && inputs.upload_dbo == 'true' }}
|
||||
uses: benwoo1110/dbo-upload-action@v1
|
||||
with:
|
||||
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
|
||||
project_id: ${{ inputs.dbo_project_id }}
|
||||
changelog: ${{ steps.release-artifact.outputs.body }}
|
||||
changelog_type: markdown
|
||||
display_name: ${{ steps.release-info.outputs.tag_name }}
|
||||
game_versions: 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17, 1.16, 1.15, 1.14, 1.13
|
||||
release_type: ${{ steps.parse-release-type.outputs.release_type }}
|
||||
project_relations: ${{ inputs.dbo_project_relations }}
|
||||
file_path: ${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar
|
||||
|
||||
- name: Upload to Hangar
|
||||
if: ${{ !cancelled() && inputs.upload_hangar == 'true' }}
|
||||
uses: benwoo1110/hangar-upload-action@v1
|
||||
with:
|
||||
api_token: ${{ secrets.HANGAR_UPLOAD_TOKEN }}
|
||||
slug: ${{ inputs.hangar_slug }}
|
||||
version: ${{ steps.release-info.outputs.tag_name }}
|
||||
channel: ${{ steps.parse-release-type.outputs.release_type }}
|
||||
files: '[{"path": "${{ github.workspace }}/${{ inputs.plugin_name }}-${{ steps.release-info.outputs.tag_name }}.jar", "platforms": ["PAPER"]}]'
|
||||
description: ${{ steps.release-artifact.outputs.body }}
|
||||
platform_dependencies: '{"PAPER": ["1.13-1.20.1"]}'
|
||||
plugin_dependencies: ${{ inputs.hangar_plugin_dependencies }}
|
||||
@@ -1,40 +0,0 @@
|
||||
name: 'Generic: Test'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
plugin_name:
|
||||
description: 'Plugin name'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
cache: gradle
|
||||
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Run unit tests
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build
|
||||
env:
|
||||
GITHUB_VERSION: pr${{ github.event.pull_request.number }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Artifact output
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}
|
||||
path: build/libs/${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}.jar
|
||||
@@ -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
|
||||
@@ -43,6 +43,3 @@ debug.log
|
||||
# Doxygen
|
||||
/docs/html
|
||||
debug.txt
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
@@ -0,0 +1,6 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
@@ -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,50 +1,16 @@
|
||||
<p align="center">
|
||||
<img src="config/multiverse2-long.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://dev.bukkit.org/projects/multiverse-core)
|
||||
[](https://ci.onarandombox.com/job/Multiverse-Core/)
|
||||
[](https://discord.gg/NZtfKky)
|
||||
[](https://patreon.com/dumptruckman)
|
||||
[](LICENSE.md)
|
||||
|
||||
|
||||
# About
|
||||
|
||||
[Multiverse](https://dev.bukkit.org/projects/multiverse-core) was created at the dawn of Bukkit multiworld support. It has since then grown into a **complete world management solution!** Multiverse provides the easiest to use world management solution for your Minecraft server, big or small, and with great addons like [Portals](https://dev.bukkit.org/projects/multiverse-portals) and [NetherPortals](https://dev.bukkit.org/projects/multiverse-netherportals/), what's not to love!
|
||||
|
||||
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!
|
||||
|
||||
## Building
|
||||
Simply build the source with Gradle:
|
||||
```
|
||||
./gradlew build
|
||||
```
|
||||
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
||||
|
||||
License
|
||||
=======
|
||||
Copyright (c) 2011, The Multiverse Team All rights reserved.
|
||||
|
||||
## Contributing
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
**Want to help improve Multiverse?** There are several ways you can support and contribute to the project.
|
||||
* Take a look at our "Bug: Unconfirmed" issues, where you can find issues that need extra testing and investigation.
|
||||
* Want others to love Multiverse too? You can join the [Multiverse Discord community](https://discord.gg/NZtfKky) and help others with issues and setup!
|
||||
* A Multiverse guru? You can update our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) with your latest tip, tricks and guides! The wiki open for all to edit and improve.
|
||||
* Love coding? You could look at ["State: Open to PR"](https://github.com/Multiverse/Multiverse-Core/labels/State%3A%20Open%20to%20PR) and ["Resolution: Accepted"](https://github.com/Multiverse/Multiverse-Core/labels/Resolution%3A%20Accepted) issues. We're always happy to receive bug fixes and feature additions as [pull requests](https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/).
|
||||
* If you'd like to make a financial contribution to the project, do consider joining our [Patreon](https://www.patreon.com/dumptruckman) or make a one-time donation [here](https://paypal.me/dumptruckman)!
|
||||
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.
|
||||
|
||||
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.
|
||||
-321
@@ -1,321 +0,0 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
||||
id "org.jetbrains.kotlin.jvm" version "1.8.10"
|
||||
}
|
||||
|
||||
version = System.getenv('GITHUB_VERSION') ?: 'local'
|
||||
group = 'com.onarandombox.multiversecore'
|
||||
description = 'Multiverse-Core'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.onarandombox.com/content/groups/public')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://hub.spigotmc.org/nexus/content/groups/public/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://jitpack.io')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.minebench.de/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.maven.apache.org/maven2/')
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'aikar repo'
|
||||
url = uri('https://repo.aikar.co/content/groups/aikar/')
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'glaremasters repo'
|
||||
url = 'https://repo.glaremasters.me/repository/towny/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'PlaceholderAPI'
|
||||
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
|
||||
}
|
||||
|
||||
maven {
|
||||
name = 'papermc repo'
|
||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
// Add configuration for server API
|
||||
compileOnly.extendsFrom serverApi
|
||||
runtimeClasspath.extendsFrom serverApi
|
||||
|
||||
// Add configuration for external plugins
|
||||
implementation.extendsFrom externalPlugin
|
||||
|
||||
// Add configuration for dependencies that will be included in fat jar
|
||||
compileClasspath.extendsFrom shadowed
|
||||
testCompileClasspath.extendsFrom shadowed
|
||||
testRuntimeClasspath.extendsFrom shadowed
|
||||
oldTestCompileClasspath.extendsFrom shadowed
|
||||
oldTestRuntimeClasspath.extendsFrom shadowed
|
||||
|
||||
// Add configuration for old tests
|
||||
oldTestImplementation.extendsFrom implementation
|
||||
oldTestRuntime.extendsFrom runtime
|
||||
}
|
||||
|
||||
dependencies {
|
||||
serverApi 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
|
||||
|
||||
// Economy
|
||||
externalPlugin('com.github.MilkBowl:VaultAPI:1.7.1') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
|
||||
// PlaceholderAPI
|
||||
externalPlugin 'me.clip:placeholderapi:2.11.3'
|
||||
|
||||
// Command Framework
|
||||
shadowed 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
|
||||
|
||||
// Config
|
||||
shadowed('me.main__.util:SerializationConfig:1.7') {
|
||||
exclude group: 'org.bukkit', module: 'bukkit'
|
||||
}
|
||||
shadowed('io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.1') {
|
||||
exclude group: 'org.spigotmc', module: 'spigot-api'
|
||||
}
|
||||
|
||||
// Utils
|
||||
shadowed 'io.vavr:vavr:0.10.4'
|
||||
shadowed 'org.glassfish.hk2:hk2-locator:3.0.3'
|
||||
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:2.2.1'
|
||||
shadowed 'net.minidev:json-smart:2.4.9'
|
||||
shadowed 'org.jetbrains:annotations:22.0.0'
|
||||
shadowed 'io.papermc:paperlib:1.0.8'
|
||||
|
||||
// Tests
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10'
|
||||
testImplementation 'com.github.seeseemelk:MockBukkit-v1.20:3.20.2'
|
||||
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test'
|
||||
testImplementation 'com.natpryce:hamkrest:1.8.0.1'
|
||||
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0'
|
||||
|
||||
// Old Tests
|
||||
oldTestImplementation 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
|
||||
oldTestImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
oldTestImplementation 'junit:junit:4.13.1'
|
||||
oldTestImplementation 'org.mockito:mockito-core:3.11.2'
|
||||
oldTestImplementation 'commons-io:commons-io:2.7'
|
||||
|
||||
// Annotation Processors
|
||||
annotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
|
||||
testAnnotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
|
||||
}
|
||||
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
|
||||
configurations {
|
||||
[apiElements, runtimeElements].each {
|
||||
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
|
||||
it.outgoing.artifact(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
oldTest {
|
||||
java {
|
||||
compileClasspath += main.output
|
||||
runtimeClasspath += main.output
|
||||
srcDir file('src/old-test/java')
|
||||
}
|
||||
resources.srcDir file('src/old-test/resources')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
|
||||
// Remove Kotlin dependency
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.groupId.text() == 'org.jetbrains.kotlin'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
|
||||
// Switch runtime deps to provided
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.scope.text() == 'runtime'
|
||||
}.each() {
|
||||
it.scope*.value = 'provided'
|
||||
}
|
||||
|
||||
// Add spigot api to pom
|
||||
project.configurations.serverApi.allDependencies.each { dependency ->
|
||||
pomNode.dependencies[0].appendNode("dependency").with {
|
||||
it.appendNode("groupId", dependency.group)
|
||||
it.appendNode("artifactId", dependency.name)
|
||||
it.appendNode("version", dependency.version)
|
||||
it.appendNode("scope", "provided")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Core"
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ext.bitlyAccessToken = System.getenv('BITLY_ACCESS_TOKEN') ?: 'bitly-access-token'
|
||||
|
||||
task prepareSource(type: Sync) {
|
||||
inputs.property 'bitlyAccessToken', bitlyAccessToken
|
||||
from sourceSets.main.java
|
||||
into "$buildDir/src"
|
||||
filter(ReplaceTokens, tokens: [
|
||||
'bitly-access-token': bitlyAccessToken,
|
||||
])
|
||||
}
|
||||
|
||||
compileJava {
|
||||
source = prepareSource.outputs
|
||||
}
|
||||
tasks.withType(JavaCompile) {
|
||||
configure(options) {
|
||||
options.compilerArgs << '-Aorg.glassfish.hk2.metadata.location=META-INF/hk2-locator/Multiverse-Core'
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
// We're not using Kotlin in the plugin itself, just tests!
|
||||
enabled = false
|
||||
}
|
||||
configurations.findAll { !it.name.startsWith('test') }.each {
|
||||
it.exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
|
||||
}
|
||||
|
||||
processResources {
|
||||
def props = [version: "${project.version}"]
|
||||
inputs.properties props
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
|
||||
// This task should never be skipped. The tests depend on this having been run but we want the new version number
|
||||
// that is created after tests are run and before we run again to publish.
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
|
||||
javadoc {
|
||||
source = sourceSets.main.allJava
|
||||
classpath = configurations.compileClasspath
|
||||
}
|
||||
|
||||
|
||||
project.configurations.api.canBeResolved = true
|
||||
|
||||
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 'me.main__.util', 'org.mvplugins.multiverse.external.serializationconfig'
|
||||
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'
|
||||
|
||||
configurations = [project.configurations.shadowed]
|
||||
|
||||
archiveFileName = "$baseName-$version.$extension"
|
||||
|
||||
dependencies {
|
||||
exclude(dependency {
|
||||
it.moduleGroup == 'org.jetbrains.kotlin'
|
||||
})
|
||||
}
|
||||
//classifier = ''
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar
|
||||
jar.enabled = false
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
|
||||
testLogging {
|
||||
exceptionFormat = 'full'
|
||||
}
|
||||
}
|
||||
+90
-614
@@ -6,660 +6,136 @@
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<!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="0"/>
|
||||
</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="true"/>
|
||||
</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="EmptyStatement"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="HiddenField">
|
||||
<property name="tokens" value="VARIABLE_DEF"/><!-- We don't care if parameters hide fields. -->
|
||||
</module>
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MagicNumber">
|
||||
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
|
||||
</module>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<!-- Don't like errors for `final` missing
|
||||
<module name="DesignForExtension"/>
|
||||
<module name="FinalClass"/>
|
||||
-->
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="VisibilityModifier">
|
||||
<property name="protectedAllowed" value="true"/>
|
||||
</module>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<!-- Don't like errors for `final` missing
|
||||
<module name="FinalParameters"/>
|
||||
-->
|
||||
<module name="TodoComment">
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="UpperEll"/>
|
||||
<module name="Indentation"/>
|
||||
<module name="MissingDeprecated"/>
|
||||
<module name="MissingOverride"/>
|
||||
</module>
|
||||
</module>
|
||||
Vendored
BIN
Binary file not shown.
-6
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,244 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
-92
@@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,411 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<name>Multiverse-Core</name>
|
||||
<description>World Management Plugin</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.number>UNKNOWN</project.build.number>
|
||||
<project.bitly-access-token>bitly-access-token</project.bitly-access-token>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<!-- Spigot -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minebench-repo</id>
|
||||
<url>https://repo.minebench.de/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>doodleproject-repo</id>
|
||||
<name>DoodleProject Maven 2 Repository</name>
|
||||
<url>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>
|
||||
<profile>
|
||||
<id>bitly</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.BITLY_ACCESS_TOKEN</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<project.bitly-access-token>${env.BITLY_ACCESS_TOKEN}</project.bitly-access-token>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<!-- Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>maven-replacer-plugin</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>replace-bitly-access-token</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.sourceDirectory}</basedir>
|
||||
<includes>
|
||||
<include>com/onarandombox/MultiverseCore/utils/webpaste/BitlyURLShortener.java</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>bitly-access-token</token>
|
||||
<value>${project.bitly-access-token}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>replace-maven-version-number</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.directory}/classes</basedir>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-b${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Jar Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M3</version>
|
||||
<configuration>
|
||||
<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>3.0.0-M3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<configuration>
|
||||
<enableRulesSummary>true</enableRulesSummary>
|
||||
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc-jar</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>me.main__.util</pattern>
|
||||
<shadedPattern>com.onarandombox.serializationconfig</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>buscript</pattern>
|
||||
<shadedPattern>com.onarandombox.buscript</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.onarandombox.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.codehaus.jettison</pattern>
|
||||
<shadedPattern>com.onarandombox.jettison</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>de.themoep.idconverter</pattern>
|
||||
<shadedPattern>com.onarandombox.idconverter</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>com.onarandombox.acf</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.locales</pattern>
|
||||
<shadedPattern>com.onarandombox.locales</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>se.eris</groupId>
|
||||
<artifactId>notnull-instrumenter-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>instrument</goal>
|
||||
<goal>tests-instrument</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<notNull>
|
||||
<param>org.jetbrains.annotations.NotNull</param>
|
||||
<param>javax.validation.constraints.NotNull</param>
|
||||
</notNull>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- SerializationConfig Dependency -->
|
||||
<dependency>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- End of SerializationConfig Dependency -->
|
||||
<!-- Start of Economy Dependency -->
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependency -->
|
||||
<!-- Start of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>buscript</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.8</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>Logging</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.themoep.idconverter</groupId>
|
||||
<artifactId>mappings</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Start of Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>4.0.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>benergy10</id>
|
||||
<url>http://repo.benergy10.dev/repository/minecraft/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>benergy10</id>
|
||||
<url>http://repo.benergy10.dev/repository/minecraft-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'multiverse-core'
|
||||
@@ -1,13 +0,0 @@
|
||||
package co.aikar.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Exists just so we can extend BukkitCommandIssuer since it has a package-private constructor.
|
||||
*/
|
||||
public abstract class OpenBukkitCommandIssuer extends BukkitCommandIssuer {
|
||||
|
||||
protected OpenBukkitCommandIssuer(BukkitCommandManager manager, CommandSender sender) {
|
||||
super(manager, sender);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,385 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* 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 String prefixchatformat;
|
||||
@Property
|
||||
private volatile boolean useasyncchat;
|
||||
@Property
|
||||
private volatile boolean teleportintercept;
|
||||
@Property
|
||||
private volatile boolean firstspawnoverride;
|
||||
@Property
|
||||
private volatile boolean displaypermerrors;
|
||||
@Property
|
||||
private volatile boolean enablebuscript;
|
||||
@Property
|
||||
private volatile int globaldebug;
|
||||
@Property
|
||||
private volatile boolean silentstart;
|
||||
@Property
|
||||
private volatile int messagecooldown;
|
||||
@Property
|
||||
private volatile double version;
|
||||
@Property
|
||||
private volatile String firstspawnworld;
|
||||
@Property
|
||||
private volatile int teleportcooldown;
|
||||
@Property
|
||||
private volatile boolean defaultportalsearch;
|
||||
@Property
|
||||
private volatile int portalsearchradius;
|
||||
@Property
|
||||
private volatile boolean autopurge;
|
||||
@Property
|
||||
private volatile boolean idonotwanttodonate;
|
||||
|
||||
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;
|
||||
prefixchatformat = "[%world%]%chat%";
|
||||
teleportintercept = true;
|
||||
firstspawnoverride = true;
|
||||
displaypermerrors = true;
|
||||
enablebuscript = true;
|
||||
globaldebug = 0;
|
||||
messagecooldown = 5000;
|
||||
teleportcooldown = 1000;
|
||||
this.version = 2.9;
|
||||
silentstart = false;
|
||||
defaultportalsearch = false;
|
||||
portalsearchradius = 128;
|
||||
autopurge = true;
|
||||
idonotwanttodonate = false;
|
||||
// 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 String getPrefixChatFormat() {
|
||||
return this.prefixchatformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setPrefixChatFormat(String prefixChatFormat) {
|
||||
this.prefixchatformat = prefixChatFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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 boolean getEnableBuscript() {
|
||||
return this.enablebuscript;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setEnableBuscript(boolean enableBuscript) {
|
||||
this.enablebuscript = enableBuscript;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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);
|
||||
Bukkit.getPluginManager().callEvent(new MVDebugModeEvent(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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSilentStart(boolean silentStart) {
|
||||
Logging.setShowingConfig(!silentStart);
|
||||
this.silentstart = silentStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSilentStart() {
|
||||
return silentstart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseDefaultPortalSearch(boolean useDefaultPortalSearch) {
|
||||
defaultportalsearch = useDefaultPortalSearch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingDefaultPortalSearch() {
|
||||
return defaultportalsearch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortalSearchRadius(int searchRadius) {
|
||||
this.portalsearchradius = searchRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPortalSearchRadius() {
|
||||
return portalsearchradius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoPurgeEnabled() {
|
||||
return autopurge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoPurgeEnabled(boolean autopurge) {
|
||||
this.autopurge = autopurge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowingDonateMessage() {
|
||||
return !idonotwanttodonate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowDonateMessage(boolean showDonateMessage) {
|
||||
this.idonotwanttodonate = !showDonateMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,655 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
|
||||
import com.onarandombox.MultiverseCore.configuration.EntryFee;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnSettings;
|
||||
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator;
|
||||
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatStyle;
|
||||
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import me.main__.util.SerializationConfig.Serializor;
|
||||
import me.main__.util.SerializationConfig.Validator;
|
||||
import me.main__.util.SerializationConfig.VirtualProperty;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/*
|
||||
* This is a property class, I think we don't need that much javadoc.
|
||||
* BEGIN CHECKSTYLE-SUPPRESSION: Javadoc
|
||||
*/
|
||||
|
||||
@SerializableAs("MVWorld")
|
||||
public class WorldProperties extends SerializationConfig {
|
||||
|
||||
private static final Map<String, String> PROPERTY_ALIASES;
|
||||
|
||||
static {
|
||||
PROPERTY_ALIASES = new HashMap<String, String>();
|
||||
PROPERTY_ALIASES.put("curr", "entryfee.currency");
|
||||
PROPERTY_ALIASES.put("currency", "entryfee.currency");
|
||||
PROPERTY_ALIASES.put("price", "entryfee.amount");
|
||||
PROPERTY_ALIASES.put("scaling", "scale");
|
||||
PROPERTY_ALIASES.put("aliascolor", "color");
|
||||
PROPERTY_ALIASES.put("heal", "autoHeal");
|
||||
PROPERTY_ALIASES.put("storm", "allowWeather");
|
||||
PROPERTY_ALIASES.put("weather", "allowWeather");
|
||||
PROPERTY_ALIASES.put("spawnmemory", "keepSpawnInMemory");
|
||||
PROPERTY_ALIASES.put("memory", "keepSpawnInMemory");
|
||||
PROPERTY_ALIASES.put("mode", "gameMode");
|
||||
PROPERTY_ALIASES.put("diff", "difficulty");
|
||||
PROPERTY_ALIASES.put("spawnlocation", "spawn");
|
||||
PROPERTY_ALIASES.put("limit", "playerLimit");
|
||||
PROPERTY_ALIASES.put("animals", "spawning.animals.spawn");
|
||||
PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn");
|
||||
PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate");
|
||||
PROPERTY_ALIASES.put("monstersrate", "spawning.monsters.spawnrate");
|
||||
PROPERTY_ALIASES.put("flight", "allowFlight");
|
||||
PROPERTY_ALIASES.put("fly", "allowFlight");
|
||||
PROPERTY_ALIASES.put("allowfly", "allowFlight");
|
||||
}
|
||||
|
||||
private final boolean keepSpawnFallback;
|
||||
|
||||
public WorldProperties(Map<String, Object> values) {
|
||||
super(values);
|
||||
Object keepSpawnObject = values.get("keepSpawnInMemory");
|
||||
keepSpawnFallback = keepSpawnObject == null || Boolean.parseBoolean(keepSpawnObject.toString());
|
||||
}
|
||||
|
||||
public WorldProperties() {
|
||||
super();
|
||||
keepSpawnFallback = true;
|
||||
}
|
||||
|
||||
public WorldProperties(final boolean fixSpawn, final Environment environment) {
|
||||
super();
|
||||
if (!fixSpawn) {
|
||||
this.adjustSpawn = false;
|
||||
}
|
||||
setScaling(getDefaultScale(environment));
|
||||
keepSpawnFallback = true;
|
||||
}
|
||||
|
||||
void setMVWorld(MVWorld world) {
|
||||
registerObjectUsing(world);
|
||||
registerGlobalValidator(new WorldPropertyValidator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the color-property.
|
||||
*/
|
||||
private static final class EnumPropertySerializor<T extends Enum<T>> implements Serializor<T, String> {
|
||||
@Override
|
||||
public String serialize(T from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(String serialized, Class<T> wanted) throws IllegalPropertyValueException {
|
||||
try {
|
||||
return Enum.valueOf(wanted, serialized.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalPropertyValueException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the difficulty-property.
|
||||
*/
|
||||
private static final class DifficultyPropertySerializor implements Serializor<Difficulty, String> {
|
||||
@Override
|
||||
public String serialize(Difficulty from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Difficulty deserialize(String serialized, Class<Difficulty> wanted) throws IllegalPropertyValueException {
|
||||
try {
|
||||
return Difficulty.getByValue(Integer.parseInt(serialized));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
return Difficulty.valueOf(serialized.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new IllegalPropertyValueException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the gameMode-property.
|
||||
*/
|
||||
private static final class GameModePropertySerializor implements Serializor<GameMode, String> {
|
||||
@Override
|
||||
public String serialize(GameMode from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode deserialize(String serialized, Class<GameMode> wanted) throws IllegalPropertyValueException {
|
||||
try {
|
||||
return GameMode.getByValue(Integer.parseInt(serialized));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try {
|
||||
return GameMode.valueOf(serialized.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new IllegalPropertyValueException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the time-property.
|
||||
*/
|
||||
private static final class TimePropertySerializor implements Serializor<Long, String> {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
private static final String TIME_REGEX = "(\\d\\d?):?(\\d\\d)(a|p)?m?";
|
||||
private static final Map<String, String> TIME_ALIASES;
|
||||
static {
|
||||
Map<String, String> staticTimes = new HashMap<String, String>();
|
||||
staticTimes.put("morning", "8:00");
|
||||
staticTimes.put("day", "12:00");
|
||||
staticTimes.put("noon", "12:00");
|
||||
staticTimes.put("midnight", "0:00");
|
||||
staticTimes.put("night", "20:00");
|
||||
|
||||
// now set TIME_ALIASES to a "frozen" map
|
||||
TIME_ALIASES = Collections.unmodifiableMap(staticTimes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(Long from) {
|
||||
// I'm tired, so they get time in 24 hour for now.
|
||||
// Someone else can add 12 hr format if they want :P
|
||||
|
||||
int hours = (int) ((from / 1000 + 8) % 24);
|
||||
int minutes = (int) (60 * (from % 1000) / 1000);
|
||||
|
||||
return String.format("%d:%02d", hours, minutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deserialize(String serialized, Class<Long> wanted) throws IllegalPropertyValueException {
|
||||
if (TIME_ALIASES.containsKey(serialized.toLowerCase())) {
|
||||
serialized = TIME_ALIASES.get(serialized.toLowerCase());
|
||||
}
|
||||
// Regex that extracts a time in the following formats:
|
||||
// 11:11pm, 11:11, 23:11, 1111, 1111p, and the aliases at the top of this file.
|
||||
Pattern pattern = Pattern.compile(TIME_REGEX, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(serialized);
|
||||
matcher.find();
|
||||
int hour = 0;
|
||||
double minute = 0;
|
||||
int count = matcher.groupCount();
|
||||
if (count >= 2) {
|
||||
hour = Integer.parseInt(matcher.group(1));
|
||||
minute = Integer.parseInt(matcher.group(2));
|
||||
}
|
||||
// If there were 4 matches (all, hour, min, am/pm)
|
||||
if (count == 4) {
|
||||
// We want 24 hour time for calcs, but if they
|
||||
// added a p[m], turn it into a 24 hr one.
|
||||
if (matcher.group(3).equals("p")) {
|
||||
hour += 12;
|
||||
}
|
||||
}
|
||||
// Translate 24th hour to 0th hour.
|
||||
if (hour == 24) {
|
||||
hour = 0;
|
||||
}
|
||||
// Clamp the hour
|
||||
if (hour > 23 || hour < 0) {
|
||||
throw new IllegalPropertyValueException("Illegal hour!");
|
||||
}
|
||||
// Clamp the minute
|
||||
if (minute > 59 || minute < 0) {
|
||||
throw new IllegalPropertyValueException("Illegal minute!");
|
||||
}
|
||||
// 60 seconds in a minute, time needs to be in hrs * 1000, per
|
||||
// the bukkit docs.
|
||||
double totaltime = (hour + (minute / 60.0)) * 1000;
|
||||
// Somehow there's an 8 hour offset...
|
||||
totaltime -= 8000;
|
||||
if (totaltime < 0) {
|
||||
totaltime = 24000 + totaltime;
|
||||
}
|
||||
|
||||
return (long) totaltime;
|
||||
}
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Begin properties
|
||||
@Property(description = "Sorry, 'hidden' must either be: true or false.")
|
||||
private volatile boolean hidden;
|
||||
@Property(description = "Alias must be a valid string.")
|
||||
private volatile String alias;
|
||||
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'color' must be a valid color-name.")
|
||||
private volatile EnglishChatColor color;
|
||||
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'style' must be a valid style-name.")
|
||||
private volatile EnglishChatStyle style;
|
||||
@Property(description = "Sorry, 'pvp' must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
|
||||
volatile VirtualProperty<Boolean> pvp; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property(description = "Scale must be a positive double value. ex: 2.3")
|
||||
private volatile double scale;
|
||||
@Property(description = "You must set this to the NAME not alias of a world.")
|
||||
private volatile String respawnWorld;
|
||||
@Property(description = "Sorry, this must either be: true or false.")
|
||||
private volatile boolean allowWeather;
|
||||
@Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class, persistVirtual = true,
|
||||
description = "Difficulty must be set as one of the following: peaceful easy normal hard")
|
||||
volatile VirtualProperty<Difficulty> difficulty; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property(description = "Sorry, 'animals' must either be: true or false.")
|
||||
private volatile SpawnSettings spawning;
|
||||
@Property
|
||||
volatile EntryFee entryfee;
|
||||
@Property(description = "Sorry, 'hunger' must either be: true or false.")
|
||||
private volatile boolean hunger;
|
||||
@Property(description = "Sorry, 'autoheal' must either be: true or false.")
|
||||
private volatile boolean autoHeal;
|
||||
@Property(description = "Sorry, 'adjustspawn' must either be: true or false.")
|
||||
private volatile boolean adjustSpawn;
|
||||
@Property(serializor = EnumPropertySerializor.class, description = "Allow portal forming must be NONE, ALL, NETHER or END.")
|
||||
private volatile AllowedPortalType portalForm;
|
||||
@Property(serializor = GameModePropertySerializor.class, description = "GameMode must be set as one of the following: survival creative")
|
||||
private volatile GameMode gameMode;
|
||||
@Property(description = "Sorry, this must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
|
||||
volatile VirtualProperty<Boolean> keepSpawnInMemory; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property
|
||||
volatile SpawnLocation spawnLocation; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property(virtualType = Location.class,
|
||||
description = "There is no help available for this variable. Go bug Rigby90 about it.")
|
||||
volatile VirtualProperty<Location> spawn; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property(description = "Set this to false ONLY if you don't want this world to load itself on server restart.")
|
||||
private volatile boolean autoLoad;
|
||||
@Property(description = "If a player dies in this world, shoudld they go to their bed?")
|
||||
private volatile boolean bedRespawn;
|
||||
@Property
|
||||
private volatile List<String> worldBlacklist;
|
||||
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
|
||||
description = "Set the time to whatever you want! (Will NOT freeze time)")
|
||||
volatile VirtualProperty<Long> time; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property
|
||||
volatile Environment environment; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property
|
||||
volatile long seed; // SUPPRESS CHECKSTYLE: VisibilityModifier
|
||||
@Property
|
||||
private volatile String generator;
|
||||
@Property
|
||||
private volatile int playerLimit;
|
||||
@Property
|
||||
private volatile boolean allowFlight;
|
||||
// End of properties
|
||||
// --------------------------------------------------------------
|
||||
|
||||
void setValidator(String fieldName, Validator validator) {
|
||||
registerValidator(fieldName, validator); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void copyValues(SerializationConfig other) {
|
||||
super.copyValues(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prepares the MVWorld for unloading.
|
||||
*/
|
||||
public void cacheVirtualProperties() {
|
||||
try {
|
||||
this.buildVPropChanges();
|
||||
} catch (IllegalStateException e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
this.hidden = false;
|
||||
this.alias = new String();
|
||||
this.color = EnglishChatColor.WHITE;
|
||||
this.style = EnglishChatStyle.NORMAL;
|
||||
this.scale = 1D;
|
||||
this.respawnWorld = new String();
|
||||
this.allowWeather = true;
|
||||
this.spawning = new SpawnSettings();
|
||||
this.entryfee = new EntryFee();
|
||||
this.hunger = true;
|
||||
this.autoHeal = true;
|
||||
this.adjustSpawn = true;
|
||||
this.portalForm = AllowedPortalType.ALL;
|
||||
this.gameMode = GameMode.SURVIVAL;
|
||||
this.spawnLocation = new NullLocation();
|
||||
this.autoLoad = true;
|
||||
this.bedRespawn = true;
|
||||
this.worldBlacklist = new ArrayList<String>();
|
||||
this.generator = null;
|
||||
this.playerLimit = -1;
|
||||
this.allowFlight = true;
|
||||
}
|
||||
|
||||
private static double getDefaultScale(Environment environment) {
|
||||
if (environment == Environment.NETHER) {
|
||||
return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
} else if (environment == Environment.THE_END) {
|
||||
return 16.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* getAliases().
|
||||
* @return The alias-map.
|
||||
* @see SerializationConfig
|
||||
*/
|
||||
protected static Map<String, String> getAliases() {
|
||||
return PROPERTY_ALIASES;
|
||||
}
|
||||
|
||||
void flushChanges() {
|
||||
this.flushPendingVPropChanges();
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.setPropertyValueUnchecked("alias", alias);
|
||||
}
|
||||
|
||||
public Environment getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.setPropertyValueUnchecked("environment", environment);
|
||||
}
|
||||
|
||||
public long getSeed() {
|
||||
return this.seed;
|
||||
}
|
||||
|
||||
public void setSeed(long seed) {
|
||||
this.setPropertyValueUnchecked("seed", seed);
|
||||
}
|
||||
|
||||
public String getGenerator() {
|
||||
return this.generator;
|
||||
}
|
||||
|
||||
public void setGenerator(String generator) {
|
||||
this.setPropertyValueUnchecked("generator", generator);
|
||||
}
|
||||
|
||||
public int getPlayerLimit() {
|
||||
return this.playerLimit;
|
||||
}
|
||||
|
||||
public void setPlayerLimit(int limit) {
|
||||
this.setPropertyValueUnchecked("playerLimit", limit);
|
||||
}
|
||||
|
||||
public boolean canAnimalsSpawn() {
|
||||
return this.spawning.getAnimalSettings().doSpawn();
|
||||
}
|
||||
|
||||
public void setAllowAnimalSpawn(boolean animals) {
|
||||
this.setPropertyValueUnchecked("spawning.animals.spawn", animals);
|
||||
}
|
||||
|
||||
public List<String> getAnimalList() {
|
||||
// These don't fire events at the moment. Should they?
|
||||
return this.spawning.getAnimalSettings().getExceptions();
|
||||
}
|
||||
|
||||
public boolean canMonstersSpawn() {
|
||||
return this.spawning.getMonsterSettings().doSpawn();
|
||||
}
|
||||
|
||||
public void setAllowMonsterSpawn(boolean monsters) {
|
||||
this.setPropertyValueUnchecked("spawning.monsters.spawn", monsters);
|
||||
}
|
||||
|
||||
public int getAnimalSpawnRate() {
|
||||
return this.spawning.getAnimalSettings().getSpawnRate();
|
||||
}
|
||||
|
||||
public int getMonsterSpawnRate() {
|
||||
return this.spawning.getMonsterSettings().getSpawnRate();
|
||||
}
|
||||
|
||||
public List<String> getMonsterList() {
|
||||
// These don't fire events at the moment. Should they?
|
||||
return this.spawning.getMonsterSettings().getExceptions();
|
||||
}
|
||||
|
||||
public boolean isPVPEnabled() {
|
||||
return this.pvp.get();
|
||||
}
|
||||
|
||||
public void setPVPMode(boolean pvp) {
|
||||
this.setPropertyValueUnchecked("pvp", pvp);
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.setPropertyValueUnchecked("hidden", hidden);
|
||||
}
|
||||
|
||||
public List<String> getWorldBlacklist() {
|
||||
return this.worldBlacklist;
|
||||
}
|
||||
|
||||
public double getScaling() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public boolean setScaling(double scaling) {
|
||||
return this.setPropertyValueUnchecked("scale", scaling);
|
||||
}
|
||||
|
||||
public boolean setColor(String aliasColor) {
|
||||
return this.setPropertyUnchecked("color", aliasColor);
|
||||
}
|
||||
|
||||
public boolean setColor(EnglishChatColor color) {
|
||||
return this.setPropertyValueUnchecked("color", color);
|
||||
}
|
||||
|
||||
public EnglishChatColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public String getRespawnToWorld() {
|
||||
return this.respawnWorld;
|
||||
}
|
||||
|
||||
public boolean setRespawnToWorld(String respawnToWorld) {
|
||||
return this.setPropertyValueUnchecked("respawnWorld", respawnToWorld);
|
||||
}
|
||||
|
||||
public Material getCurrency() {
|
||||
return this.entryfee.getCurrency();
|
||||
}
|
||||
|
||||
public void setCurrency(@Nullable Material currency) {
|
||||
this.setPropertyValueUnchecked("entryfee.currency", currency);
|
||||
}
|
||||
|
||||
public double getPrice() {
|
||||
return this.entryfee.getAmount();
|
||||
}
|
||||
|
||||
public void setPrice(double price) {
|
||||
this.setPropertyValueUnchecked("entryfee.amount", price);
|
||||
}
|
||||
|
||||
public boolean setGameMode(String mode) {
|
||||
return this.setPropertyUnchecked("gameMode", mode);
|
||||
}
|
||||
|
||||
public boolean setGameMode(GameMode mode) {
|
||||
return this.setPropertyValueUnchecked("gameMode", mode);
|
||||
}
|
||||
|
||||
public GameMode getGameMode() {
|
||||
return this.gameMode;
|
||||
}
|
||||
|
||||
public void setEnableWeather(boolean weather) {
|
||||
this.setPropertyValueUnchecked("allowWeather", weather);
|
||||
}
|
||||
|
||||
public boolean isWeatherEnabled() {
|
||||
return this.allowWeather;
|
||||
}
|
||||
|
||||
public boolean isKeepingSpawnInMemory() {
|
||||
if (keepSpawnInMemory == null) {
|
||||
return keepSpawnFallback;
|
||||
}
|
||||
try {
|
||||
return this.keepSpawnInMemory.get();
|
||||
} catch (IllegalStateException e) {
|
||||
return keepSpawnFallback;
|
||||
}
|
||||
}
|
||||
|
||||
public void setKeepSpawnInMemory(boolean value) {
|
||||
this.setPropertyValueUnchecked("keepSpawnInMemory", value);
|
||||
}
|
||||
|
||||
public boolean getHunger() {
|
||||
return this.hunger;
|
||||
}
|
||||
|
||||
public void setHunger(boolean hunger) {
|
||||
this.setPropertyValueUnchecked("hunger", hunger);
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
return this.spawn.get();
|
||||
}
|
||||
|
||||
public void setSpawnLocation(Location l) {
|
||||
this.setPropertyValueUnchecked("spawn", l);
|
||||
}
|
||||
|
||||
public Difficulty getDifficulty() {
|
||||
return this.difficulty.get();
|
||||
}
|
||||
|
||||
@Deprecated // SUPPRESS CHECKSTYLE: Deprecated
|
||||
public boolean setDifficulty(String difficulty) {
|
||||
return this.setPropertyUnchecked("difficulty", difficulty);
|
||||
}
|
||||
|
||||
public boolean setDifficulty(Difficulty difficulty) {
|
||||
return this.setPropertyValueUnchecked("difficulty", difficulty);
|
||||
}
|
||||
|
||||
public boolean getAutoHeal() {
|
||||
return this.autoHeal;
|
||||
}
|
||||
|
||||
public void setAutoHeal(boolean heal) {
|
||||
this.setPropertyValueUnchecked("autoHeal", heal);
|
||||
}
|
||||
|
||||
public void setAdjustSpawn(boolean adjust) {
|
||||
this.setPropertyValueUnchecked("adjustSpawn", adjust);
|
||||
}
|
||||
|
||||
public boolean getAdjustSpawn() {
|
||||
return this.adjustSpawn;
|
||||
}
|
||||
|
||||
public void setAutoLoad(boolean load) {
|
||||
this.setPropertyValueUnchecked("autoLoad", load);
|
||||
}
|
||||
|
||||
public boolean getAutoLoad() {
|
||||
return this.autoLoad;
|
||||
}
|
||||
|
||||
public void setBedRespawn(boolean respawn) {
|
||||
this.setPropertyValueUnchecked("bedRespawn", respawn);
|
||||
}
|
||||
|
||||
public boolean getBedRespawn() {
|
||||
return this.bedRespawn;
|
||||
}
|
||||
|
||||
public String getAllPropertyNames() {
|
||||
ChatColor myColor = ChatColor.AQUA;
|
||||
StringBuilder result = new StringBuilder();
|
||||
Map<String, Object> serialized = this.serialize();
|
||||
for (String key : serialized.keySet()) {
|
||||
result.append(myColor).append(key).append(' ');
|
||||
myColor = (myColor == ChatColor.AQUA) ? ChatColor.GOLD : ChatColor.AQUA;
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return this.getPropertyUnchecked("time");
|
||||
}
|
||||
|
||||
public boolean setTime(String timeAsString) {
|
||||
return this.setPropertyUnchecked("time", timeAsString);
|
||||
}
|
||||
|
||||
public AllowedPortalType getAllowedPortals() {
|
||||
return portalForm;
|
||||
}
|
||||
|
||||
public void allowPortalMaking(AllowedPortalType portalType) {
|
||||
this.setPropertyValueUnchecked("portalForm", portalType);
|
||||
}
|
||||
|
||||
public EnglishChatStyle getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public boolean setStyle(String style) {
|
||||
return this.setPropertyUnchecked("style", style);
|
||||
}
|
||||
|
||||
public boolean getAllowFlight() {
|
||||
return this.allowFlight;
|
||||
}
|
||||
|
||||
public void setAllowFlight(final boolean allowFlight) {
|
||||
this.setPropertyValueUnchecked("allowFlight", allowFlight);
|
||||
}
|
||||
}
|
||||
+1
-36
@@ -1,16 +1,13 @@
|
||||
package org.mvplugins.multiverse.core.api;
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to get block/location-related information.
|
||||
*/
|
||||
@Contract
|
||||
public interface BlockSafety {
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
@@ -38,35 +35,8 @@ public interface BlockSafety {
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(Location l);
|
||||
|
||||
/**
|
||||
* Finds a portal-block next to the specified {@link Location}.
|
||||
*
|
||||
* @param location The {@link Location}
|
||||
* @return The next portal-block's {@link Location}.
|
||||
*/
|
||||
Location findPortalBlockNextTo(Location location);
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
*
|
||||
* @param location A {@link Location}.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
@Nullable Location getSafeLocation(Location location);
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
*
|
||||
* @param location A {@link Location}.
|
||||
* @param tolerance The tolerance of how far up and down to search.
|
||||
* @param radius The radius around given location to search.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
@Nullable Location getSafeLocation(Location location, int tolerance, int radius);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -74,7 +44,6 @@ public interface BlockSafety {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -82,7 +51,6 @@ public interface BlockSafety {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -90,7 +58,6 @@ public interface BlockSafety {
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
*/
|
||||
@@ -98,7 +65,6 @@ public interface BlockSafety {
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Minecart} can spawn safely.
|
||||
*
|
||||
* @param cart The {@link Minecart}.
|
||||
* @return True if the minecart can spawn safely.
|
||||
*/
|
||||
@@ -106,7 +72,6 @@ public interface BlockSafety {
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Vehicle} can spawn safely.
|
||||
*
|
||||
* @param vehicle The {@link Vehicle}.
|
||||
* @return True if the vehicle can spawn safely.
|
||||
*/
|
||||
@@ -0,0 +1,202 @@
|
||||
/******************************************************************************
|
||||
* 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.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.MVEconomist;
|
||||
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.VaultHandler;
|
||||
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 {
|
||||
|
||||
/**
|
||||
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
|
||||
* interfacing with Vault.
|
||||
*
|
||||
* @return the Vault handler for Multiverse.
|
||||
* @deprecated we are now using {@link #getEconomist()} for all economy needs.
|
||||
*/
|
||||
@Deprecated
|
||||
VaultHandler getVaultHandler();
|
||||
|
||||
/**
|
||||
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without
|
||||
* worrying about any of the messy details.
|
||||
*
|
||||
* @return the economy manager for Multiverse.
|
||||
*/
|
||||
MVEconomist getEconomist();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Multiverse uses an advanced permissions setup, this object
|
||||
* simplifies getting/setting permissions.
|
||||
*
|
||||
* @return A non-null {@link MVPermissions}.
|
||||
*/
|
||||
MVPermissions getMVPerms();
|
||||
|
||||
/**
|
||||
* Multiverse uses {@link MVCommandManager} to make adding and using commands
|
||||
* a piece of cake.
|
||||
*
|
||||
* @return A non-null {@link MVCommandManager}.
|
||||
*/
|
||||
MVCommandManager getMVCommandManager();
|
||||
|
||||
/**
|
||||
* 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 MVWorldManager}.
|
||||
*/
|
||||
MVWorldManager getMVWorldManager();
|
||||
|
||||
/**
|
||||
* Saves all configs.
|
||||
*
|
||||
* @return Whether the config was successfully saved
|
||||
*/
|
||||
boolean saveMVConfigs();
|
||||
|
||||
/**
|
||||
* Gets the {@link AnchorManager}.
|
||||
*
|
||||
* @return The {@link AnchorManager}
|
||||
*/
|
||||
AnchorManager getAnchorManager();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
+9
-3
@@ -1,14 +1,12 @@
|
||||
package org.mvplugins.multiverse.core.api;
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to manipulate locations.
|
||||
*/
|
||||
@Contract
|
||||
public interface LocationManipulation {
|
||||
/**
|
||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||
@@ -42,6 +40,14 @@ public interface LocationManipulation {
|
||||
*/
|
||||
Location stringToLocation(String locationString);
|
||||
|
||||
/**
|
||||
* Returns a colored string with x, y, z axis.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strAxis(Location l);
|
||||
|
||||
/**
|
||||
* Returns a colored string with the coords.
|
||||
*
|
||||
@@ -0,0 +1,36 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* A simple API to require plugins to have a log method.
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}.
|
||||
* */
|
||||
@Deprecated
|
||||
public interface LoggablePlugin {
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
*
|
||||
* @param level The Log-{@link Level}.
|
||||
* @param msg The message to log.
|
||||
*/
|
||||
void log(Level level, String msg);
|
||||
|
||||
/**
|
||||
* Gets the server instance that this plugin is attached to.
|
||||
*
|
||||
* @return A {@link Server} instance.
|
||||
*/
|
||||
Server getServer();
|
||||
}
|
||||
@@ -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 com.onarandombox.MultiverseCore}.
|
||||
*/
|
||||
MultiverseCore getCore();
|
||||
|
||||
/**
|
||||
* Sets the reference to MultiverseCore.
|
||||
*
|
||||
* @param core A valid {@link com.onarandombox.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,334 @@
|
||||
/******************************************************************************
|
||||
* 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.WorldValidationResult;
|
||||
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. Ignored.
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
* @deprecated Use {@link #cloneWorld(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean cloneWorld(String oldName, String newName, String generator);
|
||||
|
||||
/**
|
||||
* Make a copy of a world.
|
||||
*
|
||||
* @param oldName
|
||||
* Name of world to be copied
|
||||
* @param newName
|
||||
* Name of world to be created
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
*/
|
||||
boolean cloneWorld(String oldName, String newName);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the config and deletes
|
||||
* the folder.
|
||||
*
|
||||
* @param name
|
||||
* The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config if wanted, and deletes the folder.
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeConfig);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeFromConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
|
||||
* only the contents of the world folder will be deleted
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
boolean unloadWorld(String name);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @param unloadBukkit True if Bukkit world should be unloaded
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
boolean unloadWorld(String name, boolean unloadBukkit);
|
||||
|
||||
/**
|
||||
* Loads the world. Only use this if the world has been
|
||||
* unloaded with {@link #unloadWorld(String)}.
|
||||
*
|
||||
* @param name The name of the world to load
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean loadWorld(String name);
|
||||
|
||||
/**
|
||||
* Removes all players from the specified world.
|
||||
*
|
||||
* @param name World to remove players from.
|
||||
*/
|
||||
void removePlayersFromWorld(String name);
|
||||
|
||||
/**
|
||||
* Test if a given chunk generator is valid.
|
||||
*
|
||||
* @param generator The generator name.
|
||||
* @param generatorID The generator id.
|
||||
* @param worldName The worldName to use as the default.
|
||||
* @return A {@link ChunkGenerator} or null
|
||||
*/
|
||||
ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
|
||||
|
||||
/**
|
||||
* Returns a list of all the worlds Multiverse knows about.
|
||||
*
|
||||
* @return A list of {@link 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);
|
||||
|
||||
boolean isKeepingSpawnInMemory(World world);
|
||||
|
||||
/**
|
||||
* Checks whether Multiverse knows about a provided unloaded world. This
|
||||
* method will check the parameter against the alias mappings.
|
||||
*
|
||||
* @param name The name of the unloaded world
|
||||
* @param includeLoaded The value to return if the world is loaded
|
||||
*
|
||||
* @return True if the world exists and is unloaded. False if the world
|
||||
* does not exist. {@code includeLoaded} if the world exists and is loaded.
|
||||
*/
|
||||
boolean hasUnloadedWorld(String name, boolean includeLoaded);
|
||||
|
||||
/**
|
||||
* Check if a world name is a possible importable world folder.
|
||||
*
|
||||
* @param worldName Name of the world you want to check.
|
||||
* @return True if world is valid, false otherwise.
|
||||
*/
|
||||
boolean isValidWorld(String worldName);
|
||||
|
||||
/**
|
||||
* Check if a world name is a possible importable world folder.
|
||||
*
|
||||
* @param worldName Name of the world you want to check.
|
||||
* @return WorldValidationResult.VALID if world is valid, else the reason why its not valid.
|
||||
*/
|
||||
WorldValidationResult validateWorld(String worldName);
|
||||
}
|
||||
+127
-122
@@ -1,87 +1,102 @@
|
||||
package org.mvplugins.multiverse.core.api;
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import io.vavr.control.Try;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
||||
import org.mvplugins.multiverse.core.configuration.handle.StringPropertyHandle;
|
||||
import org.mvplugins.multiverse.core.placeholders.MultiverseCorePlaceholders;
|
||||
|
||||
@Contract
|
||||
public interface MVConfig {
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Loads the config from disk.
|
||||
* @return True if the config was loaded successfully.
|
||||
* Sets portalCooldown.
|
||||
* @param portalCooldown The new value.
|
||||
*/
|
||||
Try<Void> load();
|
||||
void setTeleportCooldown(int portalCooldown);
|
||||
|
||||
/**
|
||||
* Whether the config has been loaded.
|
||||
* @return True if the config has been loaded.
|
||||
* Gets portalCooldown.
|
||||
* @return portalCooldown.
|
||||
*/
|
||||
boolean isLoaded();
|
||||
int getTeleportCooldown();
|
||||
|
||||
/**
|
||||
* Saves the config to disk.
|
||||
* Sets firstSpawnWorld.
|
||||
* @param firstSpawnWorld The new value.
|
||||
*/
|
||||
Try<Void> save();
|
||||
void setFirstSpawnWorld(String firstSpawnWorld);
|
||||
|
||||
/**
|
||||
* Gets the handler for managing config with string names and values.
|
||||
*
|
||||
* @return The config handle for string properties.
|
||||
* Gets firstSpawnWorld.
|
||||
* @return firstSpawnWorld.
|
||||
*/
|
||||
StringPropertyHandle getStringPropertyHandle();
|
||||
String getFirstSpawnWorld();
|
||||
|
||||
/**
|
||||
* Sets world access permissions should be enforced.
|
||||
* @param enforceAccess The new value.
|
||||
* Sets version.
|
||||
* @param version The new value.
|
||||
*/
|
||||
void setEnforceAccess(boolean enforceAccess);
|
||||
void setVersion(int version);
|
||||
|
||||
/**
|
||||
* Gets enforceAccess.
|
||||
* @return enforceAccess.
|
||||
* Gets version.
|
||||
* @return version.
|
||||
*/
|
||||
boolean getEnforceAccess();
|
||||
double getVersion();
|
||||
|
||||
/**
|
||||
* Sets whether the game mode should be enforced.
|
||||
* @param enforceGameMode The new value.
|
||||
* Sets messageCooldown.
|
||||
* @param messageCooldown The new value.
|
||||
*/
|
||||
void setEnforceGameMode(boolean enforceGameMode);
|
||||
void setMessageCooldown(int messageCooldown);
|
||||
|
||||
/**
|
||||
* Gets enforceGameMode value.
|
||||
* @return True if game mode should be enforced.
|
||||
* Gets messageCooldown.
|
||||
* @return messageCooldown.
|
||||
*/
|
||||
boolean getEnforceGameMode();
|
||||
int getMessageCooldown();
|
||||
|
||||
/**
|
||||
* Sets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @param autopurge True if automatic purge should be enabled.
|
||||
* Sets globalDebug.
|
||||
* @param globalDebug The new value.
|
||||
*/
|
||||
void setAutoPurgeEntities(boolean autopurge);
|
||||
void setGlobalDebug(int globalDebug);
|
||||
|
||||
/**
|
||||
* Gets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @return True if automatic purge is enabled.
|
||||
* Gets globalDebug.
|
||||
* @return globalDebug.
|
||||
*/
|
||||
boolean isAutoPurgeEntities();
|
||||
int getGlobalDebug();
|
||||
|
||||
/**
|
||||
* Sets teleportIntercept.
|
||||
* @param teleportIntercept The new value.
|
||||
* Sets displayPermErrors.
|
||||
* @param displayPermErrors The new value.
|
||||
*/
|
||||
void setTeleportIntercept(boolean teleportIntercept);
|
||||
void setDisplayPermErrors(boolean displayPermErrors);
|
||||
|
||||
/**
|
||||
* Gets teleportIntercept.
|
||||
* @return teleportIntercept.
|
||||
* Gets displayPermErrors.
|
||||
* @return displayPermErrors.
|
||||
*/
|
||||
boolean getTeleportIntercept();
|
||||
boolean getDisplayPermErrors();
|
||||
|
||||
/**
|
||||
* Sets enableBuscript.
|
||||
* @param enableBuscript The new value.
|
||||
*/
|
||||
void setEnableBuscript(boolean enableBuscript);
|
||||
|
||||
/**
|
||||
* Gets enableBuscript.
|
||||
* @return enableBuscript.
|
||||
*/
|
||||
boolean getEnableBuscript();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnOverride.
|
||||
@@ -96,81 +111,29 @@ public interface MVConfig {
|
||||
boolean getFirstSpawnOverride();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnWorld.
|
||||
* @param firstSpawnWorld The new value.
|
||||
* Sets teleportIntercept.
|
||||
* @param teleportIntercept The new value.
|
||||
*/
|
||||
void setFirstSpawnLocation(String firstSpawnWorld);
|
||||
void setTeleportIntercept(boolean teleportIntercept);
|
||||
|
||||
/**
|
||||
* Gets firstSpawnWorld.
|
||||
* @return firstSpawnWorld.
|
||||
* Gets teleportIntercept.
|
||||
* @return teleportIntercept.
|
||||
*/
|
||||
String getFirstSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets whether join destination should be enabled.
|
||||
* @param enableJoinDestination The new value
|
||||
*/
|
||||
void setEnableJoinDestination(boolean enableJoinDestination);
|
||||
|
||||
/**
|
||||
* Gets enableJoinDestination.
|
||||
* @return enableJoinDestination
|
||||
*/
|
||||
boolean getEnableJoinDestination();
|
||||
|
||||
/**
|
||||
* Sets alwaysSpawnDestination.
|
||||
* @param alwaysSpawnDestination The new value
|
||||
*/
|
||||
void setJoinDestination(String alwaysSpawnDestination);
|
||||
|
||||
/**
|
||||
* Gets alwaysSpawnDestination.
|
||||
* @return alwaysSpawnLocation
|
||||
*/
|
||||
String getJoinDestination();
|
||||
|
||||
/**
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
*
|
||||
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
|
||||
*/
|
||||
void setUseCustomPortalSearch(boolean useDefaultPortalSearch);
|
||||
|
||||
/**
|
||||
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
|
||||
*
|
||||
* @return True means Bukkit will use its own default values.
|
||||
*/
|
||||
boolean isUsingCustomPortalSearch();
|
||||
|
||||
/**
|
||||
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @param searchRadius The portal search radius.
|
||||
*/
|
||||
void setCustomPortalSearchRadius(int searchRadius);
|
||||
|
||||
/**
|
||||
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @return The portal search radius.
|
||||
*/
|
||||
int getCustomPortalSearchRadius();
|
||||
boolean getTeleportIntercept();
|
||||
|
||||
/**
|
||||
* Sets prefixChat.
|
||||
* @param prefixChat The new value.
|
||||
*/
|
||||
void setEnablePrefixChat(boolean prefixChat);
|
||||
void setPrefixChat(boolean prefixChat);
|
||||
|
||||
/**
|
||||
* Gets prefixChat.
|
||||
* @return prefixChat.
|
||||
*/
|
||||
boolean isEnablePrefixChat();
|
||||
|
||||
boolean getPrefixChat();
|
||||
|
||||
/**
|
||||
* Sets prefixChatFormat.
|
||||
* @param prefixChatFormat The new value.
|
||||
@@ -184,28 +147,28 @@ public interface MVConfig {
|
||||
String getPrefixChatFormat();
|
||||
|
||||
/**
|
||||
* Sets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
|
||||
* @param registerPapiHook The new value.
|
||||
* Sets enforceAccess.
|
||||
* @param enforceAccess The new value.
|
||||
*/
|
||||
void setRegisterPapiHook(boolean registerPapiHook);
|
||||
void setEnforceAccess(boolean enforceAccess);
|
||||
|
||||
/**
|
||||
* Gets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
|
||||
* @return registerPapiHook.
|
||||
* Gets enforceAccess.
|
||||
* @return enforceAccess.
|
||||
*/
|
||||
boolean isRegisterPapiHook();
|
||||
boolean getEnforceAccess();
|
||||
|
||||
/**
|
||||
* Sets globalDebug.
|
||||
* @param globalDebug The new value.
|
||||
* Sets useasyncchat.
|
||||
* @param useAsyncChat The new value.
|
||||
*/
|
||||
void setGlobalDebug(int globalDebug);
|
||||
void setUseAsyncChat(boolean useAsyncChat);
|
||||
|
||||
/**
|
||||
* Gets globalDebug.
|
||||
* @return globalDebug.
|
||||
* Gets useasyncchat.
|
||||
* @return useasyncchat.
|
||||
*/
|
||||
int getGlobalDebug();
|
||||
boolean getUseAsyncChat();
|
||||
|
||||
/**
|
||||
* Sets whether to suppress startup messages.
|
||||
@@ -222,11 +185,46 @@ public interface MVConfig {
|
||||
boolean getSilentStart();
|
||||
|
||||
/**
|
||||
* Sets whether or not the donation/patreon messages are shown.
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
*
|
||||
* @param idonotwanttodonate True if donation/patreon messages should be shown.
|
||||
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
|
||||
*/
|
||||
void setShowDonateMessage(boolean idonotwanttodonate);
|
||||
void setUseDefaultPortalSearch(boolean useDefaultPortalSearch);
|
||||
|
||||
/**
|
||||
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
|
||||
*
|
||||
* @return True means Bukkit will use its own default values.
|
||||
*/
|
||||
boolean isUsingDefaultPortalSearch();
|
||||
|
||||
/**
|
||||
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @param searchRadius The portal search radius.
|
||||
*/
|
||||
void setPortalSearchRadius(int searchRadius);
|
||||
|
||||
/**
|
||||
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @return The portal search radius.
|
||||
*/
|
||||
int getPortalSearchRadius();
|
||||
|
||||
/**
|
||||
* Gets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @return True if automatic purge is enabled.
|
||||
*/
|
||||
boolean isAutoPurgeEnabled();
|
||||
|
||||
/**
|
||||
* Sets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @param autopurge True if automatic purge should be enabled.
|
||||
*/
|
||||
void setAutoPurgeEnabled(boolean autopurge);
|
||||
|
||||
/**
|
||||
* Gets whether or not the donation/patreon messages are shown.
|
||||
@@ -234,4 +232,11 @@ public interface MVConfig {
|
||||
* @return True if donation/patreon messages should be shown.
|
||||
*/
|
||||
boolean isShowingDonateMessage();
|
||||
|
||||
/**
|
||||
* Sets whether or not the donation/patreon messages are shown.
|
||||
*
|
||||
* @param idonotwanttodonate True if donation/patreon messages should be shown.
|
||||
*/
|
||||
void setShowDonateMessage(boolean idonotwanttodonate);
|
||||
}
|
||||
@@ -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,136 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.DebugLog;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
@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,681 @@
|
||||
/******************************************************************************
|
||||
* 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.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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(Material)}
|
||||
*
|
||||
* @param price The Amount of money/item to enter the world.
|
||||
*/
|
||||
void setPrice(double price);
|
||||
|
||||
/**
|
||||
* Gets the type of currency that will be used when users enter this world. A value of null indicates a non-item
|
||||
* based currency is used.
|
||||
*
|
||||
* @return The type of currency that will be used when users enter this world.
|
||||
*/
|
||||
@Nullable
|
||||
Material getCurrency();
|
||||
|
||||
/**
|
||||
* Sets the type of item that will be required given the price is not 0.
|
||||
* Use a value of null to specify a non-item based currency.
|
||||
*
|
||||
* @param item The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
void setCurrency(@Nullable Material item);
|
||||
|
||||
/**
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
*
|
||||
* @return A world that exists on the server.
|
||||
*/
|
||||
World getRespawnToWorld();
|
||||
|
||||
/**
|
||||
* Sets the world players will respawn in if they die in this one.
|
||||
* Returns true upon success, false upon failure.
|
||||
*
|
||||
* @param respawnWorld The name of a world that exists on the server.
|
||||
* @return True if respawnWorld existed, false if not.
|
||||
*/
|
||||
boolean setRespawnToWorld(String respawnWorld);
|
||||
|
||||
/**
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @return This world's non-negative, non-zero scale.
|
||||
*/
|
||||
double getScaling();
|
||||
|
||||
/**
|
||||
* Sets the scale of this world. Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @param scaling A scaling value, cannot be negative or 0.
|
||||
* @return Whether the scale was set successfully.
|
||||
*/
|
||||
boolean setScaling(double scaling);
|
||||
|
||||
/**
|
||||
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @return True if the world should heal (default), false if not.
|
||||
*/
|
||||
boolean getAutoHeal();
|
||||
|
||||
/**
|
||||
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @param heal True if the world will heal.
|
||||
*/
|
||||
void setAutoHeal(boolean heal);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @return True if Multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
boolean getAdjustSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @param adjust True if multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
void setAdjustSpawn(boolean adjust);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-load this world.
|
||||
*
|
||||
* @return True if Multiverse should auto-load this world.
|
||||
*/
|
||||
boolean getAutoLoad();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-load this world.
|
||||
* <p>
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
|
||||
*/
|
||||
void setAutoLoad(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Gets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
*
|
||||
* @return True if players dying in this world should respawn at their bed.
|
||||
*/
|
||||
boolean getBedRespawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
* <p>
|
||||
* True is default.
|
||||
*
|
||||
* @param autoLoad True if players dying in this world respawn at their bed.
|
||||
*/
|
||||
void setBedRespawn(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Sets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @param limit The new limit
|
||||
*/
|
||||
void setPlayerLimit(int limit);
|
||||
|
||||
/**
|
||||
* Gets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @return The player limit
|
||||
*/
|
||||
int getPlayerLimit();
|
||||
|
||||
/**
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
* @return The time as a short string: 12:34pm
|
||||
*/
|
||||
String getTime();
|
||||
|
||||
/**
|
||||
* Sets the current time in a world.
|
||||
* <p>
|
||||
* This method will take the following formats:
|
||||
* 11:37am
|
||||
* 4:30p
|
||||
* day(morning), night, noon, midnight
|
||||
*
|
||||
* @param timeAsString The formatted time to set the world to.
|
||||
* @return True if the time was set, false if not.
|
||||
*/
|
||||
boolean setTime(String timeAsString);
|
||||
|
||||
/**
|
||||
* Sets The types of portals that are allowed in this world.
|
||||
*
|
||||
* @param type The type of portals allowed in this world.
|
||||
*/
|
||||
void allowPortalMaking(AllowedPortalType type);
|
||||
|
||||
/**
|
||||
* Gets which type(s) of portals are allowed to be constructed in this world.
|
||||
*
|
||||
* @return The type of portals that are allowed.
|
||||
*/
|
||||
AllowedPortalType getAllowedPortals();
|
||||
|
||||
// properties that are not "getter+setter" style
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
* regardless of their access permissions.
|
||||
*
|
||||
* @return A List of world names.
|
||||
*/
|
||||
List<String> getWorldBlacklist();
|
||||
|
||||
/**
|
||||
* Gets all the names of all properties that can be SET.
|
||||
*
|
||||
* @return All property names in list.
|
||||
*/
|
||||
Collection<String> getAllPropertyTypes();
|
||||
|
||||
/**
|
||||
* Gets all the names of all properties that can be SET.
|
||||
*
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
|
||||
/**
|
||||
* Whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @return True if players allowed to fly in this world.
|
||||
*/
|
||||
boolean getAllowFlight();
|
||||
|
||||
/**
|
||||
* Sets whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @param allowFlight True to allow flight in this world.
|
||||
*/
|
||||
void setAllowFlight(final boolean allowFlight);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PermissionsInterface {
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired);
|
||||
|
||||
public boolean hasAnyPermission(CommandSender sender, List<String> allPermissionStrings, boolean opRequired);
|
||||
|
||||
public boolean hasAllPermission(CommandSender sender, List<String> allPermissionStrings, boolean opRequired);
|
||||
}
|
||||
@@ -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 extends Teleporter {
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l);
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @param tolerance The tolerance.
|
||||
* @param radius The radius.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l, int tolerance, int radius);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param 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,10 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Teleporter {
|
||||
TeleportResult teleport(CommandSender teleporter, Player teleportee, MVDestination destination);
|
||||
}
|
||||
@@ -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(MultiverseWorld, java.util.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);
|
||||
}
|
||||
+1
-1
@@ -2,4 +2,4 @@
|
||||
* The Multiverse-API, containing lots of interfaces that can be quite useful for other
|
||||
* plugins when interacting with Multiverse.
|
||||
*/
|
||||
package org.mvplugins.multiverse.core.api;
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
@@ -0,0 +1,133 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandAlias("mv")
|
||||
@Subcommand("anchors")
|
||||
public class AnchorCommand extends MultiverseCoreCommand {
|
||||
|
||||
private final AnchorManager anchorManager;
|
||||
|
||||
public AnchorCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.anchorManager = plugin.getAnchorManager();
|
||||
}
|
||||
|
||||
@Subcommand("create")
|
||||
@CommandPermission("multiverse.core.anchor.create")
|
||||
@Syntax("<name>")
|
||||
@Description("Create a new anchor point.")
|
||||
public void onCreateAnchorCommand(@NotNull Player player,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<name>")
|
||||
@Description("Name of your new anchor.")
|
||||
@Flags("type=anchor name")
|
||||
@Single String anchorName) {
|
||||
|
||||
player.sendMessage((this.plugin.getAnchorManager().saveAnchorLocation(anchorName, player.getLocation()))
|
||||
|
||||
? String.format("Anchor '%s%s%s' was successfully %s created!",
|
||||
ChatColor.AQUA, anchorName, ChatColor.WHITE, ChatColor.GREEN)
|
||||
|
||||
: String.format("%sThere was an error creating anchor '%s'! Check console for errors.",
|
||||
ChatColor.RED, anchorName));
|
||||
|
||||
}
|
||||
|
||||
@Subcommand("delete")
|
||||
@CommandPermission("multiverse.core.anchor.delete")
|
||||
@Syntax("<anchor>")
|
||||
@CommandCompletion("@anchors")
|
||||
@Description("Delete an existing anchor point.")
|
||||
public void onDeleteAnchorCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<name>")
|
||||
@Description("Name of anchor you want to delete.")
|
||||
@Flags("type=anchor name")
|
||||
@Single String anchorName) {
|
||||
|
||||
sender.sendMessage((this.plugin.getAnchorManager().deleteAnchor(anchorName))
|
||||
|
||||
? String.format("Anchor '%s%s%s' was successfully %s deleted!",
|
||||
ChatColor.AQUA, anchorName, ChatColor.WHITE, ChatColor.RED)
|
||||
|
||||
: String.format("%sThere was an error deleting anchor '%s'! Check console for errors.",
|
||||
ChatColor.RED, anchorName));
|
||||
}
|
||||
|
||||
@Subcommand("list")
|
||||
@CommandPermission("multiverse.core.anchor.list")
|
||||
@Syntax("[filter] [page]")
|
||||
@Description("View a list of current anchors.")
|
||||
public void onListAnchorCommand(@NotNull CommandSender sender,
|
||||
@NotNull PageFilter pageFilter) {
|
||||
|
||||
new ContentDisplay.Builder<Collection<String>>()
|
||||
.sender(sender)
|
||||
.header("%s====[ Multiverse Anchor List ]====", ChatColor.LIGHT_PURPLE)
|
||||
.contents(buildAnchorList(sender))
|
||||
.emptyMessage("You do not any anchors set. See /mv anchors create to get started!")
|
||||
.displayHandler(DisplayHandlers.PAGE_LIST)
|
||||
.colorTool(ColorAlternator.with(ChatColor.YELLOW, ChatColor.DARK_AQUA))
|
||||
.setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
|
||||
.display();
|
||||
}
|
||||
|
||||
private List<String> buildAnchorList(@NotNull CommandSender sender) {
|
||||
Set<String> anchors = (sender instanceof Player)
|
||||
? this.anchorManager.getAnchors((Player) sender)
|
||||
: this.anchorManager.getAllAnchors();
|
||||
|
||||
List<String> anchorContent = new ArrayList<>();
|
||||
for (String anchor : anchors) {
|
||||
Location anchorLocation = this.anchorManager.getAnchorLocation(anchor);
|
||||
World world = anchorLocation.getWorld(); // this.plugin.getMVWorldManager().getMVWorld();
|
||||
|
||||
String locationString = ChatColor.RED + "!!INVALID!!";
|
||||
if (world != null) {
|
||||
MultiverseWorld mvWorld = this.plugin.getMVWorldManager().getMVWorld(world);
|
||||
locationString = (mvWorld == null)
|
||||
? String.format("%s%s !!NOT MULTIVERSE WORLD!!", ChatColor.RED, world.getName())
|
||||
: String.format("%s - %s", mvWorld.getColoredWorldString(), this.plugin.getLocationManipulation().strAxis(anchorLocation));
|
||||
}
|
||||
anchorContent.add(String.format("%s: %s", anchor, locationString));
|
||||
}
|
||||
|
||||
return anchorContent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class BedCommand extends MultiverseCoreCommand {
|
||||
|
||||
public BedCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("bed")
|
||||
@CommandPermission("multiverse.core.bed.self")
|
||||
@Description("Takes your current respawn point.")
|
||||
public void onBedCommand(@NotNull Player player) {
|
||||
doBedRespawn(player, player);
|
||||
}
|
||||
|
||||
@Subcommand("bed")
|
||||
@CommandPermission("multiverse.core.bed.other")
|
||||
@Syntax("[player]")
|
||||
@CommandCompletion("@players")
|
||||
@Description("Takes another player to their respawn location.")
|
||||
public void onOtherBedCommand(@NotNull CommandSender sender,
|
||||
|
||||
@Syntax("[player]")
|
||||
@Description("Target player to teleport to respawn location.")
|
||||
@NotNull RequiredPlayer player) {
|
||||
|
||||
doBedRespawn(sender, player.get());
|
||||
}
|
||||
|
||||
private void doBedRespawn(@NotNull CommandSender sender,
|
||||
@NotNull Player player) {
|
||||
|
||||
Location bedLocation = player.getBedSpawnLocation();
|
||||
if (bedLocation == null) {
|
||||
sender.sendMessage(String.format("%sYou do not have a respawn point set!", ChatColor.RED));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage((player.teleport(bedLocation))
|
||||
? "You have been teleported to your respawn point!"
|
||||
: String.format("%sThere was an error teleporting you to your respawn point.", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class CheckCommand extends MultiverseCoreCommand {
|
||||
|
||||
public CheckCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("check")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@Syntax("<player> <destination>")
|
||||
@CommandCompletion("@players @destinations|@MVWorlds")
|
||||
@Description("Checks to see if a player can go to a destination. Prints debug if false.")
|
||||
public void onCheckCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<player>")
|
||||
@Description("Player to check destination on.")
|
||||
RequiredPlayer player,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<destination>")
|
||||
@Description("A destination location, e.g. a world name.")
|
||||
MVDestination destination) {
|
||||
|
||||
this.plugin.getMVPerms().tellMeWhyICantDoThis(sender, player.get(), destination);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class CloneCommand extends MultiverseCoreCommand {
|
||||
|
||||
public CloneCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("clone")
|
||||
@CommandPermission("multiverse.core.clone")
|
||||
@Syntax("<world> <name>")
|
||||
@CommandCompletion("@MVWorlds|@unloadedWorlds @empty")
|
||||
@Description("Clones a world.")
|
||||
public void onCloneCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<world>")
|
||||
@Description("Current multiverse world.")
|
||||
@Conditions("isWorldInConfig") String worldName,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<name>")
|
||||
@Description("New cloned world name.")
|
||||
@Single @Flags("trim") @Conditions("creatableWorldName") String newWorldName) {
|
||||
|
||||
sender.sendMessage((this.plugin.getMVWorldManager().cloneWorld(worldName, newWorldName))
|
||||
? String.format("%sWorld cloned!", ChatColor.GREEN)
|
||||
: String.format("%sWorld could not be cloned! See console for more details.", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import co.aikar.commands.annotation.Values;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@CommandAlias("mv")
|
||||
@Subcommand("config")
|
||||
@CommandPermission("multiverse.core.config")
|
||||
public class ConfigCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ConfigCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("list")
|
||||
@Syntax("[filter]")
|
||||
@Description("Show multiverse config values.")
|
||||
public void onShowCommand(@NotNull CommandSender sender,
|
||||
@NotNull ContentFilter filter) {
|
||||
|
||||
new ContentDisplay.Builder<Map<String, Object>>()
|
||||
.sender(sender)
|
||||
.header("%s===[ Multiverse Config ]===", ChatColor.LIGHT_PURPLE)
|
||||
.contents(this.plugin.getMVConfig().serialize())
|
||||
.emptyMessage("No config values found.")
|
||||
.displayHandler(DisplayHandlers.INLINE_MAP)
|
||||
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
|
||||
.filter(filter)
|
||||
.display();
|
||||
}
|
||||
|
||||
@Subcommand("set")
|
||||
@Syntax("<property> <value>")
|
||||
@CommandCompletion("@MVConfigs")
|
||||
@Description("Set Global MV Variables.")
|
||||
public void onSetCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<property>")
|
||||
@Description("Config option.")
|
||||
@Values("@MVConfigs") String property,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<value>")
|
||||
@Description("New value for the given config option.")
|
||||
@Single String value) {
|
||||
|
||||
property = property.toLowerCase();
|
||||
|
||||
if (!this.plugin.getMVConfig().setConfigProperty(property, value)) {
|
||||
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, property, value));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.saveMVConfigs()) {
|
||||
sender.sendMessage(String.format("%sFailed to save config! Check your console for details.", ChatColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
// special rule, don't forget to set the world!
|
||||
//TODO API: Potentially should move to MultiverseCore#loadConfigs method
|
||||
if (property.equalsIgnoreCase("firstspawnworld")) {
|
||||
this.plugin.getMVWorldManager().setFirstSpawnWorld(value);
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%sSuccess! %sConfig option %s%s %sis now set to %s%s%s.",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, property, ChatColor.WHITE, ChatColor.GREEN, value, ChatColor.WHITE));
|
||||
|
||||
this.plugin.loadConfigs();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class ConfirmCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ConfirmCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("confirm")
|
||||
@CommandPermission("multiverse.core.confirm")
|
||||
@Description("Confirms dangerous commands before executing them.")
|
||||
public void onConfirmCommand(@NotNull CommandSender sender) {
|
||||
this.plugin.getMVCommandManager().getQueueManager().runQueuedCommand(sender);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class CoordCommand extends MultiverseCoreCommand {
|
||||
|
||||
public CoordCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("coord|coordinate")
|
||||
@CommandPermission("multiverse.core.coord.self")
|
||||
@Description("Detailed information on your own where abouts.")
|
||||
public void onCoordCommand(@NotNull Player player) {
|
||||
showCoordInfo(player, player);
|
||||
}
|
||||
|
||||
@Subcommand("coord|coordinate")
|
||||
@CommandPermission("multiverse.core.coord.other")
|
||||
@Syntax("[player]")
|
||||
@CommandCompletion("@players")
|
||||
@Description("Detailed information on the player's where abouts.")
|
||||
public void onOtherCoordCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[player]")
|
||||
@Description("Player you want coordinate info of.")
|
||||
RequiredPlayer player) {
|
||||
|
||||
showCoordInfo(sender, player.get());
|
||||
}
|
||||
|
||||
private void showCoordInfo(@NotNull CommandSender sender,
|
||||
@NotNull Player player) {
|
||||
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld());
|
||||
if (world == null) {
|
||||
throw new InvalidCommandArgument("Player is not in a multiverse world.");
|
||||
}
|
||||
|
||||
String name = player.equals(sender)
|
||||
? ""
|
||||
: String.format("for %s%s%s",ChatColor.YELLOW, player.getName(), ChatColor.AQUA);
|
||||
|
||||
sender.sendMessage(String.format("%s--- Location Information %s---", ChatColor.AQUA, name));
|
||||
sender.sendMessage(String.format("%sWorld: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getName()));
|
||||
sender.sendMessage(String.format("%sAlias: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getColoredWorldString()));
|
||||
sender.sendMessage(String.format("%sWorld Scale: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getScaling()));
|
||||
sender.sendMessage(String.format("%sCoordinates: %s%s", ChatColor.AQUA, ChatColor.WHITE, this.plugin.getLocationManipulation().strCoords(player.getLocation())));
|
||||
sender.sendMessage(String.format("%sWorld Scale: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getScaling()));
|
||||
sender.sendMessage(String.format("%sDirection: %s%s", ChatColor.AQUA, ChatColor.WHITE, this.plugin.getLocationManipulation().getDirection(player.getLocation())));
|
||||
sender.sendMessage(String.format("%sBlock: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getCBWorld().getBlockAt(player.getLocation()).getType()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static org.bukkit.World.*;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class CreateCommand extends MultiverseCoreCommand {
|
||||
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setFlagGroup(FlagGroup.of(
|
||||
CoreFlags.WORLD_TYPE,
|
||||
CoreFlags.SEED,
|
||||
CoreFlags.GENERATOR,
|
||||
CoreFlags.GENERATE_STRUCTURES,
|
||||
CoreFlags.SPAWN_ADJUST
|
||||
));
|
||||
}
|
||||
|
||||
@Subcommand("create")
|
||||
@CommandPermission("multiverse.core.create")
|
||||
@Syntax("<name> <env> -s [seed] -g [generator[:id]] -t [worldtype] [-n] -a [true|false]")
|
||||
@CommandCompletion("@empty @environments @flags")
|
||||
@Description("Creates a new world and loads it.")
|
||||
public void onCreateCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<name>")
|
||||
@Description("New world name.")
|
||||
@Flags("trim")
|
||||
@Conditions("creatableWorldName") String worldName,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<env>")
|
||||
@Description("The world's environment. See: /mv env")
|
||||
Environment environment,
|
||||
|
||||
@Nullable
|
||||
@Syntax("[world-flags]")
|
||||
@Description("Other world settings. See: http://gg.gg/nn8bl")
|
||||
String[] flagsArray) {
|
||||
|
||||
FlagResult flags = this.getFlagGroup().calculateResult(flagsArray);
|
||||
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting creation of world '%s'...", worldName));
|
||||
Command.broadcastCommandMessage(sender, (this.plugin.getMVWorldManager().addWorld(
|
||||
worldName,
|
||||
environment,
|
||||
// TODO API: Should Allow FlagResult object to be passed directly
|
||||
flags.getValue(CoreFlags.SEED),
|
||||
flags.getValue(CoreFlags.WORLD_TYPE),
|
||||
flags.getValue(CoreFlags.GENERATE_STRUCTURES),
|
||||
flags.getValue(CoreFlags.GENERATOR),
|
||||
flags.getValue(CoreFlags.SPAWN_ADJUST))
|
||||
)
|
||||
? String.format("%sComplete!", ChatColor.GREEN)
|
||||
: String.format("%sFailed! See console for errors.", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
public class DebugCommand extends MultiverseCoreCommand {
|
||||
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("debug")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@Description("Show the current debug level.")
|
||||
public void onShowDebugCommand(@NotNull CommandSender sender) {
|
||||
displayDebugMode(sender);
|
||||
}
|
||||
|
||||
@Subcommand("debug")
|
||||
@CommandPermission("multiverse.core.debug")
|
||||
@Syntax("<level>")
|
||||
@CommandCompletion("@toggles|@range:3")
|
||||
@Description("Change debug level.")
|
||||
public void onChangeDebugCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<level>")
|
||||
@Description("Set debug mode level, 0 to 3.")
|
||||
@Single String debugLevel) {
|
||||
|
||||
int parsedLevel = parseDebugLevel(debugLevel);
|
||||
if (parsedLevel == -1) {
|
||||
throw new InvalidCommandArgument("No such debug level. Please use a number from 0 to 3.");
|
||||
}
|
||||
|
||||
this.plugin.getMVConfig().setGlobalDebug(parsedLevel);
|
||||
if (!this.plugin.saveMVConfigs()) {
|
||||
sender.sendMessage(String.format("%sError saving changes to config! See console for more info.", ChatColor.RED));
|
||||
}
|
||||
|
||||
displayDebugMode(sender);
|
||||
}
|
||||
|
||||
private int parseDebugLevel(@NotNull String debugLevel) {
|
||||
if (debugLevel.equalsIgnoreCase("off")) {
|
||||
return 0;
|
||||
}
|
||||
if (debugLevel.equalsIgnoreCase("on")) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
int parsedLevel = Integer.parseInt(debugLevel);
|
||||
return (parsedLevel > 3 || parsedLevel < 0) ? -1 : parsedLevel;
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void displayDebugMode(@NotNull CommandSender sender) {
|
||||
int debugLevel = this.plugin.getMVConfig().getGlobalDebug();
|
||||
if (debugLevel == 0) {
|
||||
sender.sendMessage(String.format("Multiverse Debug mode is %soff", ChatColor.RED));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(String.format("Multiverse Debug mode at level %s%s", ChatColor.GREEN, debugLevel));
|
||||
Logging.fine("Multiverse debug mode enabled!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class DeleteCommand extends MultiverseCoreCommand {
|
||||
|
||||
public DeleteCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("delete")
|
||||
@CommandPermission("multiverse.core.delete")
|
||||
@Syntax("<world>")
|
||||
@CommandCompletion("@MVWorlds|@unloadedWorlds")
|
||||
@Description("Deletes a world on your server PERMANENTLY.")
|
||||
public void onDeleteCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<world>")
|
||||
@Description("Multiverse world you want to delete.")
|
||||
@Flags("trim")
|
||||
@Conditions("isWorldInConfig|validWorldFolder")
|
||||
@Single String worldName) {
|
||||
|
||||
this.plugin.getMVCommandManager().getQueueManager().addToQueue(new QueuedCommand.Builder()
|
||||
.sender(sender)
|
||||
.action(deleteRunnable(sender, worldName))
|
||||
.prompt("Are you sure you want to delete world '%s'?", worldName)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private Runnable deleteRunnable(@NotNull CommandSender sender,
|
||||
@NotNull String worldName) {
|
||||
|
||||
return () -> {
|
||||
sender.sendMessage(String.format("Deleting world '%s'...", worldName));
|
||||
sender.sendMessage((this.plugin.getMVWorldManager().deleteWorld(worldName))
|
||||
? String.format("%sWorld %s was deleted!", ChatColor.GREEN, worldName)
|
||||
: String.format("%sThere was an issue deleting '%s'! Please check console for errors.", ChatColor.RED, worldName));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class EnvironmentCommand extends MultiverseCoreCommand {
|
||||
|
||||
public EnvironmentCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("env|environments")
|
||||
@CommandPermission("multiverse.core.list.environments")
|
||||
@Description("Lists valid known environments and world types.")
|
||||
public void onEnvironmentCommand(CommandSender sender) {
|
||||
showEnvironments(sender);
|
||||
sender.sendMessage("");
|
||||
showWorldTypes(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows all valid known environments to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
public static void showEnvironments(CommandSender sender) {
|
||||
sender.sendMessage(String.format("%sValid Environments are:", ChatColor.YELLOW));
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sNETHER %sor %sEND",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.AQUA));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows all valid known world types to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
public static void showWorldTypes(CommandSender sender) {
|
||||
sender.sendMessage(String.format("%sValid World Types are:", ChatColor.YELLOW));
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT%s, %sLARGEBIOMES %sor %sAMPLIFIED",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleProperty;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandAlias("mv")
|
||||
@Subcommand("gamerule")
|
||||
public class GameRuleCommand extends MultiverseCoreCommand {
|
||||
|
||||
public GameRuleCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("list")
|
||||
@CommandPermission("multiverse.core.gamerule.list")
|
||||
@Syntax("[world] [filter]")
|
||||
@CommandCompletion("@MVWorlds")
|
||||
@Description("See the list gamerules values for a given world.")
|
||||
public void onGameRulesCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World you want to see game rule info.")
|
||||
@Flags("other,defaultself, fallbackself") MultiverseWorld world,
|
||||
|
||||
@NotNull ContentFilter filter) {
|
||||
|
||||
new ContentDisplay.Builder<Map<String, Object>>()
|
||||
.sender(sender)
|
||||
.header("=== Gamerules for %s%s%s ===", ChatColor.AQUA, world.getName(), ChatColor.WHITE)
|
||||
.contents(getGameRuleMap(world))
|
||||
.displayHandler(DisplayHandlers.INLINE_MAP)
|
||||
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
|
||||
.setting(DisplaySettings.OPERATOR, ": ")
|
||||
.filter(filter)
|
||||
.display();
|
||||
}
|
||||
|
||||
private Map<String, Object> getGameRuleMap(MultiverseWorld world) {
|
||||
return new HashMap<String, Object>() {{
|
||||
Arrays.stream(GameRule.values())
|
||||
.forEach(gr -> {
|
||||
Object value = world.getCBWorld().getGameRuleValue(gr);
|
||||
if (value != null) {
|
||||
put(gr.getName(), value.toString());
|
||||
}
|
||||
});
|
||||
}};
|
||||
}
|
||||
|
||||
@Subcommand("set")
|
||||
@CommandPermission("multiverse.core.gamerule.set")
|
||||
@Syntax("<rule> <value> [world]")
|
||||
@CommandCompletion("@gameRules @empty @MVWorlds")
|
||||
@Description("Allows a player to set a gamerule for a given world.")
|
||||
public <T> void onGameRuleChangeCommand(@NotNull CommandSender sender,
|
||||
@NotNull Player player,
|
||||
|
||||
@Syntax("<rule> <value>")
|
||||
@Description("Game rule property and value you want to change to.")
|
||||
@NotNull GameRuleProperty<T> property,
|
||||
|
||||
@Syntax("[world]")
|
||||
@Description("World you want to set this game rule.")
|
||||
@NotNull @Flags("other,defaultself") MultiverseWorld world) {
|
||||
|
||||
sender.sendMessage((world.getCBWorld().setGameRule(property.getGameRule(), property.getValue()))
|
||||
|
||||
? String.format("%sSuccess! %sGamerule %s%s%s was set to %s%s%s.",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, property.getGameRule().getName(),
|
||||
ChatColor.WHITE, ChatColor.GREEN, property.getValue(), ChatColor.WHITE)
|
||||
|
||||
: String.format("%sFailure! Gamerule %s%s%s could not be set to %s%s%s.",
|
||||
ChatColor.RED, ChatColor.AQUA, property.getGameRule().getName(),
|
||||
ChatColor.RED, ChatColor.DARK_RED, property.getValue(), ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class GeneratorCommand extends MultiverseCoreCommand {
|
||||
|
||||
public GeneratorCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("gens|generators")
|
||||
@CommandPermission("multiverse.core.generator")
|
||||
@Description("Shows a list of Loaded Generator Plugins.")
|
||||
public void onGeneratorCommand(@NotNull CommandSender sender) {
|
||||
new ContentDisplay.Builder<Collection<String>>()
|
||||
.sender(sender)
|
||||
.header("%s--- Available Generator Plugins ---", ChatColor.GOLD)
|
||||
.contents(CoreFlags.GENERATOR.suggestValue())
|
||||
.emptyMessage("%sYou do not have any generator plugins installed.", ChatColor.RED)
|
||||
.displayHandler(DisplayHandlers.INLINE_LIST)
|
||||
.colorTool(ColorAlternator.with(ChatColor.AQUA, ChatColor.WHITE))
|
||||
.display();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static org.bukkit.World.*;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class ImportCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ImportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setFlagGroup(FlagGroup.of(CoreFlags.GENERATOR, CoreFlags.SPAWN_ADJUST));
|
||||
}
|
||||
|
||||
@Subcommand("import")
|
||||
@CommandPermission("multiverse.core.import")
|
||||
@Syntax("<name> <env> -g [generator[:id]] [-n]")
|
||||
@CommandCompletion("@potentialWorlds @environments @flags")
|
||||
@Description("Imports a new world into multiverse.")
|
||||
public void onImportCommand(@NotNull CommandSender sender,
|
||||
|
||||
@Syntax("<name>")
|
||||
@Description("Folder name of the world.")
|
||||
@NotNull @co.aikar.commands.annotation.Flags("trim") @Conditions("importableWorldName") String worldName,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<env>")
|
||||
@Description("The world's environment. See: /mv env")
|
||||
Environment environment,
|
||||
|
||||
@Nullable
|
||||
@Syntax("-g [generator[:id]] [-n]")
|
||||
@Description("Other world settings. See: http://gg.gg/nn8c2")
|
||||
String[] flagsArray) {
|
||||
|
||||
FlagResult flags = this.getFlagGroup().calculateResult(flagsArray);
|
||||
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
|
||||
Command.broadcastCommandMessage(sender, (this.plugin.getMVWorldManager().addWorld(worldName,
|
||||
environment,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
flags.getValue(CoreFlags.GENERATOR),
|
||||
flags.getValue(CoreFlags.SPAWN_ADJUST))
|
||||
)
|
||||
? String.format("%sComplete!", ChatColor.GREEN)
|
||||
: String.format("%sFailed! See console for more details.", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class InfoCommand extends MultiverseCoreCommand {
|
||||
|
||||
public InfoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("info")
|
||||
@CommandPermission("multiverse.core.info")
|
||||
@Syntax("[world] [page]")
|
||||
@CommandCompletion("@MVWorlds @range:1-5")
|
||||
@Description("Display detailed information of the world.")
|
||||
public void onInfoCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World you want to see info.")
|
||||
@Flags("other,defaultself,fallbackself") MultiverseWorld world,
|
||||
|
||||
@Syntax("[page]")
|
||||
@Description("Info page to display.")
|
||||
@Default("1") int page) {
|
||||
|
||||
new ContentDisplay.Builder<Collection<String>>()
|
||||
.sender(sender)
|
||||
.contents(buildWorldInfoContent(world))
|
||||
.displayHandler(DisplayHandlers.PAGE_LIST)
|
||||
.colorTool(ColorAlternator.with(ChatColor.YELLOW, ChatColor.AQUA)).setting(DisplaySettings.SHOW_PAGE, page)
|
||||
.display();
|
||||
}
|
||||
|
||||
private List<String> buildWorldInfoContent(MultiverseWorld world) {
|
||||
List<String> contents = new ArrayList<>(38);
|
||||
|
||||
// Page 1
|
||||
contents.add(parseHeader("General Info"));
|
||||
contents.add(String.format("World Name: %s%s", ChatColor.WHITE, world.getName()));
|
||||
contents.add(String.format("World Alias: %s%s", ChatColor.WHITE, world.getColoredWorldString()));
|
||||
contents.add(String.format("Game Mode: %s%s", ChatColor.WHITE, world.getGameMode().toString()));
|
||||
contents.add(String.format("Difficulty: %s%s", ChatColor.WHITE, world.getDifficulty().toString()));
|
||||
contents.add(String.format("Spawn Location: %s%s", ChatColor.WHITE, this.plugin.getLocationManipulation().strCoords(world.getSpawnLocation())));
|
||||
contents.add(String.format("World Seed: %s%s", ChatColor.WHITE, world.getSeed()));
|
||||
String priceString = (world.getPrice() == 0)
|
||||
? String.format("%sFREE!", ChatColor.GREEN)
|
||||
: plugin.getEconomist().formatPrice(-world.getPrice(), world.getCurrency());
|
||||
contents.add(String.format((world.getPrice() >= 0)
|
||||
? "Price to enter this world: %s%s"
|
||||
: "Reward for entering this world: %s%s", ChatColor.WHITE, priceString));
|
||||
World respawnWorld = world.getRespawnToWorld();
|
||||
MultiverseWorld respawn = this.plugin.getMVWorldManager().getMVWorld(respawnWorld);
|
||||
String respawnWorldString = (respawn != null)
|
||||
? respawn.getColoredWorldString()
|
||||
: ChatColor.RED + "!!INVALID!!";
|
||||
contents.add(String.format("Players will respawn in: %s%s", ChatColor.WHITE, respawnWorldString));
|
||||
contents.add(ContentDisplay.LINE_BREAK);
|
||||
|
||||
// Page 2
|
||||
contents.add(parseHeader("More World Settings"));
|
||||
contents.add(String.format("World UID: %s%s", ChatColor.WHITE, world.getCBWorld().getUID()));
|
||||
contents.add(String.format("World Type: %s%s", ChatColor.WHITE, world.getWorldType().toString()));
|
||||
contents.add(String.format("World Scale: %s%s", ChatColor.WHITE, world.getScaling()));
|
||||
contents.add(String.format("Generator: %s%s", ChatColor.WHITE, world.getGenerator()));
|
||||
contents.add(String.format("Structures: %s%s", ChatColor.WHITE, world.getCBWorld().canGenerateStructures()));
|
||||
contents.add(String.format("Weather: %s%s", ChatColor.WHITE, world.isWeatherEnabled()));
|
||||
contents.add(String.format("Players will get hungry: %s%s", ChatColor.WHITE, world.getHunger()));
|
||||
contents.add(String.format("Keep spawn in memory: %s%s", ChatColor.WHITE, world.isKeepingSpawnInMemory()));
|
||||
contents.add(ContentDisplay.LINE_BREAK);
|
||||
|
||||
// Page 3
|
||||
contents.add(parseHeader("PVP Settings"));
|
||||
contents.add(String.format("Multiverse Setting: %s%s", ChatColor.WHITE, world.isPVPEnabled()));
|
||||
contents.add(String.format("Bukkit Setting: %s%s", ChatColor.WHITE, world.getCBWorld().getPVP()));
|
||||
contents.add(ContentDisplay.LINE_BREAK);
|
||||
|
||||
// Page 4
|
||||
contents.add(parseHeader("Monster Settings"));
|
||||
contents.add(String.format("Multiverse Setting: %s%s", ChatColor.WHITE, world.canMonstersSpawn()));
|
||||
contents.add(String.format("Bukkit Setting: %s%s", ChatColor.WHITE, world.getCBWorld().getAllowMonsters()));
|
||||
contents.add((world.canMonstersSpawn())
|
||||
? String.format("Monsters that %scannot spawn: %s%s", ChatColor.RED, ChatColor.WHITE, toCommaSeparated(world.getMonsterList()))
|
||||
: String.format("Monsters that %scan spawn: %s%s", ChatColor.GREEN, ChatColor.WHITE, toCommaSeparated(world.getMonsterList())));
|
||||
contents.add(ContentDisplay.LINE_BREAK);
|
||||
|
||||
// Page 5
|
||||
contents.add(parseHeader("Animal Settings"));
|
||||
contents.add(String.format("Multiverse Setting: %s%s", ChatColor.WHITE, world.canAnimalsSpawn()));
|
||||
contents.add(String.format("Bukkit Setting: %s%s", ChatColor.WHITE, world.getCBWorld().getAllowAnimals()));
|
||||
contents.add((world.canAnimalsSpawn())
|
||||
? String.format("Animals that %scannot spawn: %s%s", ChatColor.RED, ChatColor.WHITE, toCommaSeparated(world.getAnimalList()))
|
||||
: String.format("Animals that %scan spawn: %s%s", ChatColor.GREEN, ChatColor.WHITE, toCommaSeparated(world.getAnimalList())));
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
private String parseHeader(String header) {
|
||||
return String.format("%s===[ %s %s]===", ChatColor.AQUA, header, ChatColor.AQUA);
|
||||
}
|
||||
|
||||
private static String toCommaSeparated(List<String> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return ChatColor.GRAY + ChatColor.ITALIC.toString() + "none";
|
||||
}
|
||||
if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder(list.get(0));
|
||||
for (int i = 1; i < list.size() - 1; i++) {
|
||||
result.append(", ").append(list.get(i));
|
||||
}
|
||||
result.append(" and ").append(list.get(list.size() - 1));
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class ListCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ListCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("list")
|
||||
@CommandPermission("multiverse.core.list.worlds")
|
||||
@Syntax("[filter] [page]")
|
||||
@Description("Displays a listing of all worlds that you can enter.")
|
||||
public void onListCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull PageFilter pageFilter) {
|
||||
|
||||
new ContentDisplay.Builder<Collection<String>>()
|
||||
.sender(sender)
|
||||
.header("%s====[ Multiverse World List ]====", ChatColor.GOLD)
|
||||
.contents(getListContents(sender))
|
||||
.displayHandler(DisplayHandlers.PAGE_LIST)
|
||||
.colorTool(ColorAlternator.with(ChatColor.AQUA, ChatColor.GOLD))
|
||||
.setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
|
||||
.display();
|
||||
}
|
||||
|
||||
private List<String> getListContents(@NotNull CommandSender sender) {
|
||||
Player player = (sender instanceof Player) ? (Player) sender : null;
|
||||
List<String> worldList = new ArrayList<>();
|
||||
|
||||
this.plugin.getMVWorldManager().getMVWorlds().stream()
|
||||
.filter(world -> player == null || plugin.getMVPerms().canEnterWorld(player, world))
|
||||
.filter(world -> canSeeWorld(player, world))
|
||||
.map(world -> hiddenText(world) + world.getColoredWorldString() + " - " + parseColouredEnvironment(world.getEnvironment()))
|
||||
.sorted()
|
||||
.forEach(worldList::add);
|
||||
|
||||
this.plugin.getMVWorldManager().getUnloadedWorlds().stream()
|
||||
.filter(world -> plugin.getMVPerms().hasPermission(sender, "multiverse.access." + world, true))
|
||||
.map(world -> ChatColor.GRAY + world + " - UNLOADED")
|
||||
.sorted()
|
||||
.forEach(worldList::add);
|
||||
|
||||
return worldList;
|
||||
}
|
||||
|
||||
private boolean canSeeWorld(Player player, MultiverseWorld world) {
|
||||
return !world.isHidden()
|
||||
|| player == null
|
||||
|| this.plugin.getMVPerms().hasPermission(player, "multiverse.core.modify", true);
|
||||
}
|
||||
|
||||
private String hiddenText(MultiverseWorld world) {
|
||||
return (world.isHidden()) ? String.format("%s[H] ", ChatColor.GRAY) : "";
|
||||
}
|
||||
|
||||
private String parseColouredEnvironment(World.Environment env) {
|
||||
ChatColor color = ChatColor.GOLD;
|
||||
switch (env) {
|
||||
case NETHER:
|
||||
color = ChatColor.RED;
|
||||
break;
|
||||
case NORMAL:
|
||||
color = ChatColor.GREEN;
|
||||
break;
|
||||
case THE_END:
|
||||
color = ChatColor.AQUA;
|
||||
break;
|
||||
}
|
||||
return color + env.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class LoadCommand extends MultiverseCoreCommand {
|
||||
|
||||
public LoadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("load")
|
||||
@CommandPermission("multiverse.core.load")
|
||||
@Syntax("<world>")
|
||||
@CommandCompletion("@unloadedWorlds")
|
||||
@Description("Loads a world. World must be already in worlds.yml, else please use /mv import.")
|
||||
public void onLoadCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<world>")
|
||||
@Description("Name of world you want to load.")
|
||||
@Flags("type=world name")
|
||||
@Conditions("isUnloadedWorld") String worldName) {
|
||||
|
||||
if (!this.plugin.getMVWorldManager().loadWorld(worldName)) {
|
||||
sender.sendMessage(String.format("Error trying to load world '%s'!", worldName));
|
||||
return;
|
||||
}
|
||||
Command.broadcastCommandMessage(sender, String.format("Loaded world '%s'!", worldName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandAlias("mv")
|
||||
@Subcommand("modify")
|
||||
//TODO API: Think why properties method for MultiverseWorld is deprecated.
|
||||
public class ModifyCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ModifyCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("set")
|
||||
@CommandPermission("multiverse.core.modify.set")
|
||||
@Syntax("<property> <value> [world]")
|
||||
@CommandCompletion("@setProperties @empty @MVWorlds")
|
||||
@Description("Modify various aspects of worlds by setting a property. For more info; https://tinyurl.com/nehhzp6")
|
||||
public void onModifySetCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<property>")
|
||||
@Description("Property option key.")
|
||||
@Flags("type=property")
|
||||
@Conditions("validAddProperty:set") String property,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<value>")
|
||||
@Description("New property value.")
|
||||
@Flags("type=property value") String value,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World that you want property change to apply.")
|
||||
@Flags("other,defaultself") MultiverseWorld world) {
|
||||
|
||||
if ((property.equalsIgnoreCase("aliascolor")
|
||||
|| property.equalsIgnoreCase("color"))
|
||||
&& !EnglishChatColor.isValidAliasColor(value)) {
|
||||
sender.sendMessage(String.format("%s'%s' is not a valid color. Please pick one of the following:",
|
||||
ChatColor.RED, value));
|
||||
sender.sendMessage(EnglishChatColor.getAllColors());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!world.setPropertyValue(property, value)) {
|
||||
sender.sendMessage(ChatColor.RED + world.getPropertyHelp(property));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (PropertyDoesNotExistException e) {
|
||||
sender.sendMessage(String.format("%sSorry, You can't set '%s%s%s'!", ChatColor.RED, ChatColor.GRAY, property, ChatColor.RED));
|
||||
sender.sendMessage(String.format("Valid world-properties: %s", world.getAllPropertyNames()));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%sSuccess! %sProperty %s%s %swas set to %s%s%s.",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, property, ChatColor.WHITE, ChatColor.GREEN, value, ChatColor.WHITE));
|
||||
saveWorldConfig();
|
||||
}
|
||||
|
||||
@Subcommand("add")
|
||||
@CommandPermission("multiverse.core.modify.add")
|
||||
@Syntax("<property> <value> [world]")
|
||||
@CommandCompletion("@addProperties @empty @MVWorlds")
|
||||
@Description("Modify various aspects of worlds by adding a property. For more info: https://tinyurl.com/nehhzp6")
|
||||
public void onModifyAddCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<property>")
|
||||
@Description("Property option key.")
|
||||
@Flags("type=property")
|
||||
@Conditions("validAddProperty:add") String property,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<value>")
|
||||
@Description("Property value to add.")
|
||||
@Flags("type=property value") String value,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World that you want property change to apply.")
|
||||
@Flags("other,defaultself") MultiverseWorld world) {
|
||||
|
||||
if (!world.addToVariable(property, value)) {
|
||||
sender.sendMessage(String.format("%s %scould not be added to %s%s%s.",
|
||||
value, ChatColor.RED, ChatColor.AQUA, property, ChatColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%sSuccess! %s%s%s was added to %s%s%s.",
|
||||
ChatColor.GREEN, ChatColor.AQUA, value, ChatColor.WHITE, ChatColor.GREEN, property, ChatColor.WHITE));
|
||||
|
||||
saveWorldConfig();
|
||||
}
|
||||
|
||||
@Subcommand("remove")
|
||||
@CommandPermission("multiverse.core.modify.remove")
|
||||
@Syntax("<property> <value> [world]")
|
||||
@CommandCompletion("@addProperties @empty @MVWorlds")
|
||||
@Description("Modify various aspects of worlds by removing a property. For more info: https://tinyurl.com/nehhzp6")
|
||||
public void onModifyRemoveCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<property>")
|
||||
@Description("Property option key.")
|
||||
@Flags("type=property")
|
||||
@Conditions("validAddProperty:remove") String property,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<value>")
|
||||
@Description("Property value to remove.")
|
||||
@Flags("type=property value") String value,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World that you want property change to apply.")
|
||||
@Flags("other,defaultself") MultiverseWorld world) {
|
||||
|
||||
if (!world.removeFromVariable(property, value)) {
|
||||
sender.sendMessage(String.format("%sThere was an error removing %s%s%s from %s%s%s!",
|
||||
ChatColor.RED, ChatColor.GRAY, value, ChatColor.RED, ChatColor.GRAY, property, ChatColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%sSuccess! %s%s%s was %sremoved %sfrom %s%s%s.",
|
||||
ChatColor.GREEN, ChatColor.AQUA, value, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.GREEN, property, ChatColor.WHITE));
|
||||
|
||||
saveWorldConfig();
|
||||
}
|
||||
|
||||
@Subcommand("clear")
|
||||
@CommandPermission("multiverse.core.modify.clear")
|
||||
@Syntax("<property> <value> [world]")
|
||||
@CommandCompletion("@addProperties @empty @MVWorlds")
|
||||
@Description("Modify various aspects of worlds by clearing a property. For more info: https://tinyurl.com/nehhzp6")
|
||||
public void onModifyClearCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<property>")
|
||||
@Description("Property option key.")
|
||||
@Flags("type=property") @Conditions("validAddProperty:clear") String property,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World that you want property be cleared.")
|
||||
@Flags("other,defaultself") MultiverseWorld world) {
|
||||
|
||||
if (!world.clearList(property)) {
|
||||
sender.sendMessage(String.format("%sThere was an error clearing %s%s%s.",
|
||||
ChatColor.RED, ChatColor.GOLD, property, ChatColor.RED));
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%s%s%s was cleared. It contains 0 values now.",
|
||||
ChatColor.GOLD, property, ChatColor.WHITE));
|
||||
|
||||
saveWorldConfig();
|
||||
}
|
||||
|
||||
@Subcommand("list")
|
||||
@CommandPermission("multiverse.core.modify.list")
|
||||
@Syntax("[world] [filter]")
|
||||
@CommandCompletion("@MVWorlds")
|
||||
@Description("Show properties available to set.")
|
||||
public void onModifyListCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World that you want to see current property values set.")
|
||||
@Flags("other,defaultself,fallbackself") MultiverseWorld world,
|
||||
|
||||
@NotNull ContentFilter filter) {
|
||||
|
||||
new ContentDisplay.Builder<Map<String, Object>>()
|
||||
.sender(sender)
|
||||
.header("%s===[ Property Values for %s%s ]===", ChatColor.GOLD, world.getColoredWorldString(), ChatColor.GOLD)
|
||||
.contents(generateModifyList(world))
|
||||
.emptyMessage("No properties found.")
|
||||
.displayHandler(DisplayHandlers.INLINE_MAP)
|
||||
.filter(filter)
|
||||
.display();
|
||||
}
|
||||
|
||||
private Map<String, Object> generateModifyList(MultiverseWorld world) {
|
||||
Collection<String> properties = world.getAllPropertyTypes();
|
||||
Map<String, Object> propMap = new HashMap<>(properties.size());
|
||||
for (String property : properties) {
|
||||
String value;
|
||||
try {
|
||||
value = world.getPropertyValue(property);
|
||||
} catch (PropertyDoesNotExistException ignored) {
|
||||
value = String.format("%s!!INAVLID!!", ChatColor.RED);
|
||||
}
|
||||
propMap.put(property, value);
|
||||
}
|
||||
return propMap;
|
||||
}
|
||||
|
||||
private void saveWorldConfig() {
|
||||
if (!this.plugin.saveWorldConfig()) {
|
||||
throw new InvalidCommandArgument("There was an issue saving worlds.yml! Your changes will only be temporary.", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
|
||||
public abstract class MultiverseCoreCommand extends MultiverseCommand {
|
||||
|
||||
protected final MultiverseCore plugin;
|
||||
|
||||
protected MultiverseCoreCommand(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Split;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class PurgeCommand extends MultiverseCoreCommand {
|
||||
|
||||
public PurgeCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("purgeall")
|
||||
@CommandPermission("multiverse.core.purge.all")
|
||||
@Syntax("<all|animals|monsters|mobname>")
|
||||
@CommandCompletion("all|animals|monsters|@livingEntities")
|
||||
@Description("Removed the specified type of mob from all worlds.")
|
||||
public void onPurgeAllCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<entities>")
|
||||
@Description("Entity types that you want to remove from all worlds.")
|
||||
@Split(",") String[] targetEntities) {
|
||||
|
||||
doPurge(sender, this.plugin.getMVWorldManager().getMVWorlds(), targetEntities);
|
||||
}
|
||||
|
||||
@Subcommand("purge")
|
||||
@CommandPermission("multiverse.core.purge")
|
||||
@Syntax("<all|animals|monsters|mobname>")
|
||||
@CommandCompletion("@MVWorlds|all|animals|monsters|@livingEntities all|animals|monsters|@livingEntities")
|
||||
@Description("Removed the specified type of mob from the specified world.")
|
||||
public void onPurgeCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World that you want to remove entities.")
|
||||
@Flags("other,defaultself,fallbackself") MultiverseWorld world,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<entities>")
|
||||
@Description("Entity types that you want to remove from a world.")
|
||||
@Split(",") String[] targetEntities) {
|
||||
|
||||
doPurge(sender, Collections.singleton(world), targetEntities);
|
||||
}
|
||||
|
||||
private void doPurge(@NotNull CommandSender sender,
|
||||
@NotNull Collection<MultiverseWorld> targetWorlds,
|
||||
@NotNull String[] targetEntities) {
|
||||
|
||||
List<String> thingsToKill = Arrays.stream(targetEntities)
|
||||
.map(String::toUpperCase)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
targetWorlds.forEach(w -> this.plugin.getMVWorldManager()
|
||||
.getTheWorldPurger()
|
||||
.purgeWorld(w, thingsToKill, false, false, sender));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class RegenCommand extends MultiverseCoreCommand {
|
||||
|
||||
public RegenCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setFlagGroup(FlagGroup.of(CoreFlags.RANDOM_SEED));
|
||||
}
|
||||
|
||||
@Subcommand("regen")
|
||||
@CommandPermission("multiverse.core.regen")
|
||||
@Syntax("<world> [-s [seed]]")
|
||||
@CommandCompletion("@MVWorlds @worldFlags:-s")
|
||||
@Description("Regenerates a world on your server. The previous state will be lost PERMANENTLY.")
|
||||
public void onRegenCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<world>")
|
||||
@Description("World that you want to regen.")
|
||||
@Flags("other") MultiverseWorld world,
|
||||
|
||||
@Nullable
|
||||
@Syntax("[-s [seed]]")
|
||||
@Description("Other world settings. See: http://gg.gg/nn8lk")
|
||||
String[] flagsArray) {
|
||||
|
||||
FlagResult flags = this.getFlagGroup().calculateResult(flagsArray);
|
||||
|
||||
this.plugin.getMVCommandManager().getQueueManager().addToQueue(new QueuedCommand.Builder()
|
||||
.sender(sender)
|
||||
.action(regenRunnable(sender, world, flags))
|
||||
.prompt("Are you sure you want to regen world '%s'?", world.getColoredWorldString())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private Runnable regenRunnable(@NotNull CommandSender sender,
|
||||
@NotNull MultiverseWorld world,
|
||||
@NotNull FlagResult flags) {
|
||||
|
||||
return () -> {
|
||||
sender.sendMessage(String.format("Regening world '%s'...", world.getName()));
|
||||
|
||||
//TODO: API should allow regen of unloaded worlds.
|
||||
sender.sendMessage((this.plugin.getMVWorldManager().regenWorld(
|
||||
world.getName(),
|
||||
!flags.isDefaulted(CoreFlags.RANDOM_SEED),
|
||||
!flags.isByUserInput(CoreFlags.RANDOM_SEED),
|
||||
flags.getValue(CoreFlags.RANDOM_SEED))
|
||||
)
|
||||
? String.format("%sWorld Regenerated!", ChatColor.GREEN)
|
||||
: String.format("%sWorld could not be regenerated!", ChatColor.RED));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class ReloadCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ReloadCommand(@NotNull MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("reload")
|
||||
@CommandPermission("multiverse.core.reload")
|
||||
@Description("Reloads config files for all multiverse modules.")
|
||||
public void onReloadCommand(@NotNull CommandSender sender) {
|
||||
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<>();
|
||||
configsLoaded.add("Multiverse-Core - config.yml");
|
||||
configsLoaded.add("Multiverse-Core - worlds.yml");
|
||||
configsLoaded.add("Multiverse-Core - anchors.yml");
|
||||
|
||||
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
|
||||
this.plugin.getServer().getPluginManager().callEvent(configReload);
|
||||
|
||||
configReload.getAllConfigsLoaded().forEach(sender::sendMessage);
|
||||
sender.sendMessage(String.format("%sReload Complete!", ChatColor.GREEN));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Single;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class RemoveCommand extends MultiverseCoreCommand {
|
||||
|
||||
public RemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("remove")
|
||||
@CommandPermission("multiverse.core.remove")
|
||||
@CommandCompletion("@MVWorlds|@unloadedWorlds")
|
||||
@Syntax("<world>")
|
||||
@Description("Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.")
|
||||
public void onRemoveCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<world>")
|
||||
@Description("World you want to remove from mv's knowledge.")
|
||||
@Flags("type=world name")
|
||||
@Conditions("isWorldInConfig")
|
||||
@Single String worldName) {
|
||||
|
||||
sender.sendMessage((this.plugin.getMVWorldManager().removeWorldFromConfig(worldName))
|
||||
? String.format("World '%s' is removed from config!", worldName)
|
||||
: String.format("%sError trying to remove world from config!", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RootCommand extends MultiverseCoreCommand {
|
||||
|
||||
public RootCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@CommandAlias("mv")
|
||||
public void onRootCommand(@NotNull CommandSender sender) {
|
||||
this.plugin.getMVCommandManager().showPluginInfo(
|
||||
sender,
|
||||
this.plugin.getDescription(),
|
||||
ColorAlternator.with(ChatColor.GOLD, ChatColor.YELLOW),
|
||||
"mv"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import buscript.Buscript;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class ScriptCommand extends MultiverseCoreCommand {
|
||||
|
||||
public ScriptCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("script")
|
||||
@CommandPermission("multiverse.core.script")
|
||||
@Syntax("<script> <player>")
|
||||
@CommandCompletion("@scripts @players")
|
||||
@Description("Runs a script.")
|
||||
public void onScriptCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<script>")
|
||||
@Description("Script name that you want to run.")
|
||||
String targetScript,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<player>")
|
||||
@Description("Player that you want to execute the script on.")
|
||||
RequiredPlayer player) {
|
||||
|
||||
Buscript scriptAPI = this.plugin.getScriptAPI();
|
||||
if (scriptAPI == null) {
|
||||
throw new InvalidCommandArgument("Buscript failed to load while server was starting! Scripts cannot be run.", false);
|
||||
}
|
||||
|
||||
File file = new File(scriptAPI.getScriptFolder(), targetScript);
|
||||
if (!file.exists()) {
|
||||
throw new InvalidCommandArgument("That script file does not exist in the Multiverse-Core scripts directory!");
|
||||
}
|
||||
|
||||
scriptAPI.executeScript(file, targetScript, player.get());
|
||||
sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SetSpawnCommand extends MultiverseCoreCommand {
|
||||
|
||||
public SetSpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class SetSpawn extends BaseCommand {
|
||||
|
||||
@Subcommand("setspawn")
|
||||
@CommandPermission("multiverse.core.spawn.set")
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@CommandCompletion("@MVWorlds @location:x @location:y @location:z @location:yaw @location:pitch")
|
||||
@Description("Sets the spawn for the current world.")
|
||||
public void onSetSpawnCommand(@NotNull CommandSender sender,
|
||||
@Nullable @Optional Player player,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@Description("New location of spawn.")
|
||||
@Flags("other,defaultself") MultiverseWorld world,
|
||||
|
||||
@Nullable @Optional Double x,
|
||||
@Nullable @Optional Double y,
|
||||
@Nullable @Optional Double z,
|
||||
@Nullable @Optional Float yaw,
|
||||
@Nullable @Optional Float pitch) {
|
||||
|
||||
doSpawnSet(sender, world, parseLocation(player, world, x, y, z, yaw, pitch));
|
||||
}
|
||||
|
||||
@Subcommand("modify set spawn")
|
||||
@CommandPermission("multiverse.core.spawn.set")
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@CommandCompletion("@MVWorlds @location:x @location:y @location:z @location:yaw @location:pitch")
|
||||
@Description("Sets the spawn for the current world.")
|
||||
public void onModifySetSpawnCommand(@NotNull CommandSender sender,
|
||||
@Nullable @Optional Player player,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@Description("New location of spawn.")
|
||||
@Flags("other,defaultself") MultiverseWorld world,
|
||||
|
||||
@Nullable @Optional Double x,
|
||||
@Nullable @Optional Double y,
|
||||
@Nullable @Optional Double z,
|
||||
@Nullable @Optional Float yaw,
|
||||
@Nullable @Optional Float pitch) {
|
||||
|
||||
doSpawnSet(sender, world, parseLocation(player, world, x, y, z, yaw, pitch));
|
||||
}
|
||||
}
|
||||
|
||||
@CommandAlias("mvsetspawn")
|
||||
public class AliasSetSpawn extends BaseCommand {
|
||||
|
||||
@CommandAlias("mvsetspawn")
|
||||
@CommandPermission("multiverse.core.spawn.set")
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@CommandCompletion("@MVWorlds @location:x @location:y @location:z @location:yaw @location:pitch @empty")
|
||||
@Description("Sets the spawn for the current world.")
|
||||
public void onAliasSetSpawnCommand(@NotNull CommandSender sender,
|
||||
@Nullable @Optional Player player,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world x y z [yaw pitch]]")
|
||||
@Description("New location of spawn.")
|
||||
@Flags("other,defaultself") MultiverseWorld world,
|
||||
|
||||
@Nullable @Optional Double x,
|
||||
@Nullable @Optional Double y,
|
||||
@Nullable @Optional Double z,
|
||||
@Nullable @Optional Float yaw,
|
||||
@Nullable @Optional Float pitch) {
|
||||
doSpawnSet(sender, world, parseLocation(player, world, x, y, z, yaw, pitch));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Location parseLocation(@Nullable Player player,
|
||||
@NotNull MultiverseWorld world,
|
||||
@Nullable Double x,
|
||||
@Nullable Double y,
|
||||
@Nullable Double z,
|
||||
@Nullable Float yaw,
|
||||
@Nullable Float pitch) {
|
||||
|
||||
if (x == null) {
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument("You need to specify a location from console.");
|
||||
}
|
||||
return player.getLocation();
|
||||
}
|
||||
if (y == null) {
|
||||
throw new InvalidCommandArgument("You need to specify y and z axis as well.");
|
||||
}
|
||||
if (z == null) {
|
||||
throw new InvalidCommandArgument("You need to specify z axis as well.");
|
||||
}
|
||||
if (yaw == null) {
|
||||
return new Location(world.getCBWorld(), x, y, z);
|
||||
}
|
||||
if (pitch == null) {
|
||||
throw new InvalidCommandArgument("You need to specify pitch as well.");
|
||||
}
|
||||
|
||||
return new Location(world.getCBWorld(), x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
private void doSpawnSet(@NotNull CommandSender sender,
|
||||
@NotNull MultiverseWorld world,
|
||||
@NotNull Location location) {
|
||||
|
||||
World bukkitWorld = location.getWorld();
|
||||
if (bukkitWorld == null) {
|
||||
sender.sendMessage("No world found for the spawn location your tried to set.");
|
||||
return;
|
||||
}
|
||||
|
||||
world.setSpawnLocation(location);
|
||||
BlockSafety blockSafety = this.plugin.getBlockSafety();
|
||||
if (!blockSafety.playerCanSpawnHereSafely(location) && world.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(String.format("If you want turn this back on, just do %s/mv modify set adjustspawn true %s", ChatColor.AQUA, world.getName()));
|
||||
world.setAdjustSpawn(false);
|
||||
}
|
||||
|
||||
sender.sendMessage((sender instanceof Player && ((Player) sender).getWorld().equals(world.getCBWorld()))
|
||||
? "Spawn of this world is set to:"
|
||||
: String.format("Spawn for %s is set to:", world.getColoredWorldString()));
|
||||
|
||||
sender.sendMessage(plugin.getLocationManipulation().strCoords(location));
|
||||
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(String.format("%sThere was an issue saving worlds.yml! Your changes will only be temporary!", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class SilentCommand extends MultiverseCoreCommand {
|
||||
|
||||
public SilentCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("silent")
|
||||
@CommandPermission("multiverse.core.silent")
|
||||
@Description("Show current state of silent mode.")
|
||||
public void onShowSilentCommand(@NotNull CommandSender sender) {
|
||||
displaySilentMode(sender);
|
||||
}
|
||||
|
||||
@Subcommand("silent")
|
||||
@CommandPermission("multiverse.core.silent")
|
||||
@Syntax("<true|false>")
|
||||
@CommandCompletion("true|false")
|
||||
@Description("Reduces the amount of startup messages.")
|
||||
public void onChangeSilentCommand(@NotNull CommandSender sender,
|
||||
boolean silent) {
|
||||
|
||||
plugin.getMVConfig().setSilentStart(silent);
|
||||
if (!plugin.saveMVConfigs()) {
|
||||
sender.sendMessage(String.format("%sFailed to save config! Check your console for details.", ChatColor.RED));
|
||||
}
|
||||
|
||||
displaySilentMode(sender);
|
||||
}
|
||||
|
||||
private void displaySilentMode(CommandSender sender) {
|
||||
sender.sendMessage((plugin.getMVConfig().getSilentStart())
|
||||
? String.format("Multiverse Silent Start mode is %sOn", ChatColor.GREEN)
|
||||
: String.format("Multiverse Silent Start mode is %sOff", ChatColor.RED));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class SpawnCommand extends MultiverseCoreCommand {
|
||||
|
||||
public SpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("spawn")
|
||||
@CommandPermission("multiverse.core.spawn.self")
|
||||
@Description("Teleport yourself to the spawn of the world.")
|
||||
public void onSpawnCommand(@NotNull Player player) {
|
||||
doSpawn(player, player);
|
||||
}
|
||||
|
||||
@CommandAlias("spawn")
|
||||
@CommandPermission("multiverse.core.spawn.other")
|
||||
@Syntax("[player]")
|
||||
@CommandCompletion("@players")
|
||||
@Description("Teleport another player to the spawn of the world they are in.")
|
||||
public void onSpawnCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[player]")
|
||||
@Description("Target player to teleport to spawn.")
|
||||
RequiredPlayer player) {
|
||||
|
||||
doSpawn(sender, player.get());
|
||||
}
|
||||
|
||||
private void doSpawn(@NotNull CommandSender sender,
|
||||
@NotNull Player player) {
|
||||
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld());
|
||||
Location spawnLocation = (world == null) ? player.getWorld().getSpawnLocation() : world.getSpawnLocation();
|
||||
|
||||
this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false);
|
||||
|
||||
if (sender.equals(player)) {
|
||||
player.sendMessage("Teleported to this world's spawn.");
|
||||
return;
|
||||
}
|
||||
|
||||
String senderName = (sender instanceof ConsoleCommandSender)
|
||||
? String.format("%sconsole%s", ChatColor.LIGHT_PURPLE, ChatColor.RESET)
|
||||
: String.format("%s%s%s", ChatColor.YELLOW, sender.getName(), ChatColor.RESET);
|
||||
|
||||
player.sendMessage("You were teleported by " + senderName + "to spawn.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.CommandHelp;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SubModulesCommand {
|
||||
|
||||
public static class NetherPortals extends BaseCommand {
|
||||
|
||||
@HelpCommand
|
||||
@CommandAlias("mvnp")
|
||||
@CommandPermission("multiverse.core.submodules")
|
||||
@Description("Suggest download for Multiverse-NetherPortals.")
|
||||
public void onSuggestCommand(@NotNull CommandSender sender,
|
||||
@NotNull CommandHelp help) {
|
||||
|
||||
suggestDownload(
|
||||
sender,
|
||||
"Multiverse-NetherPortals",
|
||||
ColorAlternator.with(ChatColor.DARK_PURPLE, ChatColor.LIGHT_PURPLE),
|
||||
"https://dev.bukkit.org/projects/multiverse-netherportals"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Portals extends BaseCommand {
|
||||
|
||||
@HelpCommand
|
||||
@CommandAlias("mvp")
|
||||
@CommandPermission("multiverse.core.submodules")
|
||||
@Description("Suggest download for Multiverse-Portals.")
|
||||
public void onSuggestCommand(@NotNull CommandSender sender,
|
||||
@NotNull CommandHelp help) {
|
||||
|
||||
suggestDownload(
|
||||
sender,
|
||||
"Multiverse-Portals",
|
||||
ColorAlternator.with(ChatColor.DARK_RED, ChatColor.RED),
|
||||
"https://dev.bukkit.org/projects/multiverse-portals"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Inventories extends BaseCommand {
|
||||
|
||||
@HelpCommand
|
||||
@CommandAlias("mvinv")
|
||||
@CommandPermission("multiverse.core.submodules")
|
||||
@Description("Suggest download for Multiverse-Inventories.")
|
||||
public void onSuggestCommand(@NotNull CommandSender sender,
|
||||
@NotNull CommandHelp help) {
|
||||
|
||||
suggestDownload(
|
||||
sender,
|
||||
"Multiverse-Inventories",
|
||||
ColorAlternator.with(ChatColor.DARK_AQUA, ChatColor.AQUA),
|
||||
"https://dev.bukkit.org/projects/multiverse-inventories"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static void suggestDownload(@NotNull CommandSender sender,
|
||||
@NotNull String pluginName,
|
||||
@NotNull ColorAlternator colours,
|
||||
@NotNull String downloadLink) {
|
||||
|
||||
sender.sendMessage(String.format("%s%s%s is not installed on this server. You can learn more and download it at:",
|
||||
colours.getThisColor(), pluginName, ChatColor.WHITE));
|
||||
sender.sendMessage(String.format("%s%s", colours.getThatColor(), downloadLink));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.Teleporter;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
|
||||
import com.onarandombox.MultiverseCore.destination.CustomTeleporterDestination;
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class TeleportCommand extends MultiverseCoreCommand {
|
||||
|
||||
private final SafeTTeleporter playerTeleporter;
|
||||
|
||||
private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 300; // In ticks
|
||||
|
||||
public TeleportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.playerTeleporter = this.plugin.getSafeTTeleporter();
|
||||
}
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class Teleport extends BaseCommand {
|
||||
|
||||
@Subcommand("tp|teleport")
|
||||
@Syntax("[player] <destination>")
|
||||
@CommandCompletion("@players|@MVWorlds:playerOnly|@destinations:playerOnly @players|@MVWorlds|@destinations")
|
||||
@Description("Allows you to the teleport to a location on your server!")
|
||||
public void doTeleportCommand(@NotNull CommandSender sender,
|
||||
|
||||
@Syntax("[player]")
|
||||
@Description("Target player to teleport.")
|
||||
@NotNull @Flags("other,defaultself,fallbackself") Player player,
|
||||
|
||||
@Syntax("<destination>")
|
||||
@Description("Location, can be a world name.")
|
||||
@NotNull @Flags("type=destination") String destinationName) {
|
||||
|
||||
doTeleport(sender, player, destinationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRequiredPermissions() {
|
||||
return destPerms();
|
||||
}
|
||||
}
|
||||
|
||||
public class AliasTeleport extends BaseCommand {
|
||||
|
||||
@CommandAlias("mvtp")
|
||||
@Syntax("[player] <destination>")
|
||||
@CommandCompletion("@players|@MVWorlds:playerOnly|@destinations:playerOnly @MVWorlds|@destinations")
|
||||
@Description("Alias for /mv tp")
|
||||
public void doTeleportCommand(@NotNull CommandSender sender,
|
||||
|
||||
@Syntax("[player]")
|
||||
@Description("Target player to teleport.")
|
||||
@NotNull @Flags("other,defaultself,fallbackself") Player player,
|
||||
|
||||
@Syntax("<destination>")
|
||||
@Description("Location, can be a world name.")
|
||||
@NotNull @Flags("type=destination") String destinationName) {
|
||||
|
||||
doTeleport(sender, player, destinationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRequiredPermissions() {
|
||||
return destPerms();
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> destPerms() {
|
||||
return this.plugin.getDestFactory().getPermissions();
|
||||
}
|
||||
|
||||
private void doTeleport(@NotNull CommandSender teleporter,
|
||||
@NotNull Player teleportee,
|
||||
@NotNull String destinationName) {
|
||||
|
||||
MVDestination destination = this.plugin.getDestFactory().getPlayerAwareDestination(teleportee, destinationName);
|
||||
|
||||
MVTeleportEvent teleportEvent = new MVTeleportEvent(destination, teleportee, teleporter, true);
|
||||
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
|
||||
if (teleportEvent.isCancelled()) {
|
||||
Logging.fine("Someone else cancelled the MVTeleport Event!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (destination instanceof InvalidDestination) {
|
||||
teleporter.sendMessage(String.format("Multiverse does not know how to take you to %s%s", ChatColor.RED, destinationName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.checkSendPermissions(teleporter, teleportee, destination)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.plugin.getMVConfig().getEnforceAccess() && !this.plugin.getMVPerms().canEnterDestination(teleportee, destination)) {
|
||||
teleporter.sendMessage((teleportee.equals(teleporter))
|
||||
? "Doesn't look like you're allowed to go " + ChatColor.RED + "there..."
|
||||
: "Doesn't look like you're allowed to send " + ChatColor.GOLD + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().canTravelFromLocation(teleporter, destination.getLocation(teleportee))) {
|
||||
teleporter.sendMessage((teleportee.equals(teleporter))
|
||||
? String.format("Doh! Doesn't look like you can get to %s%s %sfrom where you are...",
|
||||
ChatColor.GREEN, destination.toString(), ChatColor.WHITE)
|
||||
: 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));
|
||||
return;
|
||||
}
|
||||
|
||||
// Special check to verify if players are trying to teleport to the same WORLD Destination
|
||||
// as the world they're in, that they ALSO have multiverse.core.spawn.self
|
||||
if (destination instanceof WorldDestination
|
||||
&& teleportee.getWorld().equals(destination.getLocation(teleportee).getWorld())
|
||||
&& !checkSpawnPermissions(teleporter, teleportee)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (destination.getLocation(teleportee) == null) {
|
||||
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
|
||||
return;
|
||||
}
|
||||
|
||||
Teleporter teleportObject = (destination instanceof CustomTeleporterDestination)
|
||||
? ((CustomTeleporterDestination) destination).getTeleporter()
|
||||
: this.playerTeleporter;
|
||||
|
||||
TeleportResult result = teleportObject.teleport(teleporter, teleportee, destination);
|
||||
if (result == TeleportResult.FAIL_UNSAFE) {
|
||||
Logging.fine("Could not teleport %s to %s.",
|
||||
teleportee.getName(), this.plugin.getLocationManipulation().strCoordsRaw(destination.getLocation(teleportee)));
|
||||
|
||||
this.plugin.getMVCommandManager().getQueueManager().addToQueue(new QueuedCommand.Builder()
|
||||
.sender(teleporter)
|
||||
.action(unsafeTeleportRunnable(teleporter, teleportee, destination.getLocation(teleportee)))
|
||||
.prompt("The location you are trying to teleport to is deemed unsafe, do you still want to try?")
|
||||
.validDuration(UNSAFE_TELEPORT_EXPIRE_DELAY)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
// else: Player was teleported successfully (or the tp event was fired I should say)
|
||||
}
|
||||
|
||||
private boolean checkSendPermissions(@NotNull CommandSender teleporter,
|
||||
@NotNull Player teleportee,
|
||||
@NotNull MVDestination destination) {
|
||||
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
|
||||
teleporter.sendMessage(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));
|
||||
teleporter.sendMessage(String.format("%s (multiverse.teleport.self.%s)", ChatColor.RED, destination.getIdentifier()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
|
||||
teleporter.sendMessage(String.format("You don't have permission to teleport another player to a %s%s Destination.", ChatColor.GREEN, destination.getType()));
|
||||
teleporter.sendMessage(String.format("%s(multiverse.teleport.other.%s)", ChatColor.RED, destination.getIdentifier()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkSpawnPermissions(@NotNull CommandSender teleporter,
|
||||
@NotNull Player teleportee) {
|
||||
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
|
||||
teleporter.sendMessage(String.format("Sorry you don't have permission to go to the world spawn!"));
|
||||
teleporter.sendMessage(String.format("%s (multiverse.core.spawn.self)", ChatColor.RED));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
|
||||
teleporter.sendMessage(String.format("Sorry you don't have permission to send %s to the world spawn!", teleportee.getDisplayName()));
|
||||
teleporter.sendMessage(String.format("%s (multiverse.core.spawn.other)", ChatColor.RED));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Runnable unsafeTeleportRunnable(@NotNull CommandSender teleporter,
|
||||
@NotNull Player teleportee,
|
||||
@NotNull Location location) {
|
||||
|
||||
return () -> this.plugin.getSafeTTeleporter().safelyTeleport(teleporter, teleportee, location, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class UnloadCommand extends MultiverseCoreCommand {
|
||||
|
||||
public UnloadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("unload")
|
||||
@CommandPermission("multiverse.core.unload")
|
||||
@Syntax("<world>")
|
||||
@CommandCompletion("@MVWorlds")
|
||||
@Description("Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.")
|
||||
public void onUnloadCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("<world>")
|
||||
@Description("Name of world you want to unload.")
|
||||
@Flags("other") MultiverseWorld world) {
|
||||
|
||||
//TODO API: Should be able to use MVWorld object directly
|
||||
if (!this.plugin.getMVWorldManager().unloadWorld(world.getName())) {
|
||||
sender.sendMessage(String.format("Error unloading world '%s'! See console for more details.",
|
||||
world.getColoredWorldString()));
|
||||
return;
|
||||
}
|
||||
Command.broadcastCommandMessage(sender, String.format("Unloaded world '%s'!", world.getColoredWorldString()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.CommandHelp;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.HelpCommand;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class UsageCommand extends MultiverseCoreCommand {
|
||||
|
||||
public UsageCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@HelpCommand
|
||||
@Subcommand("help")
|
||||
@CommandPermission("multiverse.core.help")
|
||||
@Syntax("[filter] [page]")
|
||||
@CommandCompletion("@subCommands:mv")
|
||||
@Description("Show Multiverse-Core Command usage.")
|
||||
public void onUsageCommand(@NotNull CommandHelp help) {
|
||||
this.plugin.getMVCommandManager().showUsage(help);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
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 com.onarandombox.MultiverseCore.utils.webpaste.URLShortenerFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortenerType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class VersionCommand extends MultiverseCoreCommand {
|
||||
|
||||
private static final URLShortener SHORTENER = URLShortenerFactory.getService(URLShortenerType.BITLY);
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setFlagGroup(FlagGroup.of(
|
||||
CoreFlags.PASTE_SERVICE_TYPE,
|
||||
CoreFlags.INCLUDE_PLUGIN_LIST
|
||||
));
|
||||
}
|
||||
|
||||
@Subcommand("version")
|
||||
@CommandPermission("multiverse.core.version")
|
||||
@Syntax("--paste [pastebin|hastebin|pastegg] [--include-plugin-list]")
|
||||
@CommandCompletion("@flags")
|
||||
@Description("Dumps version info to the console, optionally to pastal service.")
|
||||
public void onVersionCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[paste-service]")
|
||||
@Description("Website to upload your version info to.")
|
||||
String[] flagsArray) {
|
||||
|
||||
FlagResult flags = FlagResult.parse(flagsArray, this.getFlagGroup());
|
||||
|
||||
MVVersionEvent versionEvent = new MVVersionEvent();
|
||||
this.addVersionInfoToEvent(versionEvent);
|
||||
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
|
||||
|
||||
if (flags.getValue(CoreFlags.INCLUDE_PLUGIN_LIST)) {
|
||||
versionEvent.appendVersionInfo('\n' + "Plugins: " + getPluginList());
|
||||
versionEvent.putDetailedVersionInfo("plugins.txt", "Plugins: " + getPluginList());
|
||||
}
|
||||
|
||||
String versionInfo = versionEvent.getVersionInfo();
|
||||
versionEvent.putDetailedVersionInfo("version.txt", versionInfo);
|
||||
|
||||
Map<String, String> files = versionEvent.getDetailedVersionInfo();
|
||||
|
||||
logToConsole(versionInfo);
|
||||
|
||||
PasteServiceType pasteType = flags.getValue(CoreFlags.PASTE_SERVICE_TYPE);
|
||||
if (pasteType == PasteServiceType.NONE && !(sender instanceof ConsoleCommandSender)) {
|
||||
sender.sendMessage("Version info dumped to console! Please check your server logs.");
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitRunnable logPoster = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String pasteUrl = postToService(pasteType, true, versionInfo, files);
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
|
||||
}
|
||||
};
|
||||
|
||||
// Run the log posting operation asynchronously, since we don't know how long it will take.
|
||||
logPoster.runTaskAsynchronously(this.plugin);
|
||||
}
|
||||
|
||||
private void logToConsole(String versionInfo) {
|
||||
Arrays.stream(versionInfo.split("\\r?\\n"))
|
||||
.filter(line -> !line.isEmpty())
|
||||
.forEach(this.plugin.getServer().getLogger()::info);
|
||||
}
|
||||
|
||||
private void addVersionInfoToEvent(MVVersionEvent event) {
|
||||
// add the legacy version info
|
||||
event.appendVersionInfo(this.getLegacyString());
|
||||
|
||||
// add the legacy file, but as markdown so it's readable
|
||||
// TODO API: Readd this in 5.0.0
|
||||
// event.putDetailedVersionInfo("version.md", this.getMarkdownString());
|
||||
|
||||
// add config.yml
|
||||
File configFile = new File(this.plugin.getDataFolder(), "config.yml");
|
||||
event.putDetailedVersionInfo("multiverse-core/config.yml", configFile);
|
||||
|
||||
// add worlds.yml
|
||||
File worldsFile = new File(this.plugin.getDataFolder(), "worlds.yml");
|
||||
event.putDetailedVersionInfo("multiverse-core/worlds.yml", worldsFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the current contents of this.pasteBinBuffer to a web service.
|
||||
*
|
||||
* @param type Service type to send paste data to.
|
||||
* @param isPrivate Should the paste be marked as private.
|
||||
* @param pasteData Legacy string only data to post to a service.
|
||||
* @param pasteFiles Map of filenames/contents of debug info.
|
||||
* @return URL of visible paste
|
||||
*/
|
||||
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData, Map<String, String> pasteFiles) {
|
||||
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
|
||||
|
||||
try {
|
||||
String result = (ps.supportsMultiFile())
|
||||
? ps.postData(pasteFiles)
|
||||
: ps.postData(pasteData);
|
||||
|
||||
return (SHORTENER != null) ? SHORTENER.shorten(result) : result;
|
||||
}
|
||||
catch (PasteFailedException e) {
|
||||
e.printStackTrace();
|
||||
return String.format("%sError posting to service.", ChatColor.RED);
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return String.format("%sThat service isn't supported yet.", ChatColor.RED);
|
||||
}
|
||||
}
|
||||
|
||||
private String getLegacyString() {
|
||||
return "[Multiverse-Core] Multiverse-Core Version: " + this.plugin.getDescription().getVersion() + '\n'
|
||||
+ "[Multiverse-Core] Bukkit Version: " + this.plugin.getServer().getVersion() + '\n'
|
||||
+ "[Multiverse-Core] Loaded Worlds: " + this.plugin.getMVWorldManager().getMVWorlds() + '\n'
|
||||
+ "[Multiverse-Core] Multiverse Plugins Loaded: " + this.plugin.getPluginCount() + '\n'
|
||||
+ "[Multiverse-Core] Economy being used: " + plugin.getEconomist().getEconomyName() + '\n'
|
||||
+ "[Multiverse-Core] Permissions Plugin: " + this.plugin.getMVPerms().getType() + '\n'
|
||||
+ "[Multiverse-Core] Dumping Config Values: (version " + this.plugin.getMVConfig().getVersion() + ")" + '\n'
|
||||
+ "[Multiverse-Core] enforceaccess: " + this.plugin.getMVConfig().getEnforceAccess() + '\n'
|
||||
+ "[Multiverse-Core] prefixchat: " + this.plugin.getMVConfig().getPrefixChat() + '\n'
|
||||
+ "[Multiverse-Core] prefixchatformat: " + this.plugin.getMVConfig().getPrefixChatFormat() + '\n'
|
||||
+ "[Multiverse-Core] useasyncchat: " + this.plugin.getMVConfig().getUseAsyncChat() + '\n'
|
||||
+ "[Multiverse-Core] teleportintercept: " + this.plugin.getMVConfig().getTeleportIntercept() + '\n'
|
||||
+ "[Multiverse-Core] firstspawnoverride: " + this.plugin.getMVConfig().getFirstSpawnOverride() + '\n'
|
||||
+ "[Multiverse-Core] displaypermerrors: " + this.plugin.getMVConfig().getDisplayPermErrors() + '\n'
|
||||
+ "[Multiverse-Core] globaldebug: " + this.plugin.getMVConfig().getGlobalDebug() + '\n'
|
||||
+ "[Multiverse-Core] enablebuscript: " + plugin.getMVConfig().getEnableBuscript() + '\n'
|
||||
+ "[Multiverse-Core] silentstart: " + this.plugin.getMVConfig().getSilentStart() + '\n'
|
||||
+ "[Multiverse-Core] messagecooldown: " + this.plugin.getMessaging().getCooldown() + '\n'
|
||||
+ "[Multiverse-Core] version: " + this.plugin.getMVConfig().getVersion() + '\n'
|
||||
+ "[Multiverse-Core] firstspawnworld: " + this.plugin.getMVConfig().getFirstSpawnWorld() + '\n'
|
||||
+ "[Multiverse-Core] teleportcooldown: " + this.plugin.getMVConfig().getTeleportCooldown() + '\n'
|
||||
+ "[Multiverse-Core] defaultportalsearch: " +this. plugin.getMVConfig().isUsingDefaultPortalSearch() + '\n'
|
||||
+ "[Multiverse-Core] portalsearchradius: " + this.plugin.getMVConfig().getPortalSearchRadius() + '\n'
|
||||
+ "[Multiverse-Core] autopurge: " +this. plugin.getMVConfig().isAutoPurgeEnabled() + '\n'
|
||||
+ "[Multiverse-Core] Special Code: FRN002" + '\n';
|
||||
}
|
||||
|
||||
private String getPluginList() {
|
||||
return StringUtils.join(this.plugin.getServer().getPluginManager().getPlugins(), ", ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
|
||||
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class WhoCommand extends MultiverseCoreCommand {
|
||||
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("whoall")
|
||||
@CommandPermission("multiverse.core.list.who.all")
|
||||
@Syntax("[filter]")
|
||||
public void onWhoAllCommand(@NotNull CommandSender sender,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[filter] [page]")
|
||||
@Description("Filter and paging.")
|
||||
PageFilter pageFilter) {
|
||||
|
||||
Player player = (sender instanceof Player) ? (Player) sender : null;
|
||||
Set<Player> visiblePlayers = getVisiblePlayers(player);
|
||||
|
||||
new ContentDisplay.Builder<Collection<String>>()
|
||||
.sender(sender)
|
||||
.header("%s--- Worlds and their players --- %s%s/%s", ChatColor.GOLD, ChatColor.AQUA, visiblePlayers.size(), this.plugin.getServer().getMaxPlayers())
|
||||
.contents(buildAllWorlds(player, visiblePlayers))
|
||||
.displayHandler(DisplayHandlers.PAGE_LIST)
|
||||
.filter(pageFilter.getFilter())
|
||||
.setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
|
||||
.display();
|
||||
}
|
||||
|
||||
@Subcommand("who")
|
||||
@CommandPermission("multiverse.core.list.who")
|
||||
@Syntax("[world] [filter]")
|
||||
@CommandCompletion("@MVWorlds")
|
||||
public void onWhoCommand(@NotNull CommandSender sender,
|
||||
@Nullable @Optional Player player,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[world]")
|
||||
@Description("World to show player list.")
|
||||
@Flags("other,defaultself,fallbackself")
|
||||
@Conditions("hasWorldAccess") MultiverseWorld world,
|
||||
|
||||
@NotNull
|
||||
@Syntax("[filter]")
|
||||
@Description("Filter the player names.")
|
||||
ContentFilter filter) {
|
||||
|
||||
Set<Player> visiblePlayers = getVisiblePlayers(player);
|
||||
|
||||
new ContentDisplay.Builder<Collection<String>>()
|
||||
.sender(sender)
|
||||
.header("%s===[ Players in %s%s ]===", ChatColor.AQUA, world.getColoredWorldString(), ChatColor.AQUA)
|
||||
.contents(buildPlayerList(world, visiblePlayers))
|
||||
.emptyMessage("%sNo players found.", ChatColor.GRAY)
|
||||
.displayHandler(DisplayHandlers.PAGE_LIST)
|
||||
//TODO: Filter
|
||||
.display();
|
||||
}
|
||||
|
||||
private List<String> buildAllWorlds(@Nullable Player player,
|
||||
@NotNull Set<Player> visiblePlayers) {
|
||||
|
||||
return this.plugin.getMVWorldManager().getMVWorlds().stream()
|
||||
.filter(world -> player == null || this.plugin.getMVPerms().canEnterWorld(player, world))
|
||||
.map(world -> getPLayersInWorld(world, visiblePlayers))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String getPLayersInWorld(@NotNull MultiverseWorld world,
|
||||
@NotNull Set<Player> visiblePlayers) {
|
||||
|
||||
return String.format("%s%s - %s",
|
||||
world.getColoredWorldString(), ChatColor.WHITE, buildPlayerList(world, visiblePlayers));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<String> buildPlayerList(@NotNull MultiverseWorld world,
|
||||
@NotNull Set<Player> visiblePlayers) {
|
||||
|
||||
return world.getCBWorld().getPlayers().stream()
|
||||
.filter(visiblePlayers::contains)
|
||||
.map(Player::getDisplayName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Set<Player> getVisiblePlayers(@Nullable Player player) {
|
||||
return this.plugin.getServer().getOnlinePlayers().stream()
|
||||
.filter(targetPLayer -> player == null || player.canSee(targetPLayer))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Where all the commands are.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
@@ -0,0 +1,323 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import buscript.Buscript;
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.PaperCommandCompletions;
|
||||
import co.aikar.commands.RegisteredCommand;
|
||||
import co.aikar.commands.RootCommand;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CommandFlag;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.CommandFlag.ValueRequirement;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
|
||||
import com.onarandombox.MultiverseCore.enums.AddProperties;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Generate tab-complete suggestion.
|
||||
*/
|
||||
public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
private static final DecimalFormat df = new DecimalFormat();
|
||||
|
||||
static {
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
}
|
||||
|
||||
public MVCommandCompletions(@NotNull MVCommandManager manager,
|
||||
@NotNull MultiverseCore plugin) {
|
||||
super(manager);
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
|
||||
registerAsyncCompletion("flags", this::suggestFlags);
|
||||
registerAsyncCompletion("scripts", this::suggestScripts);
|
||||
registerAsyncCompletion("subCommands", this::suggestSubCommands);
|
||||
registerAsyncCompletion("MVWorlds", this::suggestMVWorlds);
|
||||
registerAsyncCompletion("unloadedWorlds", this::suggestUnloadedWorlds);
|
||||
registerAsyncCompletion("potentialWorlds", this::suggestPotentialWorlds);
|
||||
registerAsyncCompletion("location", this::suggestLocation);
|
||||
registerAsyncCompletion("destinations", this::suggestDestinations);
|
||||
registerAsyncCompletion("anchors", this::suggestAnchors);
|
||||
registerStaticCompletion("MVConfigs", this::suggestMVConfig);
|
||||
registerStaticCompletion("gameRules", this::suggestGameRules);
|
||||
registerStaticCompletion("environments", this::suggestEnvironments);
|
||||
registerStaticCompletion("setProperties", this::suggestSetProperties);
|
||||
registerStaticCompletion("addProperties", this::suggestAddProperties);
|
||||
registerStaticCompletion("livingEntities", this::suggestEntities);
|
||||
registerStaticCompletion("pasteTypes", this::suggestPasteTypes);
|
||||
registerStaticCompletion("toggles", this::suggestToggles);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
|
||||
final MultiverseCommand command = MVCommandReflect.getCommandCompletionContextCommand(context);
|
||||
if (command == null) {
|
||||
Logging.warning("Unable to parse flags as MultiverseCommand not found!");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
FlagGroup flagGroup = command.getFlagGroup();
|
||||
String[] args = context.getContextValue(String[].class);
|
||||
CommandFlag<?> flag = (args.length <= 1) ? null : flagGroup.getByKey(args[args.length - 2]);
|
||||
|
||||
if (flag == null || flag.getValueRequirement() == ValueRequirement.NONE) {
|
||||
// suggest new flags.
|
||||
return getRemainingFlagIdentifiers(flagGroup, args);
|
||||
}
|
||||
|
||||
Collection<String> flagSuggestions = flag.suggestValue();
|
||||
|
||||
if (flag.getValueRequirement() == ValueRequirement.OPTIONAL) {
|
||||
// suggest new flags and values.
|
||||
flagSuggestions.addAll(getRemainingFlagIdentifiers(flagGroup, args));
|
||||
return flagSuggestions;
|
||||
}
|
||||
// suggest new values.
|
||||
return flagSuggestions == null ? Collections.emptySet() : flagSuggestions;
|
||||
}
|
||||
|
||||
private Collection<String> getRemainingFlagIdentifiers(FlagGroup flagGroup, String[] args) {
|
||||
Set<String> identifiersRemaining = new HashSet<>(flagGroup.getFlagIdentifiers());
|
||||
identifiersRemaining.removeAll(Arrays.asList(args));
|
||||
return identifiersRemaining;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestScripts(@NotNull BukkitCommandCompletionContext context) {
|
||||
Buscript scriptAPI = this.plugin.getScriptAPI();
|
||||
if (scriptAPI == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.stream(scriptAPI.getScriptFolder().listFiles())
|
||||
.unordered()
|
||||
.filter(File::isFile)
|
||||
.map(File::getName)
|
||||
.filter(fileName -> !fileName.equals("scripts.bin"))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestSubCommands(@NotNull BukkitCommandCompletionContext context) {
|
||||
String rootCmdName = context.getConfig();
|
||||
if (rootCmdName == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
RootCommand rootCommand = this.plugin.getMVCommandManager().getRegisteredRootCommands().stream()
|
||||
.unordered()
|
||||
.filter(c -> c.getCommandName().equals(rootCmdName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (rootCommand == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return rootCommand.getSubCommands().entries().stream()
|
||||
.unordered()
|
||||
.filter(entry -> checkPerms(context.getIssuer(), entry.getValue()))
|
||||
.map(Map.Entry::getKey)
|
||||
.filter(cmdName -> !cmdName.startsWith("__"))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean checkPerms(@NotNull CommandIssuer issuer,
|
||||
@NotNull RegisteredCommand<?> cmd) {
|
||||
|
||||
return this.plugin.getMVCommandManager().hasPermission(issuer, cmd.getRequiredPermissions());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.worldManager.getMVWorlds().parallelStream()
|
||||
.unordered()
|
||||
.map(MultiverseWorld::getName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestUnloadedWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.worldManager.getUnloadedWorlds();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestPotentialWorlds(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Collection<MultiverseWorld> worlds = this.worldManager.getMVWorlds();
|
||||
Set<String> knownWorlds = worlds.parallelStream()
|
||||
.unordered()
|
||||
.map(MultiverseWorld::getName)
|
||||
.collect(Collectors.toCollection(() -> new HashSet<>(worlds.size())));
|
||||
|
||||
return Arrays.stream(this.plugin.getServer().getWorldContainer().listFiles()).parallel()
|
||||
.unordered()
|
||||
.filter(File::isDirectory)
|
||||
.filter(file -> !knownWorlds.contains(file.getName()))
|
||||
.map(File::getName)
|
||||
.filter(this.worldManager::isValidWorld)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestLocation(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Player player = context.getPlayer();
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
|
||||
Location playerLocation = player.getLocation();
|
||||
double coordValue;
|
||||
switch (context.getConfig()) {
|
||||
case "x":
|
||||
coordValue = playerLocation.getX();
|
||||
break;
|
||||
case "y":
|
||||
coordValue = playerLocation.getY();
|
||||
break;
|
||||
case "z":
|
||||
coordValue = playerLocation.getZ();
|
||||
break;
|
||||
case "yaw":
|
||||
coordValue = playerLocation.getYaw();
|
||||
break;
|
||||
case "pitch":
|
||||
coordValue = playerLocation.getPitch();
|
||||
break;
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Collections.singletonList(df.format(coordValue));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestDestinations(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.plugin.getDestFactory().getIdentifiers().parallelStream()
|
||||
.unordered()
|
||||
.filter(id -> !id.isEmpty())
|
||||
.map(id -> id + ":")
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestAnchors(@NotNull BukkitCommandCompletionContext context) {
|
||||
if (isPlayerOnly(context)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return this.plugin.getAnchorManager().getAnchors(context.getPlayer());
|
||||
}
|
||||
|
||||
private boolean isPlayerOnly(@NotNull BukkitCommandCompletionContext context) {
|
||||
String config = context.getConfig();
|
||||
return config != null && context.getPlayer() == null && config.equals("playerOnly");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestMVConfig() {
|
||||
final Set<String> configOptions = this.plugin.getMVConfig().serialize().keySet();
|
||||
configOptions.remove("version");
|
||||
return configOptions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestGameRules() {
|
||||
return Arrays.stream(GameRule.values())
|
||||
.map(GameRule::getName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestEnvironments() {
|
||||
return Arrays.stream(World.Environment.values())
|
||||
.map(e -> e.toString().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Collection<String> suggestSetProperties() {
|
||||
return this.worldManager.getMVWorlds().iterator().next().getAllPropertyTypes();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestAddProperties() {
|
||||
return Arrays.stream(AddProperties.values())
|
||||
.map(p -> p.toString().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestEntities() {
|
||||
return Arrays.stream(EntityType.values())
|
||||
.filter(e -> e.isAlive() && e.isSpawnable())
|
||||
.map(e -> e.toString().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestPasteTypes() {
|
||||
return Arrays.stream(PasteServiceType.values())
|
||||
.filter(pt -> pt != PasteServiceType.GITHUB && pt != PasteServiceType.NONE)
|
||||
.map(p -> p.toString().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<String> suggestToggles() {
|
||||
return Arrays.asList("on", "off");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.BukkitConditionContext;
|
||||
import co.aikar.commands.CommandConditions;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.AddProperties;
|
||||
import com.onarandombox.MultiverseCore.enums.WorldValidationResult;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Args input validation.
|
||||
*/
|
||||
public class MVCommandConditions {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public MVCommandConditions(@NotNull MultiverseCore plugin,
|
||||
@NotNull CommandConditions<BukkitCommandIssuer, BukkitCommandExecutionContext, BukkitConditionContext> conditions) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
|
||||
conditions.addCondition(String.class, "isMVWorld", this::checkIsMVWorld);
|
||||
conditions.addCondition(String.class, "isUnloadedWorld", this::checkIsUnloadedWorld);
|
||||
conditions.addCondition(String.class, "isWorldInConfig", this::checkIsWorldInConfig);
|
||||
conditions.addCondition(String.class, "creatableWorldName", this::checkCreatableWorldName);
|
||||
conditions.addCondition(String.class, "importableWorldName", this::checkImportableWorldName);
|
||||
conditions.addCondition(String.class, "validWorldFolder", this::checkValidWorldFolder);
|
||||
conditions.addCondition(String.class, "validAddProperty", this::checkValidAddProperty);
|
||||
conditions.addCondition(MultiverseWorld.class, "hasWorldAccess", this::checkHasWorldAccess);
|
||||
}
|
||||
|
||||
private void checkIsMVWorld(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String worldName) {
|
||||
|
||||
if (!this.worldManager.isMVWorld(worldName)) {
|
||||
throw new ConditionFailedException(String.format("World '%s' not found.", worldName));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIsUnloadedWorld(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String worldName) {
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
throw new ConditionFailedException(String.format("World '%s' is already loaded.", worldName));
|
||||
}
|
||||
|
||||
if (!this.worldManager.getUnloadedWorlds().contains(worldName)) {
|
||||
if (this.worldManager.isValidWorld(worldName)) {
|
||||
CommandSender sender = executionContext.getSender();
|
||||
sender.sendMessage(String.format("%sMultiverse does not know about world '%s' yet. Please import it with %s/mv import %s <env>%s.",
|
||||
ChatColor.RED, worldName, ChatColor.AQUA, worldName, ChatColor.RED));
|
||||
sender.sendMessage(String.format("See %s/mv help import %sfor more info.",
|
||||
ChatColor.AQUA, ChatColor.WHITE));
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
throw new ConditionFailedException(String.format("World '%s' not found.", worldName));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIsWorldInConfig(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String worldName) {
|
||||
|
||||
if (!this.worldManager.hasUnloadedWorld(worldName, true)) {
|
||||
throw new ConditionFailedException(String.format("World '%s' not found.", worldName));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCreatableWorldName(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String worldName) {
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
throw new ConditionFailedException(String.format("%sMultiverse cannot create %sanother %s%sworld named '%s'.",
|
||||
ChatColor.RED, ChatColor.GOLD, ChatColor.RESET, ChatColor.RED, worldName));
|
||||
}
|
||||
|
||||
WorldValidationResult validationResult = this.worldManager.validateWorld(worldName);
|
||||
validateWorldNameResult(validationResult);
|
||||
|
||||
if (validationResult != WorldValidationResult.DOES_NOT_EXIST && validationResult != WorldValidationResult.NOT_A_DIRECTORY) {
|
||||
CommandSender sender = executionContext.getSender();
|
||||
if (validationResult == WorldValidationResult.VALID) {
|
||||
sender.sendMessage(String.format("%sWorld Folder '%s' already look like a world to me! You can try importing it with %s/mv import%s.",
|
||||
ChatColor.RED, worldName, ChatColor.AQUA, ChatColor.RED));
|
||||
sender.sendMessage(String.format("See %s/mv help import %sfor more info.",
|
||||
ChatColor.AQUA, ChatColor.WHITE));
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%sA folder already exists with this name!", ChatColor.RED));
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkImportableWorldName(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String worldName) {
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
executionContext.getSender().sendMessage(String.format("%sMultiverse %s already knows about %s%s%s!",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, worldName, ChatColor.WHITE));
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
|
||||
checkValidWorldFolder(context, executionContext, worldName);
|
||||
}
|
||||
|
||||
private void checkValidWorldFolder(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String worldName) {
|
||||
|
||||
WorldValidationResult validationResult = this.worldManager.validateWorld(worldName);
|
||||
validateWorldNameResult(validationResult);
|
||||
validateWorldFolderResult(validationResult, worldName);
|
||||
}
|
||||
|
||||
private void validateWorldNameResult(WorldValidationResult validationResult) {
|
||||
switch (validationResult) {
|
||||
case NAME_BLACKLISTED:
|
||||
throw new ConditionFailedException("World should not be in reserved server folders.");
|
||||
case NAME_CONTAINS_DAT:
|
||||
throw new ConditionFailedException("Multiverse cannot have a world name that contains '.dat'.");
|
||||
case NAME_INVALID:
|
||||
throw new ConditionFailedException("World name should not contain spaces or special characters! Please rename your world folder.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateWorldFolderResult(@NotNull WorldValidationResult validationResult,
|
||||
@NotNull String worldName) {
|
||||
switch (validationResult) {
|
||||
case DOES_NOT_EXIST:
|
||||
case NOT_A_DIRECTORY:
|
||||
throw new ConditionFailedException(String.format("World folder '%s' does not exist.", worldName));
|
||||
case FOLDER_LACK_DAT:
|
||||
throw new ConditionFailedException(String.format("'%s' does not appear to be a world! It is lacking .dat file.", worldName));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkValidAddProperty (@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull String property) {
|
||||
|
||||
String actionType = context.getConfig();
|
||||
if (actionType.equalsIgnoreCase("set")) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
AddProperties.valueOf(property);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
CommandSender sender = executionContext.getSender();
|
||||
sender.sendMessage(String.format("%sSorry, you can't use %s with '%s'.",
|
||||
ChatColor.RED, actionType, property));
|
||||
sender.sendMessage(String.format("%sPlease visit our Github Wiki for more information: https://goo.gl/q1h01S",
|
||||
ChatColor.AQUA));
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkHasWorldAccess(@NotNull ConditionContext<BukkitCommandIssuer> context,
|
||||
@NotNull BukkitCommandExecutionContext executionContext,
|
||||
@NotNull MultiverseWorld world) {
|
||||
|
||||
Player player = executionContext.getPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().canEnterWorld(player, world)) {
|
||||
throw new ConditionFailedException(String.format("You aren't allowed to access to world '%s%s'!",
|
||||
world.getColoredWorldString(), ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.PaperCommandContexts;
|
||||
import co.aikar.commands.annotation.Values;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleProperty;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
|
||||
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Parse args into objects.
|
||||
*/
|
||||
public class MVCommandContexts extends PaperCommandContexts {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
private static final Pattern UUID_REGEX = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
|
||||
private static final Pattern TRIM_REGEX = Pattern.compile("^[./\\\\]+");
|
||||
|
||||
public MVCommandContexts(@NotNull MVCommandManager manager,
|
||||
@NotNull MultiverseCore plugin) {
|
||||
|
||||
super(manager);
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
|
||||
registerContext(RequiredPlayer.class, this::deriveRequiredPlayer);
|
||||
registerIssuerOnlyContext(Player.class, this::derivePlayer);
|
||||
|
||||
registerIssuerAwareContext(MultiverseWorld.class, this::deriveMultiverseWorld);
|
||||
registerContext(World.Environment.class, this::deriveEnvironment);
|
||||
registerIssuerAwareContext(GameRuleProperty.class, this::deriveGameRuleProperty);
|
||||
registerIssuerAwareContext(MVDestination.class, this::deriveMVDestination);
|
||||
registerIssuerAwareContext(PasteServiceType.class, this::derivePasteServiceType);
|
||||
registerOptionalContext(String.class, this::deriveString);
|
||||
registerIssuerAwareContext(ContentFilter.class, this::deriveContentFilter);
|
||||
registerOptionalContext(PageFilter.class, this::derivePageFilter);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Player derivePlayer(@NotNull BukkitCommandExecutionContext context) {
|
||||
Player player = context.getPlayer();
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument("You must be a player to run this command.");
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private RequiredPlayer deriveRequiredPlayer(BukkitCommandExecutionContext context) {
|
||||
String playerIdentifier = context.getFirstArg();
|
||||
Player player = getPlayerFromValue(context.getSender(), playerIdentifier);
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument("Invalid player name '" + playerIdentifier + "'!");
|
||||
}
|
||||
return new RequiredPlayer(player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MultiverseWorld deriveMultiverseWorld(@NotNull BukkitCommandExecutionContext context) {
|
||||
if (!context.hasFlag("other")) {
|
||||
return getPlayerWorld(
|
||||
context.getPlayer(),
|
||||
context.isOptional()
|
||||
, "You cannot run this command from console."
|
||||
);
|
||||
}
|
||||
|
||||
String worldName = context.getFirstArg();
|
||||
if (worldName == null) {
|
||||
if (context.hasFlag("defaultself")) {
|
||||
return getPlayerWorld(
|
||||
context.getPlayer(),
|
||||
context.isOptional()
|
||||
, "You need to specific a world name from console."
|
||||
);
|
||||
}
|
||||
if (context.isOptional()) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument("You need to specific a world name.");
|
||||
}
|
||||
|
||||
MultiverseWorld world = getWorld(context.getSender(), worldName, !context.hasFlag("ignoreunload"));
|
||||
if (world == null) {
|
||||
if (context.hasFlag("fallbackself")) {
|
||||
return getPlayerWorld(context.getPlayer(),
|
||||
context.isOptional(),
|
||||
String.format("World '%s' not found.", worldName));
|
||||
}
|
||||
if (this.worldManager.isValidWorld(worldName)) {
|
||||
CommandSender sender = context.getSender();
|
||||
sender.sendMessage(String.format("%sMultiverse does not know about world '%s' yet. Please import it with %s/mv import %s <env>%s.",
|
||||
ChatColor.RED, worldName, ChatColor.AQUA, worldName, ChatColor.RED));
|
||||
sender.sendMessage(String.format("See %s/mv help import %sfor more info.",
|
||||
ChatColor.AQUA, ChatColor.WHITE));
|
||||
throw new InvalidCommandArgument();
|
||||
}
|
||||
throw new InvalidCommandArgument(String.format("World '%s' not found.", worldName), false);
|
||||
}
|
||||
|
||||
context.popFirstArg();
|
||||
return world;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MultiverseWorld getWorld(@NotNull CommandSender sender,
|
||||
@NotNull String worldName,
|
||||
boolean checkUnloaded) {
|
||||
|
||||
MultiverseWorld targetWorld = this.worldManager.getMVWorld(worldName);
|
||||
if (targetWorld != null) {
|
||||
return targetWorld;
|
||||
}
|
||||
|
||||
//TODO: API should have a isUnloadedWorld method.
|
||||
if (checkUnloaded && this.worldManager.getUnloadedWorlds().contains(worldName)) {
|
||||
sender.sendMessage(String.format("%sWorld '%s' exists, but it is unloaded!", ChatColor.RED, worldName));
|
||||
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, worldName));
|
||||
throw new InvalidCommandArgument();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MultiverseWorld getPlayerWorld(@Nullable Player player,
|
||||
boolean allowNull,
|
||||
@NotNull String errorReason) {
|
||||
|
||||
if (player == null) {
|
||||
if (allowNull) {
|
||||
return null;
|
||||
}
|
||||
throw new InvalidCommandArgument(errorReason, false);
|
||||
}
|
||||
|
||||
MultiverseWorld targetWorld = this.worldManager.getMVWorld(player.getWorld());
|
||||
if (targetWorld == null) {
|
||||
player.sendMessage(String.format("%sMultiverse doesn't know about world '%s%s%s' that '%s%s%s' is in.",
|
||||
ChatColor.RED, ChatColor.DARK_AQUA, player.getWorld().getName(), ChatColor.RED,
|
||||
ChatColor.AQUA, player.getName(), ChatColor.RED));
|
||||
|
||||
player.sendMessage(String.format("You need to import the world with %s/mv import %s %s",
|
||||
ChatColor.DARK_AQUA, player.getWorld().getName(), player.getWorld().getEnvironment()));
|
||||
|
||||
throw new InvalidCommandArgument();
|
||||
}
|
||||
|
||||
return targetWorld;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Player getPlayerFromSelf(@NotNull BukkitCommandExecutionContext context, String errorReason) {
|
||||
Player self = context.getPlayer();
|
||||
if (self == null && !context.isOptional()) {
|
||||
throw new InvalidCommandArgument(errorReason);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Player from string.
|
||||
* Supports player name, UUID and selectors.
|
||||
*
|
||||
* @param sender Sender use to parse vanilla selectors.
|
||||
* @param playerIdentifier Text to parse into a Player object.
|
||||
* @return A Player object if found, null otherwise.
|
||||
*/
|
||||
@Nullable
|
||||
public Player getPlayerFromValue(@NotNull CommandSender sender,
|
||||
@Nullable String playerIdentifier) {
|
||||
|
||||
if (playerIdentifier == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Player player = getPlayerBySelector(sender, playerIdentifier);
|
||||
if (player == null) {
|
||||
player = Bukkit.getPlayerExact(playerIdentifier);
|
||||
}
|
||||
if (player == null) {
|
||||
player = getPlayerByUUID(playerIdentifier);
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Player getPlayerBySelector(@NotNull CommandSender sender,
|
||||
@NotNull String playerIdentifier) {
|
||||
|
||||
if (playerIdentifier.charAt(0) != '@') {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Player> matchedPlayers;
|
||||
try {
|
||||
matchedPlayers = this.plugin.getServer().selectEntities(sender, playerIdentifier).parallelStream()
|
||||
.unordered()
|
||||
.filter(e -> e instanceof Player)
|
||||
.map(e -> ((Player) e))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
throw new InvalidCommandArgument(String.format("Error parsing selector '%s' for %s! See console for more details",
|
||||
playerIdentifier, sender.getName()));
|
||||
}
|
||||
if (matchedPlayers.isEmpty()) {
|
||||
throw new InvalidCommandArgument(String.format("No player found with selector '%s' for %s",
|
||||
playerIdentifier, sender.getName()));
|
||||
}
|
||||
if (matchedPlayers.size() > 1) {
|
||||
throw new InvalidCommandArgument(String.format("Error parsing selector '%s' for %s. ambiguous result (more than one player matched) - %s",
|
||||
playerIdentifier, sender.getName(), matchedPlayers.toString()));
|
||||
}
|
||||
|
||||
return matchedPlayers.get(0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Player getPlayerByUUID(@NotNull String playerIdentifier) {
|
||||
if (!UUID_REGEX.matcher(playerIdentifier).matches()) {
|
||||
return null;
|
||||
}
|
||||
UUID playerUUID;
|
||||
try {
|
||||
playerUUID = UUID.fromString(playerIdentifier);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return Bukkit.getPlayer(playerUUID);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private World.Environment deriveEnvironment(@NotNull BukkitCommandExecutionContext context) {
|
||||
String env = context.popFirstArg();
|
||||
|
||||
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD")) {
|
||||
env = "NORMAL";
|
||||
}
|
||||
else if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER")) {
|
||||
env = "NETHER";
|
||||
}
|
||||
else if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS")) {
|
||||
env = "THE_END";
|
||||
}
|
||||
|
||||
try {
|
||||
return World.Environment.valueOf(env);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
CommandSender sender = context.getSender();
|
||||
sender.sendMessage(String.format("%s'%s' is not a valid environment.", ChatColor.RED, env));
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
throw new InvalidCommandArgument(false);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private GameRuleProperty<?> deriveGameRuleProperty(@NotNull BukkitCommandExecutionContext context) {
|
||||
int argLength = context.getArgs().size();
|
||||
if (argLength == 0) {
|
||||
throw new InvalidCommandArgument("You need to specify a game rule property and value to set.");
|
||||
}
|
||||
if (argLength == 1) {
|
||||
throw new InvalidCommandArgument("You need to specify a value to set.");
|
||||
}
|
||||
|
||||
String ruleString = context.popFirstArg();
|
||||
GameRule<?> gameRule = GameRule.getByName(ruleString);
|
||||
if (gameRule == null) {
|
||||
throw new InvalidCommandArgument(String.format("'%s' is not a valid gamerule.", ruleString));
|
||||
}
|
||||
|
||||
Class<?> ruleType = gameRule.getType();
|
||||
String value = context.getFirstArg();
|
||||
Object result = getResolver(ruleType).getContext(context);
|
||||
if (result == null) {
|
||||
context.getSender().sendMessage(String.format("%s'%s' is not a valid value.", ChatColor.RED, value));
|
||||
context.getSender().sendMessage(String.format("%sValue need to be a %s", ChatColor.RED, ruleType.getTypeName()));
|
||||
throw new InvalidCommandArgument();
|
||||
}
|
||||
if (result instanceof Integer && ((int) result) < 0) {
|
||||
throw new InvalidCommandArgument("Value need to be a positive number.");
|
||||
}
|
||||
|
||||
return new GameRuleProperty(gameRule, result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private MVDestination deriveMVDestination(@NotNull BukkitCommandExecutionContext context) {
|
||||
String destString = context.popFirstArg();
|
||||
if (destString == null) {
|
||||
throw new InvalidCommandArgument("Please specify a destination.");
|
||||
}
|
||||
|
||||
MVDestination destination = this.plugin.getDestFactory().getDestination(destString);
|
||||
if (destination instanceof InvalidDestination) {
|
||||
throw new InvalidCommandArgument(String.format("No such destination '%s' found.", destString));
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String deriveString(@NotNull BukkitCommandExecutionContext context) {
|
||||
if (context.hasAnnotation(Values.class)) {
|
||||
return context.popFirstArg();
|
||||
}
|
||||
|
||||
String string = context.popFirstArg();
|
||||
if (string == null) {
|
||||
if (!context.isOptional()) {
|
||||
String argType = context.getFlagValue("type", "string");
|
||||
throw new InvalidCommandArgument(String.format("You need to specify a %s.", argType));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (context.hasFlag("trim")) {
|
||||
return trimWorldName(string);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String trimWorldName(@NotNull String worldName) {
|
||||
// Removes relative paths.
|
||||
return TRIM_REGEX.matcher(worldName).replaceAll("");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PasteServiceType derivePasteServiceType(BukkitCommandExecutionContext context) {
|
||||
String pasteType = context.popFirstArg();
|
||||
if (pasteType == null) {
|
||||
return PasteServiceType.NONE;
|
||||
}
|
||||
|
||||
try {
|
||||
return PasteServiceType.valueOf(pasteType.toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new InvalidCommandArgument(String.format("Invalid paste service type '%s'.", pasteType));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ContentFilter deriveContentFilter(@NotNull BukkitCommandExecutionContext context) {
|
||||
String filterString = context.popFirstArg();
|
||||
return (filterString == null) ? ContentFilter.DEFAULT : new ContentFilter(filterString);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PageFilter derivePageFilter(@NotNull BukkitCommandExecutionContext context) {
|
||||
int argLength = context.getArgs().size();
|
||||
if (argLength == 0) {
|
||||
return new PageFilter(ContentFilter.DEFAULT, 1);
|
||||
}
|
||||
if (argLength == 1) {
|
||||
String pageOrFilter = context.popFirstArg();
|
||||
Optional<Integer> page = tryParseInt(pageOrFilter);
|
||||
return page.map(pageNum -> new PageFilter(ContentFilter.DEFAULT, pageNum))
|
||||
.orElseGet(() -> new PageFilter(new ContentFilter(pageOrFilter), 1));
|
||||
}
|
||||
|
||||
String filter = context.popFirstArg();
|
||||
String pageString = context.popFirstArg();
|
||||
Optional<Integer> page = tryParseInt(pageString);
|
||||
if (!page.isPresent()) {
|
||||
throw new InvalidCommandArgument(String.format("'%s' is not a number.", pageString), false);
|
||||
}
|
||||
return new PageFilter(new ContentFilter(filter), page.get());
|
||||
}
|
||||
|
||||
private Optional<Integer> tryParseInt(String value) {
|
||||
try {
|
||||
return Optional.of(Integer.parseInt(value));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.CommandHelp;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.HelpEntry;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commands.AnchorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.BedCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CheckCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CloneCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfigCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.DebugCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GameRuleCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ImportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.InfoCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.LoadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ModifyCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.PurgeCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RegenCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RootCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ScriptCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SilentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SubModulesCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.UsageCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.VersionCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.WhoCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
|
||||
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Heart of Multiverse Command Handler.
|
||||
*/
|
||||
public class MVCommandManager extends PaperCommandManager {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
private final CommandQueueManager commandQueueManager;
|
||||
private final Map<String, BaseCommand> subModuleRootCommands;
|
||||
|
||||
private static final Pattern PERMISSION_SPLIT = Pattern.compile(",");
|
||||
|
||||
public MVCommandManager(@NotNull MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
this.commandQueueManager = new CommandQueueManager(plugin);
|
||||
this.subModuleRootCommands = new HashMap<>(3);
|
||||
new MVCommandConditions(plugin, getCommandConditions());
|
||||
|
||||
// Setup help command
|
||||
enableUnstableAPI("help");
|
||||
setDefaultHelpPerPage(6);
|
||||
|
||||
// General plugin command
|
||||
registerCommand(new RootCommand(this.plugin));
|
||||
registerCommand(new UsageCommand(this.plugin));
|
||||
registerCommand(new VersionCommand(this.plugin));
|
||||
|
||||
// World commands
|
||||
registerCommand(new CreateCommand(this.plugin));
|
||||
registerCommand(new ImportCommand(this.plugin));
|
||||
registerCommand(new LoadCommand(this.plugin));
|
||||
registerCommand(new UnloadCommand(this.plugin));
|
||||
registerCommand(new RemoveCommand(this.plugin));
|
||||
registerCommand(new CloneCommand(this.plugin));
|
||||
registerCommand(new RegenCommand(this.plugin));
|
||||
registerCommand(new DeleteCommand(this.plugin));
|
||||
registerCommand(new ConfirmCommand(this.plugin));
|
||||
|
||||
// Properties management commands
|
||||
registerCommand(new ConfigCommand(this.plugin));
|
||||
registerCommand(new GameRuleCommand(this.plugin));
|
||||
registerCommand(new ModifyCommand(this.plugin));
|
||||
registerCommand(new SetSpawnCommand(this.plugin));
|
||||
registerCommand(new PurgeCommand(this.plugin));
|
||||
|
||||
// Show information commands
|
||||
registerCommand(new InfoCommand(this.plugin));
|
||||
registerCommand(new CoordCommand(this.plugin));
|
||||
registerCommand(new EnvironmentCommand(this.plugin));
|
||||
registerCommand(new GeneratorCommand(this.plugin));
|
||||
registerCommand(new ListCommand(this.plugin));
|
||||
registerCommand(new WhoCommand(this.plugin));
|
||||
|
||||
// Teleport commands
|
||||
registerCommand(new TeleportCommand(this.plugin));
|
||||
registerCommand(new AnchorCommand(this.plugin));
|
||||
registerCommand(new BedCommand(this.plugin));
|
||||
registerCommand(new SpawnCommand(this.plugin));
|
||||
|
||||
// Misc commands
|
||||
registerCommand(new DebugCommand(this.plugin));
|
||||
registerCommand(new CheckCommand(this.plugin));
|
||||
registerCommand(new ReloadCommand(this.plugin));
|
||||
registerCommand(new SilentCommand(this.plugin));
|
||||
registerCommand(new ScriptCommand(this.plugin));
|
||||
|
||||
// Sub-modules
|
||||
addAvailableSubModule("mvnp", new SubModulesCommand.NetherPortals());
|
||||
addAvailableSubModule("mvp", new SubModulesCommand.Portals());
|
||||
addAvailableSubModule("mvinv", new SubModulesCommand.Inventories());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use for download link suggestion for sub-module
|
||||
*
|
||||
* @param moduleName A sub-module for Multiverse.
|
||||
* @param cmd Command to register.
|
||||
*/
|
||||
private void addAvailableSubModule(@NotNull String moduleName,
|
||||
@NotNull BaseCommand cmd) {
|
||||
|
||||
subModuleRootCommands.put(moduleName, cmd);
|
||||
registerCommand(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace suggest download with actual command from sub-module.
|
||||
*
|
||||
* @param moduleName A sub-module for Multiverse.
|
||||
* @param cmd Command to register.
|
||||
*/
|
||||
public void registerSubModule(@NotNull String moduleName,
|
||||
@NotNull BaseCommand cmd) {
|
||||
|
||||
unregisterCommand(subModuleRootCommands.remove(moduleName));
|
||||
registerCommand(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MVCommandContexts getCommandContexts() {
|
||||
if (this.contexts == null) {
|
||||
this.contexts = new MVCommandContexts(this, plugin);
|
||||
}
|
||||
return (MVCommandContexts) this.contexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MVCommandCompletions getCommandCompletions() {
|
||||
if (this.completions == null) {
|
||||
this.completions = new MVCommandCompletions(this, plugin);
|
||||
}
|
||||
return (MVCommandCompletions) this.completions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change default implementation to be able to choose from OR / AND
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(@NotNull CommandIssuer issuer,
|
||||
@Nullable Set<String> permissions) {
|
||||
|
||||
if (permissions == null || permissions.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (permissions.contains("AND"))
|
||||
? andPermissionCheck(issuer, permissions)
|
||||
: orPermissionCheck(issuer, permissions);
|
||||
}
|
||||
|
||||
private boolean orPermissionCheck(@NotNull CommandIssuer issuer,
|
||||
@NotNull Set<String> permissions) {
|
||||
|
||||
return permissions.stream()
|
||||
.unordered()
|
||||
.anyMatch(permission -> hasPermission(issuer, permission));
|
||||
}
|
||||
|
||||
private boolean andPermissionCheck(@NotNull CommandIssuer issuer,
|
||||
@NotNull Set<String> permissions) {
|
||||
|
||||
return permissions.stream()
|
||||
.unordered()
|
||||
.allMatch(permission -> hasPermission(issuer, permission));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change default implementation to be able to choose from OR / AND
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(@NotNull CommandIssuer issuer,
|
||||
@Nullable String permission) {
|
||||
|
||||
if (permission == null || permission.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (permission.startsWith("AND:")) {
|
||||
return Arrays.stream(PERMISSION_SPLIT.split(permission.substring(4)))
|
||||
.unordered()
|
||||
.allMatch(issuer::hasPermission);
|
||||
}
|
||||
return Arrays.stream(PERMISSION_SPLIT.split(permission))
|
||||
.unordered()
|
||||
.anyMatch(issuer::hasPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets {@link CommandQueueManager}.
|
||||
*
|
||||
* @return {@link CommandQueueManager}.
|
||||
*/
|
||||
public CommandQueueManager getQueueManager() {
|
||||
return commandQueueManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standardise usage command formatting for all mv modules.
|
||||
*
|
||||
* @param help The target {@link CommandHelp}.
|
||||
*/
|
||||
public void showUsage(@NotNull CommandHelp help) {
|
||||
List<HelpEntry> entries = help.getHelpEntries();
|
||||
|
||||
if (entries.size() == 1) {
|
||||
this.plugin.getMVCommandManager().getHelpFormatter().showDetailedHelp(help, entries.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
help.showHelp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Standardise root command for all mv modules.
|
||||
*
|
||||
* @param sender Sender to send the info to.
|
||||
* @param description mv-module's description and info.
|
||||
* @param color Special colour for each mv-module.
|
||||
* @param rootCmd mv-module's root command name.
|
||||
*/
|
||||
public void showPluginInfo(@NotNull CommandSender sender,
|
||||
@NotNull PluginDescriptionFile description,
|
||||
@NotNull ColorAlternator color,
|
||||
@NotNull String rootCmd) {
|
||||
|
||||
sender.sendMessage(String.format("%s%s %s| %sv%s",
|
||||
color.getThisColor(), description.getName(), ChatColor.DARK_GRAY,
|
||||
color.getThatColor(), description.getVersion()));
|
||||
|
||||
sender.sendMessage(String.format("%sSee %s/%s help %sfor commands available.",
|
||||
ChatColor.DARK_GREEN, ChatColor.GREEN, rootCmd, ChatColor.DARK_GREEN));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.CommandCompletionContext;
|
||||
import co.aikar.commands.RegisteredCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.ReflectHelper;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class MVCommandReflect {
|
||||
|
||||
private static final Field commandScope;
|
||||
private static final Field commandField;
|
||||
|
||||
static {
|
||||
commandField = ReflectHelper.getField(CommandCompletionContext.class, "command");
|
||||
commandScope = ReflectHelper.getField(RegisteredCommand.class, "scope");
|
||||
}
|
||||
|
||||
public static MultiverseCommand getCommandCompletionContextCommand(CommandCompletionContext context) {
|
||||
RegisteredCommand registeredCommand = ReflectHelper.getFieldValue(context, commandField);
|
||||
return ReflectHelper.getFieldValue(registeredCommand, commandScope);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
|
||||
|
||||
public class MultiverseCommand extends BaseCommand {
|
||||
|
||||
private FlagGroup flagGroup;
|
||||
|
||||
public MultiverseCommand() {
|
||||
super();
|
||||
}
|
||||
|
||||
public FlagGroup getFlagGroup() {
|
||||
return flagGroup;
|
||||
}
|
||||
|
||||
public void setFlagGroup(FlagGroup flagGroup) {
|
||||
this.flagGroup = flagGroup;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools.context;
|
||||
|
||||
import org.bukkit.GameRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Single key value pair for a game rule.
|
||||
*
|
||||
* @param <T> Type of GameRule property.
|
||||
*/
|
||||
public class GameRuleProperty<T> {
|
||||
|
||||
private final GameRule<T> gameRule;
|
||||
private final T value;
|
||||
|
||||
public GameRuleProperty(@NotNull GameRule<T> gameRule,
|
||||
@NotNull T value) {
|
||||
|
||||
this.gameRule = gameRule;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GameRule<T> getGameRule() {
|
||||
return gameRule;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commandtools.context;
|
||||
|
||||
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Filter and paging.
|
||||
*/
|
||||
public class PageFilter {
|
||||
private final ContentFilter filter;
|
||||
private final int page;
|
||||
|
||||
public PageFilter(@NotNull ContentFilter filter,
|
||||
int page) {
|
||||
this.filter = filter;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ContentFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.context;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RequiredPlayer {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public RequiredPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player get() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Classes derived from parsing command args and context.
|
||||
*/
|
||||
package com.onarandombox.MultiverseCore.commandtools.context;
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flag;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* <p>Represents a flag that can be used in commands. This works as a key value pair.</p>
|
||||
*
|
||||
* <p>Key is the {@link #identifier} and {@link #aliases} set.</p>
|
||||
* <p>Value is the {@link T} parsed based on 3 scenarios during command input:</p>
|
||||
* <ol>
|
||||
* <li>Flag completely not present. {@link #getDefaultValue()}</li>
|
||||
* <li>Flag key present but no value. {@link #getValue()}</li>
|
||||
* <li>Flag key and value present. {@link #getValue(String)}</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param <T> The flag Type.
|
||||
*/
|
||||
public abstract class CommandFlag<T> {
|
||||
|
||||
protected final String name;
|
||||
protected final String identifier;
|
||||
protected final Class<T> type;
|
||||
protected final ValueRequirement valueRequirement;
|
||||
protected final Collection<String> aliases;
|
||||
|
||||
protected CommandFlag(@NotNull String name,
|
||||
@NotNull String identifier,
|
||||
@NotNull Class<T> type,
|
||||
@NotNull ValueRequirement valueRequirement) {
|
||||
|
||||
this.name = name;
|
||||
this.identifier = identifier;
|
||||
this.type = type;
|
||||
this.valueRequirement = valueRequirement;
|
||||
this.aliases = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name of the Command Flag.
|
||||
*
|
||||
* @return The Command Flag name.
|
||||
*/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets identifier of the Command Flag.
|
||||
*
|
||||
* @return The Command Flag identifier.
|
||||
*/
|
||||
@NotNull
|
||||
public String getIdentifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets {@link T} Type of the Command Flag.
|
||||
*
|
||||
* @return The Command Flag type.
|
||||
*/
|
||||
@NotNull
|
||||
public Class<T> getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the requirements of this Command Flag user input value.
|
||||
*
|
||||
* @return The {@link ValueRequirement}.
|
||||
*/
|
||||
@NotNull
|
||||
public ValueRequirement getValueRequirement() {
|
||||
return this.valueRequirement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the alternative key identifiers set for this Command Flag.
|
||||
*
|
||||
* @return Collection of aliases.
|
||||
*/
|
||||
@NotNull
|
||||
public Collection<String> getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add alternative key identifiers for this Command Flag.
|
||||
*
|
||||
* @param aliases Alias(es) to be added.
|
||||
* @return A {@link CommandFlag}.
|
||||
*/
|
||||
public CommandFlag<T> addAliases(String...aliases) {
|
||||
Collections.addAll(this.aliases, aliases);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab-complete suggestion for this Command Flag values.
|
||||
*
|
||||
* @return Collection of suggested values available.
|
||||
*/
|
||||
public abstract Collection<String> suggestValue();
|
||||
|
||||
/**
|
||||
* When this Command Flag can get value by a user input.
|
||||
*
|
||||
* @return The {@link T} value.
|
||||
*/
|
||||
public abstract T getValue(@NotNull String input) throws FlagParseFailedException;
|
||||
|
||||
/**
|
||||
* When this Command Flag user input value is null/not present.
|
||||
*
|
||||
* @return The {@link T} value.
|
||||
*/
|
||||
public T getValue() throws FlagParseFailedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this Command Flag is not present in command input.
|
||||
*
|
||||
* @return The {@link T} value.
|
||||
*/
|
||||
public T getDefaultValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommandFlag{" +
|
||||
"name='" + name + '\'' +
|
||||
", identifier='" + identifier + '\'' +
|
||||
", type=" + type +
|
||||
", valueRequirement=" + valueRequirement +
|
||||
", aliases=" + aliases +
|
||||
'}';
|
||||
}
|
||||
|
||||
public enum ValueRequirement {
|
||||
/**
|
||||
* No user input needed for value.
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* User input for value is optional.
|
||||
*/
|
||||
OPTIONAL,
|
||||
|
||||
/**
|
||||
* User input is required for Command Flag value.
|
||||
*/
|
||||
REQUIRED
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flag;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CoreFlags {
|
||||
|
||||
private static MultiverseCore multiverse;
|
||||
|
||||
public static void setCoreInstance(MultiverseCore plugin) {
|
||||
multiverse = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag for custom seed.
|
||||
*/
|
||||
public static final CommandFlag<String> SEED = new RequiredCommandFlag<String>
|
||||
("Seed", "--seed", String.class) {
|
||||
@Override
|
||||
public Collection<String> suggestValue() {
|
||||
return Collections.singleton(String.valueOf(new Random().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(@NotNull String input) throws FlagParseFailedException {
|
||||
return input;
|
||||
}
|
||||
}.addAliases("-s");
|
||||
|
||||
/**
|
||||
* Flag for custom seed. No value means random seed.
|
||||
*/
|
||||
public static final CommandFlag<String> RANDOM_SEED = new OptionalCommandFlag<String>
|
||||
("Seed", "--seed", String.class) {
|
||||
@Override
|
||||
public Collection<String> suggestValue() {
|
||||
return Collections.singletonList(String.valueOf(new Random().nextLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(@NotNull String input) throws FlagParseFailedException {
|
||||
return input;
|
||||
}
|
||||
}.addAliases("-s");
|
||||
|
||||
/**
|
||||
* Flag for world type used.
|
||||
*/
|
||||
public static final CommandFlag<WorldType> WORLD_TYPE = new RequiredCommandFlag<WorldType>
|
||||
("WorldType", "--type", WorldType.class) {
|
||||
|
||||
private final Map<String, WorldType> typeAlias = new HashMap<String, WorldType>(4){{
|
||||
put("normal", WorldType.NORMAL);
|
||||
put("flat", WorldType.FLAT);
|
||||
put("largebiomes", WorldType.LARGE_BIOMES);
|
||||
put("amplified", WorldType.AMPLIFIED);
|
||||
}};
|
||||
|
||||
@Override
|
||||
public Collection<String> suggestValue() {
|
||||
return typeAlias.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getValue(@NotNull String input) throws FlagParseFailedException {
|
||||
WorldType type = typeAlias.get(input);
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
try {
|
||||
return WorldType.valueOf(input.toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new FlagParseFailedException("'%s' is not a valid. See /mv env for available World Type.", input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getDefaultValue() {
|
||||
return WorldType.NORMAL;
|
||||
}
|
||||
}.addAliases("-t");
|
||||
|
||||
/**
|
||||
* Flag for world generator.
|
||||
*/
|
||||
public static final CommandFlag<String> GENERATOR = new RequiredCommandFlag<String>
|
||||
("Generator", "--gen", String.class) {
|
||||
@Override
|
||||
public Collection<String> suggestValue() {
|
||||
return Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins())
|
||||
.filter(Plugin::isEnabled)
|
||||
.filter(plugin -> multiverse.getUnsafeCallWrapper().wrap(
|
||||
() -> plugin.getDefaultWorldGenerator("world", ""),
|
||||
plugin.getName(),
|
||||
"Get generator"
|
||||
) != null)
|
||||
.map(plugin -> plugin.getDescription().getName())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(@NotNull String input) throws FlagParseFailedException {
|
||||
String[] genArray = input.split(":");
|
||||
String generator = genArray[0];
|
||||
String generatorId = (genArray.length > 1) ? genArray[1] : "";
|
||||
try {
|
||||
if (multiverse.getMVWorldManager().getChunkGenerator(generator, generatorId, "test") == null) {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new FlagParseFailedException("Invalid generator string '%s'. See /mv gens for available generators.", input);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}.addAliases("-g");
|
||||
|
||||
/**
|
||||
* Flag to toggle if world should generate structures.
|
||||
*/
|
||||
public static final CommandFlag<Boolean> GENERATE_STRUCTURES = new RequiredCommandFlag<Boolean>
|
||||
("GenerateStructures", "--structures", Boolean.class) {
|
||||
@Override
|
||||
public Collection<String> suggestValue() {
|
||||
return Arrays.asList("true", "false");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue(@NotNull String input) throws FlagParseFailedException {
|
||||
return input.equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getDefaultValue() {
|
||||
return true;
|
||||
}
|
||||
}.addAliases("--structure", "-a");
|
||||
|
||||
/**
|
||||
* Flag to toggle if world spawn should be adjusted.
|
||||
*/
|
||||
public static final CommandFlag<Boolean> SPAWN_ADJUST = new NoValueCommandFlag<Boolean>
|
||||
("AdjustSpawn", "--dont-adjust-spawn", Boolean.class) {
|
||||
@Override
|
||||
public Boolean getValue() throws FlagParseFailedException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getDefaultValue() {
|
||||
return true;
|
||||
}
|
||||
}.addAliases("-n");
|
||||
|
||||
/**
|
||||
* Flag to specify a paste service.
|
||||
*/
|
||||
public static final CommandFlag<PasteServiceType> PASTE_SERVICE_TYPE = new OptionalCommandFlag<PasteServiceType>
|
||||
("PasteServiceType", "--paste", PasteServiceType.class) {
|
||||
|
||||
private final List<String> pasteTypes = Arrays.stream(PasteServiceType.values())
|
||||
.filter(pt -> pt != PasteServiceType.NONE)
|
||||
.map(p -> p.toString().toLowerCase())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@Override
|
||||
public Collection<String> suggestValue() {
|
||||
return pasteTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasteServiceType getValue(@NotNull String input) throws FlagParseFailedException {
|
||||
try {
|
||||
return PasteServiceType.valueOf(input.toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new InvalidCommandArgument(String.format("Invalid paste service type '%s'.", input));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasteServiceType getValue() throws FlagParseFailedException {
|
||||
return PasteServiceType.PASTEGG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasteServiceType getDefaultValue() {
|
||||
return PasteServiceType.NONE;
|
||||
}
|
||||
}.addAliases("-p");
|
||||
|
||||
/**
|
||||
* Flag to toggle if plugin list should be included.
|
||||
*/
|
||||
public static final CommandFlag<Boolean> INCLUDE_PLUGIN_LIST = new NoValueCommandFlag<Boolean>
|
||||
("IncludePlugins", "--include-plugin-list", Boolean.class) {
|
||||
@Override
|
||||
public Boolean getValue() throws FlagParseFailedException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getDefaultValue() {
|
||||
return true;
|
||||
}
|
||||
}.addAliases("-pl");
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flag;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FlagGroup {
|
||||
|
||||
public static FlagGroup of(CommandFlag<?>...flags) {
|
||||
return new FlagGroup(flags);
|
||||
}
|
||||
|
||||
private final List<String> flagIdentifiers;
|
||||
private final Map<String, CommandFlag<?>> flagKeyMap;
|
||||
|
||||
private FlagGroup(CommandFlag<?>[] commandFlags) {
|
||||
this.flagIdentifiers = new ArrayList<>(commandFlags.length);
|
||||
this.flagKeyMap = new HashMap<>();
|
||||
for (CommandFlag<?> flag : commandFlags) {
|
||||
addFlag(flag);
|
||||
}
|
||||
}
|
||||
|
||||
private void addFlag(CommandFlag<?> flag) {
|
||||
this.flagIdentifiers.add(flag.getIdentifier());
|
||||
this.flagKeyMap.put(flag.getIdentifier(), flag);
|
||||
for (String flagAlias : flag.getAliases()) {
|
||||
this.flagKeyMap.put(flagAlias, flag);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FlagResult calculateResult(String[] args) {
|
||||
return FlagResult.parse(args,this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CommandFlag<?> getByKey(String key) {
|
||||
return this.flagKeyMap.get(key);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<String> getFlagIdentifiers() {
|
||||
return flagIdentifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FlagGroup{" +
|
||||
"flagIdentifiers=" + flagIdentifiers +
|
||||
", keyFlagMap=" + flagKeyMap +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.onarandombox.MultiverseCore.commandtools.flag;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
|
||||
public class FlagParseFailedException extends InvalidCommandArgument {
|
||||
|
||||
public FlagParseFailedException() {
|
||||
}
|
||||
|
||||
public FlagParseFailedException(String message, Object...replacements) {
|
||||
super(String.format(message, replacements), true);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 456 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user