Compare commits

..
193 Commits
Author SHA1 Message Date
Ben Woo 82a274bad2 Merge pull request #2954 from Multiverse/fix-release-type
fix: Release mode for release promotion
2023-08-22 11:14:08 +08:00
Ben Woo 8aa01026ea fix: Release mode for release promotion 2023-08-22 11:12:13 +08:00
Ben Woo 750d1ea4fa Merge pull request #2953 from Multiverse/fix-download-artifact
fix: Download artifact wrong file version
2023-08-22 11:02:38 +08:00
Ben Woo 586ac4a90e fix: Download artifact wrong file version 2023-08-22 10:56:59 +08:00
Jeremy Wood 816d5f86d6 Merge pull request #2952 from Multiverse/fix-version
fix: Version of fetch-gh-release-asset
2023-08-21 22:50:46 -04:00
Ben Woo 7e8ebfb8cd fix: Version of fetch-gh-release-asset 2023-08-22 10:47:50 +08:00
Jeremy Wood 350d228975 Merge pull request #2951 from Multiverse/release-actions
Revamp release actions
2023-08-21 22:44:19 -04:00
Ben Woo 2126efe27c fix: Remove error echo message 2023-08-22 10:24:52 +08:00
Ben Woo 3330bd3031 feat: Remove PR labeler and change "no version bump" to "no release" 2023-08-22 09:48:46 +08:00
Ben Woo 4f5b4126f4 Merge branch 'main' into release-actions 2023-08-21 23:26:04 +08:00
Ben Woo c4a80d7b78 feat: use new semantic release action for release promote 2023-08-21 23:22:35 +08:00
Ben Woo d31f7e9d87 fix: Modrinth upload action missing steps 2023-08-21 23:15:25 +08:00
Ben Woo 356d67edf4 feat: Use new semantic release action 2023-08-21 23:00:00 +08:00
Jeremy Wood 8865cfb53f Merge pull request #2948 from Multiverse/fix-null-teleporter
Fix teleporter reference being null
2023-08-20 23:23:15 -04:00
Ben Woo bf72328c37 feat: Complete release actions to DBO and Modrinth 2023-08-20 22:16:20 +08:00
Ben Woo 9a80620aa1 Fix teleporter reference being null 2023-08-20 20:26:52 +08:00
Ben Woo 982eb28f2a Merge pull request #2950 from Multiverse/dbo-upload
Add github action for DBO upload
2023-08-20 19:52:41 +08:00
Ben Woo 4ecd65a589 Add github action for DBO upload 2023-08-20 19:51:02 +08:00
Ben Woo 5fbe16ed5a Merge pull request #2949 from Multiverse/fix-regen-args
Fix regen args parsing logic
2023-08-20 19:50:40 +08:00
Ben Woo 582d256f38 Fix regen args parsing logic 2023-08-19 12:11:13 +08:00
Jeremy Wood 26e587805d Merge pull request #2947 from Multiverse/modrinth-for-promote-release
Upload to modrinth when manually promote release
2023-08-15 23:56:19 -04:00
Ben Woo 3ad2322db7 Upload to modrinth when manually promote release 2023-08-15 23:28:39 +08:00
Jeremy Wood 8764108edd Merge pull request #2946 from Multiverse/force-release
Remove line break from README.md
2023-08-15 10:52:13 -04:00
Jeremy Wood 5fa8e9acf6 Remove line break from README.md
This is just to force a new prerelease.
2023-08-15 10:51:47 -04:00
Jeremy Wood 0ead2da16f Merge pull request #2945 from Multiverse/modrinth-game-version
Fix add missing game version for modrinth
2023-08-15 10:46:59 -04:00
Ben Woo fd4bc7cf60 Fix add missing game version for modrinth 2023-08-15 22:35:10 +08:00
Jeremy Wood ad296fde1f Merge pull request #2944 from Multiverse/fix-modrinth-gha
Fix modrinth gha upload
2023-08-15 10:25:59 -04:00
Ben Woo 6f39a2c97d Fix modrinth gha upload 2023-08-15 14:54:16 +08:00
Jeremy Wood befb2b54d8 Merge pull request #2880 from Multiverse/modrinth-upload
feat: Add automatic Modrinth upload
2023-08-14 11:44:26 -04:00
Zax71 efcd14830e Remove unused GITHUB_TOKEN 2023-08-11 20:24:01 +01:00
Zax71 491bb2467f Add 1.20 to supported versions 2023-08-04 16:28:05 +01:00
Zax71 dfbe81c785 Implement requested changes 2023-08-03 11:11:29 +01:00
Zax71 986bafc13d Merge branch 'main' into modrinth-upload 2023-06-27 16:52:29 +01:00
Zax71 9b4613ce84 Support 1.13+ 2023-06-27 16:50:46 +01:00
Jeremy Wood 48e875d13e Merge pull request #2908 from Multiverse/dumptruckman/fix_classifier
Remove the published jar classifier for maven publish.
2023-04-05 08:48:36 -04:00
Jeremy Wood 14b54d5269 Remove the published jar classifier for maven publish.
Fixes #2906.
2023-04-05 08:38:37 -04:00
Jeremy Wood 1c24b17c90 Merge pull request #2872 from Multiverse/new-readme-2
Update README.md
2023-03-30 08:42:10 -04:00
Ben Woo 346ac94737 Merge branch 'main' into new-readme-2 2023-03-27 10:16:41 +08:00
zax71 6d351300de chore: remove Modrinth for now
Signed-off-by: zax71 <zabax32@gmail.com>
2023-03-26 18:26:23 +01:00
Jeremy Wood 8a69d6ad43 Merge pull request #2883 from Multiverse/artifact_pr_build
build: Add artifacting of PR build
2023-03-03 11:30:37 -05:00
Ben Woo 3b44ea218d build: Fix PR build number 2023-03-03 23:28:55 +08:00
Ben Woo 68c97f7ae6 build: Add artifacting of PR build 2023-03-03 23:21:36 +08:00
zax71 68411ae6bf Add correct number of newlines
Signed-off-by: zax71 <zabax32@gmail.com>
2023-03-02 12:54:20 +00:00
zax71 2c5e86c689 Add Modrinth Upload 2023-03-02 12:37:07 +00:00
Jeremy Wood 4eca331430 Merge pull request #2877 from Multiverse/dumptruckman/separate_test_deps
Use a separate API version for running tests.
2023-03-02 00:53:24 -05:00
Jeremy Wood b6574245b8 Remove junit exclusion from compileOnly bukkit. 2023-03-02 00:48:54 -05:00
Jeremy Wood 85d744d79f Run tests against spigot-api 1.19.3. 2023-03-02 00:44:32 -05:00
Jeremy Wood e536dff1a8 Use a separate bukkit dependency for tests. 2023-03-02 00:37:30 -05:00
Jeremy Wood 39287f55ef Delete CODEOWNERS. 2023-03-01 23:36:41 -05:00
Ben WooandJeremy Wood d5ebde53b9 Add maven central to repositories (#2859)
Co-authored-by: Jeremy Wood <farachan@gmail.com>
2023-03-02 12:32:07 +08:00
Jeremy Wood 101ddae443 Create CODEOWNERS. 2023-02-28 23:03:50 -05:00
zax71 c3eb0ee8bd Center Logo 2023-02-26 14:00:37 +00:00
zax71 6a8c0b6255 Update README.md 2023-02-26 13:56:56 +00:00
Jeremy Wood 2b97f7310f Use pull_request_target for auto labeler. 2023-02-25 20:39:56 -05:00
Jeremy Wood 073091525b Label PRs automatically as prerelease. 2023-02-25 20:34:19 -05:00
Jeremy Wood 79b9c12319 Change job name for manually promoting releases. 2023-02-25 20:29:04 -05:00
Jeremy Wood 01f745b027 Skip checking PR labels. 2023-02-25 19:39:14 -05:00
Jeremy Wood 9725bdfeeb Use ref input. 2023-02-25 14:02:01 -05:00
Jeremy Wood cdf9767959 Use target_commitish for GITHUA_SHA. 2023-02-25 13:41:26 -05:00
Jeremy Wood 66e21da6b2 Add version to publish action as well. 2023-02-25 13:39:59 -05:00
Jeremy Wood 87b14d3944 Add publish and upload. 2023-02-25 13:34:24 -05:00
Jeremy Wood 7bbeb90320 Remove dry_run. 2023-02-25 13:34:10 -05:00
Jeremy Wood cd895d03dc Remove extra } in bump_version_scheme. 2023-02-25 13:32:08 -05:00
Jeremy Wood ee2a304148 Reorder version bump types. 2023-02-25 13:31:49 -05:00
Jeremy Wood 06e9e33da4 Workflow requires version bump type. 2023-02-25 13:28:36 -05:00
Jeremy Wood 7065ffaea2 Remove checkstyle from promote workflow. 2023-02-25 13:24:24 -05:00
Jeremy Wood 1bc4e68ff9 Use promote scheme for manual workflow. 2023-02-25 13:20:40 -05:00
Jeremy Wood 4e53d13290 Add workflow for manually promoting a release. 2023-02-25 13:10:53 -05:00
Jeremy Wood 90344d36df Merge pull request #2867 from Multiverse/no_version_bump
Use "no version bump" label instead of "no release".
2023-02-24 13:19:16 -05:00
Jeremy Wood f36a56e854 Use "no version bump" label instead of "no release". 2023-02-24 13:17:39 -05:00
Jeremy Wood 5d4bacc80e Merge pull request #2866 from Multiverse/test_prerelease_2
Remove space to test pre-releases
2023-02-24 12:40:57 -05:00
Jeremy Wood d88bf6e137 Remove space to test pre-releases 2023-02-24 12:40:36 -05:00
Jeremy Wood 63f5d769d8 Merge pull request #2865 from Multiverse/prerelease-test
Add space to trigger release.
2023-02-24 11:57:39 -05:00
Jeremy Wood 9a9bfc03b9 Add space to trigger release. 2023-02-24 11:57:02 -05:00
Jeremy Wood 28112ef4d8 Merge pull request #2864 from Multiverse/simplify_release_name
Drop "Release" prefix on release names.
2023-02-24 11:46:47 -05:00
Jeremy Wood 7e5a3238b8 Drop "Release" prefix on release names. 2023-02-24 11:44:06 -05:00
Jeremy Wood 3279a6a38d Merge pull request #2863 from Multiverse/prerelease_snapshot
Check if the tag name contains pre instead of checking PR labels.
2023-02-24 11:34:18 -05:00
Jeremy Wood b64e48769d Check if the tag name contains pre instead of checking PR labels. 2023-02-24 11:29:28 -05:00
Jeremy Wood ff8002fc13 Merge pull request #2862 from Multiverse/prerelease_snapshot
Publish prerelease versions as snapshots.
2023-02-24 11:21:09 -05:00
Jeremy Wood 2af835f0c3 Publish prerelease versions as snapshots. 2023-02-24 11:15:36 -05:00
Jeremy Wood bf25b65f09 Merge pull request #2861 from Multiverse/test_prerelease
Test prerelease workflow.
2023-02-24 10:53:54 -05:00
Jeremy Wood 52eb3d820f Test out the prerelease action. 2023-02-24 09:58:10 -05:00
Jeremy Wood 908fcb1e44 Merge pull request #2854 from Multiverse/dumptruckman/fix_release_8
Combine release and publish into a single workflow.
2023-02-20 07:20:05 -05:00
Jeremy Wood 73cd26aea3 Combine release and publish into a single workflow. 2023-02-20 07:17:37 -05:00
Jeremy Wood 758d25812b Merge pull request #2853 from Multiverse/fix-gha-release
Fix upload release artifact
2023-02-20 06:42:31 -05:00
Ben Woo fa0ef421c7 Merge branch 'main' into fix-gha-release 2023-02-20 14:57:52 +08:00
Ben Woo e936a6271f Fix upload release artifact 2023-02-20 14:57:01 +08:00
Jeremy Wood 7362e543da Merge pull request #2851 from Multiverse/dumptruckman/fix_release_7
Use new action for uploading artifact.
2023-02-20 00:58:06 -05:00
Jeremy Wood 8a46d70301 Use new action for uploading artifact. 2023-02-20 00:57:21 -05:00
Jeremy Wood a168e5cb48 Merge pull request #2850 from Multiverse/dumptruckman/fix_release_6
Massage the strange release upload url.
2023-02-20 00:38:53 -05:00
Jeremy Wood ae578f9491 Massage the strange release upload url. 2023-02-20 00:36:45 -05:00
Jeremy Wood e72122378d Merge pull request #2849 from Multiverse/dumptruckman/fix_release_5
Fix name of consumed output variable on get_release in more places.
2023-02-20 00:06:05 -05:00
Jeremy Wood fd2ea3df09 Remove tag prefix. 2023-02-20 00:04:43 -05:00
Jeremy Wood e94e071c6e Fix name of consumed output variable on get_release in more places. 2023-02-19 23:58:26 -05:00
Jeremy Wood 0e19236cdc Merge pull request #2848 from Multiverse/dumptruckman/fix_release_4
Use lowercase artifact id.
2023-02-19 23:53:45 -05:00
Jeremy Wood 1c12756acf Use lowercase artifact id. 2023-02-19 23:51:14 -05:00
Jeremy Wood bcfde80c07 Merge pull request #2847 from Multiverse/dumptruckman/fix_release_3
Fix name for consumed output variable on get_release.
2023-02-19 23:39:16 -05:00
Jeremy Wood 8dc9e864eb Fix name for consumed output variable on get_release. 2023-02-19 23:37:25 -05:00
Jeremy Wood fec820f4ba Merge pull request #2846 from Multiverse/dumptruckman/fix_release_2
Use PAT to create release.
2023-02-19 23:27:49 -05:00
Jeremy Wood ff9ffad302 Use organization PAT for creating release. 2023-02-19 23:25:10 -05:00
Jeremy Wood fc2cb6aeae Move publish jobs back into publish action. 2023-02-19 23:24:44 -05:00
Jeremy Wood d2776ef448 Merge pull request #2844 from Multiverse/dumptruckman/fix_release
Fix build & publish.
2023-02-19 22:55:44 -05:00
Jeremy Wood 36ef41b710 Release and publish in the same action. 2023-02-19 22:51:30 -05:00
Jeremy Wood 9258ebd8c7 Remove Intellij gradle plugin. :( 2023-02-19 21:57:13 -05:00
Jeremy Wood d528cbcafd Merge pull request #2826 from Multiverse/dumptruckman/gradle
Switch from Maven to Gradle.
2023-02-19 20:48:01 -05:00
Jeremy Wood 760c193b0e Readd test workflow. 2023-02-19 19:36:20 -05:00
Jeremy Wood 7c6edcb081 Fix the required label names. 2023-02-19 19:09:02 -05:00
Jeremy Wood 009a94f74d Publish releases. 2023-02-19 19:03:45 -05:00
Jeremy Wood bd6fb4e51c Correctly disable useless IntelliJ plugin tasks. 2023-02-19 19:03:40 -05:00
Jeremy Wood 2fdef44744 Create release on push to main branch. 2023-02-19 19:03:40 -05:00
Jeremy Wood 5b991f44e2 Require release related label on PRs against main branch. 2023-02-19 19:03:39 -05:00
zax71 871ba16b67 Implement requested changes 2023-02-19 19:03:39 -05:00
zax71 e90c50d170 Add Caching to GitHub actions and update README.md to reflect Gradle 2023-02-19 19:03:39 -05:00
zax71 d1be3bd0be Update GitHub Actions to Gradle 2023-02-19 19:03:37 -05:00
Jeremy Wood 4d40b3f7e4 Switch from Maven to Gradle. 2023-02-19 19:02:52 -05:00
Chris 1877479094 Update github actions dependencies (#2825)
* Update Actions

* Trigger Test Build

* Fix build

* Remove Test build Trigger
2023-02-08 12:37:01 +08:00
Ben Woo 20ce469aec Merge pull request #2765 from Multiverse/java17
Bump notnull-instrumenter-maven-plugin
2022-03-07 12:19:25 +08:00
Kermina Awad 70c91f777f bump notnull-instrumenter-maven-plugin
fixes compiling on Java 17
2022-03-06 22:42:38 -05:00
Ben Woo cc24f38d83 Merge pull request #2763 from Multiverse/bitly_domain
Remove j.mp Domain from BitlyURLShortener
2022-03-06 13:55:25 +08:00
nicegamer7 5ec27db284 remove j.mp domain from BitlyURLShortener 2022-03-05 09:35:10 -05:00
Ben Woo 5d6bc806f0 Merge pull request #2747 from KisaragiEffective/feature/use-collections-static-methods
use Collections' factory method instead of static field
2022-01-17 16:42:18 +08:00
Kisaragi 5868ad64b4 use Collections' factory method instead of static field
this resolves some unchecked generics warning
2021-12-31 00:46:21 +09:00
nicegamer7 ac6fcf5ed6 Merge pull request #2728 from Multiverse/benwoo1110-patch-2
More typo fixes to issue template.
2021-10-11 22:38:00 -04:00
Ben Woo 231824fd34 More typo fixes to issue template. 2021-10-08 11:58:43 +08:00
Ben Woo a3e7efcc58 Merge pull request #2727 from Artuto/fix-bug-report-issue-template
Fix Bug Report issue template
2021-10-08 11:53:30 +08:00
Artuto a649307a29 Fix Bug Report issue template 2021-10-07 22:52:22 -05:00
nicegamer7 b0235757cc Merge pull request #2719 from Multiverse/issue-forms
Use new issue forms.
2021-10-07 22:41:15 -04:00
Ben Wooandnicegamer7 06ee82a745 Update .github/ISSUE_TEMPLATE/feature-request.yml
Co-authored-by: nicegamer7 <kerminaawad@gmail.com>
2021-10-08 10:38:06 +08:00
Ben Wooandnicegamer7 d2cad7ca8d Update .github/ISSUE_TEMPLATE/feature-request.yml
Co-authored-by: nicegamer7 <kerminaawad@gmail.com>
2021-10-08 10:38:00 +08:00
nicegamer7 2390aa8f92 Merge pull request #2717 from Multiverse/fix-dest-velocity
Fix velocity not applying.
2021-10-07 22:36:47 -04:00
nicegamer7 674c4a4a06 Merge pull request #2720 from Multiverse/link-license
Link licence to LICENSE.md and add badge.
2021-10-07 21:48:05 -04:00
Ben Woo 768402088a Link licence to LICENSE.md and add badge. 2021-10-01 21:47:31 +08:00
Ben Woo 084033cc90 Use new issue forms. 2021-10-01 21:34:18 +08:00
Ben Woo 51801b1b36 Fix velocity not apply. 2021-10-01 15:11:03 +08:00
Jeremy Wood 71054197f2 Bump version to 4.3.2-SNAPSHOT for continued development. 2021-09-18 01:27:33 -04:00
Jeremy Wood 610f96415f Release version 4.3.1. 2021-09-18 01:18:40 -04:00
Jeremy Wood 34fa336f00 Revert "Add pipeline stuff."
This reverts commit 719ade19f7.
2021-08-25 09:40:58 -04:00
Jeremy Wood d92d62bce9 Revert "Fix task file path."
This reverts commit cf14d41d19.
2021-08-25 09:40:58 -04:00
Jeremy Wood cf14d41d19 Fix task file path. 2021-08-25 09:38:13 -04:00
Jeremy Wood 719ade19f7 Add pipeline stuff. 2021-08-25 09:37:22 -04:00
Ben Woo 1a8a97daf1 Merge pull request #2675 from Multiverse/replace_travis_badge
Replace Travis Badge with Github Actions.
2021-07-22 10:12:35 +08:00
nicegamer7 d9dffa8e6d replace travis badge 2021-07-21 22:11:09 -04:00
nicegamer7 973588defb Merge pull request #2175 from JLLeitschuh/fix/JLL/use_https_to_resolve_dependencies
[SECURITY] Use HTTPS to resolve dependencies in Maven Build
2021-07-19 20:14:17 -04:00
nicegamer7 c704c1ca3a Merge branch 'main' into fix/JLL/use_https_to_resolve_dependencies 2021-07-19 20:12:25 -04:00
Ben Woo c33a268b91 Merge pull request #2672 from Multiverse/fix_java16_tests
Fix Tests on Java 16 and code cleanup.
2021-07-19 10:31:31 +08:00
Kermina Awad 9821f1d9c8 clean up test files 2021-07-18 13:51:53 -04:00
Kermina Awad be6e0b67be don't run tests in parallel 2021-07-18 13:22:04 -04:00
Kermina Awad b9b1fa6164 remove PowerMockito 2021-07-18 13:17:15 -04:00
Kermina Awad 28585dd6f9 remove unnecessary stub 2021-07-18 13:12:09 -04:00
Ben Woo 47ca7b821b Move to GitHub actions (#2671)
* Remove use of travis.

* Add basic github action maven build.
2021-07-17 09:31:20 +08:00
nicegamer7 9ce2dfd100 Merge pull request #2445 from benwoo1110/fix-help
Fix issue where special chars cause PatternSyntaxException
2021-07-16 09:51:21 -04:00
Ben Woo 473ccd09d7 Don't need to toLowerCase filter. 2021-07-16 21:38:57 +08:00
Ben WooandJeremy Wood cc2e1d44b2 Implement new content display system. (#2584)
* Implement new content display system.

* Add @FunctionalInterface annotation to displaytools interfaces.

* Use static factory method to create Builder with contents.

* Use T for generic type since it's static method.

* Rename Builder#display to show and require CommandSender.

* Rename package from displaytools to display.

* Move DisplayHandler impls into their own package.

* Overload ContentDisplay#forContent with defaults for list and map.

* Pass CommandSender to send command.

This system is much more versatile when a single ContentDisplay instance
can be used for multiple players.

* Rename ContentDisplay#send to #show.

* Split DisplaySettings into separate classes.

Co-authored-by: Jeremy Wood <farachan@gmail.com>
2021-07-07 10:25:07 +08:00
Jeremy Wood 2e8f159d38 Merge pull request #2666 from Multiverse/https
Ensure https is used for repository.
2021-07-06 14:12:46 -04:00
Jeremy Wood 6581d16125 Merge pull request #2519 from Multiverse/readme-update
Update readme with more project details
2021-07-06 13:59:35 -04:00
Jeremy Wood 562bc56e83 Merge pull request #2664 from ccuser44/main
Create LICENSE.md
2021-07-06 13:56:16 -04:00
Ben Woo 4493cd7916 Ensure https is used for repository. 2021-07-06 23:27:53 +08:00
nicegamer7 1cd9e45915 Merge pull request #2663 from Multiverse/fix-portal-search
Set defaultportalsearch to true by default.
2021-07-05 15:16:01 -04:00
ccuser44 acb6bc6dd6 Create LICENSE.md 2021-07-05 11:39:50 +03:00
Ben Woo b7b17c5d21 Set defaultportalsearch to true by default. 2021-07-05 11:28:52 +08:00
Jeremy Wood bbd9211845 Bump version to 4.3.1-SNAPSHOT for continued development. 2021-06-23 15:47:52 -04:00
Jeremy Wood fc6796e20f Release version 4.3.0. 2021-06-23 08:56:24 -04:00
Jeremy Wood 6040a27126 Merge pull request #2635 from Multiverse/fix/version_cmd_perms
Change default permission for version command. Seriously wth.
2021-06-04 13:00:39 -04:00
Jeremy Wood 1c483148dc Change default permission for version command. Seriously wth. 2021-06-04 13:00:04 -04:00
nicegamer7 128442c062 Merge pull request #2622 from Multiverse/queue-system-cleanup
Queue system cleanup
2021-05-16 11:29:23 -04:00
Kermina Awad 141854f076 correct some javadoc typos 2021-05-16 11:21:20 -04:00
xSavior_of_God f72cc6764b Fix creation and import Exploit (#2353)
Through this fix you can avoid deleting of important folders.
2021-05-16 12:56:14 +08:00
benwoo1110 d95ecfaa8e Update some CommandQueueManager docs to be clearer. 2021-04-28 14:01:30 +08:00
benwoo1110 6c96f4e974 Ensure DummyCommandBlockSender isnt used for Op. 2021-04-28 13:58:43 +08:00
Ben Woo 28cee291c6 Merge pull request #2581 from Multiverse/regen-keep-gamerules
Add ability to keep gamerules setting on world regen.
2021-04-28 10:43:09 +08:00
Ben Woo 155f32c00f Add ability to keep gamerules on world regen. 2021-04-27 23:44:24 +08:00
Ben Woo 071ba05d81 Merge pull request #2585 from Multiverse/Revamp-queue-command-
Implement new queue command system.
2021-04-27 23:10:59 +08:00
Ben Woo 2ee5aea06b Merge pull request #2580 from Multiverse/per-search-and-reflect
Improve portal search radius
2021-04-27 10:57:46 +08:00
Ben Woo 3bb8de6d33 Improve portal search radius.
* Fix portal search radius not respected after travel agent removed.
* Set portal search radius for entity entering portals.
2021-04-26 22:52:24 +08:00
Ben Woo 79ac01da34 Merge pull request #2619 from Multiverse/general_cleanup
General Cleanup
2021-04-25 11:55:56 +08:00
Kermina Awad 6e4fbb0ece correct a copy-paste error introduced in #2588 2021-04-24 14:51:24 -04:00
Kermina Awad 167ed5e0d3 update VaultAPI repo 2021-04-24 14:49:28 -04:00
Kermina Awad 91f3304f78 add to Buscript failed to load message 2021-04-24 14:13:40 -04:00
Kermina Awad 7928e73a32 enable minimizeJar for maven-shade-plugin 2021-04-24 14:08:25 -04:00
Kermina Awad d61d186544 update bStats Metrics class 2021-04-24 14:08:09 -04:00
nicegamer7 dc356e88d0 Merge pull request #2582 from Multiverse/unload-message
Update unload message logging.
2021-04-24 13:49:12 -04:00
Kermina Awad d0d5574580 update unload message logging another time 2021-04-24 13:48:09 -04:00
Ben Woo 29617059b3 Merge pull request #2611 from Turbotailz/patch-1
Make prefixchat config option default to 'false'
2021-04-06 13:10:02 +08:00
Sam Goodger bf05fc81dd Make prefixchat config option default to 'false'
This may seem like a really negligible change but having this option default to `true` actually causes a lot of pain for support in other plugins that deal with prefixes (LuckPerms and Essentials being the main victims). Users always come in guns blazing, screaming at us because they don't know how to remove the world name from their chat. It's such a simple solution, yet no one thinks that of all plugins, it would be Multiverse that is tainting their beloved chat format.

Please consider updating this default setting. It will save a lot of us trouble in the future 🙏
2021-04-06 14:19:38 +10:00
nicegamer7 a2c5bf70f0 Merge pull request #2597 from Multiverse/cleanup
Cleanup
2021-03-18 10:52:28 -04:00
benwoo1110 ea19006465 Fix selector log level. 2021-03-18 16:40:47 +08:00
benwoo1110 89f685ff9a Add missing javadocs in DestinationFactory. 2021-03-10 17:45:39 +08:00
benwoo1110 ecc76033dc Remove redundant line that was moved to WorldNameChecker. 2021-03-10 17:41:56 +08:00
benwoo1110 cc3996ca76 Implement new queue command system. 2021-03-09 20:54:42 +08:00
benwoo1110 b23c1ae606 Update unload message logging. 2021-03-04 16:00:53 +08:00
benwoo1110 9741b1794c Update readme with more project details 2020-12-31 00:42:22 +08:00
benwoo1110 5d3d732c25 Fix issue where special chars cause PatternSyntaxException
Escape regex special chars for help command
2020-10-09 12:19:32 +08:00
Jonathan Leitschuh 59b6522d59 Use HTTPS instead of HTTP to resolve dependencies
This fixes a security vulnerability in this project where the `pom.xml`
files were configuring Maven to resolve dependencies over HTTP instead of
HTTPS.

Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
2020-02-11 09:04:52 -05:00
81 changed files with 2944 additions and 971 deletions

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
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 -1
View File
@@ -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!
@@ -0,0 +1,41 @@
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
-56
View File
@@ -1,56 +0,0 @@
---
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. -->
-59
View File
@@ -1,59 +0,0 @@
---
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. -->
@@ -1,54 +0,0 @@
---
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? -->
+55
View File
@@ -0,0 +1,55 @@
name: Manually upload specific release to dev.bukkit.org
on:
workflow_dispatch:
inputs:
version:
description: 'Release to upload'
required: true
jobs:
manually_upload_dbo_release:
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: ${{ steps.release.outputs.tag_name }}
- name: Download release artifact
id: release-artifact
uses: dsaltares/fetch-gh-release-asset@1.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: tags/${{ github.event.inputs.version }}
file: multiverse-core-${{ github.event.inputs.version }}.jar
- name: Parse release type
run: |
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
echo "RELEASE_TYPE=beta" >> $GITHUB_ENV
else
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
fi
- name: Upload to dev.bukkit.org
uses: benwoo1110/dbo-upload-action@v0.1.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release-artifact.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release-artifact.outputs.version }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
release_type: ${{ env.RELEASE_TYPE }}
project_relations: >
[
{"slug": "multiverse-portals", "type": "optionalDependency"},
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
{"slug": "multiverse-signportals", "type": "optionalDependency"},
{"slug": "multiverse-inventories", "type": "optionalDependency"}
]
file_path: ${{ github.workspace }}/subdir/multiverse-core-${{ steps.release-artifact.outputs.version }}.jar
+53
View File
@@ -0,0 +1,53 @@
name: Manually upload specific release to modrinth.com
on:
workflow_dispatch:
inputs:
version:
description: 'Release to upload'
required: true
jobs:
manually_upload_modrinth_release:
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: ${{ steps.release.outputs.tag_name }}
- name: Modify version scheme
run: |
if [[ "${{ steps.release.outputs.tag_name }}" == *"pre"* ]]; then
echo "Replacing prerelease version scheme with SNAPSHOT"
echo "VERSION=$(echo ${{ steps.release.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV
else
echo "Using release version scheme"
echo "VERSION=${{ steps.release.outputs.tag_name }}" >> $GITHUB_ENV
fi
- name: Parse release type
run: |
if [[ "${{ steps.release-info.outputs.prerelease }}" == "true" ]]; then
echo "RELEASE_TYPE=beta" >> $GITHUB_ENV
else
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
with:
ref: ${{ steps.release-info.outputs.tag_name }}
- name: Upload to modrinth.com
uses: gradle/gradle-build-action@v2
with:
arguments: build modrinth
env:
GITHUB_VERSION: ${{ env.VERSION }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.release-info.outputs.body }}
VERSION_NUMBER: ${{ steps.release-info.outputs.tag_name }}
VERSION_TYPE: ${{ env.RELEASE_TYPE }}
+109
View File
@@ -0,0 +1,109 @@
name: Manually promote prerelease to release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to promote'
required: true
jobs:
manually_promote_release:
runs-on: ubuntu-latest
steps:
- name: Verify input version is prerelease
run: |
if [[ "${{ github.event.inputs.version }}" != *"pre"* ]]; then
echo "Version must be a prerelease"
exit 1
fi
- name: Get release info
id: get-release
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ github.event.inputs.version }}
- uses: actions/checkout@v3
with:
ref: ${{ steps.get-release.outputs.tag_name }}
- uses: actions/setup-java@v3
with:
java-version: '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@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_mode: promote
promote_from: ${{ github.event.inputs.version }}
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
- name: Upload release artifact
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/libs/multiverse-core-${{ steps.release.outputs.publish_version }}.jar
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
tag: ${{ steps.release.outputs.tag_name }}
- 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.outputs.tag_name }}
file: multiverse-core-${{ github.event.inputs.version }}.jar
- name: Upload to modrinth.com
uses: gradle/gradle-build-action@v2
with:
arguments: build modrinth
env:
GITHUB_VERSION: ${{ env.VERSION }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.release.outputs.body }}
VERSION_NUMBER: ${{ steps.release.outputs.tag_name }}
VERSION_TYPE: ${{ env.RELEASE_TYPE }}
- name: Upload to dev.bukkit.org
uses: benwoo1110/dbo-upload-action@v0.2.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release.outputs.tag_name }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
release_type: ${{ env.RELEASE_TYPE }}
project_relations: >
[
{"slug": "multiverse-portals", "type": "optionalDependency"},
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
{"slug": "multiverse-signportals", "type": "optionalDependency"},
{"slug": "multiverse-inventories", "type": "optionalDependency"}
]
file_path: ${{ github.workspace }}/subdir/multiverse-core-${{ steps.release.outputs.tag_name }}.jar
+93
View File
@@ -0,0 +1,93 @@
name: Create Release Version & Publish Package
on:
push:
branches: [main]
jobs:
release_on_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '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@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version_bump: prlabel
release_mode: prerelease
- name: Publish package
if: steps.release.outputs.release_created == 'true'
uses: gradle/gradle-build-action@v2
with:
arguments: publish
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/multiverse-core-${{ steps.release.outputs.publish_version }}.jar
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
tag: ${{ steps.release.outputs.tag_name }}
- name: Download release artifact
if: steps.release.outputs.release_created == 'true'
uses: dsaltares/fetch-gh-release-asset@1.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: tags/${{ steps.release.outputs.tag_name }}
file: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
- name: Upload to modrinth.com
if: steps.release.outputs.release_created == 'true'
uses: gradle/gradle-build-action@v2
with:
arguments: build modrinth -x checkstyleMain -x checkstyleTest
env:
GITHUB_VERSION: ${{ steps.release.outputs.publish_version }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CHANGELOG: ${{ steps.release.outputs.body }}
VERSION_NUMBER: ${{ steps.release.outputs.tag_name }}
VERSION_TYPE: ${{ steps.release.outputs.release_type }}
- name: Upload to dev.bukkit.org
if: steps.release.outputs.release_created == 'true'
uses: benwoo1110/dbo-upload-action@v0.2.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release.outputs.tag_name }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
release_type: ${{ steps.release.outputs.release_type }}
project_relations: >
[
{"slug": "multiverse-portals", "type": "optionalDependency"},
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
{"slug": "multiverse-signportals", "type": "optionalDependency"},
{"slug": "multiverse-inventories", "type": "optionalDependency"}
]
file_path: ${{ github.workspace }}/multiverse-core-${{ steps.release.outputs.tag_name }}.jar
+18
View File
@@ -0,0 +1,18 @@
name: Require PR Labels
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [main]
jobs:
require_label:
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
mode: exactly
count: 1
labels: "release:major, release:minor, release:patch, no release"
+36
View File
@@ -0,0 +1,36 @@
name: Run unit tests against all PRs
on:
pull_request:
types: [opened, synchronize]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Run unit tests
uses: gradle/gradle-build-action@v2
with:
arguments: build
env:
GITHUB_VERSION: pr${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Artifact output
uses: actions/upload-artifact@v3
with:
name: multiverse-core-pr${{ github.event.pull_request.number }}
path: build/libs/multiverse-core-pr${{ github.event.pull_request.number }}.jar
+3
View File
@@ -43,3 +43,6 @@ debug.log
# Doxygen
/docs/html
debug.txt
# Gradle
.gradle
-6
View File
@@ -1,6 +0,0 @@
language: java
jdk:
- oraclejdk8
notifications:
email: false
dist: trusty
+6
View File
@@ -0,0 +1,6 @@
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.
+41 -9
View File
@@ -1,16 +1,48 @@
Building
========
Simply build the source with maven:
<p align="center">
<img src="config/multiverse2-long.png" alt="Multiverse Logo">
</p>
$ mvn install
[![bukkit](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/supported/bukkit_vector.svg)](https://dev.bukkit.org/projects/multiverse-core)
[![Spigot](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/supported/spigot_vector.svg)](https://www.spigotmc.org/resources/multiverse-core.390/)
[![Release](https://img.shields.io/nexus/r/com.onarandombox.multiversecore/Multiverse-Core?label=release&server=https%3A%2F%2Frepo.onarandombox.com%2F)](https://dev.bukkit.org/projects/multiverse-core)
[![Dev builds](https://img.shields.io/nexus/s/com.onarandombox.multiversecore/Multiverse-Core?label=dev%20builds&server=http%3A%2F%2Frepo.onarandombox.com%2F)](https://ci.onarandombox.com/job/Multiverse-Core/)
[![Discord](https://img.shields.io/discord/325459248047980545?label=discord&logo=discord)](https://discord.gg/NZtfKky)
[![Support us on Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Ddumptruckman%26type%3Dpatrons&style=flat)](https://patreon.com/dumptruckman)
[![License](https://img.shields.io/github/license/Multiverse/Multiverse-Core)](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.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
## Contributing
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.
**Want to help improve Multiverse?** There are several ways you can support and contribute to the project.
* Take a look at our "Bug: Unconfirmed" issues, where you can find issues that need extra testing and investigation.
* Want others to love Multiverse too? You can join the [Multiverse Discord community](https://discord.gg/NZtfKky) and help others with issues and setup!
* A Multiverse guru? You can update our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) with your latest tip, tricks and guides! The wiki open for all to edit and improve.
* Love coding? You could look at ["State: Open to PR"](https://github.com/Multiverse/Multiverse-Core/labels/State%3A%20Open%20to%20PR) and ["Resolution: Accepted"](https://github.com/Multiverse/Multiverse-Core/labels/Resolution%3A%20Accepted) issues. We're always happy to receive bug fixes and feature additions as [pull requests](https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/).
* If you'd like to make a financial contribution to the project, do consider joining our [Patreon](https://www.patreon.com/dumptruckman) or make a one-time donation [here](https://paypal.me/dumptruckman)!
Additionally, we would like to give a big thanks to everyone that has supported Multiverse over the years, as well as those in the years to come. Thank you!
## License
Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info.
+190
View File
@@ -0,0 +1,190 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java-library'
id 'maven-publish'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id "com.modrinth.minotaur" version "2.+"
}
version = System.getenv('GITHUB_VERSION') ?: 'local'
group = 'com.onarandombox.multiversecore'
description = 'Multiverse-Core'
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenLocal()
mavenCentral()
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
maven {
url = uri('https://repo.onarandombox.com/content/groups/public')
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/groups/public/')
}
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.minebench.de/')
}
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
dependencies {
compileOnly 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT'
implementation('com.github.MilkBowl:VaultAPI:1.7') {
exclude group: 'org.bukkit', module: 'bukkit'
}
api('me.main__.util:SerializationConfig:1.7') {
exclude group: 'org.bukkit', module: 'bukkit'
}
api('com.pneumaticraft.commandhandler:CommandHandler:11') {
exclude group: 'org.bukkit', module: 'bukkit'
exclude group: 'junit', module: 'junit'
}
api 'com.dumptruckman.minecraft:buscript:2.0-SNAPSHOT'
api 'org.bstats:bstats-bukkit:2.2.1'
api('com.dumptruckman.minecraft:Logging:1.1.1') {
exclude group: 'junit', module: 'junit'
}
api 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
api 'org.jetbrains:annotations:16.0.2'
testImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:3.11.2'
testImplementation 'commons-io:commons-io:2.4'
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(shadowJar)
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Core"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
ext.bitlyAccessToken = System.getenv('BITLY_ACCESS_TOKEN') ?: 'bitly-access-token'
task prepareSource(type: Sync) {
inputs.property 'bitlyAccessToken', bitlyAccessToken
from sourceSets.main.java
into "$buildDir/src"
filter(ReplaceTokens, tokens: [
'bitly-access-token': bitlyAccessToken,
])
}
compileJava {
source = prepareSource.outputs
}
processResources {
def props = [version: "${project.version}"]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
// This task should never be skipped. The tests depend on this having been run but we want the new version number
// that is created after tests are run and before we run again to publish.
outputs.upToDateWhen { false }
}
checkstyle {
toolVersion = '6.1.1'
configFile file('config/mv_checks.xml')
ignoreFailures = true
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
}
project.configurations.api.canBeResolved = true
shadowJar {
relocate 'me.main__.util', 'com.onarandombox.serializationconfig'
relocate 'com.pneumaticraft.commandhandler', 'com.onarandombox.commandhandler'
relocate 'buscript', 'com.onarandombox.buscript'
relocate 'org.bstats', 'com.onarandombox.bstats'
relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.MultiverseCore.utils.CoreLogging'
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.MultiverseCore.utils.DebugFileLogger'
relocate 'org.codehaus.jettison', 'com.onarandombox.jettison'
relocate 'de.themoep.idconverter', 'com.onarandombox.idconverter'
configurations = [project.configurations.api]
archiveFileName = "$baseName-$version.$extension"
classifier = ''
}
build.dependsOn shadowJar
jar.enabled = false
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "multiverse-core"
versionNumber = System.getenv("VERSION_NUMBER")
versionType = System.getenv("VERSION_TYPE")
uploadFile = jar
gameVersions = ["1.20.1", "1.20", "1.19.4", "1.19.3", "1.19.2", "1.19.1", "1.19", "1.18.2", "1.18.1", "1.18", "1.17.1", "1.17", "1.16.5", "1.16.4", "1.16.3", "1.16.2", "1.16.1", "1.16", "1.15.2", "1.15.1", "1.15", "1.14.4", "1.14.3", "1.14.2", "1.14.1", "1.14", "1.13.2", "1.13.1", "1.13"]
loaders = ["bukkit", "spigot", "paper"]
changelog = System.getenv("CHANGELOG")
}
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
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
Vendored Executable
+244
View File
@@ -0,0 +1,244 @@
#!/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
View File
@@ -0,0 +1,92 @@
@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
-403
View File
@@ -1,403 +0,0 @@
<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>4.2.3-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>
</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>com.pneumaticraft.commandhandler</pattern>
<shadedPattern>com.onarandombox.commandhandler</shadedPattern>
</relocation>
<relocation>
<pattern>buscript</pattern>
<shadedPattern>com.onarandombox.buscript</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.onarandombox.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
</relocation>
<relocation>
<pattern>org.codehaus.jettison</pattern>
<shadedPattern>com.onarandombox.jettison</shadedPattern>
</relocation>
<relocation>
<pattern>de.themoep.idconverter</pattern>
<shadedPattern>com.onarandombox.idconverter</shadedPattern>
</relocation>
</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>com.pneumaticraft.commandhandler</groupId>
<artifactId>CommandHandler</artifactId>
<version>11</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>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
</repository>
<snapshotRepository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
+11
View File
@@ -0,0 +1,11 @@
/*
* This file was generated by the Gradle 'init' task.
*/
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'multiverse-core'
@@ -356,7 +356,7 @@ public class MVWorld implements MultiverseWorld {
@Override
public Map<String, Object> serialize() {
return Collections.EMPTY_MAP;
return Collections.emptyMap();
}
/**
@@ -68,6 +68,7 @@ import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
import com.onarandombox.MultiverseCore.commands.VersionCommand;
import com.onarandombox.MultiverseCore.commands.WhoCommand;
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
import com.onarandombox.MultiverseCore.destination.BedDestination;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
@@ -204,6 +205,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup our Map for our Commands using the CommandHandler.
private CommandHandler commandHandler;
private CommandQueueManager commandQueueManager;
private static final String LOG_TAG = "[Multiverse-Core]";
@@ -288,6 +290,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup the command manager
this.commandHandler = new CommandHandler(this, this.ph);
this.commandQueueManager = new CommandQueueManager(this);
// Call the Function to assign all the Commands to their Class.
this.registerCommands();
@@ -364,7 +367,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Add global variable "multiverse" to javascript environment
buscript.setScriptVariable("multiverse", this);
} catch (NullPointerException e) {
Logging.warning("Buscript failed to load! The script command will be disabled!");
Logging.warning("Buscript failed to load! The script command will be disabled! " +
"If you would like not to see this message, " +
"use `/mv conf enablebuscript false` to disable Buscript from loading.");
}
}
}
@@ -529,7 +534,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
} else if (entry.getValue() instanceof ConfigurationSection) {
Logging.fine("Migrating: " + entry.getKey());
// we have to migrate this
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
WorldProperties world = new WorldProperties(Collections.emptyMap());
ConfigurationSection section = (ConfigurationSection) entry.getValue();
// migrate animals and monsters
@@ -917,6 +922,15 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return this.commandHandler;
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public CommandQueueManager getCommandQueueManager() {
return commandQueueManager;
}
/**
* Gets the log-tag.
*
@@ -1117,12 +1131,22 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
/**
* {@inheritDoc}
* @deprecated This is deprecated!
* @deprecated This is deprecated! Do not use!
*/
@Override
@Deprecated
public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed) {
return this.worldManager.regenWorld(name, useNewSeed, randomSeed, seed);
return this.worldManager.regenWorld(name, useNewSeed, randomSeed, seed, false);
}
/**
* {@inheritDoc}
* @deprecated This is deprecated! Do not use!
*/
@Override
@Deprecated
public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed, Boolean keepGameRules) {
return this.worldManager.regenWorld(name, useNewSeed, randomSeed, seed, keepGameRules);
}
/**
@@ -96,7 +96,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
enforceaccess = false;
useasyncchat = true;
prefixchat = true;
prefixchat = false;
prefixchatformat = "[%world%]%chat%";
teleportintercept = true;
firstspawnoverride = true;
@@ -107,7 +107,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
teleportcooldown = 1000;
this.version = 2.9;
silentstart = false;
defaultportalsearch = false;
defaultportalsearch = true;
portalsearchradius = 128;
autopurge = true;
idonotwanttodonate = false;
@@ -8,6 +8,7 @@
package com.onarandombox.MultiverseCore.api;
import buscript.Buscript;
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
@@ -86,6 +87,15 @@ public interface Core {
*/
CommandHandler getCommandHandler();
/**
* Manager for command that requires /mv confirm before execution.
*
* @return A non-null {@link CommandQueueManager}.
* @deprecated To be moved to new command manager in 5.0.0
*/
@Deprecated
CommandQueueManager getCommandQueueManager();
/**
* Gets the factory class responsible for loading many different destinations
* on demand.
@@ -116,20 +126,38 @@ public interface Core {
AnchorManager getAnchorManager();
/**
* Used by queued commands to regenerate a world on a delay.
* Previously used by queued commands to regenerate a world on a delay.
* Do not use api method for any other purpose.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String)} instead.
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String, boolean)} instead.
*/
@Deprecated
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
/**
* Used by queued commands to regenerate a world on a delay.
* Do not use api method for any other purpose.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
* @param keepGameRules If GameRules should be kept on world regen.
*
* @return True if success, false if fail.
*
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String, boolean)} instead.
*/
@Deprecated
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed, Boolean keepGameRules);
/**
* Decrements the number of plugins that have specifically hooked into core.
*/
@@ -313,15 +313,28 @@ public interface MVWorldManager {
/**
* Regenerates a world.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
/**
* Regenerates a world.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
* @param keepGameRules If GameRules should be kept on world regen.
*
* @return True if success, false if fail.
*/
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules);
boolean isKeepingSpawnInMemory(World world);
/**
@@ -33,7 +33,7 @@ public class ConfirmCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
this.plugin.getCommandQueueManager().runQueuedCommand(sender);
}
}
@@ -46,10 +46,15 @@ public class CreateCommand extends MultiverseCommand {
this.addCommandExample("/mv create " + ChatColor.GOLD + "moonworld" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -g BukkitFullOfMoon");
this.worldManager = this.plugin.getMVWorldManager();
}
private String trimWorldName(String userInput) {
// Removes relative paths.
return userInput.replaceAll("^[./\\\\]+", "");
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
String worldName = trimWorldName(args.get(0));
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
@@ -66,7 +71,13 @@ public class CreateCommand extends MultiverseCommand {
useSpawnAdjust = false;
}
}
// Make sure the world name doesn't contain the words 'plugins' and '.dat'
if(worldName.contains("plugins")||worldName.contains(".dat")){
sender.sendMessage(ChatColor.RED + "Multiverse cannot create a world that contains 'plugins' or '.dat'");
return;
}
if (this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "Multiverse cannot create " + ChatColor.GOLD + ChatColor.UNDERLINE
+ "another" + ChatColor.RESET + ChatColor.RED + " world named " + worldName);
@@ -117,4 +128,4 @@ public class CreateCommand extends MultiverseCommand {
Command.broadcastCommandMessage(sender, "FAILED.");
}
}
}
}
@@ -8,9 +8,11 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -35,11 +37,24 @@ public class DeleteCommand extends MultiverseCommand {
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
Class<?>[] paramTypes = {String.class};
List<Object> objectArgs = new ArrayList<Object>(args);
this.plugin.getCommandHandler()
.queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World '" + worldName + "' Deleted!",
ChatColor.RED + "World '" + worldName + "' could NOT be deleted!");
this.plugin.getCommandQueueManager().addToQueue(new QueuedCommand(
sender,
deleteRunnable(sender, worldName),
String.format("Are you sure you want to delete world '%s'? You cannot undo this action.", worldName)
));
}
private Runnable deleteRunnable(@NotNull CommandSender sender,
@NotNull String worldName) {
return () -> {
sender.sendMessage(String.format("Deleting world '%s'...", worldName));
if (this.plugin.getMVWorldManager().deleteWorld(worldName)) {
sender.sendMessage(String.format("%sWorld %s was deleted!", ChatColor.GREEN, worldName));
return;
}
sender.sendMessage(String.format("%sThere was an issue deleting '%s'! Please check console for errors.",
ChatColor.RED, worldName));
};
}
}
@@ -8,6 +8,9 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.display.ColorAlternator;
import com.onarandombox.MultiverseCore.display.ContentDisplay;
import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameRule;
@@ -16,7 +19,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Allows management of Anchor Destinations.
@@ -68,15 +73,23 @@ public class GamerulesCommand extends MultiverseCommand {
}
}
final StringBuilder gameRules = new StringBuilder();
for (final String gameRule : world.getGameRules()) {
if (gameRules.length() != 0) {
gameRules.append(ChatColor.WHITE).append(", ");
ContentDisplay.forContent(getGameRuleMap(world))
.header("=== Gamerules for %s%s%s ===", ChatColor.AQUA, world.getName(), ChatColor.WHITE)
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
.setting(MapDisplaySettings.OPERATOR, ": ")
.show(sender);
}
private Map<String, Object> getGameRuleMap(World world) {
Map<String, Object> gameRuleMap = new HashMap<>();
for (GameRule<?> rule : GameRule.values()) {
Object value = world.getGameRuleValue(rule);
if (value == null) {
gameRuleMap.put(rule.getName(), "null");
continue;
}
gameRules.append(ChatColor.AQUA).append(gameRule).append(ChatColor.WHITE).append(": ");
gameRules.append(ChatColor.GREEN).append(world.getGameRuleValue(GameRule.getByName(gameRule)));
gameRuleMap.put(rule.getName(), value);
}
sender.sendMessage("=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ===");
sender.sendMessage(gameRules.toString());
return gameRuleMap;
}
}
@@ -40,24 +40,16 @@ public class HelpCommand extends PaginatedCoreCommand<Command> {
@Override
protected List<Command> getFilteredItems(List<Command> availableItems, String filter) {
String expression = "(?i).*" + cleanFilter(filter) + ".*";
List<Command> filtered = new ArrayList<Command>();
for (Command c : availableItems) {
if (stitchThisString(c.getKeyStrings()).matches("(?i).*" + filter + ".*")) {
if (stitchThisString(c.getKeyStrings()).matches(expression)
|| c.getCommandName().matches(expression)
|| c.getCommandDesc().matches(expression)
|| c.getCommandUsage().matches(expression)
|| c.getCommandExamples().stream().anyMatch(eg -> eg.matches(expression))) {
filtered.add(c);
} else if (c.getCommandName().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandDesc().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandUsage().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else {
for (String example : c.getCommandExamples()) {
if (example.matches("(?i).*" + filter + ".*")) {
filtered.add(c);
break;
}
}
}
}
return filtered;
@@ -81,6 +81,12 @@ public class ImportCommand extends MultiverseCommand {
this.showHelp(sender);
return;
}
// Make sure the world name doesn't contain the words 'plugins' and '.dat'
if(worldName.contains("plugins")||worldName.contains(".dat")){
sender.sendMessage(ChatColor.RED + "Multiverse cannot create a world that contains 'plugins' or '.dat'");
return;
}
// Make sure we don't already know about this world.
if (this.worldManager.isMVWorld(worldName)) {
@@ -128,4 +134,4 @@ public class ImportCommand extends MultiverseCommand {
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
}
}
}
}
@@ -9,122 +9,111 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.display.ColorAlternator;
import com.onarandombox.MultiverseCore.display.ContentDisplay;
import com.onarandombox.MultiverseCore.display.ContentFilter;
import com.onarandombox.MultiverseCore.display.DisplayHandlers;
import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/**
* Displays a listing of all worlds that a player can enter.
*/
public class ListCommand extends PaginatedCoreCommand<String> {
public class ListCommand extends MultiverseCommand {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mv list [page]");
this.setCommandUsage("/mv list [filter] [page]");
this.setArgRange(0, 2);
this.addKey("mvlist");
this.addKey("mvl");
this.addKey("mv list");
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
private List<String> getFancyWorldList(Player p) {
List<String> worldList = new ArrayList<String>();
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
}
ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment();
if (env == Environment.NETHER) {
color = ChatColor.RED;
} else if (env == Environment.NORMAL) {
color = ChatColor.GREEN;
} else if (env == Environment.THE_END) {
color = ChatColor.AQUA;
}
StringBuilder builder = new StringBuilder();
builder.append(world.getColoredWorldString()).append(ChatColor.WHITE);
builder.append(" - ").append(color).append(world.getEnvironment());
if (world.isHidden()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) {
// Prefix hidden worlds with an "[H]"
worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
}
} else {
worldList.add(builder.toString());
}
}
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
}
}
return worldList;
}
@Override
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
List<String> filtered = new ArrayList<String>();
for (String s : availableItems) {
if (s.matches("(?i).*" + filter + ".*")) {
filtered.add(s);
}
}
return filtered;
}
@Override
protected String getItemText(String item) {
return item;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse World List ]====");
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
ContentFilter filter = ContentFilter.DEFAULT;
int page = 1;
FilterObject filterObject = this.getPageAndFilter(args);
List<String> availableWorlds = new ArrayList<String>(this.getFancyWorldList(p));
if (filterObject.getFilter().length() > 0) {
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
if (availableWorlds.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No worlds matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
// Either page or filter.
if (args.size() == 1) {
try {
page = Integer.parseInt(args.get(0));
} catch (NumberFormatException ignore) {
filter = new ContentFilter(args.get(0));
}
}
if (!(sender instanceof Player)) {
for (String c : availableWorlds) {
sender.sendMessage(c);
// Filter then page.
if (args.size() == 2) {
filter = new ContentFilter(args.get(0));
try {
page = Integer.parseInt(args.get(1));
} catch (NumberFormatException ignore) {
sender.sendMessage(ChatColor.RED + args.get(1) + " is not valid number!");
}
return;
}
int totalPages = (int) Math.ceil(availableWorlds.size() / (this.itemsPerPage + 0.0));
ContentDisplay.forContent(getListContents(sender))
.header("%s====[ Multiverse World List ]====", ChatColor.GOLD)
.displayHandler(DisplayHandlers.PAGE_LIST)
.colorTool(ColorAlternator.with(ChatColor.AQUA, ChatColor.GOLD))
.filter(filter)
.setting(PagedDisplaySettings.SHOW_PAGE, page)
.show(sender);
}
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
private Collection<String> getListContents(@NotNull CommandSender sender) {
Player player = (sender instanceof Player) ? (Player) sender : null;
List<String> worldList = this.plugin.getMVWorldManager().getMVWorlds().stream()
.filter(world -> player == null || plugin.getMVPerms().canEnterWorld(player, world))
.filter(world -> canSeeWorld(player, world))
.map(world -> hiddenText(world) + world.getColoredWorldString() + " - " + parseColouredEnvironment(world.getEnvironment()))
.collect(Collectors.toList());
this.plugin.getMVWorldManager().getUnloadedWorlds().stream()
.filter(world -> plugin.getMVPerms().hasPermission(sender, "multiverse.access." + world, true))
.map(world -> ChatColor.GRAY + world + " - UNLOADED")
.forEach(worldList::add);
return worldList;
}
private boolean canSeeWorld(Player player, MultiverseWorld world) {
return !world.isHidden()
|| player == null
|| this.plugin.getMVPerms().hasPermission(player, "multiverse.core.modify", true);
}
private String hiddenText(MultiverseWorld world) {
return (world.isHidden()) ? String.format("%s[H] ", ChatColor.GRAY) : "";
}
private String parseColouredEnvironment(World.Environment env) {
ChatColor color = ChatColor.GOLD;
switch (env) {
case NETHER:
color = ChatColor.RED;
break;
case NORMAL:
color = ChatColor.GREEN;
break;
case THE_END:
color = ChatColor.AQUA;
break;
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
this.showPage(filterObject.getPage(), sender, availableWorlds);
return color + env.toString();
}
}
@@ -13,12 +13,14 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
import java.util.regex.Pattern;
/**
* A generic paginated command.
* @param <T> The type of items on the page.
*/
public abstract class PaginatedCommand<T> extends Command {
private final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
private static final int DEFAULT_ITEMS_PER_PAGE = 9;
/**
* The number of items per page.
@@ -40,12 +42,23 @@ public abstract class PaginatedCommand<T> extends Command {
/**
* Gets filtered items.
*
* @param availableItems All available items.
* @param filter The filter-{@link String}.
* @return A list of items that match the filter.
*/
protected abstract List<T> getFilteredItems(List<T> availableItems, String filter);
/**
* Escape regex special characters from filter
*
* @param filter The filter-{@link String}.
* @return String with regex characters escaped
*/
protected String cleanFilter(String filter) {
return REGEX_SPECIAL_CHARS.matcher(filter).replaceAll("\\\\$0");
}
/**
* Constructs a single string from a list of strings.
*
@@ -8,11 +8,13 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
@@ -23,8 +25,8 @@ public class RegenCommand extends MultiverseCommand {
public RegenCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Regenerates a World");
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]]");
this.setArgRange(1, 3);
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]] [--keep-gamerules]");
this.setArgRange(1, 4);
this.addKey("mvregen");
this.addKey("mv regen");
this.addCommandExample("You can use the -s with no args to get a new seed:");
@@ -37,17 +39,34 @@ public class RegenCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
Boolean useseed = (!(args.size() == 1));
Boolean randomseed = (args.size() == 2 && args.get(1).equalsIgnoreCase("-s"));
String seed = (args.size() == 3) ? args.get(2) : "";
String worldName = args.get(0);
boolean useseed = CommandHandler.hasFlag("-s", args);
String seedflag = CommandHandler.getFlag("-s", args);
boolean keepGamerules = CommandHandler.hasFlag("--keep-gamerules", args);
Class<?>[] paramTypes = {String.class, Boolean.class, Boolean.class, String.class};
List<Object> objectArgs = new ArrayList<Object>();
objectArgs.add(args.get(0));
objectArgs.add(useseed);
objectArgs.add(randomseed);
objectArgs.add(seed);
this.plugin.getCommandHandler().queueCommand(sender, "mvregen", "regenWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World Regenerated!", ChatColor.RED + "World could NOT be regenerated!");
boolean randomseed = seedflag == null || seedflag.isEmpty() || seedflag.equalsIgnoreCase("--keep-gamerules");
String seed = randomseed ? "" : seedflag;
this.plugin.getCommandQueueManager().addToQueue(new QueuedCommand(
sender,
doWorldRegen(sender, worldName, useseed, randomseed, seed, keepGamerules),
String.format("Are you sure you want to regen '%s'? You cannot undo this action.", worldName)
));
}
private Runnable doWorldRegen(@NotNull CommandSender sender,
@NotNull String worldName,
boolean useSeed,
boolean randomSeed,
@NotNull String seed,
boolean keepGamerules) {
return () -> {
if (this.plugin.getMVWorldManager().regenWorld(worldName, useSeed, randomSeed, seed, keepGamerules)) {
sender.sendMessage(ChatColor.GREEN + "World Regenerated!");
return;
}
sender.sendMessage(ChatColor.RED + "World could NOT be regenerated!");
};
}
}
@@ -11,6 +11,7 @@ import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Teleporter;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import com.onarandombox.MultiverseCore.destination.CustomTeleporterDestination;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
@@ -152,24 +153,27 @@ public class TeleportCommand extends MultiverseCommand {
if (result == TeleportResult.FAIL_UNSAFE) {
Logging.fine("Could not teleport " + teleportee.getName()
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
Logging.fine("Queueing Command");
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List<Object> items = new ArrayList<Object>();
items.add(teleporter);
items.add(teleportee);
items.add(d.getLocation(teleportee));
String player = "you";
if (!teleportee.equals(teleporter)) {
player = teleportee.getName();
}
String message = String.format("%sMultiverse %sdid not teleport %s%s %sto %s%s %sbecause it was unsafe.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
this.plugin.getCommandQueueManager().addToQueue(new QueuedCommand(
sender,
doUnsafeTeleport(teleporter, teleportee, d.getLocation(teleportee)),
String.format("%sMultiverse %sdid not teleport %s%s %sto %s%s %sbecause it was unsafe. Would you like to try anyway?",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE),
UNSAFE_TELEPORT_EXPIRE_DELAY
));
}
// else: Player was teleported successfully (or the tp event was fired I should say)
}
private Runnable doUnsafeTeleport(CommandSender teleporter, Player player, Location location) {
return () -> this.plugin.getSafeTTeleporter().safelyTeleport(teleporter, player, location, false);
}
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
@@ -45,8 +45,11 @@ public class VersionCommand extends MultiverseCommand {
this.addKey("mvver");
this.addKey("mvv");
this.addKey("mvversion");
this.setPermission("multiverse.core.version",
"Dumps version info to the console, optionally to pastebin.com with -b, to hastebin.com using -h, or to paste.gg with -p.", PermissionDefault.TRUE);
this.setPermission(
"multiverse.core.version",
"Dumps version info to the console, optionally to pastebin.com with -b, to hastebin.com using -h, or to paste.gg with -p.",
PermissionDefault.OP)
;
}
private String getLegacyString() {
@@ -0,0 +1,161 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools.queue;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.data.type.CommandBlock;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.WeakHashMap;
/**
* <p>Manages the queuing of dangerous commands that require {@code /mv confirm} before executing.</p>
*
* <p>Each sender can only have one command in queue at any given time. When a queued command is added
* for a sender that already has a command in queue, it will replace the old queued command.</p>
*/
public class CommandQueueManager {
private static final long TICKS_PER_SECOND = 20;
private static final DummyCommandBlockSender COMMAND_BLOCK = new DummyCommandBlockSender();
private final MultiverseCore plugin;
private final Map<CommandSender, QueuedCommand> queuedCommandMap;
public CommandQueueManager(@NotNull MultiverseCore plugin) {
this.plugin = plugin;
this.queuedCommandMap = new WeakHashMap<>();
}
/**
* Adds a {@link QueuedCommand} into queue.
*
* @param queuedCommand The queued command to add.
*/
public void addToQueue(QueuedCommand queuedCommand) {
CommandSender targetSender = parseSender(queuedCommand.getSender());
// Since only one command is stored in queue per sender, we remove the old one.
this.removeFromQueue(targetSender);
Logging.finer("Add new command to queue for sender %s.", targetSender);
this.queuedCommandMap.put(targetSender, queuedCommand);
queuedCommand.setExpireTask(runExpireLater(queuedCommand));
queuedCommand.getSender().sendMessage(queuedCommand.getPrompt());
queuedCommand.getSender().sendMessage(String.format("Run %s/mv confirm %sto continue. This will expire in %s seconds.",
ChatColor.GREEN, ChatColor.WHITE, queuedCommand.getValidDuration()));
}
/**
* Expire task that removes a {@link QueuedCommand} from queue after valid duration defined.
*
* @param queuedCommand Command to run the expire task on.
* @return The expire {@link BukkitTask}.
*/
@NotNull
private BukkitTask runExpireLater(@NotNull QueuedCommand queuedCommand) {
return Bukkit.getScheduler().runTaskLater(
this.plugin,
expireRunnable(queuedCommand),
queuedCommand.getValidDuration() * TICKS_PER_SECOND
);
}
/**
* Runnable responsible for expiring the queued command.
*
* @param queuedCommand Command to create the expire task on.
* @return The expire runnable.
*/
@NotNull
private Runnable expireRunnable(@NotNull QueuedCommand queuedCommand) {
return () -> {
CommandSender targetSender = parseSender(queuedCommand.getSender());
QueuedCommand matchingQueuedCommand = this.queuedCommandMap.get(targetSender);
if (!queuedCommand.equals(matchingQueuedCommand) || queuedCommand.getExpireTask().isCancelled()) {
// To be safe, but this shouldn't happen since we cancel old commands before add new once.
Logging.finer("This is an old queue command already.");
return;
}
queuedCommand.getSender().sendMessage("Your queued command has expired.");
this.queuedCommandMap.remove(queuedCommand.getSender());
};
}
/**
* Runs the command in queue for the given sender, if any.
*
* @param sender {@link CommandSender} that confirmed the command.
* @return True if queued command ran successfully, else false.
*/
public boolean runQueuedCommand(@NotNull CommandSender sender) {
CommandSender targetSender = parseSender(sender);
QueuedCommand queuedCommand = this.queuedCommandMap.get(targetSender);
if (queuedCommand == null) {
sender.sendMessage(ChatColor.RED + "You do not have any commands in queue.");
return false;
}
Logging.finer("Running queued command...");
queuedCommand.getAction().run();
return removeFromQueue(targetSender);
}
/**
* Since only one command is stored in queue per sender, we remove the old one.
*
* @param sender The {@link CommandSender} that executed the command.
* @return True if queue command is removed from sender successfully, else false.
*/
public boolean removeFromQueue(@NotNull CommandSender sender) {
CommandSender targetSender = parseSender(sender);
QueuedCommand previousCommand = this.queuedCommandMap.remove(targetSender);
if (previousCommand == null) {
Logging.finer("No queue command to remove for sender %s.", targetSender.getName());
return false;
}
previousCommand.getExpireTask().cancel();
Logging.finer("Removed queue command for sender %s.", targetSender.getName());
return true;
}
/**
* To allow all CommandBlocks to be a common sender with use of {@link DummyCommandBlockSender}.
* So confirm command can be used for a queued command on another command block.
*
* @param sender The sender to parse.
* @return The sender, or if its a command block, a {@link DummyCommandBlockSender}.
*/
@NotNull
private CommandSender parseSender(@NotNull CommandSender sender) {
Logging.fine(sender.getClass().getName());
if (isCommandBlock(sender)) {
Logging.finer("Is command block.");
return COMMAND_BLOCK;
}
return sender;
}
/**
* Checks if the sender is a command block.
*
* @param sender The sender to check.
* @return True if sender is a command block, else false.
*/
private boolean isCommandBlock(@NotNull CommandSender sender) {
return sender instanceof BlockCommandSender
&& ((BlockCommandSender) sender).getBlock().getBlockData() instanceof CommandBlock;
}
}
@@ -0,0 +1,104 @@
package com.onarandombox.MultiverseCore.commandtools.queue;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
/**
* Used by {@link CommandQueueManager}, so different commands block can be recognised as one.
*/
class DummyCommandBlockSender implements CommandSender {
@Override
public void sendMessage(@NotNull String message) {
throw new UnsupportedOperationException();
}
@Override
public void sendMessage(@NotNull String[] messages) {
throw new UnsupportedOperationException();
}
@Override
public @NotNull Server getServer() {
return Bukkit.getServer();
}
@Override
public @NotNull String getName() {
return "DummyCommandBlockSender";
}
@Override
public boolean isPermissionSet(@NotNull String name) {
throw new UnsupportedOperationException();
}
@Override
public boolean isPermissionSet(@NotNull Permission perm) {
throw new UnsupportedOperationException();
}
@Override
public boolean hasPermission(@NotNull String name) {
throw new UnsupportedOperationException();
}
@Override
public boolean hasPermission(@NotNull Permission perm) {
throw new UnsupportedOperationException();
}
@Override
public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) {
throw new UnsupportedOperationException();
}
@Override
public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) {
throw new UnsupportedOperationException();
}
@Override
public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) {
throw new UnsupportedOperationException();
}
@Override
public void removeAttachment(@NotNull PermissionAttachment attachment) {
throw new UnsupportedOperationException();
}
@Override
public void recalculatePermissions() {
throw new UnsupportedOperationException();
}
@Override
public @NotNull Set<PermissionAttachmentInfo> getEffectivePermissions() {
throw new UnsupportedOperationException();
}
@Override
public boolean isOp() {
throw new UnsupportedOperationException();
}
@Override
public void setOp(boolean value) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,86 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools.queue;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
/**
* Represents a single command used in {@link CommandQueueManager} for confirming before running potentially
* dangerous action.
*/
public class QueuedCommand {
private static final String DEFAULT_PROMPT_MESSAGE = "The command you are trying to run is deemed dangerous.";
private static final int DEFAULT_VALID_TIME = 10;
private final CommandSender sender;
private final Runnable action;
private final String prompt;
private final int validDuration;
private BukkitTask expireTask;
public QueuedCommand(CommandSender sender, Runnable action) {
this(sender, action, DEFAULT_PROMPT_MESSAGE, DEFAULT_VALID_TIME);
}
public QueuedCommand(CommandSender sender, Runnable action, String prompt) {
this(sender, action, prompt, DEFAULT_VALID_TIME);
}
public QueuedCommand(CommandSender sender, Runnable action, int validDuration) {
this(sender, action, DEFAULT_PROMPT_MESSAGE, validDuration);
}
/**
* Creates a new queue command, to be registered at {@link CommandQueueManager#addToQueue(QueuedCommand)}.
*
* @param sender The sender that ran the command needed for confirmation.
* @param action The logic to execute upon confirming.
* @param prompt Question to ask sender to confirm.
* @param validDuration Duration in which the command is valid for confirm in seconds.
*/
public QueuedCommand(CommandSender sender, Runnable action, String prompt, int validDuration) {
this.sender = sender;
this.action = action;
this.prompt = prompt;
this.validDuration = validDuration;
}
@NotNull
CommandSender getSender() {
return sender;
}
@NotNull
String getPrompt() {
return prompt;
}
int getValidDuration() {
return validDuration;
}
@NotNull
Runnable getAction() {
return action;
}
@NotNull
BukkitTask getExpireTask() {
return expireTask;
}
void setExpireTask(@NotNull BukkitTask expireTask) {
if (this.expireTask != null) {
throw new IllegalStateException("This queue command already has an expire task. You can't register twice!");
}
this.expireTask = expireTask;
}
}
@@ -0,0 +1,4 @@
/**
* Manager queuing of dangerous commands in need of confirmation.
*/
package com.onarandombox.MultiverseCore.commandtools.queue;
@@ -27,7 +27,9 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/** A factory class that will create destinations from specific strings. */
/**
* A factory class that will create destinations from specific strings.
*/
public class DestinationFactory {
private static final Pattern CANNON_PATTERN = Pattern.compile("(?i)cannon-[\\d]+(\\.[\\d]+)?");
@@ -165,7 +167,12 @@ public class DestinationFactory {
this.teleportCommand.addAdditonalPermission(other);
return true;
}
/**
* Gets all the {@link MVDestination} identifiers registered.
*
* @return A collection of destination identifiers.
*/
public Collection<String> getRegisteredIdentifiers() {
return this.destList.keySet();
}
@@ -0,0 +1,62 @@
package com.onarandombox.MultiverseCore.display;
import org.bukkit.ChatColor;
import org.jetbrains.annotations.NotNull;
/**
* Helper class to switch between 2 {@link ChatColor}.
*/
public class ColorAlternator implements ColorTool {
/**
* Creates a new {@link ColorAlternator} with 2 {@link ChatColor}s.
*
* @param colorThis The first color.
* @param colorThat The second color.
* @return The {@link ColorAlternator} created for you.
*/
public static ColorAlternator with(@NotNull ChatColor colorThis,
@NotNull ChatColor colorThat) {
return new ColorAlternator(colorThis, colorThat);
}
private boolean switcher;
private final ChatColor thisColor;
private final ChatColor thatColor;
/**
* @param colorThis The first color.
* @param colorThat The second color.
*/
public ColorAlternator(@NotNull ChatColor colorThis,
@NotNull ChatColor colorThat) {
this.thisColor = colorThis;
this.thatColor = colorThat;
}
/**
* Gets the color. Everytime this method is called, it swaps the color that it returns.
*
* @return The color.
*/
@Override
public ChatColor get() {
return (this.switcher ^= true) ? this.thisColor : this.thatColor;
}
/**
* @return The first color.
*/
public ChatColor getThisColor() {
return thisColor;
}
/**
* @return The second color.
*/
public ChatColor getThatColor() {
return thatColor;
}
}
@@ -0,0 +1,22 @@
package com.onarandombox.MultiverseCore.display;
import org.bukkit.ChatColor;
/**
* Tools to allow customisation.
*/
@FunctionalInterface
public interface ColorTool {
/**
* Gets a chat color.
*
* @return The color.
*/
ChatColor get();
/**
* Default implementation of this interface. Returns a default white color.
*/
ColorTool DEFAULT = () -> ChatColor.WHITE;
}
@@ -0,0 +1,268 @@
package com.onarandombox.MultiverseCore.display;
import com.onarandombox.MultiverseCore.display.settings.DisplaySetting;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.WeakHashMap;
/**
* Helps to display contents such as list and maps in a nicely formatted fashion.
*
* @param <T> Type of content to display.
*/
public class ContentDisplay<T> {
public static final String LINE_BREAK = "%br%";
/**
* Creates a ContentDisplay.Builder for the given content.
*
* @param content The content to be displayed.
* @param <T> The type of the content which can be inferred.
* @return A new Builder.
*/
public static <T> Builder<T> forContent(T content) {
return new Builder<>(content);
}
/**
* Creates a ContentDisplay.Builder for the given collection of content.
*
* @param content The content to be displayed.
* @return A new Builder.
*/
public static Builder<Collection<String>> forContent(Collection<String> content) {
return new Builder<>(content).displayHandler(DisplayHandlers.LIST);
}
/**
* Creates a ContentDisplay.Builder for the given map of content.
*
* @param content The content to be displayed.
* @return A new Builder.
*/
public static Builder<Map<String, Object>> forContent(Map<String, Object> content) {
return new Builder<>(content).displayHandler(DisplayHandlers.INLINE_MAP);
}
private final T contents;
private String header;
private String emptyMessage = "No matching content to display.";
private DisplayHandler<T> displayHandler;
private ColorTool colorTool = ColorTool.DEFAULT;
private ContentFilter filter = ContentFilter.DEFAULT;
private final Map<DisplaySetting<?>, Object> settingsMap = new WeakHashMap<>();
private ContentDisplay(T contents) {
this.contents = contents;
}
/**
* Do the actual displaying of contents to the sender.
*
* @param sender The CommandSender to show the display to.
*/
public void show(@NotNull CommandSender sender) {
Collection<String> formattedContent;
try {
formattedContent = (this.contents == null) ? null : this.displayHandler.format(sender, this);
} catch (DisplayFormatException e) {
sender.sendMessage(String.format("%sError: %s", ChatColor.RED, e.getMessage()));
return;
}
this.displayHandler.sendHeader(sender, this);
this.displayHandler.sendSubHeader(sender, this);
this.displayHandler.sendBody(sender, this, formattedContent);
}
/**
* @return Gets the header to display.
*/
public String getHeader() {
return header;
}
/**
* Sets the header text.
*/
public void setHeader(@NotNull String header) {
this.header = header;
}
/**
* @return Gets the contents to display.
*/
public T getContents() {
return contents;
}
/**
* @return Gets the message to display when no content is shown.
*/
@NotNull
public String getEmptyMessage() {
return emptyMessage;
}
/**
* @return Gets the display handler that formats and sends content to sender.
*/
@NotNull
public DisplayHandler<T> getDisplayHandler() {
return displayHandler;
}
/**
* @return Gets the color tool used.
*/
@NotNull
public ColorTool getColorTool() {
return colorTool;
}
/**
* @return Gets the filter used.
*/
@NotNull
public ContentFilter getFilter() {
return filter;
}
/**
* Gets the value for a given setting option.
*
* @param setting The setting option.
* @param <S> The setting type.
* @return Value set for the given setting.
*/
public <S> S getSetting(@NotNull DisplaySetting<S> setting) {
return (S) settingsMap.getOrDefault(setting, setting.defaultValue());
}
/**
* Sets other specific settings that may be used by the {@link DisplayHandler}.
*
* @param setting The settings option.
* @param value The value to set.
* @param <S> The type of setting.
*/
public <S> void setSetting(@NotNull DisplaySetting<S> setting, S value) {
this.settingsMap.put(setting, value);
}
/**
* Builds a {@link ContentDisplay}.
*
* @param <T> Type of content to display.
*/
public static class Builder<T> {
private final ContentDisplay<T> display;
private Builder(T content) {
this.display = new ContentDisplay<>(content);
}
/**
* Sets header to be displayed.
*
* @param header The header text.
* @param replacements String formatting replacements.
* @return The builder.
*/
@NotNull
public Builder<T> header(@NotNull String header, Object...replacements) {
this.display.header = String.format(header, replacements);
return this;
}
/**
* Sets the message to show when no content is available for display.
*
* @param emptyMessage The message text.
* @param replacements String formatting replacements.
* @return The builder.
*/
@NotNull
public Builder<T> emptyMessage(@NotNull String emptyMessage, Object...replacements) {
this.display.emptyMessage = String.format(emptyMessage, replacements);
return this;
}
/**
* Sets the display handler that does the formatting and sending of content. <b>Required.</b>
*
* @param displayHandler The display handler for the given content type.
* @return The builder.
*/
@NotNull
public Builder<T> displayHandler(@NotNull DisplayHandler<T> displayHandler) {
this.display.displayHandler = displayHandler;
return this;
}
/**
* Sets the color tool used to make messages more colourful.
*
* @param colorTool The color tool to use.
* @return The builder.
*/
@NotNull
public Builder<T> colorTool(@NotNull ColorTool colorTool) {
this.display.colorTool = colorTool;
return this;
}
/**
* Sets content filter used to match specific content to be displayed.
*
* @param filter The filter to use.
* @return The builder.
*/
@NotNull
public Builder<T> filter(@NotNull ContentFilter filter) {
this.display.filter = filter;
return this;
}
/**
* Sets other specific settings that may be used by the {@link DisplayHandler}.
*
* @param setting The settings option.
* @param value The value to set.
* @param <S> The type of setting.
* @return The builder.
*/
@NotNull
public <S> Builder<T> setting(@NotNull DisplaySetting<S> setting, S value) {
this.display.settingsMap.put(setting, value);
return this;
}
/**
* Validates and build the content display.
*
* @return The content display.
*/
@NotNull
public ContentDisplay<T> build() {
Objects.requireNonNull(this.display.displayHandler);
return this.display;
}
/**
* Build and show the content to the sender.
*
* @param sender The CommandSender to show the display to.
*/
public void show(CommandSender sender) {
this.build().show(sender);
}
}
}
@@ -0,0 +1,153 @@
package com.onarandombox.MultiverseCore.display;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.ChatColor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/**
* <p>Filter content and text based on regex matching.</p>
*
* <p>Compile regex pattern based on {@link ContentFilter#filterString}. When prefixed with 'r=',
* use {@link ContentFilter#filterString} as the full regex pattern. Else, set to any match that
* contains the {@link ContentFilter#filterString}.<p>
*/
public class ContentFilter {
public static final ContentFilter DEFAULT = new ContentFilter();
private static final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
private String filterString;
private Pattern filterPattern;
private boolean exactMatch;
private ContentFilter() {
}
/**
* @param filterString The text to do matching, either plaintext or regex.
*/
public ContentFilter(@NotNull String filterString) {
this(filterString, false);
}
/**
* @param filterString The text to do matching, else plaintext or regex.
* @param exactMatch Should check for exact match when doing regex matching.
*/
public ContentFilter(@NotNull String filterString,
boolean exactMatch) {
this.filterString = filterString;
this.exactMatch = exactMatch;
parseFilter();
}
private void parseFilter() {
if (filterString == null) {
return;
}
if (filterString.startsWith("r=")) {
convertToMatcher(filterString.substring(2));
return;
}
String cleanedFilter = REGEX_SPECIAL_CHARS.matcher(filterString.toLowerCase()).replaceAll("\\\\$0");
convertToMatcher("(?i).*" + cleanedFilter + ".*");
}
/**
* Compile and store the regex into a {@link Pattern}.
*
* @param regex The regex text.
*/
private void convertToMatcher(@NotNull String regex) {
try {
this.filterPattern = Pattern.compile(regex);
Logging.finest("Parsed regex pattern: %s", this.filterPattern.toString());
}
catch (PatternSyntaxException ignored) {
Logging.warning("Error parsing regex: %s", filterString);
}
}
/**
* Do regex matching.
*
* @param text String to check regex on.
* @return True of matches regex pattern, false otherwise.
*/
public boolean checkMatch(@Nullable Object text) {
if (!hasFilter()) {
return true;
}
if (text == null || !hasValidPattern()) {
return false;
}
text = ChatColor.stripColor(String.valueOf(text));
return (exactMatch)
? filterPattern.matcher((CharSequence) text).matches()
: filterPattern.matcher((CharSequence) text).find();
}
/**
* Checks if a filter string is present.
*
* @return True if there is a filter string, else false.
*/
public boolean hasFilter() {
return filterString != null;
}
/**
* Checks if regex pattern syntax is valid.
*
* @return True if valid, else false.
*/
public boolean hasValidPattern() {
return filterPattern != null;
}
/**
* @return The filter string.
*/
@Nullable
public String getString() {
return filterString;
}
/**
* @return The regex pattern.
*/
@Nullable
public Pattern getPattern() {
return filterPattern;
}
/**
* @return True if filter is set to do exact matching, else false.
*/
public boolean isExactMatch() {
return exactMatch;
}
/**
* Nicely format the filter string to be used for showing the sender.
*
* @return The formatted filter string.
*/
public @NotNull String getFormattedString() {
return String.format("%sFilter: '%s'", ChatColor.ITALIC, filterString);
}
@Override
public String toString() {
return "ContentFilter{" +
"filterString='" + filterString + '\'' +
", filterPattern=" + filterPattern +
", exactMatch=" + exactMatch +
'}';
}
}
@@ -0,0 +1,25 @@
package com.onarandombox.MultiverseCore.display;
/**
* Thrown when an issue occur while formatting content.
*/
public class DisplayFormatException extends Exception {
public DisplayFormatException() {
}
public DisplayFormatException(String message) {
super(message);
}
public DisplayFormatException(String message, Throwable cause) {
super(message, cause);
}
public DisplayFormatException(Throwable cause) {
super(cause);
}
public DisplayFormatException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
@@ -0,0 +1,68 @@
package com.onarandombox.MultiverseCore.display;
import com.google.common.base.Strings;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
* Handles the formatting and sending of all content by the {@link ContentDisplay}.
*
* @param <T> Type of content to display.
*/
@FunctionalInterface
public interface DisplayHandler<T> {
/**
* Formats the raw content into a {@link Collection} for displaying to the given sender.
*
* @param sender The {@link CommandSender} who will the content will be displayed to.
* @param display The responsible {@link ContentDisplay}.
* @return The formatted content.
* @throws DisplayFormatException Issue occurred while formatting content. E.g. invalid page.
*/
Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display)
throws DisplayFormatException;
/**
* Sends the header.
*
* @param sender The {@link CommandSender} who will the header will be displayed to.
* @param display The responsible {@link ContentDisplay}.
*/
default void sendHeader(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display) {
if (!Strings.isNullOrEmpty(display.getHeader())) {
sender.sendMessage(display.getHeader());
}
}
/**
* Sends info such as filter and page.
*
* @param sender The {@link CommandSender} who will the sub header will be displayed to.
* @param display The responsible {@link ContentDisplay}.
*/
default void sendSubHeader(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display) {
if (display.getFilter().hasFilter()) {
sender.sendMessage(String.format("%s[ %s ]", ChatColor.GRAY, display.getFilter().getFormattedString()));
}
}
/**
* Sends the content.
*
* @param sender The {@link CommandSender} who will the body will be displayed to.
* @param display The responsible {@link ContentDisplay}.
* @param formattedContent The content after being formatted by {@link #format(CommandSender, ContentDisplay)}
*/
default void sendBody(@NotNull CommandSender sender, @NotNull ContentDisplay<T> display,
Collection<String> formattedContent) {
if (formattedContent == null || formattedContent.size() == 0) {
sender.sendMessage(display.getEmptyMessage());
return;
}
sender.sendMessage(formattedContent.toArray(new String[0]));
}
}
@@ -0,0 +1,47 @@
package com.onarandombox.MultiverseCore.display;
import com.onarandombox.MultiverseCore.display.handlers.InlineListDisplayHandler;
import com.onarandombox.MultiverseCore.display.handlers.InlineMapDisplayHandler;
import com.onarandombox.MultiverseCore.display.handlers.ListDisplayHandler;
import com.onarandombox.MultiverseCore.display.handlers.PagedListDisplayHandler;
import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
import java.util.Collection;
import java.util.Map;
/**
* Various implementations of {@link DisplayHandler}.
*/
public class DisplayHandlers {
/**
* Standard list display.
*
* Supported settings: none.
*/
public static final DisplayHandler<Collection<String>> LIST = new ListDisplayHandler();
/**
* List display with paging.
*
* Supported settings: {@link PagedDisplaySettings#SHOW_PAGE}, {@link PagedDisplaySettings#LINES_PER_PAGE},
* {@link PagedDisplaySettings#PAGE_IN_CONSOLE}, {@link PagedDisplaySettings#DO_END_PADDING}.
*/
public static final DisplayHandler<Collection<String>> PAGE_LIST = new PagedListDisplayHandler();
/**
* Display a list inline.
*
* Supported settings: {@link InlineDisplaySettings#SEPARATOR}.
*/
public static final DisplayHandler<Collection<String>> INLINE_LIST = new InlineListDisplayHandler();
/**
* Display key value pair inline.
*
* Supported settings: {@link InlineDisplaySettings#SEPARATOR}, {@link MapDisplaySettings#OPERATOR}.
*/
public static final DisplayHandler<Map<String, Object>> INLINE_MAP = new InlineMapDisplayHandler();
}
@@ -0,0 +1,36 @@
package com.onarandombox.MultiverseCore.display.handlers;
import com.onarandombox.MultiverseCore.display.ContentDisplay;
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
import com.onarandombox.MultiverseCore.display.DisplayHandler;
import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
public class InlineListDisplayHandler implements DisplayHandler<Collection<String>> {
@Override
public Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display)
throws DisplayFormatException {
StringBuilder builder = new StringBuilder();
String separator = display.getSetting(InlineDisplaySettings.SEPARATOR);
for (Iterator<String> iterator = display.getContents().iterator(); iterator.hasNext(); ) {
String content = iterator.next();
if (!display.getFilter().checkMatch(content)) {
continue;
}
builder.append(display.getColorTool().get()).append(content);
if (iterator.hasNext()) {
builder.append(separator);
}
}
return (builder.length() == 0)
? Collections.singletonList(display.getEmptyMessage())
: Collections.singleton(builder.toString());
}
}
@@ -0,0 +1,44 @@
package com.onarandombox.MultiverseCore.display.handlers;
import com.onarandombox.MultiverseCore.display.ContentDisplay;
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
import com.onarandombox.MultiverseCore.display.DisplayHandler;
import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings;
import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
public class InlineMapDisplayHandler implements DisplayHandler<Map<String, Object>> {
@Override
public Collection<String> format(@NotNull CommandSender sender,
@NotNull ContentDisplay<Map<String, Object>> display)
throws DisplayFormatException {
StringBuilder builder = new StringBuilder();
String separator = display.getSetting(InlineDisplaySettings.SEPARATOR);
String operator = display.getSetting(MapDisplaySettings.OPERATOR);
for (Iterator<Map.Entry<String, Object>> iterator = display.getContents().entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<String, Object> entry = iterator.next();
if (!display.getFilter().checkMatch(entry.getKey()) && !display.getFilter().checkMatch(entry.getValue())) {
continue;
}
builder.append(display.getColorTool().get())
.append(entry.getKey())
.append(operator)
.append(display.getColorTool().get())
.append(entry.getValue());
if (iterator.hasNext()) {
builder.append(separator);
}
}
return (builder.length() == 0)
? Collections.singletonList(display.getEmptyMessage())
: Collections.singleton(builder.toString());
}
}
@@ -0,0 +1,22 @@
package com.onarandombox.MultiverseCore.display.handlers;
import com.onarandombox.MultiverseCore.display.ContentDisplay;
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
import com.onarandombox.MultiverseCore.display.DisplayHandler;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.stream.Collectors;
public class ListDisplayHandler implements DisplayHandler<Collection<String>> {
@Override
public Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display)
throws DisplayFormatException {
return display.getContents().stream()
.filter(display.getFilter()::checkMatch)
.map(s -> (ContentDisplay.LINE_BREAK.equals(s)) ? "" : display.getColorTool().get() + s)
.collect(Collectors.toList());
}
}
@@ -0,0 +1,105 @@
package com.onarandombox.MultiverseCore.display.handlers;
import com.onarandombox.MultiverseCore.display.ContentDisplay;
import com.onarandombox.MultiverseCore.display.DisplayFormatException;
import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.IntStream;
public class PagedListDisplayHandler extends ListDisplayHandler {
@Override
public Collection<String> format(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display)
throws DisplayFormatException {
if (dontNeedPaging(sender, display)) {
return super.format(sender, display);
}
int pages = 1;
int currentLength = 0;
int targetPage = display.getSetting(PagedDisplaySettings.SHOW_PAGE);
int linesPerPage = display.getSetting(PagedDisplaySettings.LINES_PER_PAGE);
List<String> content = new ArrayList<>(linesPerPage);
// Calculate the paging.
for (String line : display.getContents()) {
if (!display.getFilter().checkMatch(line)) {
continue;
}
// When it's the next page.
boolean isLineBreak = ContentDisplay.LINE_BREAK.equals(line);
if (isLineBreak || ++currentLength > linesPerPage) {
pages++;
currentLength = 0;
if (isLineBreak) {
continue;
}
}
if (pages == targetPage) {
// Let first line be the header when no header is defined.
if (display.getHeader() == null) {
display.setHeader(line);
currentLength--;
continue;
}
content.add(display.getColorTool().get() + line);
}
}
// Page out of range.
if (targetPage < 1 || targetPage > pages) {
if (pages == 1) {
throw new DisplayFormatException("There is only 1 page!");
}
throw new DisplayFormatException("Please enter a page from 1 to " + pages + ".");
}
// No content
if (content.size() == 0) {
content.add(display.getEmptyMessage());
}
// Add empty lines to make output length consistent.
if (display.getSetting(PagedDisplaySettings.DO_END_PADDING)) {
IntStream.range(0, linesPerPage - content.size()).forEach(i -> content.add(""));
}
display.setSetting(PagedDisplaySettings.TOTAL_PAGE, pages);
return content;
}
@Override
public void sendSubHeader(@NotNull CommandSender sender, @NotNull ContentDisplay<Collection<String>> display) {
if (dontNeedPaging(sender, display)) {
super.sendSubHeader(sender, display);
return;
}
if (display.getFilter().hasFilter()) {
sender.sendMessage(String.format("%s[ Page %s of %s, %s ]",
ChatColor.GRAY,
display.getSetting(PagedDisplaySettings.SHOW_PAGE),
display.getSetting(PagedDisplaySettings.TOTAL_PAGE),
display.getFilter().getFormattedString())
);
return;
}
sender.sendMessage(String.format("%s[ Page %s of %s ]",
ChatColor.GRAY,
display.getSetting(PagedDisplaySettings.SHOW_PAGE),
display.getSetting(PagedDisplaySettings.TOTAL_PAGE))
);
}
private boolean dontNeedPaging(CommandSender sender, ContentDisplay<Collection<String>> display) {
return sender instanceof ConsoleCommandSender
&& !display.getSetting(PagedDisplaySettings.PAGE_IN_CONSOLE);
}
}
@@ -0,0 +1,19 @@
package com.onarandombox.MultiverseCore.display.settings;
import com.onarandombox.MultiverseCore.display.DisplayHandler;
/**
* Represents a setting option that can be used by {@link DisplayHandler}.
*
* @param <T>
*/
@FunctionalInterface
public interface DisplaySetting<T> {
/**
* Gets the default value of this Display Setting.
*
* @return The default value.
*/
T defaultValue();
}
@@ -0,0 +1,15 @@
package com.onarandombox.MultiverseCore.display.settings;
import com.onarandombox.MultiverseCore.display.DisplayHandler;
import org.bukkit.ChatColor;
/**
* Collection of {@link DisplaySetting} that are used by various {@link DisplayHandler}.
*/
public class InlineDisplaySettings {
/**
* Inline separator. E.g. '1, 2, 3'
*/
public static final DisplaySetting<String> SEPARATOR = () -> ChatColor.WHITE + ", ";
}
@@ -0,0 +1,15 @@
package com.onarandombox.MultiverseCore.display.settings;
import com.onarandombox.MultiverseCore.display.DisplayHandler;
import org.bukkit.ChatColor;
/**
* Collection of {@link DisplaySetting} that are used by various {@link DisplayHandler}.
*/
public class MapDisplaySettings {
/**
* The thing between a key value pair. E.g. 'Me = Smart'
*/
public static final DisplaySetting<String> OPERATOR = () -> ChatColor.WHITE + " = ";
}
@@ -0,0 +1,30 @@
package com.onarandombox.MultiverseCore.display.settings;
public class PagedDisplaySettings {
/**
* Page to display.
*/
public static final DisplaySetting<Integer> SHOW_PAGE = () -> 1;
/**
* Total pages available to display.
*/
public static final DisplaySetting<Integer> TOTAL_PAGE = () -> 1;
/**
* The max number of lines per page. This excludes header.
*/
public static final DisplaySetting<Integer> LINES_PER_PAGE = () -> 8;
/**
* Should add empty lines if content lines shown is less that {@link #LINES_PER_PAGE}.
*/
public static final DisplaySetting<Boolean> DO_END_PADDING = () -> true;
/**
* Should display with paging when it's sent to console.
*/
public static final DisplaySetting<Boolean> PAGE_IN_CONSOLE = () -> false;
}
@@ -11,6 +11,7 @@ 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.utils.CompatibilityLayer;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -18,6 +19,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent;
@@ -107,4 +109,17 @@ public class MVEntityListener implements Listener {
event.setCancelled(this.plugin.getMVWorldManager().getTheWorldPurger().shouldWeKillThisCreature(mvworld, event.getEntity()));
}
/**
* Handles portal search radius adjustment.
* @param event The Event that was fired.
*/
@EventHandler
public void entityPortal(EntityPortalEvent event) {
if (event.isCancelled() || event.getTo() == null) {
return;
}
if (!this.plugin.getMVConfig().isUsingDefaultPortalSearch()) {
CompatibilityLayer.setPortalSearchRadius(event, this.plugin.getMVConfig().getPortalSearchRadius());
}
}
}
@@ -7,10 +7,6 @@
package com.onarandombox.MultiverseCore.listeners;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
@@ -35,6 +31,9 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Multiverse's {@link Listener} for players.
*/
@@ -171,7 +170,7 @@ public class MVPlayerListener implements Listener {
return;
}
Player teleportee = event.getPlayer();
CommandSender teleporter = null;
CommandSender teleporter = teleportee;
String teleporterName = MultiverseCore.getPlayerTeleporter(teleportee.getName());
if (teleporterName != null) {
if (teleporterName.equals("CONSOLE")) {
@@ -313,16 +312,8 @@ public class MVPlayerListener implements Listener {
+ "' was allowed to go to '" + event.getTo().getWorld().getName()
+ "' because enforceaccess is off.");
}
if (!plugin.getMVConfig().isUsingDefaultPortalSearch()) {
try {
Class.forName("org.bukkit.TravelAgent");
if (event.getPortalTravelAgent() != null) {
event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius());
}
} catch (ClassNotFoundException ignore) {
Logging.fine("TravelAgent not available for PlayerPortalEvent for " + event.getPlayer().getName());
}
if (!this.plugin.getMVConfig().isUsingDefaultPortalSearch()) {
CompatibilityLayer.setPortalSearchRadius(event, this.plugin.getMVConfig().getPortalSearchRadius());
}
}
@@ -1,32 +1,35 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Bukkit;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import java.lang.reflect.Method;
/**
* A utility class to enable version specific minecraft features.
* Utility class to enable version specific minecraft features.
*/
public class CompatibilityLayer {
private static Method checkAnchorSpawn;
private static boolean useTravelAgent;
private static Method playerPortalSearchRadius;
private static Method entityPortalSearchRadius;
/**
* Initialise the reflection methods.
* Initialise the reflection class, methods and fields.
*/
public static void init() {
try {
checkAnchorSpawn = PlayerRespawnEvent.class.getDeclaredMethod("isAnchorSpawn");
} catch (NoSuchMethodException e) {
Logging.fine("%s does not support respawn anchors.", Bukkit.getVersion());
}
checkAnchorSpawn = ReflectHelper.getMethod(PlayerRespawnEvent.class, "isAnchorSpawn");
useTravelAgent = ReflectHelper.hasClass("org.bukkit.TravelAgent");
playerPortalSearchRadius = ReflectHelper.getMethod(PlayerPortalEvent.class, "setSearchRadius", int.class);
entityPortalSearchRadius = ReflectHelper.getMethod(EntityPortalEvent.class, "setSearchRadius", int.class);
}
/**
* Check if the respawn point is of respawn anchor type.
* Introduced in minecraft 1.16
* <p>Check if the respawn point is of respawn anchor type.</p>
* <p>Introduced in minecraft 1.16</p>
*
* @param event A player respawn event.
* @return If the respawn location is an anchor point.
@@ -35,12 +38,69 @@ public class CompatibilityLayer {
if (checkAnchorSpawn == null) {
return false;
}
try {
return (boolean) checkAnchorSpawn.invoke(event);
} catch (Exception e) {
Logging.warning("Error checking for: %s", checkAnchorSpawn);
e.printStackTrace();
Boolean result = ReflectHelper.invokeMethod(event, checkAnchorSpawn);
if (result == null) {
Logging.warning("Unable to check if spawning at respawn anchor!");
return false;
}
return false;
return result;
}
}
/**
* <p>Gets if Travel Agent is supported on the server's minecraft version.</p>
* <p>Removed in minecraft 1.14</p>
*
* @return True if Travel Agent is supported, else false.
*/
public static boolean isUseTravelAgent() {
return useTravelAgent;
}
/**
* <p>Sets search radius for a PlayerPortalEvent.</p>
*
* <p>Use travel agent if available, else using new PlayerPortalEvent.setSearchRadius(int) method
* introduced in minecraft 1.15</p>
*
* @param event A Player Portal Event.
* @param searchRadius Target search radius to set to.
*/
public static void setPortalSearchRadius(PlayerPortalEvent event, int searchRadius) {
if (useTravelAgent) {
event.getPortalTravelAgent().setSearchRadius(searchRadius);
event.useTravelAgent(true);
Logging.finer("Used travel agent to set player portal search radius.");
return;
}
if (playerPortalSearchRadius == null) {
Logging.warning("Unable to set player portal search radius!");
return;
}
ReflectHelper.invokeMethod(event, playerPortalSearchRadius, searchRadius);
Logging.finer("Used new method to set player portal search radius.");
}
/**
* <p>Sets search radius for a EntityPortalEvent.</p>
*
* <p>Use travel agent if available, else using new EntityPortalEvent.setSearchRadius(int) method
* introduced in minecraft 1.15</p>
*
* @param event A Entity Portal Event.
* @param searchRadius Target search radius to set to.
*/
public static void setPortalSearchRadius(EntityPortalEvent event, int searchRadius) {
if (useTravelAgent) {
event.getPortalTravelAgent().setSearchRadius(searchRadius);
event.useTravelAgent(true);
Logging.finer("Used travel agent to set entity portal search radius.");
return;
}
if (entityPortalSearchRadius == null) {
Logging.warning("Unable to set entity portal search radius!");
return;
}
ReflectHelper.invokeMethod(event, entityPortalSearchRadius, searchRadius);
Logging.finer("Used new method to set entity portal search radius.");
}
}
@@ -135,7 +135,7 @@ public class PlayerFinder {
List<Player> matchedPlayers = getMultiBySelector(playerSelector, sender);
if (matchedPlayers == null || matchedPlayers.isEmpty()) {
Logging.warning("No player found with selector '%s' for %s.", playerSelector, sender.getName());
Logging.fine("No player found with selector '%s' for %s.", playerSelector, sender.getName());
return null;
}
if (matchedPlayers.size() > 1) {
@@ -9,11 +9,11 @@ package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -25,8 +25,6 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;
import java.util.logging.Level;
/**
* The default-implementation of {@link SafeTTeleporter}.
*/
@@ -37,6 +35,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
this.plugin = plugin;
}
private static final Vector DEFAULT_VECTOR = new Vector();
private static final int DEFAULT_TOLERANCE = 6;
private static final int DEFAULT_RADIUS = 9;
@@ -214,8 +213,11 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
if (safeLoc != null) {
if (teleportee.teleport(safeLoc)) {
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
teleportee.setVelocity(d.getVelocity());
Vector v = d.getVelocity();
if (v != null && !DEFAULT_VECTOR.equals(v)) {
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
teleportee.setVelocity(d.getVelocity());
}, 1);
}
return TeleportResult.SUCCESS;
}
@@ -18,6 +18,7 @@ import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
@@ -55,7 +56,6 @@ import java.util.stream.Collectors;
*/
public class WorldManager implements MVWorldManager {
private final MultiverseCore plugin;
private final Pattern worldNamePattern = Pattern.compile("[a-zA-Z0-9/._-]+");
private final WorldPurger worldPurger;
private final Map<String, MultiverseWorld> worlds;
private Map<String, WorldProperties> worldsFromTheConfig;
@@ -130,7 +130,7 @@ public class WorldManager implements MVWorldManager {
}
// Check for valid world name
if (!(WorldNameChecker.isValidWorldName(oldName) && WorldNameChecker.isValidWorldName(oldName))) {
if (!(WorldNameChecker.isValidWorldName(oldName) && WorldNameChecker.isValidWorldName(newName))) {
return false;
}
@@ -387,14 +387,14 @@ public class WorldManager implements MVWorldManager {
this.worldsFromTheConfig.get(name).cacheVirtualProperties();
if (unloadBukkit && this.unloadWorldFromBukkit(name, true)) {
this.worlds.remove(name);
Logging.info("World '%s' was unloaded from memory.", name);
Logging.info("World '%s' was unloaded from Bukkit.", name);
return true;
} else if (!unloadBukkit){
this.worlds.remove(name);
Logging.info("World '%s' was unloaded from memory.", name);
Logging.info("World '%s' was unloaded from Multiverse.", name);
return true;
} else {
Logging.warning("World '%s' could not be unloaded. Is it a default world?", name);
Logging.warning("World '%s' could not be unloaded from Bukkit. Is it a default world?", name);
}
} else if (this.plugin.getServer().getWorld(name) != null) {
Logging.warning("Hmm Multiverse does not know about this world but it's loaded in memory.");
@@ -897,12 +897,23 @@ public class WorldManager implements MVWorldManager {
*/
@Override
public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed) {
return regenWorld(name, useNewSeed, randomSeed, seed, false);
}
/**
* {@inheritDoc}
*/
@Override
public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules) {
MultiverseWorld world = this.getMVWorld(name);
if (world == null)
if (world == null) {
Logging.warning("Unable to regen a world that does not exist!");
return false;
}
List<Player> ps = world.getCBWorld().getPlayers();
// Apply new seed if needed.
if (useNewSeed) {
long theSeed;
@@ -918,19 +929,64 @@ public class WorldManager implements MVWorldManager {
world.setSeed(theSeed);
}
WorldType type = world.getWorldType();
if (this.deleteWorld(name, false, false)) {
this.doLoad(name, true, type);
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
Location newSpawn = world.getSpawnLocation();
// Send all players that were in the old world, BACK to it!
for (Player p : ps) {
teleporter.safelyTeleport(null, p, newSpawn, true);
// Save current GameRules if needed.
Map<GameRule<?>, Object> gameRuleMap = null;
if (keepGameRules) {
gameRuleMap = new HashMap<>(GameRule.values().length);
World CBWorld = world.getCBWorld();
for (GameRule<?> gameRule : GameRule.values()) {
// Only save if not default value.
Object value = CBWorld.getGameRuleValue(gameRule);
if (value != CBWorld.getGameRuleDefault(gameRule)) {
gameRuleMap.put(gameRule, value);
}
}
return true;
}
return false;
// Do the regen.
if (!this.deleteWorld(name, false, false)) {
Logging.severe("Unable to regen world as world cannot be deleted.");
return false;
}
if (!this.doLoad(name, true, type)) {
Logging.severe("Unable to regen world as world cannot be loaded.");
return false;
}
// Get new MultiverseWorld reference.
world = this.getMVWorld(name);
// Load back GameRules if needed.
if (keepGameRules) {
Logging.fine("Restoring previous world's GameRules...");
World CBWorld = world.getCBWorld();
for (Map.Entry<GameRule<?>, Object> gameRuleEntry : gameRuleMap.entrySet()) {
if (!setGameRuleValue(CBWorld, gameRuleEntry.getKey(), gameRuleEntry.getValue())) {
Logging.warning("Unable to set GameRule '%s' to '%s' on regen world.",
gameRuleEntry.getKey().getName(), gameRuleEntry.getValue());
}
}
}
// Send all players that were in the old world, BACK to it!
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
Location newSpawn = world.getSpawnLocation();
for (Player p : ps) {
teleporter.safelyTeleport(null, p, newSpawn, true);
}
return true;
}
private <T> boolean setGameRuleValue(World world, GameRule<T> gameRule, Object value) {
try {
return world.setGameRule(gameRule, (T) value);
} catch (Exception e) {
return false;
}
}
/**
@@ -1,11 +1,12 @@
package com.onarandombox.MultiverseCore.utils.metrics;
import org.bstats.charts.AdvancedPie;
import org.bstats.charts.MultiLineChart;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import org.bstats.bukkit.Metrics;
enum MetricsHelper {
;
@@ -17,16 +18,16 @@ enum MetricsHelper {
map.put(key, count + 1);
}
static Metrics.AdvancedPie createAdvancedPieChart(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
static AdvancedPie createAdvancedPieChart(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
Map<String, Integer> map = new HashMap<>();
metricsFunc.accept(map);
return new Metrics.AdvancedPie(chartId, () -> map);
return new AdvancedPie(chartId, () -> map);
}
static Metrics.MultiLineChart createMultiLineChart(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
static MultiLineChart createMultiLineChart(String chartId, Consumer<Map<String, Integer>> metricsFunc) {
Map<String, Integer> map = new HashMap<>();
metricsFunc.accept(map);
return new Metrics.MultiLineChart(chartId, () -> map);
return new MultiLineChart(chartId, () -> map);
}
}
@@ -11,7 +11,7 @@ import java.util.Map;
* A {@link URLShortener} using {@code bit.ly}. Requires an access token.
*/
class BitlyURLShortener extends URLShortener {
private static final String ACCESS_TOKEN = "Bearer bitly-access-token";
private static final String ACCESS_TOKEN = "Bearer @bitly-access-token@";
private static final String BITLY_POST_REQUEST = "https://api-ssl.bitly.com/v4/shorten";
BitlyURLShortener() {
@@ -27,7 +27,6 @@ class BitlyURLShortener extends URLShortener {
@Override
String encodeData(String data) {
JSONObject json = new JSONObject();
json.put("domain", "j.mp");
json.put("long_url", data);
return json.toJSONString();
}
+1 -1
View File
@@ -4,7 +4,7 @@ authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--']
website: 'https://dev.bukkit.org/projects/multiverse-core'
softdepend: ['Vault']
api-version: 1.13
version: maven-version-number
version: ${version}
commands:
mv:
description: Generic Multiverse Command
@@ -14,15 +14,9 @@ import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
@@ -31,9 +25,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
@PowerMockIgnore("javax.script.*")
public class TestDebugMode {
TestInstanceCreator creator;
Server mockServer;
@@ -7,35 +7,29 @@ import com.onarandombox.MultiverseCore.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
@PowerMockIgnore("javax.script.*")
public class TestEntitySpawnRules {
TestInstanceCreator creator;
MultiverseCore core;
@@ -107,42 +101,42 @@ public class TestEntitySpawnRules {
@Test
public void test() {
// test 1: no spawning at all allowed
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(false, false, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(true);
// test 2: only monsters
adjustSettings(false, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(false, true, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 3: all spawning allowed
adjustSettings(true, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(true, true, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(false);
verify(zombieEvent).setCancelled(false);
// test 4: no spawning with zombie exception
adjustSettings(false, false, Collections.EMPTY_LIST, Arrays.asList("ZOMBIE"));
adjustSettings(false, false, Collections.emptyList(), Arrays.asList("ZOMBIE"));
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 5: all spawning with sheep exception
adjustSettings(true, true, Arrays.asList("SHEEP"), Collections.EMPTY_LIST);
adjustSettings(true, true, Arrays.asList("SHEEP"), Collections.emptyList());
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 6: eggs
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
adjustSettings(false, false, Collections.emptyList(), Collections.emptyList());
createAnimals();
spawnAll(SpawnReason.SPAWNER_EGG);
verify(sheepEvent, never()).setCancelled(anyBoolean());
@@ -157,6 +151,6 @@ public class TestEntitySpawnRules {
when(zombie.getType()).thenReturn(EntityType.ZOMBIE);
when(zombie.getWorld()).thenReturn(this.cbworld);
when(cbworld.getEntities()).thenReturn(Arrays.asList((Entity) sheep, (Entity) zombie));
when(cbworld.getEntities()).thenReturn(Arrays.asList(sheep, zombie));
}
}
@@ -2,24 +2,17 @@ package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import org.bukkit.Material;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
@PowerMockIgnore("javax.script.*")
public class TestEntryFeeConversion {
private TestInstanceCreator creator;
@@ -6,24 +6,16 @@ import org.bukkit.Server;
import org.bukkit.World.Environment;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class })
@PowerMockIgnore("javax.script.*")
public class TestModifyCommand {
TestInstanceCreator creator;
Server mockServer;
@@ -13,8 +13,6 @@ import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
import com.onarandombox.MultiverseCore.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@@ -36,33 +34,26 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.internal.verification.VerificationModeFactory;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class,
WeatherChangeEvent.class, ThunderChangeEvent.class, AsyncPlayerChatEvent.class,
PlayerJoinEvent.class, PlayerRespawnEvent.class, EntityRegainHealthEvent.class,
FoodLevelChangeEvent.class, WorldManager.class, PluginDescriptionFile.class, JavaPluginLoader.class })
@PowerMockIgnore("javax.script.*")
public class TestWorldProperties {
private TestInstanceCreator creator;
private MultiverseCore core;
@@ -122,7 +113,7 @@ public class TestWorldProperties {
String[] netherArgs = new String[] { "import", "world_nether", "nether" };
core.onCommand(mockCommandSender, mockCommand, "", netherArgs);
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
verify(mockCommandSender, VerificationModeFactory.times(2)).sendMessage(
verify(mockCommandSender, times(2)).sendMessage(
ChatColor.GREEN + "Complete!");
assertEquals(core.getServer().getWorlds().size(), 2);
@@ -222,7 +213,7 @@ public class TestWorldProperties {
assertTrue(mvWorld.setColor("BLACK"));
assertFalse(mvWorld.setColor("INVALID COLOR"));
assertEquals(ChatColor.BLACK, mvWorld.getColor());
assertEquals(ChatColor.BLACK.toString() + "alias" + ChatColor.WHITE.toString(), mvWorld.getColoredWorldString());
assertEquals(ChatColor.BLACK + "alias" + ChatColor.WHITE, mvWorld.getColoredWorldString());
mvWorld.setPVPMode(false);
assertEquals(false, mvWorld.isPVPEnabled());
assertTrue(mvWorld.setScaling(2D));
@@ -329,7 +320,7 @@ public class TestWorldProperties {
assertEquals(true, mvWorld.isHidden());
assertEquals("alias", mvWorld.getAlias());
assertEquals(ChatColor.GREEN, mvWorld.getColor());
assertEquals(ChatColor.GREEN.toString() + "alias" + ChatColor.WHITE.toString(), mvWorld.getColoredWorldString());
assertEquals(ChatColor.GREEN + "alias" + ChatColor.WHITE, mvWorld.getColoredWorldString());
assertEquals(false, mvWorld.isPVPEnabled());
assertEquals(2D, mvWorld.getScaling(), 0);
assertSame(worldManager.getMVWorld("world_nether").getCBWorld(),
@@ -366,36 +357,36 @@ public class TestWorldProperties {
when(mockPlayer.hasPlayedBefore()).thenReturn(true);
when(mockPlayer.hasPermission("multiverse.access.world")).thenReturn(true);
when(mockPlayer.getName()).thenReturn("MultiverseMan");
playerChatEvent = PowerMockito.mock(AsyncPlayerChatEvent.class);
playerChatEvent = mock(AsyncPlayerChatEvent.class);
when(playerChatEvent.getPlayer()).thenReturn(mockPlayer);
when(playerChatEvent.getFormat()).thenReturn("format");
// player join
mockNewPlayer = mock(Player.class);
when(mockNewPlayer.hasPlayedBefore()).thenReturn(false);
playerJoinEvent = PowerMockito.mock(PlayerJoinEvent.class);
playerJoinEvent = mock(PlayerJoinEvent.class);
when(playerJoinEvent.getPlayer()).thenReturn(mockPlayer);
playerNewJoinEvent = PowerMockito.mock(PlayerJoinEvent.class);
playerNewJoinEvent = mock(PlayerJoinEvent.class);
when(playerNewJoinEvent.getPlayer()).thenReturn(mockNewPlayer);
// player respawn
playerRespawnBed = PowerMockito.mock(PlayerRespawnEvent.class);
playerRespawnBed = mock(PlayerRespawnEvent.class);
when(playerRespawnBed.getPlayer()).thenReturn(mockPlayer);
when(playerRespawnBed.isBedSpawn()).thenReturn(true);
playerRespawnNormal = PowerMockito.mock(PlayerRespawnEvent.class);
playerRespawnNormal = mock(PlayerRespawnEvent.class);
when(playerRespawnNormal.getPlayer()).thenReturn(mockPlayer);
when(playerRespawnNormal.isBedSpawn()).thenReturn(false);
//// Entity events
mockHumanEntity = mock(HumanEntity.class);
// entity regain health
entityRegainHealthEvent = PowerMockito.mock(EntityRegainHealthEvent.class);
entityRegainHealthEvent = mock(EntityRegainHealthEvent.class);
when(entityRegainHealthEvent.getRegainReason()).thenReturn(RegainReason.REGEN);
when(mockHumanEntity.getLocation()).thenReturn(new Location(world, 0, 0, 0));
when(entityRegainHealthEvent.getEntity()).thenReturn(mockHumanEntity);
// entity food level change event
entityFoodLevelChangeEvent = PowerMockito.mock(FoodLevelChangeEvent.class);
entityFoodLevelChangeEvent = mock(FoodLevelChangeEvent.class);
// this won't do anything since we're not mocking a player,
// but the plugin should be able to handle this!
when(entityFoodLevelChangeEvent.getEntity()).thenReturn(mockHumanEntity);
entityFoodLevelRiseEvent = PowerMockito.mock(FoodLevelChangeEvent.class);
entityFoodLevelRiseEvent = mock(FoodLevelChangeEvent.class);
when(mockPlayer.getFoodLevel()).thenReturn(2);
when(entityFoodLevelRiseEvent.getEntity()).thenReturn(mockPlayer);
when(entityFoodLevelRiseEvent.getFoodLevel()).thenReturn(3);
@@ -4,28 +4,21 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Zombie;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Arrays;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class })
@PowerMockIgnore("javax.script.*")
public class TestWorldPurger {
TestInstanceCreator creator;
MultiverseCore core;
@@ -121,6 +114,6 @@ public class TestWorldPurger {
zombie = mock(Zombie.class);
when(zombie.getType()).thenReturn(EntityType.ZOMBIE);
when(zombie.getWorld()).thenReturn(world);
when(cbworld.getEntities()).thenReturn(Arrays.asList((Entity) sheep, (Entity) zombie));
when(cbworld.getEntities()).thenReturn(Arrays.asList(sheep, zombie));
}
}
@@ -12,39 +12,30 @@ import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import com.onarandombox.MultiverseCore.utils.WorldCreatorMatcher;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.WorldCreator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Matchers;
import org.mockito.internal.verification.VerificationModeFactory;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
import static junit.framework.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class, WorldManager.class,
PluginDescriptionFile.class, JavaPluginLoader.class })
@PowerMockIgnore("javax.script.*")
public class TestWorldStuff {
private TestInstanceCreator creator;
@@ -1,7 +1,8 @@
package com.onarandombox.MultiverseCore.utils;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
@@ -10,10 +11,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.dumptruckman.minecraft.util.Logging;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class FileUtilsTest {
@@ -137,7 +136,7 @@ public class FileUtilsTest {
assertTrue(Files.isRegularFile(targetChildDirFile));
}
@Test()
@Test
public void copyFolder_intoExistingFolder_whereFileExists() throws Exception {
Path targetDir = Files.createDirectory(tempDir.resolve("target"));
Path targetFile = Files.createFile(targetDir.resolve("parentDirFile.txt"));
@@ -21,13 +21,17 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.LinkedHashMap;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class MockWorldFactory {
@@ -27,13 +27,9 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.bukkit.scheduler.BukkitScheduler;
import org.mockito.ArgumentMatchers;
import org.mockito.internal.util.reflection.ReflectionMemberAccessor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.api.easymock.PowerMock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.MockGateway;
import org.powermock.reflect.Whitebox;
import java.io.File;
import java.lang.reflect.Field;
@@ -44,15 +40,16 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
public class TestInstanceCreator {
private MultiverseCore core;
@@ -69,28 +66,20 @@ public class TestInstanceCreator {
pluginDirectory.mkdirs();
assertTrue(pluginDirectory.exists());
MockGateway.MOCK_STANDARD_METHODS = false;
// Initialize the Mock server.
mockServer = mock(Server.class);
JavaPluginLoader mockPluginLoader = PowerMock.createMock(JavaPluginLoader.class);
Whitebox.setInternalState(mockPluginLoader, "server", mockServer);
JavaPluginLoader mockPluginLoader = mock(JavaPluginLoader.class);
new ReflectionMemberAccessor().set(JavaPluginLoader.class.getDeclaredField("server"), mockPluginLoader, mockServer);
when(mockServer.getName()).thenReturn("TestBukkit");
Logger.getLogger("Minecraft").setParent(Util.logger);
when(mockServer.getLogger()).thenReturn(Util.logger);
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
// Return a fake PDF file.
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test",
PluginDescriptionFile pdf = spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test",
"com.onarandombox.MultiverseCore.MultiverseCore"));
when(pdf.getAuthors()).thenReturn(new ArrayList<String>());
core = PowerMockito.spy(new MultiverseCore(mockPluginLoader, pdf, pluginDirectory, new File(pluginDirectory, "testPluginFile")));
PowerMockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
return null; // don't run metrics in tests
}
}).when(core, "setupMetrics");
core = spy(new MultiverseCore(mockPluginLoader, pdf, pluginDirectory, new File(pluginDirectory, "testPluginFile")));
// Let's let all MV files go to bin/test
doReturn(pluginDirectory).when(core).getDataFolder();
@@ -103,7 +92,7 @@ public class TestInstanceCreator {
JavaPlugin[] plugins = new JavaPlugin[] { core };
// Mock the Plugin Manager
PluginManager mockPluginManager = PowerMockito.mock(PluginManager.class);
PluginManager mockPluginManager = mock(PluginManager.class);
when(mockPluginManager.getPlugins()).thenReturn(plugins);
when(mockPluginManager.getPlugin("Multiverse-Core")).thenReturn(core);
when(mockPluginManager.getPermission(anyString())).thenReturn(null);
@@ -157,7 +146,7 @@ public class TestInstanceCreator {
when(mockServer.getPluginManager()).thenReturn(mockPluginManager);
when(mockServer.createWorld(ArgumentMatchers.isA(WorldCreator.class))).thenAnswer(
when(mockServer.createWorld(isA(WorldCreator.class))).thenAnswer(
new Answer<World>() {
@Override
public World answer(InvocationOnMock invocation) throws Throwable {
@@ -219,7 +208,7 @@ public class TestInstanceCreator {
buscriptfield.setAccessible(true);
try {
buscript = PowerMockito.spy(new Buscript(core));
buscript = spy(new Buscript(core));
when(buscript.getPlugin()).thenReturn(core);
} catch (NullPointerException e) {
buscript = null;
@@ -228,25 +217,25 @@ public class TestInstanceCreator {
buscriptfield.set(core, buscript);
// Set worldManager
WorldManager wm = PowerMockito.spy(new WorldManager(core));
WorldManager wm = spy(new WorldManager(core));
Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager");
worldmanagerfield.setAccessible(true);
worldmanagerfield.set(core, wm);
// Set playerListener
MVPlayerListener pl = PowerMockito.spy(new MVPlayerListener(core));
MVPlayerListener pl = spy(new MVPlayerListener(core));
Field playerlistenerfield = MultiverseCore.class.getDeclaredField("playerListener");
playerlistenerfield.setAccessible(true);
playerlistenerfield.set(core, pl);
// Set entityListener
MVEntityListener el = PowerMockito.spy(new MVEntityListener(core));
MVEntityListener el = spy(new MVEntityListener(core));
Field entitylistenerfield = MultiverseCore.class.getDeclaredField("entityListener");
entitylistenerfield.setAccessible(true);
entitylistenerfield.set(core, el);
// Set weatherListener
MVWeatherListener wl = PowerMockito.spy(new MVWeatherListener(core));
MVWeatherListener wl = spy(new MVWeatherListener(core));
Field weatherlistenerfield = MultiverseCore.class.getDeclaredField("weatherListener");
weatherlistenerfield.setAccessible(true);
weatherlistenerfield.set(core, wl);
@@ -264,9 +253,9 @@ public class TestInstanceCreator {
when(commandSender.getServer()).thenReturn(mockServer);
when(commandSender.getName()).thenReturn("MockCommandSender");
when(commandSender.isPermissionSet(anyString())).thenReturn(true);
when(commandSender.isPermissionSet(ArgumentMatchers.isA(Permission.class))).thenReturn(true);
when(commandSender.isPermissionSet(isA(Permission.class))).thenReturn(true);
when(commandSender.hasPermission(anyString())).thenReturn(true);
when(commandSender.hasPermission(ArgumentMatchers.isA(Permission.class))).thenReturn(true);
when(commandSender.hasPermission(isA(Permission.class))).thenReturn(true);
when(commandSender.addAttachment(core)).thenReturn(null);
when(commandSender.isOp()).thenReturn(true);
@@ -10,8 +10,8 @@ package com.onarandombox.MultiverseCore.utils;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
public class Util {
private Util() {}
@@ -11,7 +11,7 @@ import org.bukkit.WorldCreator;
import org.mockito.ArgumentMatcher;
public class WorldCreatorMatcher implements ArgumentMatcher<WorldCreator> {
private WorldCreator worldCreator;
private final WorldCreator worldCreator;
private boolean careAboutSeeds = false;
private boolean careAboutGenerators = false;
@@ -0,0 +1 @@
mock-maker-inline