Compare commits

...
700 Commits
Author SHA1 Message Date
benwoo1110 74b04070ab Rename to lowercase commandtools. 2021-03-07 17:40:18 +08:00
benwoo1110 1c1245a711 Add docs for ContentFilter class. 2021-03-07 16:26:50 +08:00
benwoo1110 ddcd325c21 Add documentation to displaytools classes. 2021-03-07 16:26:26 +08:00
benwoo1110 198abf55ea Rename some packages. 2021-03-07 15:38:44 +08:00
benwoo1110 139ddd1bb2 Remove old display implemetations. 2021-03-07 15:27:31 +08:00
benwoo1110 c10cd5c45a Implement page break and other cleanups. 2021-03-07 14:55:41 +08:00
benwoo1110 7d80b89b02 Improve display pagging. 2021-03-07 13:52:52 +08:00
benwoo1110 e25e12737a Revert back pom, networking is dumb. 2021-03-07 11:56:06 +08:00
benwoo1110 e80d3909e0 Dont use https? 2021-03-07 10:34:43 +08:00
benwoo1110 85aa931ae3 why not working lol 2021-03-07 10:25:13 +08:00
benwoo1110 b7baeb4d3e try bump maven plugin versions. 2021-03-07 10:11:14 +08:00
benwoo1110 8f4f89b804 Use my own ci server. 2021-03-07 09:52:37 +08:00
benwoo1110 a478fac019 Use my own distribution manager. 2021-03-07 09:45:22 +08:00
benwoo1110 1f87175716 Use new content display system. 2021-03-07 09:43:47 +08:00
benwoo1110 650f2022b9 Rename to CoreFlags 2021-03-05 14:16:08 +08:00
benwoo1110 51c642b71c Remove getAvailableWorldGenerators from wm. 2021-03-05 14:11:24 +08:00
benwoo1110 77faf2bddc Fix gen flag not working. 2021-03-05 14:08:23 +08:00
benwoo1110 826fe08cfc Add documentation to flag classes, 2021-03-05 13:51:52 +08:00
benwoo1110 7a86227a94 Implement flags for version command. 2021-03-05 12:57:48 +08:00
benwoo1110 a6d4e21b85 Remove PlayerWorld. 2021-03-05 12:19:06 +08:00
benwoo1110 55cf19b1d8 Generate improvements througout. 2021-03-05 12:15:34 +08:00
benwoo1110 2fc6f3dc26 Rename commandtools package, 2021-03-05 00:43:10 +08:00
benwoo1110 8f250011b7 Implement new flag suggestion system. 2021-03-05 00:34:26 +08:00
benwoo1110 b8a0729715 Apply new flag system to create, import and regen commands. 2021-03-04 23:18:58 +08:00
benwoo1110 40b260feb5 Fix wrong exception thrown in DummyCommandBlockSender 2021-03-04 22:45:14 +08:00
benwoo1110 b3b8a5ed73 Test implement new flag system. 2021-03-04 22:36:21 +08:00
benwoo1110 03d1b3682d Fix merge conflicts 2021-03-04 19:11:57 +08:00
Ben Woo 7c59dcbcb9 Merge pull request #2494 from benwoo1110/property-fix
Fix cannot remove block currency with mvm set command.
2021-03-04 15:32:34 +08:00
Ben Woo 15cacba7c9 Merge pull request #2573 from Multiverse/java-11
Fix compiling with Java 11+
2021-03-02 09:01:38 +08:00
Ben Woo adbe88daa6 Merge pull request #2565 from Multiverse/fis-respawn-anchor
Add respawn anchor support.
2021-03-02 00:36:43 +08:00
Kermina Awad 5350c012f7 fix compiling on java 15 2021-02-25 17:48:17 -05:00
benwoo1110 a91f377cf5 Fix compile on java 11. 2021-02-24 16:40:21 +08:00
Ben Woo c3ae5ac210 Merge pull request #2539 from Multiverse/disable_buscript
Add a Config Option to Disable Buscript
2021-02-24 14:12:35 +08:00
Ben Woo f4ce740c06 Merge pull request #2568 from Multiverse/fullname-face-direction
Add support for fullname face direction.
2021-02-24 14:09:56 +08:00
Kermina Awad 3ff8d34053 add config option to disable buscript 2021-02-23 14:38:54 -05:00
benwoo1110 f362f09380 Add support for fullname face direction.
So we can do `w:world:north` on top of the current ``w:world:n`.
2021-02-21 17:19:18 +08:00
benwoo1110 84a9db597a Add respawn anchor support. 2021-02-19 00:57:19 +08:00
benwoo1110 2c9d2d0fe7 Merge branch '5.0.0' into acf-test 2021-02-14 17:30:33 +08:00
benwoo1110 2c98fc7d90 Merge branch 'main' into 5.0.0 2021-02-08 17:08:06 +08:00
nicegamer7 89fd700e32 Merge pull request #2489 from benwoo1110/world-UID
Adds world UID and generator details to /mvinfo command
2021-01-17 12:36:27 -05:00
benwoo1110 035f3644ad Merge branch 'main' into 5.0.0 2021-01-08 18:19:29 +08:00
benwoo1110 e1bcff732f Split into subclass for flag for better input type checking. 2021-01-08 11:32:38 +08:00
benwoo1110 4a90a6a1c7 Add configurable option for inline separator. 2021-01-08 10:33:54 +08:00
benwoo1110 4a4a2505e7 Make use of getAvailableWorldGenerators to reduce duplicate code. 2021-01-08 10:25:06 +08:00
benwoo1110 e2bf1a2bbe Add getAvailableWorldGenerators method to WorldManager, 2021-01-08 10:24:51 +08:00
benwoo1110 835ca69b78 Improve worldflags parsing and squashed some bugs. 2021-01-07 21:16:06 +08:00
benwoo1110 2eb4ce6807 Revamp world flags with tab complete. 2021-01-07 19:37:29 +08:00
benwoo1110 197764622c Testing getContextValue for CommandCompletions. 2021-01-07 11:12:35 +08:00
benwoo1110 cde7ab961f empty message shouldnt show prefix by default. 2021-01-03 23:49:12 +08:00
benwoo1110 0f23deeca1 whoall command use ListDisplay. 2021-01-03 16:07:09 +08:00
benwoo1110 6b7089eec0 Custom prefix and suffix for InlineDisplay. 2021-01-03 16:06:41 +08:00
benwoo1110 e90f1bb986 Update who command to use content filter. 2021-01-03 12:41:46 +08:00
benwoo1110 16878f002a Update messaging and docs. 2021-01-03 12:32:34 +08:00
benwoo1110 8ec08fd26a Fix ShowKeyValue not displaying anything. 2021-01-03 12:03:47 +08:00
benwoo1110 c9cf25c4e3 Generator command use ListDisplay. 2021-01-03 00:39:50 +08:00
benwoo1110 bfffc8c94e Fix pageOutOfRange checking. 2021-01-03 00:25:44 +08:00
benwoo1110 6e7328a407 Allow null player for getPlayerAwareDestination. 2021-01-03 00:22:13 +08:00
benwoo1110 617b0b5900 Add displaying of filter for ShowInline. 2021-01-02 23:56:07 +08:00
benwoo1110 e7bcdbe64b Fix null filter string context parsing. 2021-01-02 23:54:01 +08:00
benwoo1110 cdfe317517 Add ability to have custom empty message, and mroe cleanup. 2021-01-02 23:47:59 +08:00
benwoo1110 6987208241 Revamp ContentDisplay with builder. 2021-01-02 23:33:40 +08:00
benwoo1110 e1dc90b65d Improve Condition and context check and messaging. 2021-01-02 21:10:09 +08:00
benwoo1110 fd10eec765 Minor no player message colour change. 2021-01-02 21:09:48 +08:00
benwoo1110 54a2e270a8 Add package info. 2021-01-02 21:09:27 +08:00
benwoo1110 73d1035f84 Fix hasContentToShow checking. 2021-01-02 13:18:25 +08:00
benwoo1110 c874a98bac Minor cleanup to modify command. 2021-01-02 13:18:03 +08:00
benwoo1110 b73a4e552f Who command use ListDisplay. 2021-01-02 13:17:52 +08:00
benwoo1110 cd5a4c69f9 Cleanup modify command, and use KeyValueDisplay for properties. 2021-01-02 12:16:42 +08:00
benwoo1110 9dd9444248 Refactor inline display classes, 2021-01-02 12:16:11 +08:00
benwoo1110 942555f380 Fix a message typo. 2021-01-01 23:28:19 +08:00
benwoo1110 21d775d8a2 Fix tests and typos from previous messaging change. 2021-01-01 17:25:33 +08:00
benwoo1110 fd5e9485e9 Move to use string formatting and some cleanup. 2021-01-01 17:13:00 +08:00
benwoo1110 ebe420be15 Better error handling for getting generator. 2021-01-01 13:58:27 +08:00
benwoo1110 7b3e6ee07d Cleanup across the board. 2020-12-31 17:20:09 +08:00
benwoo1110 808c4ce704 Add docs and minor cleanup. 2020-12-31 16:07:57 +08:00
benwoo1110 04802f2fda Remove useless logging. 2020-12-31 13:50:08 +08:00
benwoo1110 1ffa1ece2d Add docs to contexts and display. More cleanup. 2020-12-31 12:29:27 +08:00
benwoo1110 95cce25453 Add package info and more cleanup. 2020-12-31 12:21:06 +08:00
benwoo1110 d0c280506c Cleanup command queue classes and add docs. 2020-12-31 12:09:43 +08:00
benwoo1110 3b9f1849d7 Cleanup display package and add docs. 2020-12-31 11:39:10 +08:00
benwoo1110 b3517ad9ce getCommandCompletions returns MVCommandCompletions directly. 2020-12-31 11:38:33 +08:00
Ben Woo d0f6434592 Merge branch 'main' into acf-test 2020-12-31 10:15:25 +08:00
benwoo1110 36e0d34695 Add player name as destination. 2020-12-31 01:03:23 +08:00
benwoo1110 6771bb6c44 Improve download suggestion.
Now shows download link even when extra args like `/mvp more stuff` is entered.
2020-12-30 23:29:07 +08:00
benwoo1110 3962f23691 Fix wrong selfOtherPerm checking. 2020-12-30 16:41:55 +08:00
benwoo1110 ef073b0403 Add ContentFilter to commands, and some cleanup. 2020-12-30 16:31:20 +08:00
benwoo1110 c8432b9b57 Use KeyValueDisplay to show gamerules. 2020-12-30 15:59:12 +08:00
benwoo1110 3f8e514f51 Futher absract content display to add KeyValueDisplay. 2020-12-30 15:37:25 +08:00
benwoo1110 942f8a99ab Refactored PageFisplay to make it more expandable. 2020-12-30 10:58:58 +08:00
benwoo1110 81f6014e94 Add DestinationFactory#getPlayerAwareDestination to parse cannon dest. 2020-12-28 22:06:51 +08:00
benwoo1110 fee822a2fe Add download suggestion for submodules. 2020-12-28 12:19:44 +08:00
benwoo1110 161478f05a Update AND permission checking key. 2020-12-28 11:03:02 +08:00
benwoo1110 e9ec1275fe Split location into individual params for better tab complete. 2020-12-28 10:52:24 +08:00
benwoo1110 fc6415af8c Cleanup some tab-completes. 2020-12-28 10:43:34 +08:00
benwoo1110 e88828f420 Add playerOnly flag to tab-complete suggestions. 2020-12-28 01:04:44 +08:00
benwoo1110 22afd094b2 Add tab complete for scripts. 2020-12-28 00:44:22 +08:00
benwoo1110 8f99d2c560 Fix modify command. 2020-12-28 00:13:40 +08:00
benwoo1110 6b47164726 Add missing description for who command. 2020-12-27 23:56:34 +08:00
benwoo1110 455b04ce8c Add param syntax and description to all command. 2020-12-27 23:40:21 +08:00
benwoo1110 cf05044b13 Remove mvm alias. 2020-12-27 23:07:10 +08:00
benwoo1110 44cbdc3baf Improve help command with better formatting. 2020-12-27 22:37:55 +08:00
benwoo1110 114400e77b Remove unnecessary logging. 2020-12-27 19:42:22 +08:00
benwoo1110 ff5498313b show the property values for mvm list command. 2020-12-26 20:58:43 +08:00
benwoo1110 7198a5a421 Update modify command with SET tab complete. 2020-12-26 20:46:36 +08:00
benwoo1110 793bbe3858 Add api to getAllPropertyTypes. 2020-12-26 20:41:00 +08:00
benwoo1110 90937d6322 Whoops ;D 2020-12-26 20:37:47 +08:00
benwoo1110 8c18caf30b Rename CommandPlayer to PlayerWorld. 2020-12-26 20:33:27 +08:00
benwoo1110 39e4b5c528 Command player now stores mvworld as well. 2020-12-26 20:32:42 +08:00
benwoo1110 ee2e7d3a70 Show player name when viewing others coord. 2020-12-26 18:14:08 +08:00
benwoo1110 5efcda37a5 Update todos. (again) 2020-12-26 18:05:35 +08:00
benwoo1110 17d5313981 Config command show properties and values that were updated. 2020-12-26 18:03:07 +08:00
benwoo1110 31494e2876 Update todos. 2020-12-26 17:55:09 +08:00
benwoo1110 8304e7a4ef Improvae coord command with Context. 2020-12-26 17:51:59 +08:00
benwoo1110 2dedffa353 Improve potential world tab complete. 2020-12-26 17:51:38 +08:00
benwoo1110 3e1d3e776b Parse world flags in command execution itself. 2020-12-26 17:16:13 +08:00
benwoo1110 538cdb1a69 Fix gamerule tabe complete. 2020-12-26 15:47:12 +08:00
benwoo1110 611af12ba6 Add tab complete for location. 2020-12-26 15:43:51 +08:00
benwoo1110 b5b9e19cff Add suggestDownload method.
Possibly use this in the future.
2020-12-23 21:17:46 +08:00
benwoo1110 20b492fa3c Add root command to show plugin info. 2020-12-23 18:17:31 +08:00
benwoo1110 e4a6e8a9ec All command block should share the same queue. 2020-12-23 17:16:15 +08:00
benwoo1110 b0cbd5b840 Add ability to have optional MultiverseWorld. 2020-12-22 23:54:15 +08:00
benwoo1110 4b45779cd1 Add mv modules base commands to plugins.yml. 2020-12-22 22:37:48 +08:00
benwoo1110 cee6f68439 Add toggles completion and remove need for onlyself flag. 2020-12-22 18:58:20 +08:00
benwoo1110 b953f1a011 Add mvp base command to plugin.yml 2020-12-22 18:05:23 +08:00
benwoo1110 29dcef5330 Allow for option to have AND permission checking. 2020-12-22 18:05:08 +08:00
benwoo1110 b0c4d72828 Improve gamemode command, and some cleanup. 2020-12-22 17:45:41 +08:00
benwoo1110 10c1040ead bump version to 5.0.0 2020-12-22 11:12:24 +08:00
Kermina Awad b6a784dc1b fix some typos/consistency errors 2020-12-21 13:24:06 -05:00
Kermina Awad 5fad1e0623 fix unit tests 2020-12-21 13:23:45 -05:00
benwoo1110 052194ca64 Add proper license message to files. 2020-12-22 00:38:05 +08:00
benwoo1110 dcadf23677 Clean up and remove all old command files. 2020-12-22 00:26:14 +08:00
benwoo1110 0c61dfff3a Implement changing of gamerules. 2020-12-22 00:17:09 +08:00
benwoo1110 026dd2f444 Ensure that version config option cannot be modifed. 2020-12-21 23:37:46 +08:00
benwoo1110 305cf50c9c Add page filters and improve anchor list command. 2020-12-21 23:26:48 +08:00
benwoo1110 8292af84b9 Adds world UID and generator details to /mvinfo command. 2020-12-21 21:36:54 +08:00
benwoo1110 904e29ed1b Implement paged info command with fancy colour. 2020-12-21 21:25:17 +08:00
benwoo1110 a76c61301e Implement paged list command. 2020-12-21 20:03:28 +08:00
benwoo1110 a05d4581f6 Optimise some streams. 2020-12-21 20:03:08 +08:00
benwoo1110 a783f773b3 Implement basic PageDisplay class. 2020-12-21 18:49:32 +08:00
benwoo1110 620203fbb7 Add custom prompt for confirm commands. 2020-12-21 15:15:07 +08:00
benwoo1110 56b881dcda Add showing of available types on invalid input, and some cleanup. 2020-12-21 14:53:05 +08:00
benwoo1110 408a66c4b1 Add who command. 2020-12-21 11:30:41 +08:00
benwoo1110 5f37bb629b Some cleanup and add Optional String. 2020-12-21 11:30:27 +08:00
benwoo1110 a7921a9074 Add anchor commands. 2020-12-21 00:09:45 +08:00
benwoo1110 f99d083347 Add mvspawn alias comand. 2020-12-20 22:56:47 +08:00
benwoo1110 096bcde439 Fix NPE with string arguments, and some cleanup. 2020-12-20 22:26:20 +08:00
benwoo1110 b6fbcf9e40 Fix .dat world folder checking. 2020-12-20 22:02:04 +08:00
benwoo1110 ff5f9e0691 Improve world validation and command completion. 2020-12-20 21:48:53 +08:00
benwoo1110 65c332f93d Add desination identifier tab completion. 2020-12-20 14:49:54 +08:00
benwoo1110 94c8189d2e Merge branch 'acf-test' of https://github.com/Multiverse/Multiverse-Core into acf-test 2020-12-20 14:49:32 +08:00
Kermina Awad a66e804f05 re-enable tests (still failing) 2020-12-20 01:38:55 -05:00
benwoo1110 8e00ba11ac Change MVConfig suggection to static 2020-12-20 14:38:48 +08:00
benwoo1110 3ca9de69f0 Add teleport permission checking support. 2020-12-20 14:33:25 +08:00
benwoo1110 1302a1efb8 Fix debug lavel parsing. 2020-12-20 14:13:26 +08:00
benwoo1110 013c39fd53 Update config.yml comments with new command syntax. 2020-12-20 12:38:40 +08:00
benwoo1110 4720bfe308 Cleanup plugins.yml 2020-12-20 12:38:07 +08:00
benwoo1110 45e7db7abd Remove unneeded code from old queue command handling. 2020-12-20 12:20:45 +08:00
Ben Woo 001a6000f8 Merge pull request #2515 from Multiverse/update_bstats
Update bStats Metrics Class
2020-12-20 12:10:52 +08:00
benwoo1110 14fc5c85a7 Add special case for mv modify set spawn. 2020-12-20 11:50:03 +08:00
Kermina Awad bf61069fed update bStats Metrics class 2020-12-19 22:17:04 -05:00
benwoo1110 42f0965eca Cleanup to various commands. 2020-12-20 10:32:44 +08:00
benwoo1110 532469145d Add .dat worldname validation. 2020-12-20 10:32:10 +08:00
benwoo1110 c0b36fefd8 Add bed command 2020-12-20 09:19:37 +08:00
benwoo1110 c6baeea5f9 Minor cleanup to version command. 2020-12-20 09:04:59 +08:00
benwoo1110 dce2cf5601 Add version command. 2020-12-20 00:51:17 +08:00
benwoo1110 52c210f755 Add NONE PasteServiceType 2020-12-20 00:19:54 +08:00
benwoo1110 23241572df Add modify list command. 2020-12-19 23:54:30 +08:00
benwoo1110 fbe0138fa2 Some cleanup. 2020-12-19 23:44:05 +08:00
benwoo1110 4b4474b1a9 Add modify command. 2020-12-19 23:38:42 +08:00
benwoo1110 28304baa6e Fix teleport and set spawn command. 2020-12-19 23:38:32 +08:00
benwoo1110 7b2a14c31f Add set spawn command. 2020-12-19 19:35:40 +08:00
benwoo1110 da6d6d64c2 Add purge command. 2020-12-18 23:57:34 +08:00
benwoo1110 bb92aa57a8 Add silent command and some clean up. 2020-12-18 22:48:01 +08:00
benwoo1110 5709278722 Add teleport command. 2020-12-18 22:20:15 +08:00
benwoo1110 e4f043216e Add environment and regen commands. 2020-12-18 19:38:41 +08:00
benwoo1110 3809f47a54 Merge the 2 gamerule command class. 2020-12-18 18:53:56 +08:00
benwoo1110 0641099055 Add check command and improve world related validation. 2020-12-18 18:36:34 +08:00
benwoo1110 1b65a91de4 Make MultiverseCommandAbstract 2020-12-18 18:35:59 +08:00
benwoo1110 ad40caecef Purpose build class for command manager that extends ACF. 2020-12-18 12:20:43 +08:00
benwoo1110 e518ea4e47 Add import command and improve world folder checking. 2020-12-18 11:24:42 +08:00
benwoo1110 519e449a54 Add clone command and some more cleanup. 2020-12-18 09:52:12 +08:00
benwoo1110 23ed7cb6ed Update todo. 2020-12-17 21:59:00 +08:00
benwoo1110 391ba7b4fa Add generator command. 2020-12-17 21:57:23 +08:00
benwoo1110 5413b92ce2 Add gamerule command and mics cleanup. 2020-12-17 21:38:40 +08:00
benwoo1110 a77ad6d7ab Clean up. 2020-12-17 20:58:34 +08:00
benwoo1110 7493ce5dd8 Add world folder suggestion and validation. 2020-12-17 15:17:29 +08:00
benwoo1110 07bfa44ecc Add some static command completetion for enums. 2020-12-17 13:46:46 +08:00
benwoo1110 c8d1aa467d Add gamerules, list and script. 2020-12-17 13:46:23 +08:00
benwoo1110 d494017186 Add remove command. 2020-12-17 00:21:18 +08:00
benwoo1110 5483988276 Implement optional argument properly 2020-12-17 00:16:20 +08:00
benwoo1110 6f12290a01 Cleannnn command classes. 2020-12-15 23:38:35 +08:00
benwoo1110 df3c9574aa Amazing progress!! 2020-12-15 21:19:02 +08:00
benwoo1110 9cda6556c9 Queue command works! 2020-12-15 16:21:28 +08:00
benwoo1110 1cda2a18a5 Add queue object to main class. 2020-12-15 14:28:08 +08:00
benwoo1110 15810c9404 More ACF testing, add queue manager. 2020-12-15 13:32:08 +08:00
Ben Woo d93def8b5b Merge pull request #2503 from Multiverse/getplayerexact
Use getPlayerExact in favour of getPlayer.
2020-12-14 10:28:58 +08:00
benwoo1110 d8ff083418 First test implementation of ACF
(mocking test are completely broken rip)
2020-12-13 23:09:16 +08:00
nicegamer7 540394e266 Merge pull request #2505 from benwoo1110/logging
Update to all use static logging.
2020-12-12 09:58:19 -05:00
benwoo1110 425b1c80cc Update to all use static logging. 2020-12-12 10:49:49 +08:00
Kermina Awad 47ae6f5378 use getPlayerExact instead of getPlayer 2020-12-11 12:48:19 -05:00
benwoo1110 48601e4215 Fix cannot remove block currency with mvm set command.
Setting currency to 0 is now considered as no currency value.
2020-11-27 21:14:27 +08:00
Alexander Krantz ed80083fe8 Fix null location when teleporting to own playerbed destination. (#2487)
* Fix teleporting to a the calling player's bed

* Change name to my-bed to prevent collisions with player names

* Re-add old player bed for backwards compatibility

* Remove second bed destination name

* Give constant more sensible name
2020-11-27 12:58:11 +08:00
Ben Woo d041e0a8d1 Merge pull request #2490 from benwoo1110/fix-tags
Update issue template with new tags.
2020-11-25 11:44:16 +08:00
benwoo1110 de85be5832 Update issue template with new tags. 2020-11-25 11:41:57 +08:00
Ben Woo 81d59d8bf5 Update issue template to use paste.gg (#2450)
* Update issue template to use paste.gg

* Update to show paste.gg as link
2020-10-27 11:56:18 -04:00
Jeremy Wood 0c2d2f4e0a One more test for the webhook... 2020-10-08 02:38:34 -04:00
Jeremy Wood 3d9108fb48 Minor change to test webhooks on new base branch. 2020-10-08 02:35:30 -04:00
Jeremy Wood f41337f8a8 Bumped version to 5.0.0-SNAPSHOT for development of next major version. 2020-10-08 02:24:07 -04:00
Jeremy Wood 25c616bc32 Bumped version to 4.2.3-SNAPSHOT for continued development. 2020-10-08 02:21:13 -04:00
Jeremy Wood 148187025a Release version 4.2.2. 2020-10-08 00:38:58 -04:00
Jeremy Wood 115b0dc078 Dump full version output in multifile pastes. 2020-10-07 23:52:43 -04:00
Jeremy Wood 78bf6ba3bf Merge pull request #2442 from Multiverse/version_command_typo
Correct a Typo in VersionCommand
2020-10-07 23:33:13 -04:00
Kermina Awad e31c391af4 correct a typo in VersionCommand 2020-10-07 23:15:21 -04:00
Jeremy Wood 6ed4be9a64 Move back to '\n' line separators in version command. 2020-10-07 23:12:50 -04:00
Jeremy Wood d626e7e4b1 Merge pull request #2429 from benwoo1110/green-warning
More noticable warning for deprecated event
2020-10-07 22:41:54 -04:00
Jeremy Wood e7dd4fee51 Merge pull request #2430 from benwoo1110/clone-cleanup
Remove uneeded variables from clone method
2020-10-07 22:41:01 -04:00
Ben Woo 146075de69 Loads unloaded world before deleting (#2431)
* Loads unload world before deleting

Fixes issue where unloaded worlds can't be deleted.

* Missing commit line smh
2020-10-07 22:38:45 -04:00
Jeremy Wood 9fce6c54f6 Merge pull request #2435 from Multiverse/webpaste
Fix Double Prefix when Logging Version Info
2020-10-07 22:37:22 -04:00
Ben Woo f189eb3b7e Fix issue template label (#2437)
* Fix issue template label

* Remove "type: " from label
2020-10-07 22:32:32 -04:00
benwoo1110 ed77cacb1a Adds generator detail to /mvinfo command 2020-10-07 21:00:40 +08:00
Kermina Awad 2d4fe301cf fix double prefix when logging version info 2020-10-06 16:26:20 -04:00
Jeremy Wood e5fe1fe565 Bump version to 4.2.2-SNAPSHOT for continued development. 2020-10-06 15:46:37 -04:00
Jeremy Wood 83010f1a28 Release version 4.2.1. 2020-10-06 15:08:13 -04:00
Jeremy Wood 864e50e38c Add TestingMode util. 2020-10-06 15:07:56 -04:00
Jeremy Wood 0a99258f3e Bump version to 4.2.1-SNAPSHOT for continued development. 2020-10-06 15:01:42 -04:00
benwoo1110 cfae997de4 Adds world UID to /mvinfo command 2020-10-07 00:39:08 +08:00
benwoo1110 b345baf20e Remove uneeded variables from clone method 2020-10-06 21:12:18 +08:00
benwoo1110 d532052c7b More noticable warning for deprecated event
Add green color to the warning
2020-10-06 20:47:41 +08:00
Jeremy Wood 1c02fb4387 Release version 4.2.0. 2020-10-06 01:45:11 -04:00
Jeremy Wood 2a99649e1e Merge pull request #2426 from Multiverse/webpaste
Make it Easier to Upload Files with the Version Event
2020-10-06 01:24:33 -04:00
Kermina Awad 994bf922af make it easier to upload files with the version event 2020-10-06 00:47:33 -04:00
Ben Wooandwben1110 36094e2bea Disallow world names with spaces (#2393)
* Disallowed world names with spaces

* Fixed wildcard imports

* Use Pattern regex check for worldname validation

Co-authored-by: wben1110 (desktop) <unconfigured@null.spigotmc.org>
2020-10-05 23:58:18 -04:00
Jeremy Wood 6243b41956 Merge pull request #2421 from benwoo1110/issue-tag
Added auto label and config.yml to issue template
2020-10-05 21:02:06 -04:00
benwoo1110 32170cc089 Added auto label and config.yml to issue template 2020-10-05 16:39:16 +08:00
Jeremy Wood c1a3d48944 Merge pull request #2420 from benwoo1110/plugin.yml-update
Updated plugin.yml commands and some missing alias
2020-10-05 01:34:31 -04:00
nicegamer7 75855826e7 Cleanup webpaste code (#2411) 2020-10-05 01:25:15 -04:00
Jeremy Wood d35363b10c Merge pull request #2103 from blubberdiblub/make-saved-anchors-locale-insensitive
Ensure anchors are saved in a machine-readable way
2020-10-05 00:36:19 -04:00
Jeremy Wood ad1b733498 Merge pull request #2379 from rti/master
load cloned world with doLoad() instead of addWorld() (fixes #2378)
2020-10-05 00:29:25 -04:00
benwoo1110 9159dfbb7d Updated plugin.yml commands and some missing alias 2020-10-05 00:28:48 +08:00
Robert Timm b8acd339b3 load cloned world with doLoad() instead of addWorld() (fixes #2378) 2020-10-02 10:01:54 +02:00
nicegamer7 51e035eb3e Update GameMode command and increase Java support. (#2279)
* update gamerule command

* fix NPE in gamerules command and remove deprecated method

* catch buscript initialization errors

* update gamerule command to be more descriptive

* undo GameruleCommand style changes

* update legacy version reporting to include all config options

* use LF line ending for files being pasted to the web

* avoid duplicate code
2020-09-22 15:02:03 -04:00
Jeremy Wood 2fd8e3edc3 Merge pull request #2406 from Jadiction/patch-1
A, not an :P
2020-09-15 15:06:16 -04:00
Jad faf20ee36e A, not an :P 2020-09-10 18:09:58 -05:00
benwoo1110andwben1110 e1494808f3 Fixed inability to clone due to unable to copy session.lock (#2392)
* Added ability to exclude files when copying folders

* Remove wildcard imports

* Added unit testing for ignoring files as well

Co-authored-by: wben1110 (desktop) <unconfigured@null.spigotmc.org>
2020-08-27 08:47:57 -04:00
benwoo1110 05cf052204 Add GitHub issue templates (#2385)
* Added issue templates

* Fixed a typo

* Added more details to template

Added dev build link

Need to enter `/server` output

Declaration that issue is reproducible with only mv plugins

* Added capitalization to issue title
2020-08-26 13:34:37 -04:00
Jeremy Wood 242f05fc77 Merge pull request #2288 from Multiverse/webpaste
Rework Webpaste Package
2020-07-28 20:50:08 -04:00
Jeremy Wood dd29fcc1dd Merge pull request #2315 from Multiverse/another_metric_fix
Don't Report Generator Settings
2020-07-28 20:41:07 -04:00
Kermina Awad d5013546d1 don't report generator settings 2020-06-29 11:40:01 -04:00
Kermina Awad 058c0837f0 bring multi-file pastes to parity with single file pastes 2020-06-14 16:04:58 -04:00
Kermina Awad e01c646562 add paste.gg paste service 2020-06-14 16:04:17 -04:00
Jeremy Wood 3afca50930 Merge pull request #2289 from Multiverse/ammed_bstats
Correct Metric Reports
2020-06-13 18:52:43 -04:00
Kermina Awad 94ca18e95c correct some metrics 2020-06-13 14:20:36 -04:00
Kermina Awad 707eae92a8 improve javadocs, also, no need to make implementations public 2020-06-13 10:36:30 -04:00
Kermina Awad b4a4519876 no need for protected access modifier 2020-06-13 10:36:25 -04:00
Kermina Awad 4f41b7aa6e rework webpaste package 2020-06-13 10:36:21 -04:00
Kermina Awad b9267a3dfc update version command description 2020-06-13 10:36:16 -04:00
Kermina Awad a53c4214f0 add extra space for readability 2020-06-13 10:36:08 -04:00
Kermina Awad 343695e23e add notice as to why pasting to GitHub is disabled 2020-06-13 10:36:04 -04:00
Kermina Awad e17e9c8ce9 rename GithubPasteService as GitHubPasteService 2020-06-13 10:36:00 -04:00
Kermina Awad 676c3a2e3d make pasting more system agnostic 2020-06-13 10:35:58 -04:00
Kermina Awad e821611744 fix pasting to hastebin 2020-06-13 10:35:55 -04:00
Kermina Awad d69c492577 cleanup GitHub and Pastebin paste services 2020-06-13 10:35:53 -04:00
Kermina Awad eb91eefc80 fix BitlyURLShortener 2020-06-13 10:35:49 -04:00
Kermina Awad f570c81366 update version command 2020-06-13 10:35:47 -04:00
Jeremy Wood b3f23278b1 Yay for tests that use method names in strings. -.- 2020-06-13 02:01:41 -04:00
Jeremy Wood 3fa2bfa7cf Merge pull request #2280 from Multiverse/bstats
Fixes #2252, implements #1918.
2020-06-13 01:20:29 -04:00
Jeremy Wood 582d6bef1a Readd world count metric as multiline chart (for future use). 2020-06-13 01:17:00 -04:00
Jeremy Wood 04c65cc59e Cleanup new metrics implementation. (#2286)
* Refactor metrics initialization into its own class.

* Simplify the creation of metrics.

* Clean up new metrics.

* Refactor out duplicate metrics code.
2020-06-13 00:51:18 -04:00
Kermina Awad 268c4982c3 update metric implementations 2020-06-12 23:50:17 -04:00
Kermina Awad 8983a0c024 add vault as softdepend 2020-06-07 19:31:51 -04:00
Kermina Awad 1cbe901e4d lead dev should be the first author listed 2020-06-06 13:38:03 -04:00
Kermina Awad 4894abd1f1 switch to bStats 2020-06-06 13:36:53 -04:00
nicegamer7 1fac13247f Fix Travis Builds for Pull Requests (#2208)
* fix travis

* I don't think we need this

* we don't use circleci anymore
2020-05-06 13:07:48 -04:00
Jeremy Wood 59cfacf007 Merge pull request #2227 from A248/patch-1
Fix NPE for invalid world argument in gamerule cmd
2020-05-05 21:19:42 -04:00
Jeremy Wood 5f916fbf27 Merge pull request #2242 from wellnesscookie/master
Fixes alias not clearing after cloning the world
2020-05-05 21:14:12 -04:00
wellnesscookie c70e254dbf Fixes alias not clearing after cloning the world
This will rather set an alias to an empty string which will automatically be resulted in alias being as same as the name of the cloned world.
Previously, it was not working as intended and kept the alias of the oldWorld.
2020-04-30 20:43:11 +02:00
A248 9d42a05759 Fix NPE for invalid world argument in gamerule cmd
Stumbled upon an NPE when using /mv gamerule. I realised it was because I had specified a nonexistent world. This will fix it.
2020-04-16 18:31:23 -04:00
Niels Boehm 46f8453b5b Ensure archors are saved in a machine-readable way
`locationToString()` is primarily used by the AnchorManager to persist
anchors to disk (the other use is for logging).

In a locale that uses periods as decimal separator, this works fine and
the anchors can be loaded when the server restarts.

However, in a locale that doesn't use periods (but commas, for instance)
this produces an `anchors.yml` that cannot be parsed when loaded.

Tying the string formatting in `locationToString()` to an English locale
makes it behave as expected, regardless of the external locale setting.
2019-09-23 14:54:35 +02:00
Jeremy Wood b4b0940918 Added additional configuration option to disable the donation messages. 2019-08-26 13:47:54 -04:00
Jeremy Wood 22ad7214b0 Made the donation messages at startup hidden with silent start. 2019-08-26 13:47:26 -04:00
Jeremy Wood 1ba693ffd5 Bumped version to 4.1.1-SNAPSHOT for continued development. 2019-08-23 15:38:51 -04:00
Jeremy Wood 6ee0d8a05e Release version 4.1.0. 2019-08-23 15:28:06 -04:00
Jeremy Wood d3ff2922fd World cloning should work once again! Resolves #1978. 2019-08-23 15:27:45 -04:00
Jeremy Wood 5e2824abeb Prevent importing worlds without .dat file. Fixes #1917. 2019-08-15 21:15:45 -04:00
Jeremy Wood 926e23bf19 Removed super dated toString in plugin main class. 2019-08-02 21:49:11 -04:00
Jeremy Wood 841598232c Added --include-plugin-list to mv version command. 2019-07-31 00:25:34 -04:00
Jeremy Wood 540b6abcab Now using CommandHandler 11! 2019-07-30 23:48:32 -04:00
Jeremy Wood 38d5917915 Added debug mode change event. 2019-07-30 23:03:51 -04:00
Jeremy Wood da6bd20b42 Bumped version to 4.1.0-SNAPSHOT for incoming features. 2019-07-30 22:10:48 -04:00
Jeremy Wood 8859fa78fd Bumped core protocol to 24. 2019-07-30 22:09:14 -04:00
Jeremy Wood 4de6b9ce47 Bumped version to 4.0.2-SNAPSHOT for continued development. 2019-07-30 21:50:37 -04:00
Jeremy Wood f595f4cdb9 Release version 4.0.1. 2019-07-23 21:47:40 -04:00
Jeremy Wood 1581e1e009 Make TravelAgent warning message a debug message. 2019-07-23 21:47:13 -04:00
Jeremy Wood 7cb9bd4bc2 Added message acknowledging deprecated event. 2019-07-23 21:46:23 -04:00
Jeremy Wood 32e72bb355 Bump version to 4.0.1 for continued development. 2019-06-25 13:34:08 -04:00
Jeremy Wood 950402a144 Release version 4.0.0. 2019-06-25 13:33:20 -04:00
Jeremy Wood f598551d9c Merge pull request #2019 from Brokkonaut/master
Phantoms are monsters
2019-06-16 23:57:30 -04:00
Brokkonaut c3f08318d4 Phantoms are monsters 2019-06-17 05:48:02 +02:00
Jeremy Wood f0343b08b5 Merge pull request #2001 from Brokkonaut/fix-javadocs-setcurrency
Fix javadocs: setCurrency(Material) instead of setCurrency(int)
2019-06-04 12:04:14 -04:00
Jeremy Wood 20a1fcb9f5 Bump protocol version to 23. 2019-06-04 10:08:35 -04:00
Jeremy Wood 253ede1c9a Wrap the travel agent in an adapter. 2019-06-04 10:08:11 -04:00
Jeremy Wood d4454703e4 Bumped version to 4.0.0-SNAPSHOT for 1.14 updates. 2019-06-04 09:15:34 -04:00
Jeremy Wood 9737b62813 Bump version to 3.0.0 for release. 2019-06-04 09:11:01 -04:00
Brokkonaut 06bd1a838f Fix javadocs: it is now setCurrency(Material) instead of setCurrency(int) 2019-05-21 19:15:14 +02:00
BaronyCraft 4343167240 allow coord arguments to setspawn command (#1975)
* allow coord arguments to setspawn command

* Implement PR changes as requested
2019-03-14 20:20:49 -04:00
Jeremy Wood 7762aca019 Removed commons-io as compile dependency to fix weird pom issues. 2019-02-02 00:53:51 -05:00
Jeremy Wood 6ebc1188e8 Removed unnecessary json dependency. 2019-01-31 22:09:09 -05:00
Jeremy Wood 8b358b0955 Don't send mvv url response to console twice when run from console. 2019-01-31 22:03:11 -05:00
Jeremy Wood b201b09719 Added a theoretically working Hastebin option for mvv output. 2019-01-31 22:02:13 -05:00
Jeremy Wood 4c9d108f08 Disabled github paste service. 2019-01-31 21:31:39 -05:00
Jeremy Wood 564a7d3684 Removed pastie paste service. 2019-01-31 21:26:12 -05:00
Jeremy Wood d832e9e6d9 Updated vault dependency to 1.7. 2019-01-31 21:21:50 -05:00
Jeremy Wood aa574b6236 Cleaned up the pom a bit and fixed some dependency shading issues. 2019-01-31 21:19:23 -05:00
Jeremy Wood d7894eb847 Fix another NPE in MaterialConverter. 2019-01-30 10:11:43 -05:00
Jeremy Wood 5e067fa72d Fixes NPE in MaterialConverter. 2019-01-30 08:53:40 -05:00
Jeremy Wood b1bf68a0ad Wtf... why was this still here. 2019-01-30 01:02:55 -05:00
Jeremy Wood 89a8f24b14 Welcome to fully semantic versioning with 3.0.0-SNAPSHOT. 2019-01-30 00:38:44 -05:00
Jeremy Wood 43ecdc913a Add null type annotations to MaterialConverter. 2019-01-30 00:19:26 -05:00
Jeremy Wood 0f14ee557d Make Bukkit dependency scope provided. 2019-01-30 00:14:16 -05:00
Jeremy Wood 9b88d1d491 Updated logging library to 1.1.1. 2019-01-29 23:54:58 -05:00
Jeremy Wood 606a3fa3ce Added MaterialConverter util class for type id conversions. 2019-01-29 23:46:40 -05:00
Jeremy Wood a7cace0fdc Fixed potential NPE. 2019-01-28 19:43:13 -05:00
Jeremy Wood ae314108a3 Removed deprecated MVConfigProperty and MVActiveConfigProperty. 2019-01-27 21:34:26 -05:00
Brokkonaut d0180f05d5 Option to disable the automatic purge of entities (#1933) 2019-01-25 13:16:29 -05:00
Jeremy Wood 07df8d0d09 Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2019-01-24 21:23:24 -05:00
Jeremy Wood 4552f70f7e Shade in id converter. 2019-01-24 21:22:56 -05:00
Jeremy Wood a6912c3cb5 Added api-version: 1.13 to plugin.yml.
Should fix #1958
2019-01-24 09:28:03 -05:00
Jeremy Wood 4bdeacfd05 Updated testing dependencies and maven plugins. 2019-01-24 01:00:42 -05:00
Jeremy Wood 01f549f408 Updated Multiverse-Core for Bukkit 1.13.2. 2019-01-23 23:50:47 -05:00
Jeremy Wood f7bbb5029b Bumped protocol to 22. 2019-01-23 22:29:49 -05:00
Jeremy Wood 658b5219c3 Bumped version to 2.7.0-SNAPSHOT. 2019-01-23 22:29:12 -05:00
Jeremy Wood fb505ab161 Bumped version to 2.6.1-SNAPSHOT for continued development. 2018-07-23 14:16:29 -04:00
Jeremy Wood 284b3179ad Version 2.6.0 release. 2018-07-23 14:15:44 -04:00
Jeremy Wood 532ffacf5a Added relativity options to ExactDestination. Implements #1892. 2018-02-22 18:11:12 -05:00
Jeremy Wood 2b4d386eb2 Removed unnecessary for #1836. 2017-07-13 15:47:43 -04:00
Jeremy Wood bc20ecbe60 Hotfix for #1836. 2017-07-12 22:58:33 -04:00
Jeremy Wood 4878395460 Bumped protocol version to 21 for upcoming addition of Kotlin lib. 2017-07-09 18:54:49 -04:00
Jeremy Wood 467ec809b5 Bump version to 2.6.0-SNAPSHOT for significant incoming changes. 2017-07-09 18:53:50 -04:00
Jeremy Wood ceb6850670 Bump version to 2.5.1. 2017-07-09 11:36:23 -04:00
Jeremy Wood 63abf33414 Config travis and circle for Java 8. Resolves #1834 2017-07-09 11:30:45 -04:00
Jeremy Wood bcd7fcaee7 Build for Java 8. Might fix Travis and Circle... 2017-07-09 09:36:39 -04:00
Jeremy Wood d18581828d Exclude old Bukkit from SerializationConfig. 2017-07-09 09:36:02 -04:00
Jeremy Wood 54209e1535 Testing new webhook 2017-06-17 01:03:22 -04:00
Jeremy Wood 2ed59a866f Updated to Buscript 2.0.
This reduces the size of the plugin jar by over ONE MEGABYTE!!
2017-06-16 22:08:51 -04:00
Jeremy Wood 41b3096600 Now building against MC 1.12. 2017-06-16 21:55:09 -04:00
Jeremy Wood 42adfa8175 Bumped version to 2.5.1-SNAPSHOT for continued development. 2017-06-01 21:07:56 -04:00
Jeremy Wood 12bcf71028 Updated to 2.5.0 for release. 2017-06-01 20:25:04 -04:00
Jeremy Wood a826d0b2ff Build against spigot-api 1.11.2-R0.1-SNAPSHOT. 2017-06-01 20:20:10 -04:00
Jeremy Wood 59cab8a417 Remove relative paths from potentially imported worlds. 2017-04-05 16:07:31 -04:00
RezzedUp da6a62b984 Remove relative paths from potentially imported worlds.
Before, relative paths that left the server's root directory were
accepted. Now, the world name has all relative-path components trimmed
off.
2017-04-05 00:44:00 -05:00
Jeremy Wood 806c5909c4 Updated plugin.yml. Can't believe I haven't done this sooner. 2017-02-11 00:07:28 -05:00
Eric Stokes c00847f173 If we're gonna use TravisCI it should at least use JDK7 now. 2016-11-19 21:35:54 -07:00
Eric Stokes 626e5d3e4b Added the autogenerated dependency-reduced-pom.xml to the .gitignore 2016-11-19 18:43:49 -07:00
Eric Stokes f5e8a9c2e8 Fixed deprecated assertTrue call in TestInstanceCreator 2016-11-19 15:44:07 -07:00
Eric Stokes 3364709e53 Fixed deprecated use (since it's going away in 1.11)
* MultiverseCore constructor shouldn't be deprecated, it just needed a fix.
* Removed TestPluginLoader, it should have been mocked anyway.
* New constructor takes a JavaPluginLoader instad of a PluginLoader, so
  we'll have to mock.

You can't win, Java. If you make it `final`, I shall become more powerful
than you can possibly imagine.
2016-11-19 15:43:44 -07:00
Eric Stokes 67d172fd08 Removed redundantThrows checkstyle rule, it's gone in 6.2+
See: checkstyle/checkstyle#473
2016-11-19 14:30:04 -07:00
Eric Stokes f3a420d85c Added additional properties to the test checks for world properties 2016-11-19 14:18:12 -07:00
rlf aba1f05c5b Misc documentation fixes from @rlf 2016-11-19 14:17:26 -07:00
rlf 8fdc0ad3da Fixed failing tests (thanks @rlf)
* This is the test fixing portion of PR#1746
* This fixes using a HashMap and relying on the order of the values.
2016-11-19 13:51:11 -07:00
Eric Stokes 3db57ee1d9 Move to Java 7 (Maybe java 8 soon...)
* Also bump CH to v10, which uses Java 7
* Probably don't use this build, I have to test it first...
2016-11-19 13:02:19 -07:00
httpdop b3841adcc1 Update dependencies and versions 2016-11-06 11:14:10 +01:00
Liam 0b0b3c0088 Updated Vault repo
New vault repo is here: http://nexus.hc.to/content/repositories/pub_releases
2016-10-26 23:49:30 +01:00
Jeremy Wood a64a8d9605 Perhaps the id was important? 2016-05-03 10:58:30 -04:00
Jeremy Wood 0a0d3ba527 Added snapshot repo to distro management. 2016-05-03 10:48:06 -04:00
Jeremy Wood a351fbb345 Moving to new version numbers - 2.5.0-SNAPSHOT 2016-05-03 10:45:32 -04:00
Eric Stokes 46359cfbfe Fixes #1678 anchor list doesn't obey enforceaccess 2016-03-12 15:51:16 -07:00
Eric Stokes f52004cb76 Removed deprecated use of scheduleAsyncDelayedTask 2016-03-12 15:10:27 -07:00
Eric Stokes 0e3848874a Added support for version command to upload to gist.github.com 2016-03-12 15:10:07 -07:00
Eric Stokes 71ba31a0f4 Fixed spacing of spigotmc repo in POM 2016-03-12 13:00:29 -07:00
Eric Stokes 7b1e77340b Removed deprecated use of loadConfiguration
The new method properly uses the Reader class and resolves the reason
for deprecation, the lack of encoding support.
2016-03-12 13:00:05 -07:00
Eric Stokes bebd4742b9 Fixed shortened links pointing to wiki pages that didn't exist anymore 2016-03-06 21:01:44 -07:00
Eric Stokes b933027523 #1672 Fixed typo that made animal lists behave like monster lists 2016-03-06 21:01:16 -07:00
Eric Stokes bd1d852393 #1671 Fixed lists changing not forcing validation of the elements 2016-03-06 20:59:18 -07:00
Eric Stokes 648365f336 #1671 Fixed incorrect WorldPropertyValidator type 2016-03-06 20:56:04 -07:00
Jeremy Wood 12b6a69146 Use latest spigot-api. Also switched to compile scope... 2016-03-02 11:33:39 -05:00
Jeremy Wood cd312c3ab9 Updated used version of MC stats. 2016-02-29 20:04:26 -05:00
Jeremy Wood d2d243caec Deny import of "plugins" and "logs" folder as a world. Should fix #1655 2016-02-15 10:40:07 -05:00
Jeremy Wood 865434d1b1 Don't accept null worlds from the server. Addresses #1649. 2016-02-04 09:39:30 -05:00
Romarjosh Villamor 0858e324dd Added Spigot Dependency and repository 2016-01-30 04:01:53 -08:00
Jeremy Wood 618986e216 Parse difficulty safely. Fixes #1634. 2015-12-17 09:16:18 -05:00
Jeremy Wood cc3dfe9fd4 Bumped protocol version to 20. 2015-10-28 20:12:25 -04:00
Jeremy Wood 6ee8466ac0 Updated Vault dependency to VaultAPI 1.5.
May break backwards compatibility with old Vault (Probably pre 1.4)
2015-10-28 20:10:03 -04:00
Jeremy Wood 3b7dd21440 Added Economist methods to get and set balances. 2015-10-28 20:02:39 -04:00
JBYoshi 528dc25fcb Update cloneWorld().
- Make it actually work.
- Support for unloaded worlds - saves memory!
- The Thread code seems unnecessary since the main thread just waits for it to finish, so I'm removing it.
- Added cloneWorld(String, String).
- Deprecate the old cloneWorld() method.
Closes #1436
Closes #1491

Due to some limitations, I have to temporarily load the old world in
order to properly clone. However, **no chunks are loaded during this
process.**
2015-10-27 22:06:56 -04:00
Jeremy Wood 762d8e3ebb Added possible fix for dependency issues on build. 2015-10-23 12:36:54 -04:00
Simon Rigby ef251c256d Merge pull request #1618 from Multiverse/Fix-Travis-Codehaus
Fix Travis-CI failing for Codehaus Dependencies
2015-10-23 17:16:30 +01:00
Simon Rigby da3015c72c Fix Travis-CI failing for Codehaus Dependencies 2015-10-23 17:11:59 +01:00
Jeremy Wood 601f457e6f Removed mcstats.org repo since it appears to be offline. 2015-09-22 08:50:27 -04:00
Jeremy Wood ec805f38d7 Updated protocol version to 19. 2015-09-22 08:40:18 -04:00
Jeremy Wood 61710369f4 Minor tweaks to new economy system. 2015-07-14 15:47:20 -04:00
Liam 4824d53fab Merge pull request #1593 from TWSSYesterday/Update#1
Changing words
2015-07-14 20:26:57 +01:00
Liam 65cc817573 Changing words
mc-region-fixer instead of chunkster because it's the only one that works of the two.
2015-07-14 20:24:18 +01:00
Jeremy Wood 9bb7dd6e5d Removed AllPay dependency and implemented the new MVEconomist which is used to delegate all economy matters of importance to Multiverse. 2015-07-14 15:00:33 -04:00
Jeremy Wood fadb3280e3 Updated testing framework to work with bukkit changes. 2015-07-14 14:50:47 -04:00
Jeremy Wood b64dfa34af Updated Who command for bukkit changes. 2015-07-14 13:44:44 -04:00
Jeremy Wood 584a81fac6 Updated Bukkit dependency to 1.8.7-R0.1-SNAPSHOT. 2015-07-14 11:40:58 -04:00
Jeremy Wood 4233e4f8b4 Don't try to handle events for worlds we don't own in MVPortalListener. Fixes #1589. 2015-07-13 12:16:36 -04:00
Jeremy Wood 28da4aac2f Allows a valid location to be set. Fixes #1579.
Credit to tuskiomi for discovering this issue.
2015-06-10 13:46:38 -04:00
Jeremy Wood c37dd803c8 Fixed up commons-io dependencies. 2014-08-21 13:14:14 -04:00
TWSSYesterday 27abb55006 Fix
Fixed.
2014-06-17 12:19:39 +01:00
TWSSYesterday c607aa1c47 Colouring added as well as general grammar cleanup
Rephrased some messages, and added colour when there is no world folder found.
2014-06-17 12:12:52 +01:00
Jeremy Wood 79f8f6bd55 Merge pull request #1437 from jflory7/patch-1
Corrected command example to proper command
2014-05-20 15:34:08 -04:00
Justin F. 1446dd936a Corrected command example to proper command
Tiny usage error here – I noticed it on my server and figured I'd make a pull request for this minor error. :)
2014-05-16 23:17:33 -04:00
Jeremy Wood 8664f56eeb Now correctly handles portalForm for end and nether portals! Fixes #1394. 2014-03-18 12:41:15 -04:00
Jeremy Wood 1c2514d5db keepSpawnInMemory will use fallback value in more scenarios. Fixes #1392. 2014-03-18 10:07:24 -04:00
Jeremy Wood 34c8b7cf0b Possibly fixed the pvp/difficulty property issue! 2014-02-26 17:01:48 -05:00
Jeremy Wood 63af4370b5 Now using CommandHandler version 8. 2014-02-20 10:07:16 -05:00
Jeremy Wood 832e0f6497 Once again managing teleportation into MV worlds from non-MV worlds. Fixes #1385. 2014-02-19 16:58:48 -05:00
Jeremy Wood b198942742 Merge pull request #1384 from antiroot/patch-1
Added missing space in log output for Teleport command
2014-02-18 15:06:30 -05:00
antiroot b60250287e Update TeleportCommand.java
Missing spaces in log output for TeleportResult.FAIL_UNSAFE case
2014-02-18 10:41:48 -06:00
Jeremy Wood 86ba242f33 Added entryfee.amount alias and possibly corrected alias currency. Should fix #1201. 2014-02-08 13:29:19 -05:00
Jeremy Wood 0639d39d5a Now including the correct metrics package for shading. Fixes #1376. 2014-02-07 10:49:45 -05:00
Jeremy Wood ee745f8a55 Updated vault. 2014-02-06 22:22:18 -05:00
Jeremy Wood 243fc8bc20 Updated metrics. 2014-02-06 22:22:06 -05:00
Jeremy Wood 807730805c Updated bukkit version. 2014-02-06 22:20:13 -05:00
Jeremy Wood c8abdf00b5 Merge pull request #1021 from Multiverse/custom-teleporters
Custom teleporters.
2014-02-06 22:16:29 -05:00
Jeremy Wood 21aaf4a03e Non-default worlds will now no longer initially load their spawn chunks if keepSpawnInMemory is false. Fixes #1079 2014-02-06 13:12:14 -05:00
Jeremy Wood 8ea639eba8 Removed deprecated UpdateChecker. 2014-02-05 16:39:14 -05:00
Eric Stokes a7e6fd1412 Update Travis CI to use openjdk6 to build, since the Oracle one is gone. 2013-12-14 11:40:11 +04:30
Jeremy Wood 636b8289f6 Made creating amplified worlds a little more intuitive. 2013-12-10 15:14:36 -05:00
main() 79290eed0d Merge pull request #1230 from main--/ryantheleach-playerbeds
Closes #1070.
2013-06-15 03:25:16 -07:00
Jeremy Wood 9f927605da Now actually allows world names with periods. 2013-05-27 14:35:32 -04:00
Jeremy Wood e69b5a6b17 Merge pull request #1205 from bloodmc/master
Added World Load/Unload Event listeners to support Forge in MCPC.
2013-05-24 09:25:03 -07:00
bloodshot cbe6c2c901 Added World Load/Unload Event listeners to support Forge.
* Added extra check to WorldManager.doLoad to check parent folder when
loading worlds. This is required by Forge since the world container is not
MC root but the overworld root.
2013-05-24 11:47:02 -04:00
main() 875685b705 Merge pull request #1150 from DerFlash/prefixchat
added config option to change the format for prefixchat
2013-04-29 11:58:28 -07:00
Björn Teichmann ad6f0d1b62 added config option to change the format for prefixchat 2013-04-08 09:47:29 +02:00
main() 4a66a2f5bb If the debug level is >= 1: stacktrace 2013-03-18 18:02:55 +01:00
main() a8040abd52 "Not MV's fault"-Message for getChunkGenerator()
If a plugin, for whatever weird reason, gets loaded and enabled correctly,
but just getDefaultWorldGenerator() throws, people might think it's MV's
fault. Not anymore.
2013-03-18 17:27:03 +01:00
Jeremy Wood 72a14719ac Now using apache commons for file operations. Hopefully we will get more success with deleting and copying stuff. May fix Inventories test failures. 2013-03-11 15:35:05 -04:00
main() 2b827a1fae Style fixes. 2013-03-02 13:13:24 +01:00
main() e45520c43b Update checkstyle. 2013-03-02 13:13:09 +01:00
main() 0fb33d12d6 Now mocking plugin.getLogger() in the tests.
Fixes the test issues with AllPay.
2013-03-02 12:31:31 +01:00
main() ebe44ed99e Fixed the GenericBank imports 2013-03-02 12:24:05 +01:00
Jeremy Wood 23ba7fe73b Updated to AllPay 13. 2013-02-26 09:49:38 -05:00
Jeremy Wood 4efa97ee0e Removing deprecated getMVConfiguration() method because I suspect it could be related to some issues. 2013-02-20 13:56:24 -05:00
Ryan Leach ce80fc190d Inital extra bed commit with back-compatibility
Needs review and permissions advice before continuing.

line ending derp

---

Modified by @main--:
 * formatting fixed
 * removed changes to travis.yml and gitattributes
 * improved code style
2013-02-15 18:34:58 +01:00
Jeremy Wood 8bfe3a5473 Don't try to set search radius when portal travel agent is null. Fixes #1072. 2013-02-04 15:15:52 -05:00
Jeremy Wood 07a38e3e58 Should fix issue where gamemode/flight change on /reload of server due to permission issues. 2013-01-02 13:20:52 -05:00
Jeremy Wood 360c63fad9 Updated to AllPay 11 2013-01-02 11:44:38 -05:00
Jeremy Wood 2a5edc4f91 Added argument check to setBlockSafety. 2012-12-27 16:02:46 -05:00
main() dba21cadaf Custom teleporters. 2012-12-26 20:09:09 +01:00
main() fa9191dd8f The message now CLEARLY states that it's not Multiverse's fault. 2012-12-22 15:26:20 +01:00
main() 4043d5abcb Getting the generator is now wrapped in a try block.
The Bukkit API calls a plugin method. If that method throws exceptions, they fall through right into our face and then Bukkit blames us. Not good.
Thanks andrewkm for mentioning this.
2012-12-22 00:53:03 +01:00
Jeremy Wood eff56f74da Changed the default portal search radius back to match vanilla's 128 instead of 16. 2012-12-21 10:14:45 -05:00
Jeremy Wood d97a9bccde Now building against Vault 1.2.20 which is hosted on our own repo now. 2012-12-13 08:50:32 -05:00
Jeremy Wood 55741b524d Added bats to animals for the time being. Fixes #996 2012-12-10 23:27:55 -05:00
Jeremy Wood 186d3f15a4 Woo, Travis.ci! 2012-12-10 12:04:26 -08:00
Jeremy Wood 841f6f05df Added "/mv gamerule" and "/mv gamerules" for setting and listing game rules per world. Fixes #987. 2012-12-03 15:05:58 -05:00
Jeremy Wood ebc2a516bb Added world property 'allowFlight' to disable flying per world. Does not have an override permission yet. Adds #440. 2012-12-03 11:59:01 -05:00
Jeremy Wood 9e029ad6ae Maps can now be made for non default worlds! Fixes #972 2012-11-30 13:08:15 -05:00
main() b2135a8f42 Added world seed to the info command.
Fixes #627.
2012-11-28 14:39:07 +01:00
Jeremy Wood 8cbffd1cee Now building against Bukkit 1.4.5-R0.2 2012-11-27 15:59:24 -05:00
Jeremy Wood ff22077adf New worlds now use the correct scale. Fixes #979. 2012-11-27 14:09:33 -05:00
Jeremy Wood 60c0a1ab92 Fixed world spawns not keeping pitch + yaw. Fixes #976 2012-11-23 12:30:11 -05:00
Jeremy Wood 58eeecbcb8 Fixed issue where Multiverse always checks block safety to fix world spawns on startup/reload. 2012-11-23 11:49:14 -05:00
Jeremy Wood 876456b932 Fixed up some migration issues caused by WorldProperties refactor. Fixes #968. 2012-11-19 14:05:07 -05:00
Jeremy Wood 18db50ca56 MVWorld now throws IllegalStateException when it cannot obtain a world reference. This should help pinpoint the source of sometimes cryptic exceptions elsewhere. 2012-11-15 13:49:11 -05:00
Jeremy Wood cce1ccc967 Now caches the world properties before unloading the world in order to prevent NPE on unload then load. Really fixes #947. 2012-11-15 09:30:19 -05:00
Jeremy Wood e5537dd8f1 "mv regen" now respects world type! 2012-11-14 20:55:12 -05:00
Jeremy Wood 0c7ba2ae67 Fixed tests for entity purger changes. 2012-11-14 15:52:21 -05:00
Jeremy Wood bbfc672582 Improved world purger debug. 2012-11-14 15:19:09 -05:00
Jeremy Wood a65dc4966b Now removes projectiles shot by the entities removed by the purger. Should fix #958. 2012-11-14 15:11:55 -05:00
Jeremy Wood 4780f87278 Now uses world UUID to retrieve world reference. 2012-11-14 14:24:10 -05:00
Jeremy Wood b11d911e4a Newly created END worlds will now use a scale of 16. This will result in people ending up invariably closer to the end island when teleporting in while using MV-NetherPortals. 2012-11-14 13:58:08 -05:00
Jeremy Wood 155aad8bf2 Multiverse now uses it's own portal search radius by default (16 blocks instead of bukkit's 128). 2 new configuration options added to adjust this behaviour. 2012-11-14 13:52:37 -05:00
Jeremy Wood 6e1d4ef961 Block safety debugging moved to finest level. 2012-11-14 12:52:33 -05:00
Jeremy Wood cfa5a04e3a Fixes #960 2012-11-14 09:08:04 -05:00
Jeremy Wood 7d1c47c2fc Shifted world properties to its own class WorldProperties so we can now only initialize an MVWorld if there is a 'more solid' world reference. Let's hope this works! Should fix #947 2012-11-13 17:30:35 -05:00
Jeremy Wood 957c55955d Now using SerializationConfig 1.7 2012-11-13 13:39:22 -05:00
main() 0226ab9609 Style again. 2012-11-06 17:52:29 +01:00
Jeremy Wood b888561d98 Added package-private method for setting MVWorld plugin and name. Fixes #923. 2012-11-05 13:08:37 -05:00
Jeremy Wood f210851294 Changed how we deal with CB world reference. Partially fixes #923. 2012-11-05 13:02:03 -05:00
main() 73e394d5ec Style. 2012-11-05 16:40:06 +01:00
Jeremy Wood 63f8811b67 Fixed #942. 2012-11-05 09:05:11 -05:00
Jeremy Wood d01ce71343 Fixed #935. 2012-10-31 08:31:07 -04:00
Jeremy Wood fe00aae7e3 Fixes #934 - Vault dependency issue. 2012-10-30 08:45:05 -04:00
Jeremy Wood d4347d0cff Fixed incorrect log level. 2012-10-25 15:48:28 -03:00
Jeremy Wood b033d59b8a Optimized some log messages and change some Level.INFO messages to Level.CONFIG for the new silent start mode. Fixes #697. 2012-10-25 14:36:44 -04:00
Jeremy Wood aedbfd7bab Added command "mv silent [on|off]" for enabling silent startup mode. 2012-10-25 14:35:22 -04:00
Jeremy Wood b93822502e Reverted debug command. 2012-10-25 14:02:01 -04:00
Jeremy Wood f053f0546b Now using Logging 1.0.9! 2012-10-25 13:56:57 -04:00
Jeremy Wood af3b3d0fab Added ability to set debug level to -1 to disable common startup messages. 2012-10-25 10:43:57 -04:00
Jeremy Wood b1fa677330 Now using Logging 1.0.8 2012-10-25 10:35:27 -04:00
main() 9691a0f978 Merge pull request #931 from ammaraskar/limit
Add player limit per world. Closes #727.
2012-10-25 02:11:29 -07:00
Ammar Askar 0b1a387003 Add player limit per world. Addresses #727 2012-10-25 14:02:27 +05:00
Jeremy Wood 4ce503f55e Cow using EnumSet for maximum performance!!!! 2012-10-23 14:26:09 -04:00
main() 74947a7efd Fixed all other style warnings 2012-10-23 16:58:16 +02:00
main() 85cd71cb8a Fixed high priority style warnings 2012-10-23 16:49:08 +02:00
Jeremy Wood 3ad7d86f74 Deprecated DebugLog. 2012-10-22 17:40:39 -04:00
Jeremy Wood ac9194ec87 Now building with SerializationConfig 1.6c, finally fixes weird config exception messages. 2012-10-22 17:35:06 -04:00
main() 96e8208f3d Merge branch 'ammaraskar_folder' 2012-10-22 19:08:15 +02:00
Ammar Askar 895360ce8b Only delete world folder contents on mv regen, fixes #767 2012-10-22 19:06:19 +02:00
main() 59e34ef353 Merge pull request #925 from ammaraskar/entities
Add golems to animals fixes #891
2012-10-22 08:39:44 -07:00
Ammar Askar 11e556c099 Add golems to animals fixes #891 2012-10-22 20:34:01 +05:00
main() a9579a6594 Merge pull request #922 from ammaraskar/spawn
Added configurable animal and monster ticks per spawn setting. Fixes #519
2012-10-22 04:12:42 -07:00
Ammar Askar 5a1fe2a9e5 Added configurable animal and monster ticks per spawn setting. Fixes #519 2012-10-22 13:20:09 +05:00
Eric Stokes 1c5c792cf3 A broadcast is not needed if we're not doing anything 2012-10-21 18:57:54 -06:00
Eric Stokes dbe9494dbf Fixed Bed Spawns
This fixes #652 and fixes #916
This also fixes some other issues with NullPointerExceptions when trying to teleport to a bed if it was invalid.
2012-10-21 18:49:48 -06:00
Jeremy Wood b116effa2b Using HashSet instead of ArrayList for better contains() efficiency. 2012-10-21 17:55:41 -04:00
Jeremy Wood d361ceb45b Increased efficiency/safety of recent /mv who changes. 2012-10-21 17:49:51 -04:00
Eric Stokes 35709f5389 Tell user when creating a duplicate world
Fixes #921
2012-10-21 14:49:56 -06:00
Eric Stokes b45a4cf20a Fix NPCs Showing up in mv who
This fixes #501. FINALLY!

If anyone wants NPCs back, open a ticket, and I'll add a flag, but this is now the default behavior.
2012-10-21 14:22:12 -06:00
Eric Stokes 009ceeeede Fixed #918, Update to RB
Also added a test for #918, I probably need one more (to test that generators DO work) but I just tested that ingame this time.
2012-10-21 13:38:36 -06:00
Jeremy Wood 19fb9df5cf Added online player count / max players to /mv who header 2012-10-21 00:39:13 -04:00
Jeremy Wood 0829df01aa Readded the accidently removed shading of AllPay! 2012-10-20 20:55:56 -04:00
Jeremy Wood 78ac068a3f Fixed world's not charging correctly. Fixes #893. Fixes #777. Possibly fixes #723. That's a 3fer, good buddy. 2012-10-20 20:49:15 -04:00
Jeremy Wood 57da3df860 Added in Vault as the prefered method for checking economy stuff. Will defer to AllPay for item based world costs. 2012-10-20 20:43:58 -04:00
Jeremy Wood 74241e3d9c Updated protocol to 18 for Vault. 2012-10-20 20:12:42 -04:00
Jeremy Wood 6a4921d7d1 MVWorld.toString() now outputs JSON data. 2012-10-20 12:44:50 -04:00
Jeremy Wood 271e5f339e Version command now outputs world information instead of juts count. 2012-10-20 12:44:29 -04:00
Eric Stokes ec89db1bed Update MCSTATS to 1.2-SNAPSHOT
1.0-SNAPSHOT is gone from the repo :(
2012-10-19 23:35:48 -06:00
Jeremy Wood 7346cbe48c Actually enables debug logging when enabled via command. 2012-10-19 15:11:02 -04:00
Jeremy Wood ac3049f3ab Now properly enables debug logging on startup if debug logging should be enabled. 2012-10-19 15:10:36 -04:00
Jeremy Wood e82db95bbc Now using Logging 1.0.6! 2012-10-19 15:10:02 -04:00
Jeremy Wood 0d0f167396 Stopped trying to replace the old DebugLog. 2012-10-18 21:39:43 -04:00
Jeremy Wood b35a0325b8 Now using Logging 1.0.4 2012-10-18 21:19:33 -04:00
Jeremy Wood 3572d3fbe7 Now using Logging 1.0.3! 2012-10-18 15:17:52 -04:00
Jeremy Wood 7304269866 Upgraded to testificated Logging 1.0.2! 2012-10-18 14:46:25 -04:00
Jeremy Wood d7535b0551 replaced logging with com.dumptruckman.minecraft:Logging lib. 2012-10-17 14:23:00 -04:00
main() 0437a4bd92 Why is/was this "Multiverse-Adventure"... 2012-10-17 14:26:40 +02:00
main() d881908ecc Made entity listener use the world purger's logic
This should fix #872 and most other spawning issues.
2012-09-20 20:01:55 +02:00
Jeremy Wood 3715bc8bc5 Should now detect Async chat availability for even better backwards compatibility. 2012-09-05 20:53:59 -04:00
main() a9f00a46f5 Fixed #859
The WhoCommand was handling invisible players incorrectly
2012-08-26 14:47:01 +02:00
Jeremy Wood d9a7275682 Stop checking for null worlds. 2012-08-21 15:06:55 -04:00
Jeremy Wood 80f6a0159c Now using ConcurrentHashMap instead of ReentrantLock for caching player world. 2012-08-21 15:06:33 -04:00
Jeremy Wood f2e1053b88 Now using ConcurrentHashMap instead of locks for worlds Map. 2012-08-21 14:54:49 -04:00
Jeremy Wood e975968637 MVWorld properties now volatile instead of using thread lock. 2012-08-21 14:25:11 -04:00
Jeremy Wood a778d353c4 Config now volatile instead of using thread lock. 2012-08-21 14:19:05 -04:00
Jeremy Wood d40e67b47d Config properties now volatile instead of using thread lock. 2012-08-21 14:17:24 -04:00
Jeremy Wood 9196973d1c Fixed NPE in world loading.. Thanks Grimlock257 for spotting this. 2012-08-21 13:20:13 -04:00
Jeremy Wood 242d20884c Now building against Bukkit 1.3.1-R2.1-SNAPSHOT 2012-08-21 09:16:28 -04:00
main() b909af873d Should fix #847
(NPE in the GeneratorPlotter for worlds with a null generator)
2012-08-20 10:22:39 +02:00
main() e6f7ba5ac9 Fixed the tests 2012-08-18 15:17:17 +02:00
main() 4ecb28b3bb Less duplicate code ... I think. 2012-08-18 15:13:09 +02:00
main() d0ea4168bc Style! 2012-08-18 14:54:18 +02:00
main() fd9464ced1 More anchor permissions (as suggested in #831) 2012-08-18 14:45:15 +02:00
Jeremy Wood 49eb93af2e Once again prints debug mode output to the console 2012-08-15 11:33:16 -04:00
Jeremy Wood 9274570fa4 Added config option for setting whether or not to use async chat. (Default true (uses async)) 2012-08-15 09:27:52 -04:00
Jeremy Wood 319a701a16 Modifying world values now persists again! (When the hell did this break???) 2012-08-14 15:00:08 -04:00
Jeremy Wood 807c8d0f2c Debug setting saves to config now. 2012-08-13 13:52:25 -04:00
Jeremy Wood 29d97274fe Stopped being dumb and denying bukkit of it's precious invisible constraints for ConfigurationSerializable. Fixes #827. 2012-08-13 13:51:42 -04:00
Jeremy Wood eb1dc502cd Now using ReentrantLock instead of synchronized blocks. Should help debug lag issue. 2012-08-11 23:21:58 -04:00
Jeremy Wood 622fb19c4a Using logging instead of System.out... 2012-08-09 09:18:06 -04:00
Jeremy Wood 5705b5b6a0 Added missing import... 2012-08-09 09:15:07 -04:00
main() 1d1a2213c1 Merge branch 'metrics' 2012-08-09 13:43:07 +02:00
Jeremy Wood 4dd3df26a5 Now building against Bukkit-1.3.1-R1.0 2012-08-08 10:56:22 -04:00
main() 39293482d2 Removed duplicate maven source plugin 2012-08-06 18:44:42 +02:00
main() 9813e5f531 MBot's ?internalerror is useful but this is better 2012-08-06 18:41:02 +02:00
main() 48adbec011 dat style
CheckStyle is merciless!
2012-08-06 15:34:01 +02:00
main() a9a5d7467a Fixed world regeneration 2012-08-06 15:17:14 +02:00
main() b8a0891c4c Fixed again... 2012-08-06 12:06:50 +02:00
main() 53567d4646 Hopefully fixed the tests 2012-08-06 11:54:54 +02:00
main() 3395f3d7c7 We shouldn't try to load deleted worlds 2012-08-06 11:29:54 +02:00
Jeremy Wood e197091bb2 Added better support for large biomes. 2012-08-05 15:40:58 -04:00
Jeremy Wood ede0395d39 Mapping the known world of players for Async chat event. 2012-08-05 14:58:24 -04:00
Jeremy Wood 17963964c7 Minor test update. 2012-08-05 14:53:41 -04:00
Jeremy Wood bb0e2e4a2d Tests now using AsyncPlayerChatEvent. 2012-08-05 00:28:00 -04:00
Jeremy Wood ce4e608cf4 MultiverseCoreConfiguration.setDefaults() now protected as it should be. 2012-08-05 00:27:33 -04:00
Jeremy Wood 944f961ee5 Removed synchronization from setDefaults() due to how SerializationConfig operates. 2012-08-05 00:26:55 -04:00
Jeremy Wood 5335e73707 Now using AsyncPlayerChatEvent... let's hope for the best! 2012-08-05 00:11:39 -04:00
Jeremy Wood d05e2b500f Synchronized world properties required by Async chat event. 2012-08-05 00:11:13 -04:00
Jeremy Wood b2f3b74062 Synchronized all access to worlds map in WorldManager. 2012-08-05 00:00:46 -04:00
Jeremy Wood 16e42f6469 Finalized some object in MultiverseCore to help with thread-safe migration. 2012-08-04 23:51:43 -04:00
Jeremy Wood a31dc83635 Synchronized getting/setting of mv config object. 2012-08-04 23:50:01 -04:00
Jeremy Wood 7b99130bfa Synchronized config values to be used in new Async chat event. 2012-08-04 23:43:09 -04:00
Matt H f57468126a Added '/mv clone' command to clone a world. 2012-08-04 14:29:13 -06:00
Jeremy Wood d17fee6b7c Now building against Bukkit 1.3.1-R0.1-SNAPSHOT. 2012-08-03 13:29:55 -04:00
Jeremy Wood 1a943e42a9 Added maven source and javadoc plugins. 2012-08-03 13:28:32 -04:00
Jeremy Wood 2b80ca80ae Bumped protocol from 16 to 17. 2012-07-25 22:10:06 -04:00
Jeremy Wood 24e26bb7d7 Added buscript Javascript library. 2012-07-25 22:09:28 -04:00
Jeremy Wood 6133cf6bdf Bumped protocol from 15 to 16 2012-07-19 21:10:51 -04:00
Jeremy Wood 085c7a1ccc Migrated Multiverse-Adventure's copyFolder() into core. 2012-07-19 21:08:39 -04:00
main() dd0b2137d6 Changes... 2012-07-12 17:34:25 +02:00
main() 8a4ba2a66c Metrics! 2012-07-12 17:24:23 +02:00
Jeremy Wood 3e7841afc9 Don't bother checking economy stuff if it doesn't even cost to enter. 2012-07-03 16:25:56 -04:00
Jeremy Wood 1427671a8c Bumped version to 2.5... this should have been done a while ago. 2012-07-03 15:49:38 -04:00
Jeremy Wood a15317e21d Removed many instances of String.format in favor of higher performance inline concatenation. We should prune many more of these as well. 2012-07-03 15:48:57 -04:00
main() b10a37f232 Added compatibility check to MultiversePlugin 2012-06-26 20:11:24 +02:00
main() 144de09423 Added the abstract class MultiversePlugin. 2012-06-26 17:29:34 +02:00
main() a60e4e06e1 DebugLog: No more duplicates and you can now modify the log-tag. 2012-06-26 17:26:10 +02:00
Jeremy Wood 9eccf93b66 Probably fixes #707. 2012-06-20 10:18:52 -03:00
main() 220f6a31de Should fix #738. 2012-06-16 10:27:27 +02:00
main() 8cb4f22467 Improved EnglishChatColor and added the "style" world-property.
Closes #732.
2012-06-13 15:58:17 +02:00
Jeremy Wood a2a2594f5a Properly closed debug.log for unit tests by calling onDisable(). 2012-06-12 12:51:36 -04:00
Jeremy Wood 87df407743 You can once again set animals/monsters via /mvm set. 2012-06-07 17:08:47 -04:00
Jeremy Wood cf007f091a Stop creating a new map every time we want property aliases. 2012-06-07 15:44:32 -04:00
Jeremy Wood 680c35e0dc Moved migration debug message to correct location. 2012-06-07 14:52:28 -04:00
Jeremy Wood 1a385c21d7 Removed leftover debug message. 2012-06-07 14:51:43 -04:00
Jeremy Wood cced74d4b0 Suppress stacktraces thrown when migrating worlds.yml. Fixes #700. 2012-06-07 14:50:37 -04:00
Jeremy Wood 1db555581b DebugLog now extends Logger. 2012-06-07 13:26:22 -04:00
Jeremy Wood 63e0c028d9 Slightly improved debugging for worlds migration. 2012-06-07 12:55:32 -04:00
main() ee82dc213f Merge pull request #691 from heisan213/patch-1
Prevent NPE when teleporting to a world not made by MV.
2012-05-22 11:14:30 -07:00
heisan213 d2c09b9d33 Prevent NPE when teleporting to a world not made by MV. 2012-05-22 19:25:32 +03:00
main() 21a3eeacc8 That's the way it should be. 2012-05-03 16:20:59 +02:00
main() 48768b5d6c Now all properties are settable ingame. (bugfix) 2012-05-02 16:25:40 +02:00
main() 96294c092c Wrong default value... 2012-05-01 19:10:51 +02:00
main() 9a3fde2f13 Saving keepSpawnInMemory to config file 2012-05-01 19:08:07 +02:00
main() 6520a31938 Fixed spawnlocation migration 2012-05-01 18:52:05 +02:00
main() f1779c9e68 Shame on me. -.- 2012-05-01 18:46:47 +02:00
main() 9cc35d7b12 public 2012-05-01 18:08:51 +02:00
main() 02347e05d8 Fixed UOE when temporarily saving the NullLocation to the config 2012-05-01 17:43:05 +02:00
main() a4196a901a Fixed spawn location loading 2012-05-01 17:00:05 +02:00
main() 9b2dd0d6c9 Forgot some values, fixed allowweather migration 2012-05-01 16:49:40 +02:00
Jeremy Wood 0efb28be19 Properly close all input/output streams! 2012-05-01 10:47:20 -04:00
main() 5d9941d073 Why is 'null' deserialized to "null" instead of null!? 2012-05-01 15:31:10 +02:00
main() 82cfbaba4e Fixed NPE in migrateWorldConfigs() 2012-05-01 12:48:45 +02:00
main() 9868c66cdb Added migrators. Needs testing. 2012-05-01 12:42:48 +02:00
main() 3a32857683 MethodLength deserves only a warning and why should we count empty lines!? 2012-05-01 12:42:01 +02:00
main() d7a3e1839e Should fix environment, seed and generator-issues. 2012-05-01 12:23:04 +02:00
main() 1496d940bf Merge pull request #547 from Multiverse/mvworld-plus-serializationconfig-equals-awesome
MVWorld + SerializationConfig = Awesome
2012-04-30 13:54:37 -07:00
Jeremy Wood bd57ec19d2 Now building against Bukkit 1.2.5-R1.0 2012-04-18 14:58:05 -03:00
Jeremy Wood da54f9769b Stop giving up immediately on the first failed file deletion and continue deleting files recursively. 2012-04-06 14:54:48 -04:00
Jeremy Wood 2e4b814d6d Added one extra tidbit of logging for GameMode enforcement. 2012-04-03 12:00:02 -04:00
Eric Stokes 3f93fb3648 Add new param to the PTPE, Don't die if we don't find or can't access bukkit.yml 2012-03-18 17:26:24 -06:00
main() 176e729a87 Ignoring TestWorldCreation.
TestInstanceCreator.tearDown() doesn't remove 'fish.world' correctly from the worlds.yml (fixed in mvworld-plus-serializationconfig-equals-awesome)
*cough* @FernFerret *cough*
2012-03-17 12:32:55 +01:00
main() 62f79e7592 Disabled Spout support because we aren't using it 2012-03-17 12:27:50 +01:00
main() f60f770b98 Fixed #578
Another iPhone-commit...
2012-03-16 07:33:35 +01:00
Eric Stokes 3c434d18e3 Bump AllPay Version 2012-03-13 22:24:49 -06:00
Eric Stokes c9b52c81a6 Add some neat debug to Permissions 2012-03-12 20:58:58 -06:00
Eric Stokes 5be6ea2766 Use the fromstring in entity type 2012-03-10 10:29:44 -07:00
main() 98f5e1e4ee This IS fixed! 2012-03-10 17:41:53 +01:00
main() de6fc6481e Merge branch 'master' into mvworld-plus-serializationconfig-equals-awesome
Conflicts:
	src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java
2012-03-10 14:03:04 +01:00
main() dcc6b828a8 Unused imports. 2012-03-10 13:59:04 +01:00
Eric Stokes 7da91f7875 Fix NPE with players and purging, Update AP and CH 2012-03-10 00:32:26 -07:00
Eric Stokes d84f930a54 Fix purging removing the player entity
...and lots of other bad stuff...
2012-03-09 23:45:10 -07:00
main() bdd5e8bd91 Now shortening the URL in /mvv using bit.ly! 2012-03-08 17:59:25 +01:00
main() d1280a9031 Some fixes + added tests. 2012-03-07 19:59:20 +01:00
main() 08b8f01c44 Bugfix: We shouldn't check access-perms if enforceaccess is off! 2012-03-04 20:38:26 +01:00
main() fd227960b9 Now correctly saving worlds 2012-03-04 20:21:42 +01:00
main() 0efc0b965b Fixed removeWorldFromConfig(String). 2012-03-04 19:53:40 +01:00
main() bbe134bd1a Dots in world-names are now possible! :D 2012-03-04 19:36:14 +01:00
main() 91f7debb08 MVWorld + SerializationConfig = Awesome
Yes, I did it.
2012-03-04 16:08:09 +01:00
main() 871a601e37 General cleanup. 2012-03-03 17:07:07 +01:00
main() bd7ad20b7b Fixed the tests.
Why is this option even on by default...
2012-03-02 21:22:12 +01:00
main() 873d878252 Build fixed. Bukkit, I hate breaking changes!
However, this is not tested *at all*. Try it if you're brave enough ^^
2012-03-01 16:55:37 +01:00
main() 8c63cac4c5 I'm walking...
(Yes, I'm doing this on my iPhone)
Should fix #530.
2012-03-01 13:12:09 +01:00
main() 283913010f Now using SerializationConfig v1.3 2012-02-26 16:45:23 +01:00
main() 109582335b Missing javadoc. 2012-02-25 14:59:33 +01:00
main() 3f09fbd710 Fixed the world-purger using the names from the new EntiyType-enum.
Closes #478.
Should fix #482.
Poor sheep.
2012-02-25 14:48:36 +01:00
main() ccb96ead10 Nasty bugs are nasty. 2012-02-25 13:11:21 +01:00
Eric Stokes 5c48899d92 Add initial support for enforcing access better 2012-02-23 20:15:10 -07:00
Eric Stokes 5f5d7084fa Add **much** better mv check command 2012-02-22 20:22:37 -07:00
Eric Stokes 7b9c26d40a Cleanup logging a bit, state when core is allowing players to access 2012-02-21 17:45:29 -07:00
Eric Stokes 0c96da48f9 Allow Spawner eggs to override settings 2012-02-21 16:58:36 -07:00
Eric Stokes fbbe031b2c Fix for method deprecations in R5 2012-02-21 05:25:59 -07:00
main() 868ac57a4a Removed TODOs in deprecated classes. There's nothing left to be done there. 2012-02-06 19:25:34 +01:00
main() 7c21a114db Fixed a bug in the info-command.
Information about the player's current world was shown when he entered an invalid world-name.
2012-02-06 17:19:51 +01:00
main() e7573d3bd7 Rewrote the who-command. Fixes #467. 2012-02-06 17:19:50 +01:00
main() 772d5a222d Unused import... 2012-02-06 17:19:44 +01:00
Eric Stokes 9eaca3e093 Bump to 2.4 2012-02-05 21:57:31 -07:00
Eric Stokes 2eb61af76f Remove Structures and Types from import
Fixes #466
2012-02-05 20:32:09 -07:00
Eric Stokes ad9d4e41ff Remove EGG, that's for chickens, silly. 2012-02-05 00:10:36 -07:00
Eric Stokes 6a2e0e5810 Fix Portals being blocked in End
This Fixes #463
This is caused by a bug in Bukkit/Bukkit@b2364780cb see line 38 of EntityCreatePortalEvent
2012-02-04 23:46:40 -07:00
Eric Stokes a9c6582487 Fix bypass perms. Fixes #443
I had a typo and didn't add the parent perms :(

Sorry about this big breakage... should be fixed.
2012-02-04 18:06:50 -07:00
Eric Stokes b66028e0e0 Lots of cleanup prepping for 2.3AB 2012-02-04 17:40:12 -07:00
Eric Stokes 3ac4e55dc2 Minor bug fixed preparing for 2.3
Fix chatPrefix -> chatprefix
Fix portalcooldown -> teleportcooldown
Fix made teleportcooldown show up in the config
Add New warnings to the default.
2012-02-04 10:14:58 -07:00
Eric Stokes 950991ff1b Removed old checks, cleanup poop
Add in the deprecated config method to not break other plugins
Fix handling of unloaded worlds in info and list
2012-02-04 09:10:56 -07:00
main() a1b07065b2 Merge branch 'master' of github.com:Multiverse/Multiverse-Core into config-changes
Conflicts:
	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
	src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java
	src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java
	src/main/java/com/onarandombox/MultiverseCore/utils/MVPermissions.java
	src/main/resources/defaults/config.yml
2012-02-04 15:19:37 +01:00
main() a1075224d3 Fixed config... 2012-02-04 14:22:55 +01:00
Eric Stokes d707a9f9a8 Made config command more hardcoded, but work. 2012-02-04 00:18:48 -07:00
Eric Stokes 90b04aa798 Add migrater for new configs, remove default, it's autogenned now 2012-02-03 23:36:17 -07:00
main() 5d1532e811 Updated build instructions in README (goodbye, submodules!) 2012-02-02 17:25:53 +01:00
main() 443d62580b CommandHandler is now mavenized, we can delete the submodule! 2012-02-02 17:20:46 +01:00
Eric Stokes 541819ea8f Move to shaded CH, this will break all MV plugins 2012-02-01 21:44:15 -07:00
Eric Stokes b09ea0e66a Add shading relocation so we don't conflict anymore! 2012-02-01 19:37:33 -07:00
Eric Stokes 8272e121f4 Update to allpay 6 2012-02-01 19:13:47 -07:00
main() 5d2534f497 Goodbye economy-dependencies! 2012-02-01 18:07:27 -07:00
main() 1e7eef90f9 Now using AllPay as maven-dependency, not as git-submodule. 2012-02-01 17:13:59 +01:00
main() 44df567936 Now using SerializationConfig. 2012-02-01 16:28:23 +01:00
main() d595cb9a31 Added SerializationConfig-dependency, including it with the shade-plugin. 2012-01-31 20:49:55 +01:00
Eric Stokes e8a72d19e1 Fix checkstyle violations 2012-01-29 15:56:57 -07:00
Eric Stokes dde3b63fb9 Fix non-active properties not saving.
Fixes #409
2012-01-29 15:40:16 -07:00
Eric Stokes 87d4d4e1f4 Allow generate-structures to be used per world 2012-01-29 12:41:48 -07:00
Eric Stokes 7aca740296 Fix javadocs in PortalTypeConfigProperty 2012-01-29 12:37:40 -07:00
Eric Stokes 6c9bc6951f Many small fixes.
- Update to 1.1-R2
 - Fix the '--list' not working with the import
 - Fix typo in new portalform catcher
 - Fix 'the_end' not working on import/create
2012-01-29 12:11:41 -07:00
Eric Stokes 74726b44ab Mid commit on adding portal prevention 2012-01-29 09:33:56 -07:00
Eric Stokes 18a57bf975 Allow eggs to spawn monsters 2012-01-28 08:27:57 -07:00
main() b2578b1736 "No newline at end of file" deserves more than only an information. 2012-01-28 15:48:46 +01:00
main() eec765bc48 Merge branch 'util-refactoring' 2012-01-28 15:41:58 +01:00
main() 060c0b1b44 (Re)designed PurgeWorlds/WorldPurger for extension. 2012-01-28 15:06:45 +01:00
Eric Stokes ba90228586 Fix anchors pages not being accessable
Fixes #434
2012-01-27 22:24:50 -07:00
main() 8017172f0e ...
-.-
RAGE!
2012-01-26 19:00:31 +01:00
main() b4ea5e9299 Change in SafeTTeleporter: We can SET the BlockSafety! 2012-01-26 18:56:54 +01:00
main() 59f2c8b62e (Re)designed SafeTTeleporter for extension. 2012-01-26 18:55:09 +01:00
main() 9a28158e5f Merge branch 'master' of github.com:Multiverse/Multiverse-Core into util-refactoring 2012-01-26 18:28:29 +01:00
Eric Stokes 4d97453881 Add the rest of the required items for the new events 2012-01-25 18:14:46 -07:00
Eric Stokes 8488f9db3c Remove the MVVersionRequestEvent, Update pom
I've had enough of our repo being fussy. Just adding the bukkit repos too.
We'll get the proxy stuff working eventually...
2012-01-25 17:13:30 -07:00
main() 51586c7dd5 More tests :D 2012-01-25 21:03:09 +01:00
Eric Stokes 7b74384a8e Fix compatibility with new tests.
Note: @main-- the new tests are balls slow for doing location generation. Like, they take 1s per check, which made the old one run for 16x16x9 seconds (making the test run take about 38.4 minutes)

For now, I've added a special case for nullterrains, which uses the new -n param to skip checking.
2012-01-24 20:32:39 -07:00
main() 33afa4d0d7 Now using the new listeners from ecb97fd5c1 2012-01-24 19:18:03 -07:00
main() 0980e0a201 Merge branch 'master' of github.com:Multiverse/Multiverse-Core into new-tests
Conflicts:
	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
2012-01-23 19:05:21 +01:00
main() 8bab4ae606 Merge branch 'master' of github.com:Multiverse/Multiverse-Core into new-tests 2012-01-11 16:44:59 +01:00
main() a1299239a2 Added more checks 2012-01-07 21:26:51 +01:00
main() 7cdb52e740 Yay for colored messages! 2012-01-07 21:26:23 +01:00
main() e2d6652ef1 One single missing char that kept breaking everything.
It took me half an hour to find this -.-
RAGE!
2012-01-07 17:13:00 +01:00
main() 814725a2ba Merge branch 'master' of github.com:Multiverse/Multiverse-Core into new-tests
Conflicts:
	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
2012-01-07 16:10:18 +01:00
main() da6e6145f2 (Re)designed MVMessaging for extension. 2012-01-07 16:05:16 +01:00
main() ee715b13b0 (Re)designed LocationManipulation for extension. 2012-01-07 16:02:23 +01:00
main() a18611fb76 (Re)designed BlockSafety for extension. 2012-01-06 21:11:51 +01:00
main() 9173a15eb9 Started work on tons of new tests 2011-12-31 18:34:04 +01:00
224 changed files with 15854 additions and 7959 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 💬 ​Multiverse Discord Server
url: https://discord.gg/NZtfKky
about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help!
+56
View File
@@ -0,0 +1,56 @@
---
name: ❓ Help!
about: Encountered a problem with Multiverse-Core? Not sure how to fix it?
title: ''
labels: 'Type: Assistance'
assignees: ''
---
<!-- Multiverse-Core help guide
Don't write inside the arrows as they will be hidden when you post your issue.
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
If you need help other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
Or come join our Discord server to get help sooner: https://discord.gg/NZtfKky
If you're happy to wait (or you were sent here from Discord), read on:
1. Check the Usage and FAQ pages to see if it answers your queries:
https://github.com/Multiverse/Multiverse-Core/wiki/Basics
https://github.com/Multiverse/Multiverse-Core/wiki/FAQ
2. Fill out the template.
This will help us understand what problem you've encountered and help us
find a solution.
3. When linking files, do not attach them to the post!
Copy and paste any logs into https://gist.github.com/ or other similar service.
4. Delete this line and all above lines before posting your issue! -->
### Information
* **Server version:** <!-- Insert output of `/version` command -->
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
### Help request
**Problem**
<!-- What problem did you encounter? -->
**What I have tried**
<!-- What have you tried so far? -->
**Screenshots**
<!-- If relevant, include any screenshots here. -->
+59
View File
@@ -0,0 +1,59 @@
---
name: 🐛 Report a Bug
about: Report a Multiverse-Core bug. Only use this if you're 100% sure it's something wrong with Multiverse-Core - otherwise, try "Help!".
title: ''
labels: 'Bug: Unconfirmed'
assignees: ''
---
<!-- Multiverse-Core bug reporting guide
Don't put anything inside this block, as it won't be included in the issue.
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
If you are having issues with other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
If you are reporting a bug, please follow the following steps:
1. Fill out the template in full.
Run the commands in the console. Don't just put "latest" as a version,
or we will ignore it.
2. When linking files, do not attach them to the post!
Copy and paste any logs into https://gist.github.com/, then paste a
link to them in the relevant parts of the template.
**DO NOT drag files into this box!**
3. Make sure not to write between the arrows, as anything there will be
hidden.
4. Delete this line and all above lines before posting your issue! -->
### Information
* **Server version:** <!-- Insert output of `/version` command -->
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
### Details
I was **`<able / not able>`** to reproduce my issue on a freshly setup and up-to-date server with the latest version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
**Description**
<!-- Replace this with a brief summary of the bug. -->
**Steps to reproduce**
<!-- Replace this with exactly what you did to cause the bug. -->
**Expected behavior**
<!-- Replace this with what you expected to happen. -->
**Screenshots**
<!-- Replace this with screenshots, if necessary. -->
@@ -0,0 +1,54 @@
---
name: 💡 Request a Feature
about: Suggest a feature you want to see in Multiverse-Core!
title: ''
labels: 'Type: Idea'
assignees: ''
---
<!-- Multiverse-Core feature request guide
Fill out the template. Don't write inside the arrows as they will be hidden
when you post your issue.
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
If you are look for other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord
server: https://discord.gg/NZtfKky
If you have a feature suggestion for Multiverse-Core, read the following tips:
1. Fill out the template.
This will help us understand what you're requesting and why you want us
to add it.
2. Keep it simple.
Make sure it's easy to understand what you're requesting. A good way is
to keep it to one request per GitHub issue, as we can then easily track
feature requests.
3. Check whether it has already been asked or added.
You can search the issue tracker to see if your feature has already been
requested at https://github.com/Multiverse/Multiverse-Core/issues.
4. Ask yourself: "Does this belong in Multiverse-Core?"
There are lots of features that we reject because most servers won't
need or use them. If your feature is very specific or already exists in
another plugin, it might not be a good fit for Multiverse-Core.
5. Delete this line and all above lines before posting your issue! -->
### Feature request
**Feature description**
<!-- What feature are you suggesting? -->
**How the feature is useful**
<!-- How is the feature useful to players, server owners and/or developers? -->
+1
View File
@@ -12,6 +12,7 @@
# maven
/target
dependency-reduced-pom.xml
# vim
.*.sw[a-p]
-7
View File
@@ -1,7 +0,0 @@
[submodule "lib/allpay"]
path = lib/allpay
url = git://github.com/FernFerret/AllPay.git
[submodule "lib/commandhandler"]
path = lib/commandhandler
url = git://github.com/PneumatiCraft/CommandHandler.git
branch = notrie
+6
View File
@@ -0,0 +1,6 @@
language: java
jdk:
- oraclejdk8
notifications:
email: false
dist: trusty
+3 -5
View File
@@ -1,11 +1,8 @@
Building
========
Update the submodules after you clone and before you build with maven.
Simply build the source with maven:
```
$ git submodule update --init --recursive
$ mvn install
```
$ mvn install
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
@@ -16,3 +13,4 @@ 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.
+5 -6
View File
@@ -13,9 +13,7 @@
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="info"/>
</module>
<module name="NewlineAtEndOfFile" />
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileTabCharacter">
@@ -78,7 +76,10 @@
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="MethodLength"/>
<module name="MethodLength">
<property name="severity" value="warning"/>
<property name="countEmpty" value="false"/>
</module>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
@@ -103,7 +104,6 @@
</module>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
@@ -115,7 +115,6 @@
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Don't like errors for `final` missing
Submodule lib/allpay deleted from 7abba1f004.
+257 -127
View File
@@ -3,19 +3,45 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>2.3</version>
<version>5.0.0-SNAPSHOT</version>
<name>Multiverse-Core</name>
<description>World Management Plugin</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>UNKNOWN</project.build.number>
<project.bitly-access-token>bitly-access-token</project.bitly-access-token>
</properties>
<repositories>
<!-- Spigot -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
<repository>
<id>spigot</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
</repositories>
<pluginRepositories>
@@ -48,6 +74,17 @@
<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>
@@ -57,61 +94,62 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.7.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Build Helper - Additional Source Folders -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-wsdl-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/lib/allpay/src/main/java</source>
<source>${project.basedir}/lib/commandhandler/src</source>
<source>${project.basedir}/lib/commandhandler/lib/ShellParser/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.8</version>
<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>
<configuration>
<file>target/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-b${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<version>3.0.2</version>
<configuration>
<archive>
<manifestEntries>
@@ -119,16 +157,10 @@
</archive>
</configuration>
</plugin>
<!-- Maven Source Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<version>3.0.0-M3</version>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
@@ -141,141 +173,239 @@
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.11</version>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<version>2.17</version>
<configuration>
<enableRulesSummary>true</enableRulesSummary>
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>javadoc-jar</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<failOnError>false</failOnError>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>me.main__.util</pattern>
<shadedPattern>com.onarandombox.serializationconfig</shadedPattern>
</relocation>
<relocation>
<pattern>buscript</pattern>
<shadedPattern>com.onarandombox.buscript</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.onarandombox.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
</relocation>
<relocation>
<pattern>org.codehaus.jettison</pattern>
<shadedPattern>com.onarandombox.jettison</shadedPattern>
</relocation>
<relocation>
<pattern>de.themoep.idconverter</pattern>
<shadedPattern>com.onarandombox.idconverter</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>com.onarandombox.acf</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>com.onarandombox.locales</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>se.eris</groupId>
<artifactId>notnull-instrumenter-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>instrument</goal>
<goal>tests-instrument</goal>
</goals>
<configuration>
<notNull>
<param>org.jetbrains.annotations.NotNull</param>
<param>javax.validation.constraints.NotNull</param>
</notNull>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Bukkit Dependency -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.1-R1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Bukkit Dependency -->
<!-- Start of Spout -->
<!-- SerializationConfig Dependency -->
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutpluginapi</artifactId>
<version>dev-SNAPSHOT</version>
<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 Spout -->
<!-- Start of Economy Dependencies -->
<!-- End of SerializationConfig Dependency -->
<!-- Start of Economy Dependency -->
<dependency>
<groupId>cosine.boseconomy</groupId>
<artifactId>BOSEconomy</artifactId>
<version>0.6.2</version>
<type>jar</type>
<scope>compile</scope>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- End of Economy Dependency -->
<!-- Start of CommandHandler Dependency -->
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>buscript</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.8</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>Logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.2</version>
</dependency>
<dependency>
<groupId>de.themoep.idconverter</groupId>
<artifactId>mappings</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.crafter.tickleman.RealShop</groupId>
<artifactId>RealShop</artifactId>
<version>0.63</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.iCo6</groupId>
<artifactId>iConomy</artifactId>
<version>6.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>5.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nijiko.coelho.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>4.65</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earth2me.essentials</groupId>
<artifactId>Essentials</artifactId>
<version>2.4.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.ashtheking.currency</groupId>
<artifactId>MultiCurrency</artifactId>
<version>0.09</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ca.agnate</groupId>
<artifactId>EconXP</artifactId>
<version>1.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Economy Dependencies -->
<!-- Start of Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.4.9</version>
<version>2.0.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.4.9</version>
<version>2.0.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.4.9</version>
<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>3.0</version>
<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>
<!-- End of Test Dependencies -->
</dependencies>
<distributionManagement>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
<id>benergy10</id>
<url>http://repo.benergy10.dev/repository/minecraft/</url>
</repository>
<snapshotRepository>
<id>benergy10</id>
<url>http://repo.benergy10.dev/repository/minecraft-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,385 @@
package com.onarandombox.MultiverseCore;
import java.util.Map;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
import me.main__.util.SerializationConfig.NoSuchPropertyException;
import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.Bukkit;
/**
* Our configuration.
*/
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
private static MultiverseCoreConfiguration instance;
/**
* Sets the statically saved instance.
* @param instance The new instance.
*/
public static void setInstance(MultiverseCoreConfiguration instance) {
MultiverseCoreConfiguration.instance = instance;
}
/**
* @return True if the static instance of config is set.
*/
public static boolean isSet() {
return instance != null;
}
/**
* Gets the statically saved instance.
* @return The statically saved instance.
*/
public static MultiverseCoreConfiguration getInstance() {
if (instance == null)
throw new IllegalStateException("The instance wasn't set!");
return instance;
}
@Property
private volatile boolean enforceaccess;
@Property
private volatile boolean prefixchat;
@Property
private volatile String prefixchatformat;
@Property
private volatile boolean useasyncchat;
@Property
private volatile boolean teleportintercept;
@Property
private volatile boolean firstspawnoverride;
@Property
private volatile boolean displaypermerrors;
@Property
private volatile boolean enablebuscript;
@Property
private volatile int globaldebug;
@Property
private volatile boolean silentstart;
@Property
private volatile int messagecooldown;
@Property
private volatile double version;
@Property
private volatile String firstspawnworld;
@Property
private volatile int teleportcooldown;
@Property
private volatile boolean defaultportalsearch;
@Property
private volatile int portalsearchradius;
@Property
private volatile boolean autopurge;
@Property
private volatile boolean idonotwanttodonate;
public MultiverseCoreConfiguration() {
super();
MultiverseCoreConfiguration.setInstance(this);
}
public MultiverseCoreConfiguration(Map<String, Object> values) {
super(values);
MultiverseCoreConfiguration.setInstance(this);
}
/**
* {@inheritDoc}
*/
@Override
protected void setDefaults() {
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
enforceaccess = false;
useasyncchat = true;
prefixchat = true;
prefixchatformat = "[%world%]%chat%";
teleportintercept = true;
firstspawnoverride = true;
displaypermerrors = true;
enablebuscript = true;
globaldebug = 0;
messagecooldown = 5000;
teleportcooldown = 1000;
this.version = 2.9;
silentstart = false;
defaultportalsearch = false;
portalsearchradius = 128;
autopurge = true;
idonotwanttodonate = false;
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
}
/**
* {@inheritDoc}
*/
@Override
public boolean setConfigProperty(String property, String value) {
try {
return this.setProperty(property, value, true);
} catch (NoSuchPropertyException e) {
return false;
}
}
// And here we go:
/**
* {@inheritDoc}
*/
@Override
public boolean getEnforceAccess() {
return this.enforceaccess;
}
/**
* {@inheritDoc}
*/
@Override
public void setEnforceAccess(boolean enforceAccess) {
this.enforceaccess = enforceAccess;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getPrefixChat() {
return this.prefixchat;
}
/**
* {@inheritDoc}
*/
@Override
public void setPrefixChat(boolean prefixChat) {
this.prefixchat = prefixChat;
}
/**
* {@inheritDoc}
*/
@Override
public String getPrefixChatFormat() {
return this.prefixchatformat;
}
/**
* {@inheritDoc}
*/
@Override
public void setPrefixChatFormat(String prefixChatFormat) {
this.prefixchatformat = prefixChatFormat;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getTeleportIntercept() {
return this.teleportintercept;
}
/**
* {@inheritDoc}
*/
@Override
public void setTeleportIntercept(boolean teleportIntercept) {
this.teleportintercept = teleportIntercept;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getFirstSpawnOverride() {
return this.firstspawnoverride;
}
/**
* {@inheritDoc}
*/
@Override
public void setFirstSpawnOverride(boolean firstSpawnOverride) {
this.firstspawnoverride = firstSpawnOverride;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getDisplayPermErrors() {
return this.displaypermerrors;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getEnableBuscript() {
return this.enablebuscript;
}
/**
* {@inheritDoc}
*/
@Override
public void setEnableBuscript(boolean enableBuscript) {
this.enablebuscript = enableBuscript;
}
/**
* {@inheritDoc}
*/
@Override
public void setDisplayPermErrors(boolean displayPermErrors) {
this.displaypermerrors = displayPermErrors;
}
/**
* {@inheritDoc}
*/
@Override
public int getGlobalDebug() {
return this.globaldebug;
}
/**
* {@inheritDoc}
*/
@Override
public void setGlobalDebug(int globalDebug) {
this.globaldebug = globalDebug;
Logging.setDebugLevel(globalDebug);
Bukkit.getPluginManager().callEvent(new MVDebugModeEvent(globalDebug));
}
/**
* {@inheritDoc}
*/
@Override
public int getMessageCooldown() {
return this.messagecooldown;
}
/**
* {@inheritDoc}
*/
@Override
public void setMessageCooldown(int messageCooldown) {
this.messagecooldown = messageCooldown;
}
/**
* {@inheritDoc}
*/
@Override
public double getVersion() {
return this.version;
}
/**
* {@inheritDoc}
*/
@Override
public void setVersion(int version) {
this.version = version;
}
/**
* {@inheritDoc}
*/
@Override
public String getFirstSpawnWorld() {
return this.firstspawnworld;
}
/**
* {@inheritDoc}
*/
@Override
public void setFirstSpawnWorld(String firstSpawnWorld) {
this.firstspawnworld = firstSpawnWorld;
}
/**
* {@inheritDoc}
*/
@Override
public int getTeleportCooldown() {
return this.teleportcooldown;
}
/**
* {@inheritDoc}
*/
@Override
public void setTeleportCooldown(int teleportCooldown) {
this.teleportcooldown = teleportCooldown;
}
@Override
public void setUseAsyncChat(boolean useAsyncChat) {
this.useasyncchat = useAsyncChat;
}
@Override
public boolean getUseAsyncChat() {
return this.useasyncchat;
}
@Override
public void setSilentStart(boolean silentStart) {
Logging.setShowingConfig(!silentStart);
this.silentstart = silentStart;
}
@Override
public boolean getSilentStart() {
return silentstart;
}
@Override
public void setUseDefaultPortalSearch(boolean useDefaultPortalSearch) {
defaultportalsearch = useDefaultPortalSearch;
}
@Override
public boolean isUsingDefaultPortalSearch() {
return defaultportalsearch;
}
@Override
public void setPortalSearchRadius(int searchRadius) {
this.portalsearchradius = searchRadius;
}
@Override
public int getPortalSearchRadius() {
return portalsearchradius;
}
@Override
public boolean isAutoPurgeEnabled() {
return autopurge;
}
@Override
public void setAutoPurgeEnabled(boolean autopurge) {
this.autopurge = autopurge;
}
@Override
public boolean isShowingDonateMessage() {
return !idonotwanttodonate;
}
@Override
public void setShowDonateMessage(boolean showDonateMessage) {
this.idonotwanttodonate = !showDonateMessage;
}
}
@@ -0,0 +1,655 @@
package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
import com.onarandombox.MultiverseCore.configuration.EntryFee;
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
import com.onarandombox.MultiverseCore.configuration.SpawnSettings;
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.enums.EnglishChatStyle;
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
import me.main__.util.SerializationConfig.Serializor;
import me.main__.util.SerializationConfig.Validator;
import me.main__.util.SerializationConfig.VirtualProperty;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World.Environment;
import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* This is a property class, I think we don't need that much javadoc.
* BEGIN CHECKSTYLE-SUPPRESSION: Javadoc
*/
@SerializableAs("MVWorld")
public class WorldProperties extends SerializationConfig {
private static final Map<String, String> PROPERTY_ALIASES;
static {
PROPERTY_ALIASES = new HashMap<String, String>();
PROPERTY_ALIASES.put("curr", "entryfee.currency");
PROPERTY_ALIASES.put("currency", "entryfee.currency");
PROPERTY_ALIASES.put("price", "entryfee.amount");
PROPERTY_ALIASES.put("scaling", "scale");
PROPERTY_ALIASES.put("aliascolor", "color");
PROPERTY_ALIASES.put("heal", "autoHeal");
PROPERTY_ALIASES.put("storm", "allowWeather");
PROPERTY_ALIASES.put("weather", "allowWeather");
PROPERTY_ALIASES.put("spawnmemory", "keepSpawnInMemory");
PROPERTY_ALIASES.put("memory", "keepSpawnInMemory");
PROPERTY_ALIASES.put("mode", "gameMode");
PROPERTY_ALIASES.put("diff", "difficulty");
PROPERTY_ALIASES.put("spawnlocation", "spawn");
PROPERTY_ALIASES.put("limit", "playerLimit");
PROPERTY_ALIASES.put("animals", "spawning.animals.spawn");
PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn");
PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate");
PROPERTY_ALIASES.put("monstersrate", "spawning.monsters.spawnrate");
PROPERTY_ALIASES.put("flight", "allowFlight");
PROPERTY_ALIASES.put("fly", "allowFlight");
PROPERTY_ALIASES.put("allowfly", "allowFlight");
}
private final boolean keepSpawnFallback;
public WorldProperties(Map<String, Object> values) {
super(values);
Object keepSpawnObject = values.get("keepSpawnInMemory");
keepSpawnFallback = keepSpawnObject == null || Boolean.parseBoolean(keepSpawnObject.toString());
}
public WorldProperties() {
super();
keepSpawnFallback = true;
}
public WorldProperties(final boolean fixSpawn, final Environment environment) {
super();
if (!fixSpawn) {
this.adjustSpawn = false;
}
setScaling(getDefaultScale(environment));
keepSpawnFallback = true;
}
void setMVWorld(MVWorld world) {
registerObjectUsing(world);
registerGlobalValidator(new WorldPropertyValidator());
}
/**
* Serializor for the color-property.
*/
private static final class EnumPropertySerializor<T extends Enum<T>> implements Serializor<T, String> {
@Override
public String serialize(T from) {
return from.toString();
}
@Override
public T deserialize(String serialized, Class<T> wanted) throws IllegalPropertyValueException {
try {
return Enum.valueOf(wanted, serialized.toUpperCase());
} catch (IllegalArgumentException e) {
throw new IllegalPropertyValueException(e);
}
}
}
/**
* Serializor for the difficulty-property.
*/
private static final class DifficultyPropertySerializor implements Serializor<Difficulty, String> {
@Override
public String serialize(Difficulty from) {
return from.toString();
}
@Override
public Difficulty deserialize(String serialized, Class<Difficulty> wanted) throws IllegalPropertyValueException {
try {
return Difficulty.getByValue(Integer.parseInt(serialized));
} catch (Exception e) {
}
try {
return Difficulty.valueOf(serialized.toUpperCase());
} catch (Exception e) {
}
throw new IllegalPropertyValueException();
}
}
/**
* Serializor for the gameMode-property.
*/
private static final class GameModePropertySerializor implements Serializor<GameMode, String> {
@Override
public String serialize(GameMode from) {
return from.toString();
}
@Override
public GameMode deserialize(String serialized, Class<GameMode> wanted) throws IllegalPropertyValueException {
try {
return GameMode.getByValue(Integer.parseInt(serialized));
} catch (NumberFormatException nfe) {
}
try {
return GameMode.valueOf(serialized.toUpperCase());
} catch (Exception e) {
}
throw new IllegalPropertyValueException();
}
}
/**
* Serializor for the time-property.
*/
private static final class TimePropertySerializor implements Serializor<Long, String> {
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
private static final String TIME_REGEX = "(\\d\\d?):?(\\d\\d)(a|p)?m?";
private static final Map<String, String> TIME_ALIASES;
static {
Map<String, String> staticTimes = new HashMap<String, String>();
staticTimes.put("morning", "8:00");
staticTimes.put("day", "12:00");
staticTimes.put("noon", "12:00");
staticTimes.put("midnight", "0:00");
staticTimes.put("night", "20:00");
// now set TIME_ALIASES to a "frozen" map
TIME_ALIASES = Collections.unmodifiableMap(staticTimes);
}
@Override
public String serialize(Long from) {
// I'm tired, so they get time in 24 hour for now.
// Someone else can add 12 hr format if they want :P
int hours = (int) ((from / 1000 + 8) % 24);
int minutes = (int) (60 * (from % 1000) / 1000);
return String.format("%d:%02d", hours, minutes);
}
@Override
public Long deserialize(String serialized, Class<Long> wanted) throws IllegalPropertyValueException {
if (TIME_ALIASES.containsKey(serialized.toLowerCase())) {
serialized = TIME_ALIASES.get(serialized.toLowerCase());
}
// Regex that extracts a time in the following formats:
// 11:11pm, 11:11, 23:11, 1111, 1111p, and the aliases at the top of this file.
Pattern pattern = Pattern.compile(TIME_REGEX, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(serialized);
matcher.find();
int hour = 0;
double minute = 0;
int count = matcher.groupCount();
if (count >= 2) {
hour = Integer.parseInt(matcher.group(1));
minute = Integer.parseInt(matcher.group(2));
}
// If there were 4 matches (all, hour, min, am/pm)
if (count == 4) {
// We want 24 hour time for calcs, but if they
// added a p[m], turn it into a 24 hr one.
if (matcher.group(3).equals("p")) {
hour += 12;
}
}
// Translate 24th hour to 0th hour.
if (hour == 24) {
hour = 0;
}
// Clamp the hour
if (hour > 23 || hour < 0) {
throw new IllegalPropertyValueException("Illegal hour!");
}
// Clamp the minute
if (minute > 59 || minute < 0) {
throw new IllegalPropertyValueException("Illegal minute!");
}
// 60 seconds in a minute, time needs to be in hrs * 1000, per
// the bukkit docs.
double totaltime = (hour + (minute / 60.0)) * 1000;
// Somehow there's an 8 hour offset...
totaltime -= 8000;
if (totaltime < 0) {
totaltime = 24000 + totaltime;
}
return (long) totaltime;
}
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
}
// --------------------------------------------------------------
// Begin properties
@Property(description = "Sorry, 'hidden' must either be: true or false.")
private volatile boolean hidden;
@Property(description = "Alias must be a valid string.")
private volatile String alias;
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'color' must be a valid color-name.")
private volatile EnglishChatColor color;
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'style' must be a valid style-name.")
private volatile EnglishChatStyle style;
@Property(description = "Sorry, 'pvp' must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
volatile VirtualProperty<Boolean> pvp; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property(description = "Scale must be a positive double value. ex: 2.3")
private volatile double scale;
@Property(description = "You must set this to the NAME not alias of a world.")
private volatile String respawnWorld;
@Property(description = "Sorry, this must either be: true or false.")
private volatile boolean allowWeather;
@Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class, persistVirtual = true,
description = "Difficulty must be set as one of the following: peaceful easy normal hard")
volatile VirtualProperty<Difficulty> difficulty; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property(description = "Sorry, 'animals' must either be: true or false.")
private volatile SpawnSettings spawning;
@Property
volatile EntryFee entryfee;
@Property(description = "Sorry, 'hunger' must either be: true or false.")
private volatile boolean hunger;
@Property(description = "Sorry, 'autoheal' must either be: true or false.")
private volatile boolean autoHeal;
@Property(description = "Sorry, 'adjustspawn' must either be: true or false.")
private volatile boolean adjustSpawn;
@Property(serializor = EnumPropertySerializor.class, description = "Allow portal forming must be NONE, ALL, NETHER or END.")
private volatile AllowedPortalType portalForm;
@Property(serializor = GameModePropertySerializor.class, description = "GameMode must be set as one of the following: survival creative")
private volatile GameMode gameMode;
@Property(description = "Sorry, this must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
volatile VirtualProperty<Boolean> keepSpawnInMemory; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property
volatile SpawnLocation spawnLocation; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property(virtualType = Location.class,
description = "There is no help available for this variable. Go bug Rigby90 about it.")
volatile VirtualProperty<Location> spawn; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property(description = "Set this to false ONLY if you don't want this world to load itself on server restart.")
private volatile boolean autoLoad;
@Property(description = "If a player dies in this world, shoudld they go to their bed?")
private volatile boolean bedRespawn;
@Property
private volatile List<String> worldBlacklist;
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
description = "Set the time to whatever you want! (Will NOT freeze time)")
volatile VirtualProperty<Long> time; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property
volatile Environment environment; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property
volatile long seed; // SUPPRESS CHECKSTYLE: VisibilityModifier
@Property
private volatile String generator;
@Property
private volatile int playerLimit;
@Property
private volatile boolean allowFlight;
// End of properties
// --------------------------------------------------------------
void setValidator(String fieldName, Validator validator) {
registerValidator(fieldName, validator); //To change body of overridden methods use File | Settings | File Templates.
}
/**
* {@inheritDoc}
*/
@Override
public void copyValues(SerializationConfig other) {
super.copyValues(other);
}
/**
* This prepares the MVWorld for unloading.
*/
public void cacheVirtualProperties() {
try {
this.buildVPropChanges();
} catch (IllegalStateException e) {
// do nothing
}
}
/**
* {@inheritDoc}
*/
@Override
protected void setDefaults() {
this.hidden = false;
this.alias = new String();
this.color = EnglishChatColor.WHITE;
this.style = EnglishChatStyle.NORMAL;
this.scale = 1D;
this.respawnWorld = new String();
this.allowWeather = true;
this.spawning = new SpawnSettings();
this.entryfee = new EntryFee();
this.hunger = true;
this.autoHeal = true;
this.adjustSpawn = true;
this.portalForm = AllowedPortalType.ALL;
this.gameMode = GameMode.SURVIVAL;
this.spawnLocation = new NullLocation();
this.autoLoad = true;
this.bedRespawn = true;
this.worldBlacklist = new ArrayList<String>();
this.generator = null;
this.playerLimit = -1;
this.allowFlight = true;
}
private static double getDefaultScale(Environment environment) {
if (environment == Environment.NETHER) {
return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
} else if (environment == Environment.THE_END) {
return 16.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
return 1.0;
}
/**
* getAliases().
* @return The alias-map.
* @see SerializationConfig
*/
protected static Map<String, String> getAliases() {
return PROPERTY_ALIASES;
}
void flushChanges() {
this.flushPendingVPropChanges();
}
public String getAlias() {
return this.alias;
}
public void setAlias(String alias) {
this.setPropertyValueUnchecked("alias", alias);
}
public Environment getEnvironment() {
return this.environment;
}
public void setEnvironment(Environment environment) {
this.setPropertyValueUnchecked("environment", environment);
}
public long getSeed() {
return this.seed;
}
public void setSeed(long seed) {
this.setPropertyValueUnchecked("seed", seed);
}
public String getGenerator() {
return this.generator;
}
public void setGenerator(String generator) {
this.setPropertyValueUnchecked("generator", generator);
}
public int getPlayerLimit() {
return this.playerLimit;
}
public void setPlayerLimit(int limit) {
this.setPropertyValueUnchecked("playerLimit", limit);
}
public boolean canAnimalsSpawn() {
return this.spawning.getAnimalSettings().doSpawn();
}
public void setAllowAnimalSpawn(boolean animals) {
this.setPropertyValueUnchecked("spawning.animals.spawn", animals);
}
public List<String> getAnimalList() {
// These don't fire events at the moment. Should they?
return this.spawning.getAnimalSettings().getExceptions();
}
public boolean canMonstersSpawn() {
return this.spawning.getMonsterSettings().doSpawn();
}
public void setAllowMonsterSpawn(boolean monsters) {
this.setPropertyValueUnchecked("spawning.monsters.spawn", monsters);
}
public int getAnimalSpawnRate() {
return this.spawning.getAnimalSettings().getSpawnRate();
}
public int getMonsterSpawnRate() {
return this.spawning.getMonsterSettings().getSpawnRate();
}
public List<String> getMonsterList() {
// These don't fire events at the moment. Should they?
return this.spawning.getMonsterSettings().getExceptions();
}
public boolean isPVPEnabled() {
return this.pvp.get();
}
public void setPVPMode(boolean pvp) {
this.setPropertyValueUnchecked("pvp", pvp);
}
public boolean isHidden() {
return this.hidden;
}
public void setHidden(boolean hidden) {
this.setPropertyValueUnchecked("hidden", hidden);
}
public List<String> getWorldBlacklist() {
return this.worldBlacklist;
}
public double getScaling() {
return this.scale;
}
public boolean setScaling(double scaling) {
return this.setPropertyValueUnchecked("scale", scaling);
}
public boolean setColor(String aliasColor) {
return this.setPropertyUnchecked("color", aliasColor);
}
public boolean setColor(EnglishChatColor color) {
return this.setPropertyValueUnchecked("color", color);
}
public EnglishChatColor getColor() {
return this.color;
}
public String getRespawnToWorld() {
return this.respawnWorld;
}
public boolean setRespawnToWorld(String respawnToWorld) {
return this.setPropertyValueUnchecked("respawnWorld", respawnToWorld);
}
public Material getCurrency() {
return this.entryfee.getCurrency();
}
public void setCurrency(@Nullable Material currency) {
this.setPropertyValueUnchecked("entryfee.currency", currency);
}
public double getPrice() {
return this.entryfee.getAmount();
}
public void setPrice(double price) {
this.setPropertyValueUnchecked("entryfee.amount", price);
}
public boolean setGameMode(String mode) {
return this.setPropertyUnchecked("gameMode", mode);
}
public boolean setGameMode(GameMode mode) {
return this.setPropertyValueUnchecked("gameMode", mode);
}
public GameMode getGameMode() {
return this.gameMode;
}
public void setEnableWeather(boolean weather) {
this.setPropertyValueUnchecked("allowWeather", weather);
}
public boolean isWeatherEnabled() {
return this.allowWeather;
}
public boolean isKeepingSpawnInMemory() {
if (keepSpawnInMemory == null) {
return keepSpawnFallback;
}
try {
return this.keepSpawnInMemory.get();
} catch (IllegalStateException e) {
return keepSpawnFallback;
}
}
public void setKeepSpawnInMemory(boolean value) {
this.setPropertyValueUnchecked("keepSpawnInMemory", value);
}
public boolean getHunger() {
return this.hunger;
}
public void setHunger(boolean hunger) {
this.setPropertyValueUnchecked("hunger", hunger);
}
public Location getSpawnLocation() {
return this.spawn.get();
}
public void setSpawnLocation(Location l) {
this.setPropertyValueUnchecked("spawn", l);
}
public Difficulty getDifficulty() {
return this.difficulty.get();
}
@Deprecated // SUPPRESS CHECKSTYLE: Deprecated
public boolean setDifficulty(String difficulty) {
return this.setPropertyUnchecked("difficulty", difficulty);
}
public boolean setDifficulty(Difficulty difficulty) {
return this.setPropertyValueUnchecked("difficulty", difficulty);
}
public boolean getAutoHeal() {
return this.autoHeal;
}
public void setAutoHeal(boolean heal) {
this.setPropertyValueUnchecked("autoHeal", heal);
}
public void setAdjustSpawn(boolean adjust) {
this.setPropertyValueUnchecked("adjustSpawn", adjust);
}
public boolean getAdjustSpawn() {
return this.adjustSpawn;
}
public void setAutoLoad(boolean load) {
this.setPropertyValueUnchecked("autoLoad", load);
}
public boolean getAutoLoad() {
return this.autoLoad;
}
public void setBedRespawn(boolean respawn) {
this.setPropertyValueUnchecked("bedRespawn", respawn);
}
public boolean getBedRespawn() {
return this.bedRespawn;
}
public String getAllPropertyNames() {
ChatColor myColor = ChatColor.AQUA;
StringBuilder result = new StringBuilder();
Map<String, Object> serialized = this.serialize();
for (String key : serialized.keySet()) {
result.append(myColor).append(key).append(' ');
myColor = (myColor == ChatColor.AQUA) ? ChatColor.GOLD : ChatColor.AQUA;
}
return result.toString();
}
public String getTime() {
return this.getPropertyUnchecked("time");
}
public boolean setTime(String timeAsString) {
return this.setPropertyUnchecked("time", timeAsString);
}
public AllowedPortalType getAllowedPortals() {
return portalForm;
}
public void allowPortalMaking(AllowedPortalType portalType) {
this.setPropertyValueUnchecked("portalForm", portalType);
}
public EnglishChatStyle getStyle() {
return style;
}
public boolean setStyle(String style) {
return this.setPropertyUnchecked("style", style);
}
public boolean getAllowFlight() {
return this.allowFlight;
}
public void setAllowFlight(final boolean allowFlight) {
this.setPropertyValueUnchecked("allowFlight", allowFlight);
}
}
@@ -0,0 +1,79 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle;
/**
* Used to get block/location-related information.
*/
public interface BlockSafety {
/**
* This function checks whether the block at the given coordinates are above air or not.
* @param l The {@link Location} of the block.
* @return True if the block at that {@link Location} is above air.
*/
boolean isBlockAboveAir(Location l);
/**
* Checks if a player can spawn safely at the given coordinates.
* @param world The {@link World}.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param z The z-coordinate.
* @return True if a player can spawn safely at the given coordinates.
*/
boolean playerCanSpawnHereSafely(World world, double x, double y, double z);
/**
* This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air
* etc. This also ensures there is enough space for a player to spawn!
*
* @param l The {@link Location}
* @return Whether the player can spawn safely at the given {@link Location}
*/
boolean playerCanSpawnHereSafely(Location l);
/**
* Gets a safe bed spawn location OR null if the bed is invalid.
* @param l The location of the bead head (block with the pillow on it).
* @return Safe location around the bed or null if no location was found.
*/
Location getSafeBedSpawn(Location l);
/**
* Gets the location of the top block at the specified {@link Location}.
* @param l Any {@link Location}.
* @return The {@link Location} of the top-block.
*/
Location getTopBlock(Location l);
/**
* Gets the location of the top block at the specified {@link Location}.
* @param l Any {@link Location}.
* @return The {@link Location} of the top-block.
*/
Location getBottomBlock(Location l);
/**
* Checks if an entity would be on track at the specified {@link Location}.
* @param l The {@link Location}.
* @return True if an entity would be on tracks at the specified {@link Location}.
*/
boolean isEntitiyOnTrack(Location l);
/**
* Checks if the specified {@link Minecart} can spawn safely.
* @param cart The {@link Minecart}.
* @return True if the minecart can spawn safely.
*/
boolean canSpawnCartSafely(Minecart cart);
/**
* Checks if the specified {@link Vehicle} can spawn safely.
* @param vehicle The {@link Vehicle}.
* @return True if the vehicle can spawn safely.
*/
boolean canSpawnVehicleSafely(Vehicle vehicle);
}
@@ -7,12 +7,17 @@
package com.onarandombox.MultiverseCore.api;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
import buscript.Buscript;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.*;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.configuration.file.FileConfiguration;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import org.bukkit.entity.Player;
/**
@@ -23,18 +28,22 @@ import org.bukkit.entity.Player;
public interface Core {
/**
* Gets the Multiverse config file.
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
* interfacing with Vault.
*
* @return The Multiverse config file.
* @return the Vault handler for Multiverse.
* @deprecated we are now using {@link #getEconomist()} for all economy needs.
*/
FileConfiguration getMVConfiguration();
@Deprecated
VaultHandler getVaultHandler();
/**
* Gets the Banking system that Multiverse-Core has hooked into.
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without
* worrying about any of the messy details.
*
* @return A {@link GenericBank} that can be used for payments.
* @return the economy manager for Multiverse.
*/
GenericBank getBank();
MVEconomist getEconomist();
/**
* Reloads the Multiverse Configuration files:
@@ -46,9 +55,9 @@ public interface Core {
* Gets the Multiverse message system. This allows you to send messages
* to users at specified intervals.
*
* @return The loaded {@link MVMessaging}.
* @return The loaded {@link MultiverseMessaging}.
*/
MVMessaging getMessaging();
MultiverseMessaging getMessaging();
/**
* Gets the {@link MVPlayerSession} for the given player.
@@ -61,14 +70,6 @@ public interface Core {
*/
MVPlayerSession getPlayerSession(Player player);
/**
* Gets the instantiated Safe-T-Teleporter for performing
* safe teleports.
*
* @return A non-null {@link SafeTTeleporter}.
*/
SafeTTeleporter getTeleporter();
/**
* Multiverse uses an advanced permissions setup, this object
* simplifies getting/setting permissions.
@@ -78,12 +79,12 @@ public interface Core {
MVPermissions getMVPerms();
/**
* Multiverse uses {@link CommandHandler} to make adding and using commands
* Multiverse uses {@link MVCommandManager} to make adding and using commands
* a piece of cake.
*
* @return A non-null {@link CommandHandler}.
* @return A non-null {@link MVCommandManager}.
*/
CommandHandler getCommandHandler();
MVCommandManager getMVCommandManager();
/**
* Gets the factory class responsible for loading many different destinations
@@ -96,7 +97,7 @@ public interface Core {
/**
* Gets the primary class responsible for managing Multiverse Worlds.
*
* @return {@link WorldManager}.
* @return {@link MVWorldManager}.
*/
MVWorldManager getMVWorldManager();
@@ -114,32 +115,6 @@ public interface Core {
*/
AnchorManager getAnchorManager();
/**
* Used by queued commands to regenerate a world on a delay.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
/**
* Sets the {@link GenericBank}-Bank AllPay is using.
*
* @param bank The new {@link GenericBank}
*/
void setBank(GenericBank bank);
/**
* Gets this plugin's {@link AllPay}-Banker.
*
* @return An {@link AllPay}-Banker
*/
AllPay getBanker();
/**
* Decrements the number of plugins that have specifically hooked into core.
*/
@@ -163,4 +138,65 @@ public interface Core {
* @return The readable authors-{@link String}
*/
String getAuthors();
/**
* Gets the {@link BlockSafety} this {@link Core} is using.
* @return The {@link BlockSafety} this {@link Core} is using.
* @see BlockSafety
* @see SimpleBlockSafety
*/
BlockSafety getBlockSafety();
/**
* Sets the {@link BlockSafety} this {@link Core} is using.
* @param blockSafety The new {@link BlockSafety}.
* @see BlockSafety
* @see SimpleBlockSafety
*/
void setBlockSafety(BlockSafety blockSafety);
/**
* Gets the {@link LocationManipulation} this {@link Core} is using.
* @return The {@link LocationManipulation} this {@link Core} is using.
* @see LocationManipulation
* @see SimpleLocationManipulation
*/
LocationManipulation getLocationManipulation();
/**
* Sets the {@link LocationManipulation} this {@link Core} is using.
* @param locationManipulation The new {@link LocationManipulation}.
* @see LocationManipulation
* @see SimpleLocationManipulation
*/
void setLocationManipulation(LocationManipulation locationManipulation);
/**
* Gets the {@link SafeTTeleporter} this {@link Core} is using.
* @return The {@link SafeTTeleporter} this {@link Core} is using.
* @see SafeTTeleporter
* @see SimpleSafeTTeleporter
*/
SafeTTeleporter getSafeTTeleporter();
/**
* Sets the {@link SafeTTeleporter} this {@link Core} is using.
* @param safeTTeleporter The new {@link SafeTTeleporter}.
* @see SafeTTeleporter
* @see SimpleSafeTTeleporter
*/
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
/**
* Gets the {@link MultiverseCoreConfig}.
* @return The configuration.
*/
MultiverseCoreConfig getMVConfig();
/**
* Gets the buscript object for Multiverse. This is what handles Javascript processing.
*
* @return The Multiverse buscript object.
*/
Buscript getScriptAPI();
}
@@ -1,20 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
/**
* A fancy text.
*/
public interface FancyText {
/**
* Gets the {@link String}-representation of this {@link FancyText}.
*
* @return The {@link String}-representation of this {@link FancyText}.
*/
String getFancyText();
}
@@ -0,0 +1,107 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.Location;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;
/**
* Used to manipulate locations.
*/
public interface LocationManipulation {
/**
* Convert a Location into a Colon separated string to allow us to store it in text.
* <p>
* WORLD:X,Y,Z:yaw:pitch
* <p>
* The corresponding String2Loc function is {@link #stringToLocation}
*
* @param location The Location to save.
* @return The location as a string in this format: WORLD:x,y,z:yaw:pitch
*/
String locationToString(Location location);
/**
* This method simply does some rounding, rather than forcing a call to the server to get the blockdata.
*
* @param l The location to round to the block location
* @return A rounded location.
*/
Location getBlockLocation(Location l);
/**
* Returns a new location from a given string. The format is as follows:
* <p>
* WORLD:X,Y,Z:yaw:pitch
* <p>
* The corresponding Location2String function is {@link #stringToLocation}
*
* @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch)
* @return A new location defined by the string or null if the string was invalid.
*/
Location stringToLocation(String locationString);
/**
* Returns a colored string with x, y, z axis.
*
* @param l The {@link Location}
* @return The {@link String}
*/
String strAxis(Location l);
/**
* Returns a colored string with the coords.
*
* @param l The {@link Location}
* @return The {@link String}
*/
String strCoords(Location l);
/**
* Converts a location to a printable readable formatted string including pitch/yaw.
*
* @param l The {@link Location}
* @return The {@link String}
*/
String strCoordsRaw(Location l);
/**
* Return the NESW Direction a Location is facing.
*
* @param location The {@link Location}
* @return The NESW Direction
*/
String getDirection(Location location);
/**
* Returns the float yaw position for the given cardinal direction.
*
* @param orientation The cardinal direction
* @return The yaw
*/
float getYaw(String orientation);
/**
* Returns a speed float from a given vector.
*
* @param v The {@link Vector}
* @return The speed
*/
float getSpeed(Vector v);
/**
* Returns a translated vector from the given direction.
*
* @param v The old {@link Vector}
* @param direction The new direction
* @return The translated {@link Vector}
*/
Vector getTranslatedVector(Vector v, String direction);
/**
* Returns the next Location that a {@link Vehicle} is traveling at.
*
* @param v The {@link Vehicle}
* @return The {@link Location}
*/
Location getNextBlock(Vehicle v);
}
@@ -7,11 +7,17 @@
package com.onarandombox.MultiverseCore.api;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Server;
import java.util.logging.Level;
/** A simple API to require plugins to have a log method. */
/**
* A simple API to require plugins to have a log method.
*
* @deprecated Replaced by {@link Logging}.
* */
@Deprecated
public interface LoggablePlugin {
/**
* Logs a message at the specified level.
@@ -45,7 +45,7 @@ public interface MVDestination {
boolean isThisType(JavaPlugin plugin, String destination);
/**
* Returns the location a specific entity will spawn at.
* Returns the location a specific entity will spawn at when being teleported to this Destination.
* <p>
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
@@ -30,14 +30,14 @@ public interface MVPlugin extends LoggablePlugin {
/**
* Gets the reference to MultiverseCore.
*
* @return A valid {@link MultiverseCore}.
* @return A valid {@link com.onarandombox.MultiverseCore}.
*/
MultiverseCore getCore();
/**
* Sets the reference to MultiverseCore.
*
* @param core A valid {@link MultiverseCore}.
* @param core A valid {@link com.onarandombox.MultiverseCore}.
*/
void setCore(MultiverseCore core);
@@ -7,7 +7,9 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.enums.WorldValidationResult;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
@@ -28,37 +30,65 @@ public interface MVWorldManager {
/**
* Add a new World to the Multiverse Setup.
*
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @param generator The Custom generator plugin to use.
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @param generateStructures If true, this world will get NPC villages.
* @param generator The Custom generator plugin to use.
* @return True if the world is added, false if not.
*/
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator);
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
String generator);
/**
* Add a new World to the Multiverse Setup.
*
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @param generator The Custom generator plugin to use.
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @param generateStructures If true, this world will get NPC villages.
* @param generator The Custom generator plugin to use.
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
* @return True if the world is added, false if not.
*/
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust);
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
String generator, boolean useSpawnAdjust);
/**
* Remove the world from the Multiverse list, from the
* config and deletes the folder.
* Make a copy of a world.
*
* @param name The name of the world to remove
* @param oldName Name of world to be copied
* @param newName Name of world to be created
* @param generator The Custom generator plugin to use. Ignored.
* @return True if the world is copied successfully, false if not.
* @deprecated Use {@link #cloneWorld(String, String)} instead.
*/
@Deprecated
boolean cloneWorld(String oldName, String newName, String generator);
/**
* Make a copy of a world.
*
* @param oldName
* Name of world to be copied
* @param newName
* Name of world to be created
* @return True if the world is copied successfully, false if not.
*/
boolean cloneWorld(String oldName, String newName);
/**
* Remove the world from the Multiverse list, from the config and deletes
* the folder.
*
* @param name
* The name of the world to remove
* @return True if success, false if failure.
*/
boolean deleteWorld(String name);
@@ -74,6 +104,17 @@ public interface MVWorldManager {
*/
boolean deleteWorld(String name, boolean removeConfig);
/**
*
* @param name The name of the world to remove
* @param removeFromConfig If true(default), we'll remove the entries from the
* config. If false, they'll stay and the world may come back.
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
* only the contents of the world folder will be deleted
* @return True if success, false if failure.
*/
boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
/**
* Unload a world from Multiverse.
*
@@ -82,6 +123,15 @@ public interface MVWorldManager {
*/
boolean unloadWorld(String name);
/**
* Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
*
* @param name Name of the world to unload
* @param unloadBukkit True if Bukkit world should be unloaded
* @return True if the world was unloaded, false if not.
*/
boolean unloadWorld(String name, boolean unloadBukkit);
/**
* Loads the world. Only use this if the world has been
* unloaded with {@link #unloadWorld(String)}.
@@ -150,7 +200,7 @@ public interface MVWorldManager {
boolean isMVWorld(World world);
/**
* Load the Worlds & Settings from the configuration file.
* Load the Worlds &amp; Settings from the configuration file.
*
* @param forceLoad If set to true, this will perform a total
* reset and not just load new worlds.
@@ -158,7 +208,7 @@ public interface MVWorldManager {
void loadWorlds(boolean forceLoad);
/**
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
* Loads the Worlds &amp; Settings for any worlds that bukkit loaded before us.
* <p>
* This way people will _always_ have some worlds in the list.
*/
@@ -168,9 +218,21 @@ public interface MVWorldManager {
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
* @deprecated {@link PurgeWorlds} is deprecated!
*/
@Deprecated
PurgeWorlds getWorldPurger();
/**
* Gets the {@link WorldPurger}.
* <p>
* TODO: Remove {@link #getWorldPurger()} and replace it with this method.
* @return The {@link WorldPurger} this {@link MVWorldManager} is using.
* @see WorldPurger
* @see SimpleWorldPurger
*/
WorldPurger getTheWorldPurger();
/**
* Gets the world players will spawn in on first join.
* Currently this always returns worlds.get(0) from Bukkit.
@@ -227,4 +289,46 @@ public interface MVWorldManager {
* @return The {@link MultiverseWorld} new players should spawn in.
*/
MultiverseWorld getFirstSpawnWorld();
/**
* Regenerates a world.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
boolean isKeepingSpawnInMemory(World world);
/**
* Checks whether Multiverse knows about a provided unloaded world. This
* method will check the parameter against the alias mappings.
*
* @param name The name of the unloaded world
* @param includeLoaded The value to return if the world is loaded
*
* @return True if the world exists and is unloaded. False if the world
* does not exist. {@code includeLoaded} if the world exists and is loaded.
*/
boolean hasUnloadedWorld(String name, boolean includeLoaded);
/**
* Check if a world name is a possible importable world folder.
*
* @param worldName Name of the world you want to check.
* @return True if world is valid, false otherwise.
*/
boolean isValidWorld(String worldName);
/**
* Check if a world name is a possible importable world folder.
*
* @param worldName Name of the world you want to check.
* @return WorldValidationResult.VALID if world is valid, else the reason why its not valid.
*/
WorldValidationResult validateWorld(String worldName);
}
@@ -0,0 +1,242 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
/**
* The configuration of MultiverseCore.
*/
public interface MultiverseCoreConfig extends ConfigurationSerializable {
/**
* Sets a property using a {@link String}.
* @param property The name of the property.
* @param value The value.
* @return True on success, false if the operation failed.
*/
boolean setConfigProperty(String property, String value);
/**
* Sets portalCooldown.
* @param portalCooldown The new value.
*/
void setTeleportCooldown(int portalCooldown);
/**
* Gets portalCooldown.
* @return portalCooldown.
*/
int getTeleportCooldown();
/**
* Sets firstSpawnWorld.
* @param firstSpawnWorld The new value.
*/
void setFirstSpawnWorld(String firstSpawnWorld);
/**
* Gets firstSpawnWorld.
* @return firstSpawnWorld.
*/
String getFirstSpawnWorld();
/**
* Sets version.
* @param version The new value.
*/
void setVersion(int version);
/**
* Gets version.
* @return version.
*/
double getVersion();
/**
* Sets messageCooldown.
* @param messageCooldown The new value.
*/
void setMessageCooldown(int messageCooldown);
/**
* Gets messageCooldown.
* @return messageCooldown.
*/
int getMessageCooldown();
/**
* Sets globalDebug.
* @param globalDebug The new value.
*/
void setGlobalDebug(int globalDebug);
/**
* Gets globalDebug.
* @return globalDebug.
*/
int getGlobalDebug();
/**
* Sets displayPermErrors.
* @param displayPermErrors The new value.
*/
void setDisplayPermErrors(boolean displayPermErrors);
/**
* Gets displayPermErrors.
* @return displayPermErrors.
*/
boolean getDisplayPermErrors();
/**
* Sets enableBuscript.
* @param enableBuscript The new value.
*/
void setEnableBuscript(boolean enableBuscript);
/**
* Gets enableBuscript.
* @return enableBuscript.
*/
boolean getEnableBuscript();
/**
* Sets firstSpawnOverride.
* @param firstSpawnOverride The new value.
*/
void setFirstSpawnOverride(boolean firstSpawnOverride);
/**
* Gets firstSpawnOverride.
* @return firstSpawnOverride.
*/
boolean getFirstSpawnOverride();
/**
* Sets teleportIntercept.
* @param teleportIntercept The new value.
*/
void setTeleportIntercept(boolean teleportIntercept);
/**
* Gets teleportIntercept.
* @return teleportIntercept.
*/
boolean getTeleportIntercept();
/**
* Sets prefixChat.
* @param prefixChat The new value.
*/
void setPrefixChat(boolean prefixChat);
/**
* Gets prefixChat.
* @return prefixChat.
*/
boolean getPrefixChat();
/**
* Sets prefixChatFormat.
* @param prefixChatFormat The new value.
*/
void setPrefixChatFormat(String prefixChatFormat);
/**
* Gets prefixChatFormat.
* @return prefixChatFormat.
*/
String getPrefixChatFormat();
/**
* Sets enforceAccess.
* @param enforceAccess The new value.
*/
void setEnforceAccess(boolean enforceAccess);
/**
* Gets enforceAccess.
* @return enforceAccess.
*/
boolean getEnforceAccess();
/**
* Sets useasyncchat.
* @param useAsyncChat The new value.
*/
void setUseAsyncChat(boolean useAsyncChat);
/**
* Gets useasyncchat.
* @return useasyncchat.
*/
boolean getUseAsyncChat();
/**
* Sets whether to suppress startup messages.
*
* @param silentStart true to suppress messages.
*/
void setSilentStart(boolean silentStart);
/**
* Whether we are suppressing startup messages.
*
* @return true if we are suppressing startup messages.
*/
boolean getSilentStart();
/**
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
*
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
*/
void setUseDefaultPortalSearch(boolean useDefaultPortalSearch);
/**
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
*
* @return True means Bukkit will use its own default values.
*/
boolean isUsingDefaultPortalSearch();
/**
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
*
* @param searchRadius The portal search radius.
*/
void setPortalSearchRadius(int searchRadius);
/**
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
*
* @return The portal search radius.
*/
int getPortalSearchRadius();
/**
* Gets whether or not the automatic purge of entities is enabled.
*
* @return True if automatic purge is enabled.
*/
boolean isAutoPurgeEnabled();
/**
* Sets whether or not the automatic purge of entities is enabled.
*
* @param autopurge True if automatic purge should be enabled.
*/
void setAutoPurgeEnabled(boolean autopurge);
/**
* Gets whether or not the donation/patreon messages are shown.
*
* @return True if donation/patreon messages should be shown.
*/
boolean isShowingDonateMessage();
/**
* Sets whether or not the donation/patreon messages are shown.
*
* @param idonotwanttodonate True if donation/patreon messages should be shown.
*/
void setShowDonateMessage(boolean idonotwanttodonate);
}
@@ -0,0 +1,56 @@
package com.onarandombox.MultiverseCore.api;
import java.util.Collection;
import org.bukkit.command.CommandSender;
/**
* Multiverse-messaging.
*/
public interface MultiverseMessaging {
/**
* Sets the message-cooldown.
* @param milliseconds The new message-cooldown in milliseconds.
*/
void setCooldown(int milliseconds);
/**
* Sends a message to the specified sender if the cooldown has passed.
*
* @param sender The person/console to send the message to.
* @param message The message to send.
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
* @return true if the message was sent, false if not.
*/
boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown);
/**
* Sends a group of messages to the specified sender if the cooldown has passed.
* This method is needed, since sending many messages in quick succession would violate
* the cooldown.
*
* @param sender The person/console to send the message to.
* @param messages The messages to send.
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
* @return true if the message was sent, false if not.
*/
boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown);
/**
* Sends a group of messages to the specified sender if the cooldown has passed.
* This method is needed, since sending many messages in quick succession would violate
* the cooldown.
*
* @param sender The person/console to send the message to.
* @param messages The messages to send.
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
* @return true if the message was sent, false if not.
*/
boolean sendMessages(CommandSender sender, Collection<String> messages, boolean ignoreCooldown);
/**
* Gets the message-cooldown.
* @return The message-cooldown.
*/
int getCooldown();
}
@@ -0,0 +1,136 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
/**
* Make things easier for MV-Plugins!
*/
public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
private MultiverseCore core;
/**
* Prefix for standard log entrys.
*/
protected String logTag;
private DebugLog debugLog;
/**
* {@inheritDoc}
*
* Note: You can't override this, use {@link #onPluginEnable()} instead!
* @see #onPluginEnable()
*/
@Override
public final void onEnable() {
MultiverseCore theCore = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
if (theCore == null) {
this.getLogger().severe("Core not found! The plugin dev needs to add a dependency!");
this.getLogger().severe("Disabling!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
if (theCore.getProtocolVersion() < this.getProtocolVersion()) {
this.getLogger().severe("You need a newer version of Multiverse-Core!");
this.getLogger().severe("Disabling!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.setCore(theCore);
this.getServer().getLogger().info(String.format("%s - Version %s enabled - By %s",
this.getDescription().getName(), this.getDescription().getVersion(), getAuthors()));
getDataFolder().mkdirs();
File debugLogFile = new File(getDataFolder(), "debug.log");
try {
debugLogFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
debugLog = new DebugLog(this.getDescription().getName(), getDataFolder() + File.separator + "debug.log");
debugLog.setTag(String.format("[%s-Debug]", this.getDescription().getName()));
this.onPluginEnable();
}
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return The readable authors-{@link String}
*/
protected String getAuthors() {
String authors = "";
List<String> auths = this.getDescription().getAuthors();
if (auths.size() == 0) {
return "";
}
if (auths.size() == 1) {
return auths.get(0);
}
for (int i = 0; i < auths.size(); i++) {
if (i == this.getDescription().getAuthors().size() - 1) {
authors += " and " + this.getDescription().getAuthors().get(i);
} else {
authors += ", " + this.getDescription().getAuthors().get(i);
}
}
return authors.substring(2);
}
/**
* Called when the plugin is enabled.
* @see #onEnable()
*/
protected abstract void onPluginEnable();
@Override
public void log(Level level, String msg) {
int debugLevel = this.getCore().getMVConfig().getGlobalDebug();
if ((level == Level.FINE && debugLevel >= 1) || (level == Level.FINER && debugLevel >= 2)
|| (level == Level.FINEST && debugLevel >= 3)) {
debugLog.log(level, msg);
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
String message = new StringBuilder(getLogTag()).append(msg).toString();
this.getServer().getLogger().log(level, message);
debugLog.log(level, message);
}
}
private String getLogTag() {
if (logTag == null)
logTag = String.format("[%s]", this.getDescription().getName());
return logTag;
}
/**
* Sets the debug log-tag.
* @param tag The new tag.
*/
protected final void setDebugLogTag(String tag) {
this.debugLog.setTag(tag);
}
@Override
public final String dumpVersionInfo(String buffer) {
throw new UnsupportedOperationException("This is gone.");
}
@Override
public final MultiverseCore getCore() {
if (this.core == null)
throw new IllegalStateException("Core is null!");
return this.core;
}
@Override
public final void setCore(MultiverseCore core) {
this.core = core;
}
}
@@ -7,25 +7,25 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.List;
/**
* The API for a Multiverse Handled World.
*/
public interface MultiverseWorld {
/**
* Returns the Bukkit world object that this world describes.
*
@@ -34,79 +34,24 @@ public interface MultiverseWorld {
World getCBWorld();
/**
* Adds the property to the given value.
* It will throw a PropertyDoesNotExistException if the property is not found.
* Gets the name of this world. The name cannot be changed.
* <p>
* Note for plugin developers: Usually {@link #getAlias()}
* is what you want to use instead of this method.
*
* @param property The name of a world property to set.
* @param value A value in string representation, it will be parsed to the correct type.
* @param sender The sender who wants this value to be set.
* @return True if the value was set, false if not.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
* @return The name of the world as a String.
*/
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
String getName();
/**
* Gets the actual MVConfigProperty from this world.
* It will throw a PropertyDoesNotExistException if the property is not found.
* Gets the type of this world. As of 1.2 this will be:
* FLAT, NORMAL or VERSION_1_1
* <p>
* This is <b>not</b> the generator.
*
* @param property The name of a world property to get.
* @return A valid MVWorldProperty.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
* @deprecated Use {@link #getProperty(String, Class)} instead
* @return The Type of this world.
*/
@Deprecated
MVConfigProperty<?> getProperty(String property) throws PropertyDoesNotExistException;
/**
* Gets the string representation of a property.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @return A valid MVWorldProperty.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
String getPropertyValue(String property) throws PropertyDoesNotExistException;
/**
* Gets the actual MVConfigProperty from this world.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
* @param <T> The type of the expected property.
*
* @return A valid MVWorldProperty.
*
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
<T> MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
/**
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
* @return True if it was cleared, false if not.
*/
boolean clearVariable(String property);
/**
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was added, false if not.
*/
boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
* from.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was removed, false if not.
*/
boolean removeFromVariable(String property, String value);
WorldType getWorldType();
/**
* Gets the environment of this world.
@@ -124,27 +69,137 @@ public interface MultiverseWorld {
*/
void setEnvironment(World.Environment environment);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
Difficulty getDifficulty();
/**
* Sets the difficulty of this world and returns true if success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. {@code PEACEFUL}
*
* @param difficulty The difficulty to set the world to as a string.
* @return True if success, false if the provided string
* could not be translated to a difficulty.
* @deprecated Use {@link #setDifficulty(Difficulty)} or, if you have to
* pass a string, use {@link #setPropertyValue(String, String)} instead.
*/
@Deprecated
boolean setDifficulty(String difficulty);
/**
* Sets the difficulty of this world and returns {@code true} on success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. PEACEFUL
*
* @param difficulty The new difficulty.
* @return True if success, false if the operation failed... for whatever reason.
*/
boolean setDifficulty(Difficulty difficulty);
/**
* Gets the world seed of this world.
*
* @return The Long version of the seed.
*/
Long getSeed();
long getSeed();
/**
* Sets the seed of this world.
*
* @param seed A Long that is the seed.
*/
void setSeed(Long seed);
void setSeed(long seed);
/**
* Gets the name of this world. This cannot be changed.
* Gets the generator of this world.
*
* @return The name of the world as a String.
* @return The name of the generator.
*/
String getName();
String getGenerator();
/**
* Sets the generator of this world.
*
* @param generator The new generator's name.
*/
void setGenerator(String generator);
/**
* Gets the help-message for a property.
* @param property The name of the property.
* @return The help-message.
* @throws PropertyDoesNotExistException Thrown if the property was not found.
*/
String getPropertyHelp(String property) throws PropertyDoesNotExistException;
/**
* Gets a property as {@link String}.
*
* @param property The name of a world property to get.
* @return The string-representation of that property.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
String getPropertyValue(String property) throws PropertyDoesNotExistException;
/**
* Sets a property to a given value.
*
* @param property The name of a world property to set.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was set, false if not.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
/**
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was added, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
* from.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was removed, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean removeFromVariable(String property, String value);
/**
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
* @return True if it was cleared, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean clearVariable(String property);
/**
* Clears a list property (sets it to []).
*
* @param property The property to clear.
* @return True if success, false if fail.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean clearList(String property);
// end of old config stuff
// permission stuff
/**
* Gets the lowercased name of the world. This method is required, since the permissables
* lowercase all permissions when recalculating.
@@ -157,6 +212,21 @@ public interface MultiverseWorld {
*/
String getPermissibleName();
/**
* Gets the permission required to enter this world.
*
* @return The permission required to be exempt from charges to/from this world.
*/
Permission getAccessPermission();
/**
* Gets the permission required to be exempt when entering.
*
* @return The permission required to be exempt when entering.
*/
Permission getExemptPermission();
// end of permission stuff
/**
* Gets the alias of this world.
* <p>
@@ -173,6 +243,13 @@ public interface MultiverseWorld {
*/
void setAlias(String alias);
/**
* Gets the color that this world's name/alias will display as.
*
* @return The color of this world.
*/
ChatColor getColor();
/**
* Sets the color that this world's name/alias will display as.
*
@@ -182,18 +259,29 @@ public interface MultiverseWorld {
boolean setColor(String color);
/**
* Gets the color that this world's name/alias will display as.
* Gets the style that this world's name/alias will display as.
*
* @return The color of this world.
* @return The style of this world. {@code null} for "normal" style.
*/
ChatColor getColor();
ChatColor getStyle();
/**
* Sets the style that this world's name/alias will display as.
*
* @param style A valid style name.
* @return True if the style was set, false if not.
*/
boolean setStyle(String style);
/**
* Tells you if someone entered a valid color.
*
* @param color A string that may translate to a color.
* @return True if it is a color, false if not.
*
* @deprecated This has been moved: {@link com.onarandombox.MultiverseCore.enums.EnglishChatColor#isValidAliasColor(String)}
*/
@Deprecated
boolean isValidAliasColor(String color);
/**
@@ -203,6 +291,7 @@ public interface MultiverseWorld {
*/
String getColoredWorldString();
// animals&monster stuff
/**
* Gets whether or not animals are allowed to spawn in this world.
*
@@ -210,6 +299,22 @@ public interface MultiverseWorld {
*/
boolean canAnimalsSpawn();
/**
* Sets whether or not animals can spawn.
* If there are values in {@link #getAnimalList()} and this is false,
* those animals become the exceptions, and will spawn
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
/**
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
*
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
*/
List<String> getAnimalList();
/**
* Gets whether or not monsters are allowed to spawn in this world.
*
@@ -218,7 +323,31 @@ public interface MultiverseWorld {
boolean canMonstersSpawn();
/**
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
* Sets whether or not monsters can spawn.
* If there are values in {@link #getMonsterList()} and this is false,
* those monsters become the exceptions, and will spawn
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
*
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
*/
List<String> getMonsterList();
// end of animal&monster stuff
/**
* Gets whether or not PVP is enabled in this world in some form (fake or not).
*
* @return True if players can take damage from other players.
*/
boolean isPVPEnabled();
/**
* Turn pvp on or off. This setting is used to set the world's PVP mode.
*
* @param pvpMode True to enable PVP damage, false to disable it.
*/
@@ -233,13 +362,6 @@ public interface MultiverseWorld {
@Deprecated
boolean getFakePVP();
/**
* Gets whether or not PVP is enabled in this world in some form (fake or not).
*
* @return True if players can take damage from other players.
*/
boolean isPVPEnabled();
/**
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
* access permissions to go to this world.
@@ -256,6 +378,13 @@ public interface MultiverseWorld {
*/
void setHidden(boolean hidden);
/**
* Gets whether weather is enabled in this world.
*
* @return True if weather events will occur, false if not.
*/
boolean isWeatherEnabled();
/**
* Sets whether or not there will be weather events in a given world.
* If set to false, Multiverse will disable the weather in the world immediately.
@@ -265,11 +394,11 @@ public interface MultiverseWorld {
void setEnableWeather(boolean enableWeather);
/**
* Gets whether weather is enabled in this world.
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
*
* @return True if weather events will occur, false if not.
* @return True if CraftBukkit is keeping spawn chunks in memory.
*/
boolean isWeatherEnabled();
boolean isKeepingSpawnInMemory();
/**
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
@@ -281,29 +410,11 @@ public interface MultiverseWorld {
void setKeepSpawnInMemory(boolean keepSpawnInMemory);
/**
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
* Gets the spawn location of this world.
*
* @return True if CraftBukkit is keeping spawn chunks in memory.
* @return The spawn location of this world.
*/
boolean isKeepingSpawnInMemory();
/**
* Sets the difficulty of this world and returns true if success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. PEACEFUL
*
* @param difficulty The difficulty to set the world to as a string.
* @return True if success, false if the provided string
* could not be translated to a difficulty.
*/
boolean setDifficulty(String difficulty);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
Difficulty getDifficulty();
Location getSpawnLocation();
/**
* Sets the spawn location for a world.
@@ -313,11 +424,11 @@ public interface MultiverseWorld {
void setSpawnLocation(Location spawnLocation);
/**
* Gets the spawn location of this world.
* Gets whether or not the hunger level of players will go down in a world.
*
* @return The spawn location of this world.
* @return True if it will go down, false if it will remain steady.
*/
Location getSpawnLocation();
boolean getHunger();
/**
* Sets whether or not the hunger level of players will go down in a world.
@@ -327,22 +438,6 @@ public interface MultiverseWorld {
*/
void setHunger(boolean hungerEnabled);
/**
* Gets whether or not the hunger level of players will go down in a world.
*
* @return True if it will go down, false if it will remain steady.
*/
boolean getHunger();
/**
* Sets the game mode of this world.
*
* @param gameMode A valid game mode string (either
* an int ex. 0 or a string ex. creative).
* @return True if the game mode was successfully changed, false if not.
*/
boolean setGameMode(String gameMode);
/**
* Gets the GameMode of this world.
*
@@ -351,27 +446,24 @@ public interface MultiverseWorld {
GameMode getGameMode();
/**
* Gets the permission required to enter this world.
* Sets the game mode of this world.
*
* @return The permission required to be exempt from charges to/from this world.
* @param gameMode A valid game mode string (either
* an int ex. 0 or a string ex. creative).
* @return True if the game mode was successfully changed, false if not.
* @deprecated Use {@link #setGameMode(GameMode)} instead. If you have to
* pass a string, use {@link #setPropertyValue(String, String)}.
*/
Permission getAccessPermission();
@Deprecated
boolean setGameMode(String gameMode);
/**
* Gets the permission required to be exempt when entering.
* Sets the game mode of this world.
*
* @return The permission required to be exempt when entering.
* @param gameMode The new {@link GameMode}.
* @return True if the game mode was successfully changed, false if not.
*/
Permission getExemptPermission();
/**
* Sets the price for entry to this world.
* You can think of this like an amount.
* The type can be set with {@link #setCurrency(int)}
*
* @param price The Amount of money/item to enter the world.
*/
void setPrice(double price);
boolean setGameMode(GameMode gameMode);
/**
* Gets the amount of currency it requires to enter this world.
@@ -380,20 +472,38 @@ public interface MultiverseWorld {
*/
double getPrice();
/**
* Sets the price for entry to this world.
* You can think of this like an amount.
* The type can be set with {@link #setCurrency(Material)}
*
* @param price The Amount of money/item to enter the world.
*/
void setPrice(double price);
/**
* Gets the type of currency that will be used when users enter this world. A value of null indicates a non-item
* based currency is used.
*
* @return The type of currency that will be used when users enter this world.
*/
@Nullable
Material getCurrency();
/**
* Sets the type of item that will be required given the price is not 0.
* Use -1 to use an AllPay economy, or any valid itemid
* Use a value of null to specify a non-item based currency.
*
* @param item The Type of currency that will be used when users enter this world.
*/
void setCurrency(int item);
void setCurrency(@Nullable Material item);
/**
* Gets the Type of currency that will be used when users enter this world.
* Gets the world players will respawn in if they die in this one.
*
* @return The Type of currency that will be used when users enter this world.
* @return A world that exists on the server.
*/
int getCurrency();
World getRespawnToWorld();
/**
* Sets the world players will respawn in if they die in this one.
@@ -405,11 +515,12 @@ public interface MultiverseWorld {
boolean setRespawnToWorld(String respawnWorld);
/**
* Gets the world players will respawn in if they die in this one.
* Gets the scaling value of this world.Really only has an effect if you use
* Multiverse-NetherPortals.
*
* @return A world that exists on the server.
* @return This world's non-negative, non-zero scale.
*/
World getRespawnToWorld();
double getScaling();
/**
* Sets the scale of this world. Really only has an effect if you use
@@ -421,60 +532,11 @@ public interface MultiverseWorld {
boolean setScaling(double scaling);
/**
* Gets the scaling value of this world.Really only has an effect if you use
* Multiverse-NetherPortals.
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
*
* @return This world's non-negative, non-zero scale.
* @return True if the world should heal (default), false if not.
*/
double getScaling();
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
* regardless of their access permissions.
*
* @return A List of world names.
*/
List<String> getWorldBlacklist();
/**
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
*
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
*/
List<String> getAnimalList();
/**
* Sets whether or not animals can spawn.
* If there are values in {@link #getAnimalList()} and this is false,
* those animals become the exceptions, and will spawn
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
/**
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} ()} result.
*
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
*/
List<String> getMonsterList();
/**
* Sets whether or not monsters can spawn.
* If there are values in {@link #getMonsterList()} and this is false,
* those monsters become the exceptions, and will spawn
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* Clears a list property (sets it to []).
*
* @param property The property to clear.
* @return True if success, false if fail.
*/
boolean clearList(String property);
boolean getAutoHeal();
/**
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
@@ -484,11 +546,11 @@ public interface MultiverseWorld {
void setAutoHeal(boolean heal);
/**
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
*
* @return True if the world should heal (default), false if not.
* @return True if Multiverse should adjust the spawn, false if not.
*/
boolean getAutoHeal();
boolean getAdjustSpawn();
/**
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
@@ -498,11 +560,11 @@ public interface MultiverseWorld {
void setAdjustSpawn(boolean adjust);
/**
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
* Gets whether or not Multiverse should auto-load this world.
*
* @return True if Multiverse should adjust the spawn, false if not.
* @return True if Multiverse should auto-load this world.
*/
boolean getAdjustSpawn();
boolean getAutoLoad();
/**
* Sets whether or not Multiverse should auto-load this world.
@@ -514,11 +576,12 @@ public interface MultiverseWorld {
void setAutoLoad(boolean autoLoad);
/**
* Gets whether or not Multiverse should auto-load this world.
* Gets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
*
* @return True if Multiverse should auto-load this world.
* @return True if players dying in this world should respawn at their bed.
*/
boolean getAutoLoad();
boolean getBedRespawn();
/**
* Sets whether or not a player who dies in this world will respawn in their
@@ -531,19 +594,26 @@ public interface MultiverseWorld {
void setBedRespawn(boolean autoLoad);
/**
* Gets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
* Sets the player limit for this world after which players without an override
* permission node will not be allowed in. A value of -1 or less signifies no limit
*
* @return True if players dying in this world should respawn at their bed.
* @param limit The new limit
*/
boolean getBedRespawn();
void setPlayerLimit(int limit);
/**
* Gets all the names of all properties that can be SET.
* Gets the player limit for this world after which players without an override
* permission node will not be allowed in. A value of -1 or less signifies no limit
*
* @return All property names, with alternating colors.
* @return The player limit
*/
String getAllPropertyNames();
int getPlayerLimit();
/**
* Same as {@link #getTime()}, but returns a string.
* @return The time as a short string: 12:34pm
*/
String getTime();
/**
* Sets the current time in a world.
@@ -559,18 +629,53 @@ public interface MultiverseWorld {
boolean setTime(String timeAsString);
/**
* Same as {@link #getTime()}, but returns a string.
* @return The time as a short string: 12:34pm
* Sets The types of portals that are allowed in this world.
*
* @param type The type of portals allowed in this world.
*/
String getTime();
void allowPortalMaking(AllowedPortalType type);
/**
* Gets the type of this world. As of 1.1-R1 this will be:
* FLAT or NORMAL
* <p>
* This is *not* the generator.
* Gets which type(s) of portals are allowed to be constructed in this world.
*
* @return The Type of this world.
* @return The type of portals that are allowed.
*/
WorldType getWorldType();
AllowedPortalType getAllowedPortals();
// properties that are not "getter+setter" style
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
* regardless of their access permissions.
*
* @return A List of world names.
*/
List<String> getWorldBlacklist();
/**
* Gets all the names of all properties that can be SET.
*
* @return All property names in list.
*/
Collection<String> getAllPropertyTypes();
/**
* Gets all the names of all properties that can be SET.
*
* @return All property names, with alternating colors.
*/
String getAllPropertyNames();
/**
* Whether or not players are allowed to fly in this world.
*
* @return True if players allowed to fly in this world.
*/
boolean getAllowFlight();
/**
* Sets whether or not players are allowed to fly in this world.
*
* @param allowFlight True to allow flight in this world.
*/
void setAllowFlight(final boolean allowFlight);
}
@@ -0,0 +1,13 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.command.CommandSender;
import java.util.List;
public interface PermissionsInterface {
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired);
public boolean hasAnyPermission(CommandSender sender, List<String> allPermissionStrings, boolean opRequired);
public boolean hasAllPermission(CommandSender sender, List<String> allPermissionStrings, boolean opRequired);
}
@@ -0,0 +1,71 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
/**
* Used to safely teleport people.
*/
public interface SafeTTeleporter extends Teleporter {
/**
* Gets the next safe location around the given location.
* @param l A {@link Location}.
* @return A safe {@link Location}.
*/
Location getSafeLocation(Location l);
/**
* Gets the next safe location around the given location.
* @param l A {@link Location}.
* @param tolerance The tolerance.
* @param radius The radius.
* @return A safe {@link Location}.
*/
Location getSafeLocation(Location l, int tolerance, int radius);
/**
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param teleporter Person who performed the teleport command.
* @param teleportee Entity to teleport
* @param d Destination to teleport them to
* @return true for success, false for failure
*/
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d);
/**
* Safely teleport the entity to the Location. This may perform checks to
* see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param teleporter Person who issued the teleport command.
* @param teleportee Entity to teleport.
* @param location Location to teleport them to.
* @param safely Should the destination be checked for safety before teleport?
* @return true for success, false for failure.
*/
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location,
boolean safely);
/**
* Returns a safe location for the entity to spawn at.
*
* @param e The entity to spawn
* @param d The MVDestination to take the entity to.
* @return A new location to spawn the entity at.
*/
Location getSafeLocation(Entity e, MVDestination d);
/**
* Finds a portal-block next to the specified {@link Location}.
* @param l The {@link Location}
* @return The next portal-block's {@link Location}.
*/
Location findPortalBlockNextTo(Location l);
}
@@ -0,0 +1,10 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public interface Teleporter {
TeleportResult teleport(CommandSender teleporter, Player teleportee, MVDestination destination);
}
@@ -0,0 +1,68 @@
package com.onarandombox.MultiverseCore.api;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
/**
* Used to remove animals from worlds that don't belong there.
*/
public interface WorldPurger {
/**
* Synchronizes the given worlds with their settings.
*
* @param worlds A list of {@link MultiverseWorld}
*/
void purgeWorlds(List<MultiverseWorld> worlds);
/**
* Convenience method for {@link #purgeWorld(MultiverseWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
*
* @param world The {@link MultiverseWorld}.
*/
void purgeWorld(MultiverseWorld world);
/**
* Clear all animals/monsters that do not belong to a world according to the config.
*
* @param mvworld The {@link MultiverseWorld}.
* @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
*/
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters);
/**
* Clear all animals/monsters that do not belong to a world according to the config.
*
* @param mvworld The {@link MultiverseWorld}.
* @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
* @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
*/
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, CommandSender sender);
/**
* Determines whether the specified creature should be killed.
*
* @param e The creature.
* @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters);
/**
* Determines whether the specified creature should be killed and automatically reads the params from a world object.
*
* @param w The world.
* @param e The creature.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e);
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,132 +7,127 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* Allows management of Anchor Destinations.
*/
public class AnchorCommand extends PaginatedCoreCommand<String> {
@CommandAlias("mv")
@Subcommand("anchors")
public class AnchorCommand extends MultiverseCoreCommand {
private final AnchorManager anchorManager;
public AnchorCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create, Delete and Manage Anchor Destinations.");
this.setCommandUsage("/mv anchor " + ChatColor.GREEN + "{name}" + ChatColor.GOLD + " [-d]");
this.setArgRange(0, 2);
this.addKey("mv anchor");
this.addKey("mv anchors");
this.addKey("mvanchor");
this.addKey("mvanchors");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
this.addCommandExample("/mv anchors ");
this.setPermission("multiverse.core.anchor", "Allows management of Anchor Destinations.", PermissionDefault.OP);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.anchorManager = plugin.getAnchorManager();
}
private List<String> getFancyAnchorList(Player p) {
List<String> anchorList = new ArrayList<String>();
ChatColor color = ChatColor.GREEN;
for (String anchor : this.plugin.getAnchorManager().getAnchors(p)) {
anchorList.add(color + anchor);
color = (color == ChatColor.GREEN) ? ChatColor.GOLD : ChatColor.GREEN;
}
return anchorList;
}
@Subcommand("create")
@CommandPermission("multiverse.core.anchor.create")
@Syntax("<name>")
@Description("Create a new anchor point.")
public void onCreateAnchorCommand(@NotNull Player player,
private void showList(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
@NotNull
@Syntax("<name>")
@Description("Name of your new anchor.")
@Flags("type=anchor name")
@Single String anchorName) {
player.sendMessage((this.plugin.getAnchorManager().saveAnchorLocation(anchorName, player.getLocation()))
FilterObject filterObject = this.getPageAndFilter(args);
? String.format("Anchor '%s%s%s' was successfully %s created!",
ChatColor.AQUA, anchorName, ChatColor.WHITE, ChatColor.GREEN)
List<String> availableAnchors = new ArrayList<String>(this.getFancyAnchorList(p));
if (filterObject.getFilter().length() > 0) {
availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
if (availableAnchors.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
} else {
if (availableAnchors.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors were defined.");
return;
}
}
if (!(sender instanceof Player)) {
for (String c : availableAnchors) {
sender.sendMessage(c);
}
return;
}
int totalPages = (int) Math.ceil(availableAnchors.size() / (this.itemsPerPage + 0.0));
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
this.showPage(filterObject.getPage(), sender, availableAnchors);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 0) {
this.showList(sender, args);
return;
}
if (args.size() == 2) {
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
}
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("You must be a player to create Anchors.");
return;
}
Player player = (Player) sender;
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
}
: String.format("%sThere was an error creating anchor '%s'! Check console for errors.",
ChatColor.RED, anchorName));
}
@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;
@Subcommand("delete")
@CommandPermission("multiverse.core.anchor.delete")
@Syntax("<anchor>")
@CommandCompletion("@anchors")
@Description("Delete an existing anchor point.")
public void onDeleteAnchorCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<name>")
@Description("Name of anchor you want to delete.")
@Flags("type=anchor name")
@Single String anchorName) {
sender.sendMessage((this.plugin.getAnchorManager().deleteAnchor(anchorName))
? String.format("Anchor '%s%s%s' was successfully %s deleted!",
ChatColor.AQUA, anchorName, ChatColor.WHITE, ChatColor.RED)
: String.format("%sThere was an error deleting anchor '%s'! Check console for errors.",
ChatColor.RED, anchorName));
}
@Override
protected String getItemText(String item) {
return item;
@Subcommand("list")
@CommandPermission("multiverse.core.anchor.list")
@Syntax("[filter] [page]")
@Description("View a list of current anchors.")
public void onListAnchorCommand(@NotNull CommandSender sender,
@NotNull PageFilter pageFilter) {
new ContentDisplay.Builder<Collection<String>>()
.sender(sender)
.header("%s====[ Multiverse Anchor List ]====", ChatColor.LIGHT_PURPLE)
.contents(buildAnchorList(sender))
.emptyMessage("You do not any anchors set. See /mv anchors create to get started!")
.displayHandler(DisplayHandlers.PAGE_LIST)
.colorTool(ColorAlternator.with(ChatColor.YELLOW, ChatColor.DARK_AQUA))
.setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
.display();
}
private List<String> buildAnchorList(@NotNull CommandSender sender) {
Set<String> anchors = (sender instanceof Player)
? this.anchorManager.getAnchors((Player) sender)
: this.anchorManager.getAllAnchors();
List<String> anchorContent = new ArrayList<>();
for (String anchor : anchors) {
Location anchorLocation = this.anchorManager.getAnchorLocation(anchor);
World world = anchorLocation.getWorld(); // this.plugin.getMVWorldManager().getMVWorld();
String locationString = ChatColor.RED + "!!INVALID!!";
if (world != null) {
MultiverseWorld mvWorld = this.plugin.getMVWorldManager().getMVWorld(world);
locationString = (mvWorld == null)
? String.format("%s%s !!NOT MULTIVERSE WORLD!!", ChatColor.RED, world.getName())
: String.format("%s - %s", mvWorld.getColoredWorldString(), this.plugin.getLocationManipulation().strAxis(anchorLocation));
}
anchorContent.add(String.format("%s: %s", anchor, locationString));
}
return anchorContent;
}
}
@@ -0,0 +1,64 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@CommandAlias("mv")
public class BedCommand extends MultiverseCoreCommand {
public BedCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("bed")
@CommandPermission("multiverse.core.bed.self")
@Description("Takes your current respawn point.")
public void onBedCommand(@NotNull Player player) {
doBedRespawn(player, player);
}
@Subcommand("bed")
@CommandPermission("multiverse.core.bed.other")
@Syntax("[player]")
@CommandCompletion("@players")
@Description("Takes another player to their respawn location.")
public void onOtherBedCommand(@NotNull CommandSender sender,
@Syntax("[player]")
@Description("Target player to teleport to respawn location.")
@NotNull RequiredPlayer player) {
doBedRespawn(sender, player.get());
}
private void doBedRespawn(@NotNull CommandSender sender,
@NotNull Player player) {
Location bedLocation = player.getBedSpawnLocation();
if (bedLocation == null) {
sender.sendMessage(String.format("%sYou do not have a respawn point set!", ChatColor.RED));
return;
}
sender.sendMessage((player.teleport(bedLocation))
? "You have been teleported to your respawn point!"
: String.format("%sThere was an error teleporting you to your respawn point.", ChatColor.RED));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,56 +7,42 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import org.bukkit.ChatColor;
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Checks to see if a player can go to a destination.
*/
public class CheckCommand extends MultiverseCommand {
@CommandAlias("mv")
public class CheckCommand extends MultiverseCoreCommand {
public CheckCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Help you validate your multiverse settings");
this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}");
this.setArgRange(2, 2);
this.addKey("mv check");
this.addKey("mvcheck");
this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld");
this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = this.plugin.getServer().getPlayer(args.get(0));
if (p == null) {
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
sender.sendMessage("Are they online?");
return;
}
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
if (dest instanceof InvalidDestination) {
sender.sendMessage("You asked if '" + args.get(0) + "' could go to " + ChatColor.GREEN + args.get(0) + ChatColor.WHITE + ",");
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
return;
}
@Subcommand("check")
@CommandPermission("multiverse.core.debug")
@Syntax("<player> <destination>")
@CommandCompletion("@players @destinations|@MVWorlds")
@Description("Checks to see if a player can go to a destination. Prints debug if false.")
public void onCheckCommand(@NotNull CommandSender sender,
MVPermissions perms = this.plugin.getMVPerms();
if (perms.canEnterDestination(p, dest)) {
sender.sendMessage(ChatColor.GREEN + args.get(0) + ChatColor.WHITE + " can travel to " + ChatColor.GREEN + args.get(1));
} else {
sender.sendMessage(ChatColor.AQUA + args.get(0) + ChatColor.RED + " CANNOT travel to " + ChatColor.AQUA + args.get(1));
sender.sendMessage("Please turn debug mode to 3 then watch the console to find out why!");
sender.sendMessage("Use: " + ChatColor.GREEN + "/mv debug 3");
}
@NotNull
@Syntax("<player>")
@Description("Player to check destination on.")
RequiredPlayer player,
@NotNull
@Syntax("<destination>")
@Description("A destination location, e.g. a world name.")
MVDestination destination) {
this.plugin.getMVPerms().tellMeWhyICantDoThis(sender, player.get(), destination);
}
}
@@ -0,0 +1,52 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@CommandAlias("mv")
public class CloneCommand extends MultiverseCoreCommand {
public CloneCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("clone")
@CommandPermission("multiverse.core.clone")
@Syntax("<world> <name>")
@CommandCompletion("@MVWorlds|@unloadedWorlds @empty")
@Description("Clones a world.")
public void onCloneCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<world>")
@Description("Current multiverse world.")
@Conditions("isWorldInConfig") String worldName,
@NotNull
@Syntax("<name>")
@Description("New cloned world name.")
@Single @Flags("trim") @Conditions("creatableWorldName") String newWorldName) {
sender.sendMessage((this.plugin.getMVWorldManager().cloneWorld(worldName, newWorldName))
? String.format("%sWorld cloned!", ChatColor.GREEN)
: String.format("%sWorld could not be cloned! See console for more details.", ChatColor.RED));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,91 +7,88 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import co.aikar.commands.annotation.Values;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
@CommandAlias("mv")
@Subcommand("config")
@CommandPermission("multiverse.core.config")
public class ConfigCommand extends MultiverseCoreCommand {
/**
* Allows you to set Global MV Variables.
*/
public class ConfigCommand extends MultiverseCommand {
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Configuration");
this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
this.setArgRange(1, 2);
this.addKey("mv config");
this.addKey("mvconfig");
this.addKey("mv conf");
this.addKey("mvconf");
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
this.addCommandExample("/mv config show");
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() <= 1) {
String[] allProps = ConfigProperty.getAllValues().split(" ");
String currentvals = "";
for (String prop : allProps) {
currentvals += ChatColor.GREEN;
currentvals += prop;
currentvals += ChatColor.WHITE;
currentvals += " = ";
currentvals += ChatColor.GOLD;
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
currentvals += ChatColor.WHITE;
currentvals += ", ";
}
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
@Subcommand("list")
@Syntax("[filter]")
@Description("Show multiverse config values.")
public void onShowCommand(@NotNull CommandSender sender,
@NotNull ContentFilter filter) {
new ContentDisplay.Builder<Map<String, Object>>()
.sender(sender)
.header("%s===[ Multiverse Config ]===", ChatColor.LIGHT_PURPLE)
.contents(this.plugin.getMVConfig().serialize())
.emptyMessage("No config values found.")
.displayHandler(DisplayHandlers.INLINE_MAP)
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
.filter(filter)
.display();
}
@Subcommand("set")
@Syntax("<property> <value>")
@CommandCompletion("@MVConfigs")
@Description("Set Global MV Variables.")
public void onSetCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<property>")
@Description("Config option.")
@Values("@MVConfigs") String property,
@NotNull
@Syntax("<value>")
@Description("New value for the given config option.")
@Single String value) {
property = property.toLowerCase();
if (!this.plugin.getMVConfig().setConfigProperty(property, value)) {
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, property, value));
return;
}
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
// Don't forget to set the world!
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
} else if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown")
|| args.get(0).equalsIgnoreCase("debug")) {
try {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
return;
}
} else {
ConfigProperty property = null;
try {
property = ConfigProperty.valueOf(args.get(0).toLowerCase());
} catch (IllegalArgumentException e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA
+ args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
sender.sendMessage(ChatColor.GREEN + "Valid values are:");
sender.sendMessage(ConfigProperty.getAllValues());
return;
}
if (property != null) {
try {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(1)));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
return;
}
if (!this.plugin.saveMVConfigs()) {
sender.sendMessage(String.format("%sFailed to save config! Check your console for details.", ChatColor.RED));
return;
}
}
}
if (this.plugin.saveMVConfigs()) {
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
this.plugin.loadConfigs();
} else {
sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!");
// special rule, don't forget to set the world!
//TODO API: Potentially should move to MultiverseCore#loadConfigs method
if (property.equalsIgnoreCase("firstspawnworld")) {
this.plugin.getMVWorldManager().setFirstSpawnWorld(value);
}
sender.sendMessage(String.format("%sSuccess! %sConfig option %s%s %sis now set to %s%s%s.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, property, ChatColor.WHITE, ChatColor.GREEN, value, ChatColor.WHITE));
this.plugin.loadConfigs();
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,33 +7,25 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Confirms actions.
*/
public class ConfirmCommand extends MultiverseCommand {
@CommandAlias("mv")
public class ConfirmCommand extends MultiverseCoreCommand {
public ConfirmCommand(MultiverseCore plugin) {
super(plugin);
// Any command that is dangerous should require op
this.setName("Confirms a command that could destroy life, the universe and everything.");
this.setCommandUsage("/mv confirm");
this.setArgRange(0, 0);
this.addKey("mvconfirm");
this.addKey("mv confirm");
this.addCommandExample("/mv confirm");
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
@Subcommand("confirm")
@CommandPermission("multiverse.core.confirm")
@Description("Confirms dangerous commands before executing them.")
public void onConfirmCommand(@NotNull CommandSender sender) {
this.plugin.getMVCommandManager().getQueueManager().runQueuedCommand(sender);
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,65 +7,69 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat;
import java.util.List;
/**
* Returns detailed information on the Players where abouts.
*/
public class CoordCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@CommandAlias("mv")
public class CoordCommand extends MultiverseCoreCommand {
public CoordCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Coordinates");
this.setCommandUsage("/mv coord");
this.setArgRange(0, 0);
this.addKey("mv coord");
this.addKey("mvcoord");
this.addKey("mvco");
this.addCommandExample("/mv coord");
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
if (sender instanceof Player) {
Player p = (Player) sender;
World world = p.getWorld();
@Subcommand("coord|coordinate")
@CommandPermission("multiverse.core.coord.self")
@Description("Detailed information on your own where abouts.")
public void onCoordCommand(@NotNull Player player) {
showCoordInfo(player, player);
}
if (!this.worldManager.isMVWorld(world.getName())) {
this.plugin.showNotMVWorldMessage(sender, world.getName());
return;
}
@Subcommand("coord|coordinate")
@CommandPermission("multiverse.core.coord.other")
@Syntax("[player]")
@CommandCompletion("@players")
@Description("Detailed information on the player's where abouts.")
public void onOtherCoordCommand(@NotNull CommandSender sender,
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
@NotNull
@Syntax("[player]")
@Description("Player you want coordinate info of.")
RequiredPlayer player) {
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + LocationManipulation.strCoords(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
} else {
sender.sendMessage("This command needs to be used from a Player.");
showCoordInfo(sender, player.get());
}
private void showCoordInfo(@NotNull CommandSender sender,
@NotNull Player player) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld());
if (world == null) {
throw new InvalidCommandArgument("Player is not in a multiverse world.");
}
String name = player.equals(sender)
? ""
: String.format("for %s%s%s",ChatColor.YELLOW, player.getName(), ChatColor.AQUA);
sender.sendMessage(String.format("%s--- Location Information %s---", ChatColor.AQUA, name));
sender.sendMessage(String.format("%sWorld: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getName()));
sender.sendMessage(String.format("%sAlias: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getColoredWorldString()));
sender.sendMessage(String.format("%sWorld Scale: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getScaling()));
sender.sendMessage(String.format("%sCoordinates: %s%s", ChatColor.AQUA, ChatColor.WHITE, this.plugin.getLocationManipulation().strCoords(player.getLocation())));
sender.sendMessage(String.format("%sWorld Scale: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getScaling()));
sender.sendMessage(String.format("%sDirection: %s%s", ChatColor.AQUA, ChatColor.WHITE, this.plugin.getLocationManipulation().getDirection(player.getLocation())));
sender.sendMessage(String.format("%sBlock: %s%s", ChatColor.AQUA, ChatColor.WHITE, world.getCBWorld().getBlockAt(player.getLocation()).getType()));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,87 +7,77 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.pneumaticraft.commandhandler.CommandHandler;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.List;
import static org.bukkit.World.*;
/**
* Creates a new world and loads it.
*/
public class CreateCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@CommandAlias("mv")
public class CreateCommand extends MultiverseCoreCommand {
public CreateCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create World");
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n]");
this.setArgRange(2, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
this.setPermission("multiverse.core.create", "Creates a new world and loads it.", PermissionDefault.OP);
this.addCommandExample("/mv create " + ChatColor.GOLD + "world" + ChatColor.GREEN + " normal");
this.addCommandExample("/mv create " + ChatColor.GOLD + "lavaland" + ChatColor.RED + " nether");
this.addCommandExample("/mv create " + ChatColor.GOLD + "starwars" + ChatColor.AQUA + " end");
this.addCommandExample("/mv create " + ChatColor.GOLD + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
this.addCommandExample("/mv create " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -s gargamel");
this.addCommandExample("/mv create " + ChatColor.GOLD + "moonworld" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -g BukkitFullOfMoon");
this.worldManager = this.plugin.getMVWorldManager();
this.setFlagGroup(FlagGroup.of(
CoreFlags.WORLD_TYPE,
CoreFlags.SEED,
CoreFlags.GENERATOR,
CoreFlags.GENERATE_STRUCTURES,
CoreFlags.SPAWN_ADJUST
));
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
String typeString = CommandHandler.getFlag("-t", args);
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
return;
}
@Subcommand("create")
@CommandPermission("multiverse.core.create")
@Syntax("<name> <env> -s [seed] -g [generator[:id]] -t [worldtype] [-n] -a [true|false]")
@CommandCompletion("@empty @environments @flags")
@Description("Creates a new world and loads it.")
public void onCreateCommand(@NotNull CommandSender sender,
Environment environment = EnvironmentCommand.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
@NotNull
@Syntax("<name>")
@Description("New world name.")
@Flags("trim")
@Conditions("creatableWorldName") String worldName,
// If they didn't specify a type, default to NORMAL
if (typeString == null) {
typeString = "NORMAL";
}
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
if (type == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
EnvironmentCommand.showWorldTypes(sender);
return;
}
@NotNull
@Syntax("<env>")
@Description("The world's environment. See: /mv env")
Environment environment,
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
@Nullable
@Syntax("[world-flags]")
@Description("Other world settings. See: http://gg.gg/nn8bl")
String[] flagsArray) {
if (this.worldManager.addWorld(worldName, environment, seed, type, generator, useSpawnAdjust)) {
Command.broadcastCommandMessage(sender, "Complete!");
} else {
Command.broadcastCommandMessage(sender, "FAILED.");
}
FlagResult flags = this.getFlagGroup().calculateResult(flagsArray);
Command.broadcastCommandMessage(sender, String.format("Starting creation of world '%s'...", worldName));
Command.broadcastCommandMessage(sender, (this.plugin.getMVWorldManager().addWorld(
worldName,
environment,
// TODO API: Should Allow FlagResult object to be passed directly
flags.getValue(CoreFlags.SEED),
flags.getValue(CoreFlags.WORLD_TYPE),
flags.getValue(CoreFlags.GENERATE_STRUCTURES),
flags.getValue(CoreFlags.GENERATOR),
flags.getValue(CoreFlags.SPAWN_ADJUST))
)
? String.format("%sComplete!", ChatColor.GREEN)
: String.format("%sFailed! See console for errors.", ChatColor.RED));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,59 +7,85 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.logging.Level;
/**
* Enables debug-information.
*/
public class DebugCommand extends MultiverseCommand {
@CommandAlias("mv")
@CommandPermission("multiverse.core.debug")
public class DebugCommand extends MultiverseCoreCommand {
public DebugCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn Debug on/off?");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
this.setArgRange(0, 1);
this.addKey("mv debug");
this.addKey("mv d");
this.addKey("mvdebug");
this.addCommandExample("/mv debug " + ChatColor.GOLD + "2");
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("off")) {
MultiverseCore.GlobalDebug = 0;
} else {
try {
int debugLevel = Integer.parseInt(args.get(0));
if (debugLevel > 3 || debugLevel < 0) {
throw new NumberFormatException();
}
MultiverseCore.GlobalDebug = debugLevel;
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
}
@Subcommand("debug")
@CommandPermission("multiverse.core.debug")
@Description("Show the current debug level.")
public void onShowDebugCommand(@NotNull CommandSender sender) {
displayDebugMode(sender);
}
}
@Subcommand("debug")
@CommandPermission("multiverse.core.debug")
@Syntax("<level>")
@CommandCompletion("@toggles|@range:3")
@Description("Change debug level.")
public void onChangeDebugCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<level>")
@Description("Set debug mode level, 0 to 3.")
@Single String debugLevel) {
int parsedLevel = parseDebugLevel(debugLevel);
if (parsedLevel == -1) {
throw new InvalidCommandArgument("No such debug level. Please use a number from 0 to 3.");
}
this.displayDebugMode(sender);
this.plugin.getMVConfig().setGlobalDebug(parsedLevel);
if (!this.plugin.saveMVConfigs()) {
sender.sendMessage(String.format("%sError saving changes to config! See console for more info.", ChatColor.RED));
}
displayDebugMode(sender);
}
private void displayDebugMode(CommandSender sender) {
if (MultiverseCore.GlobalDebug == 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
private int parseDebugLevel(@NotNull String debugLevel) {
if (debugLevel.equalsIgnoreCase("off")) {
return 0;
}
if (debugLevel.equalsIgnoreCase("on")) {
return 1;
}
try {
int parsedLevel = Integer.parseInt(debugLevel);
return (parsedLevel > 3 || parsedLevel < 0) ? -1 : parsedLevel;
}
catch (NumberFormatException ignored) {
return -1;
}
}
private void displayDebugMode(@NotNull CommandSender sender) {
int debugLevel = this.plugin.getMVConfig().getGlobalDebug();
if (debugLevel == 0) {
sender.sendMessage(String.format("Multiverse Debug mode is %soff", ChatColor.RED));
}
else {
sender.sendMessage(String.format("Multiverse Debug mode at level %s%s", ChatColor.GREEN, debugLevel));
Logging.fine("Multiverse debug mode enabled!");
}
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,35 +7,58 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* Deletes worlds.
*/
public class DeleteCommand extends MultiverseCommand {
@CommandAlias("mv")
public class DeleteCommand extends MultiverseCoreCommand {
public DeleteCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Delete World");
this.setCommandUsage("/mv delete" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvdelete");
this.addKey("mv delete");
this.addCommandExample("/mv create " + ChatColor.GOLD + "MyWorld");
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?>[] paramTypes = {String.class};
List<Object> objectArgs = new ArrayList<Object>(args);
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
@Subcommand("delete")
@CommandPermission("multiverse.core.delete")
@Syntax("<world>")
@CommandCompletion("@MVWorlds|@unloadedWorlds")
@Description("Deletes a world on your server PERMANENTLY.")
public void onDeleteCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<world>")
@Description("Multiverse world you want to delete.")
@Flags("trim")
@Conditions("isWorldInConfig|validWorldFolder")
@Single String worldName) {
this.plugin.getMVCommandManager().getQueueManager().addToQueue(new QueuedCommand.Builder()
.sender(sender)
.action(deleteRunnable(sender, worldName))
.prompt("Are you sure you want to delete world '%s'?", worldName)
.build()
);
}
private Runnable deleteRunnable(@NotNull CommandSender sender,
@NotNull String worldName) {
return () -> {
sender.sendMessage(String.format("Deleting world '%s'...", worldName));
sender.sendMessage((this.plugin.getMVWorldManager().deleteWorld(worldName))
? String.format("%sWorld %s was deleted!", ChatColor.GREEN, worldName)
: String.format("%sThere was an issue deleting '%s'! Please check console for errors.", ChatColor.RED, worldName));
};
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,32 +7,28 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Lists valid known environments.
*/
public class EnvironmentCommand extends MultiverseCommand {
@CommandAlias("mv")
public class EnvironmentCommand extends MultiverseCoreCommand {
public EnvironmentCommand(MultiverseCore plugin) {
super(plugin);
this.setName("List Environments");
this.setCommandUsage("/mv env");
this.setArgRange(0, 0);
this.addKey("mvenv");
this.addKey("mv env");
this.addKey("mv type");
this.addKey("mv environment");
this.addKey("mv environments");
this.addCommandExample("/mv env");
this.setPermission("multiverse.core.list.environments", "Lists valid known environments/world types.", PermissionDefault.OP);
}
@Subcommand("env|environments")
@CommandPermission("multiverse.core.list.environments")
@Description("Lists valid known environments and world types.")
public void onEnvironmentCommand(CommandSender sender) {
showEnvironments(sender);
sender.sendMessage("");
showWorldTypes(sender);
}
/**
@@ -41,72 +37,19 @@ public class EnvironmentCommand extends MultiverseCommand {
* @param sender The {@link CommandSender}.
*/
public static void showEnvironments(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
sender.sendMessage(ChatColor.GREEN + "NORMAL");
sender.sendMessage(ChatColor.RED + "NETHER");
sender.sendMessage(ChatColor.AQUA + "END");
sender.sendMessage(String.format("%sValid Environments are:", ChatColor.YELLOW));
sender.sendMessage(String.format("%sNORMAL%s, %sNETHER %sor %sEND",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.AQUA));
}
/**
* Shows all valid known world types to a {@link CommandSender}.
*
* @param sender The {@link CommandSender}.
*/
public static void showWorldTypes(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
sender.sendMessage(String.format("%sNORMAL %sor %sFLAT",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA));
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
EnvironmentCommand.showEnvironments(sender);
EnvironmentCommand.showWorldTypes(sender);
}
/**
* Converts a {@link String} into a {@link WorldType}.
*
* @param type The WorldType as a {@link String}
* @return The WorldType as a {@link WorldType}
*/
public static WorldType getWorldTypeFromString(String type) {
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (type.equalsIgnoreCase("normal"))
type = "NORMAL";
if (type.equalsIgnoreCase("flat"))
type = "FLAT";
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
return WorldType.valueOf(type);
} catch (IllegalArgumentException e) {
return null;
}
}
/**
* Converts a {@link String} into an {@link org.bukkit.World.Environment}.
*
* @param env The environment as {@link String}
* @return The environment as {@link org.bukkit.World.Environment}
*/
public static World.Environment getEnvFromString(String env) {
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
env = "NETHER";
if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS"))
env = "THE_END";
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
env = "NORMAL";
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
return World.Environment.valueOf(env);
} catch (IllegalArgumentException e) {
return null;
}
sender.sendMessage(String.format("%sValid World Types are:", ChatColor.YELLOW));
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT%s, %sLARGEBIOMES %sor %sAMPLIFIED",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
}
}
@@ -0,0 +1,106 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleProperty;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
import org.bukkit.ChatColor;
import org.bukkit.GameRule;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@CommandAlias("mv")
@Subcommand("gamerule")
public class GameRuleCommand extends MultiverseCoreCommand {
public GameRuleCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("list")
@CommandPermission("multiverse.core.gamerule.list")
@Syntax("[world] [filter]")
@CommandCompletion("@MVWorlds")
@Description("See the list gamerules values for a given world.")
public void onGameRulesCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("[world]")
@Description("World you want to see game rule info.")
@Flags("other,defaultself, fallbackself") MultiverseWorld world,
@NotNull ContentFilter filter) {
new ContentDisplay.Builder<Map<String, Object>>()
.sender(sender)
.header("=== Gamerules for %s%s%s ===", ChatColor.AQUA, world.getName(), ChatColor.WHITE)
.contents(getGameRuleMap(world))
.displayHandler(DisplayHandlers.INLINE_MAP)
.colorTool(ColorAlternator.with(ChatColor.GREEN, ChatColor.GOLD))
.setting(DisplaySettings.OPERATOR, ": ")
.filter(filter)
.display();
}
private Map<String, Object> getGameRuleMap(MultiverseWorld world) {
return new HashMap<String, Object>() {{
Arrays.stream(GameRule.values())
.forEach(gr -> {
Object value = world.getCBWorld().getGameRuleValue(gr);
if (value != null) {
put(gr.getName(), value.toString());
}
});
}};
}
@Subcommand("set")
@CommandPermission("multiverse.core.gamerule.set")
@Syntax("<rule> <value> [world]")
@CommandCompletion("@gameRules @empty @MVWorlds")
@Description("Allows a player to set a gamerule for a given world.")
public <T> void onGameRuleChangeCommand(@NotNull CommandSender sender,
@NotNull Player player,
@Syntax("<rule> <value>")
@Description("Game rule property and value you want to change to.")
@NotNull GameRuleProperty<T> property,
@Syntax("[world]")
@Description("World you want to set this game rule.")
@NotNull @Flags("other,defaultself") MultiverseWorld world) {
sender.sendMessage((world.getCBWorld().setGameRule(property.getGameRule(), property.getValue()))
? String.format("%sSuccess! %sGamerule %s%s%s was set to %s%s%s.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, property.getGameRule().getName(),
ChatColor.WHITE, ChatColor.GREEN, property.getValue(), ChatColor.WHITE)
: String.format("%sFailure! Gamerule %s%s%s could not be set to %s%s%s.",
ChatColor.RED, ChatColor.AQUA, property.getGameRule().getName(),
ChatColor.RED, ChatColor.DARK_RED, property.getValue(), ChatColor.RED));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,54 +7,39 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.Collection;
/**
* Returns a list of loaded generator plugins.
*/
public class GeneratorCommand extends MultiverseCommand {
@CommandAlias("mv")
public class GeneratorCommand extends MultiverseCoreCommand {
public GeneratorCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Information");
this.setCommandUsage("/mv generators");
this.setArgRange(0, 0);
this.addKey("mv generators");
this.addKey("mvgenerators");
this.addKey("mv gens");
this.addKey("mvgens");
this.addCommandExample("/mv generators");
this.setPermission("multiverse.core.generator", "Returns a list of Loaded Generator Plugins.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
List<String> generators = new ArrayList<String>();
for (Plugin p : plugins) {
if (p.isEnabled() && p.getDefaultWorldGenerator("world", "") != null) {
generators.add(p.getDescription().getName());
}
}
sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---");
String loadedGens = "";
boolean altColor = false;
for (String s : generators) {
loadedGens += (altColor ? ChatColor.YELLOW : ChatColor.WHITE) + s + " ";
altColor = !altColor;
}
if (loadedGens.length() == 0) {
loadedGens = ChatColor.RED + "No Generator Plugins found.";
}
sender.sendMessage(loadedGens);
@Subcommand("gens|generators")
@CommandPermission("multiverse.core.generator")
@Description("Shows a list of Loaded Generator Plugins.")
public void onGeneratorCommand(@NotNull CommandSender sender) {
new ContentDisplay.Builder<Collection<String>>()
.sender(sender)
.header("%s--- Available Generator Plugins ---", ChatColor.GOLD)
.contents(CoreFlags.GENERATOR.suggestValue())
.emptyMessage("%sYou do not have any generator plugins installed.", ChatColor.RED)
.displayHandler(DisplayHandlers.INLINE_LIST)
.colorTool(ColorAlternator.with(ChatColor.AQUA, ChatColor.WHITE))
.display();
}
}
@@ -1,106 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Displays a nice help menu.
*/
public class HelpCommand extends PaginatedCoreCommand<Command> {
public HelpCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Get Help with Multiverse");
this.setCommandUsage("/mv " + ChatColor.GOLD + "[FILTER] [PAGE #]");
this.setArgRange(0, 2);
this.addKey("mv");
this.addKey("mvh");
this.addKey("mvhelp");
this.addKey("mv help");
this.addKey("mvsearch");
this.addKey("mv search");
this.addCommandExample("/mv help ?");
this.setPermission("multiverse.help", "Displays a nice help menu.", PermissionDefault.TRUE);
this.setItemsPerPage(7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
@Override
protected List<Command> getFilteredItems(List<Command> availableItems, String filter) {
List<Command> filtered = new ArrayList<Command>();
for (Command c : availableItems) {
if (stitchThisString(c.getKeyStrings()).matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandName().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandDesc().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandUsage().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else {
for (String example : c.getCommandExamples()) {
if (example.matches("(?i).*" + filter + ".*")) {
filtered.add(c);
break;
}
}
}
}
return filtered;
}
@Override
protected String getItemText(Command item) {
return ChatColor.AQUA + item.getCommandUsage();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.AQUA + "====[ Multiverse Help ]====");
FilterObject filterObject = this.getPageAndFilter(args);
List<Command> availableCommands = new ArrayList<Command>(this.plugin.getCommandHandler().getCommands(sender));
if (filterObject.getFilter().length() > 0) {
availableCommands = this.getFilteredItems(availableCommands, filterObject.getFilter());
if (availableCommands.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No commands matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
}
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.AQUA + " Add a '" + ChatColor.DARK_PURPLE + "?" + ChatColor.AQUA + "' after a command to see more about it.");
for (Command c : availableCommands) {
sender.sendMessage(ChatColor.AQUA + c.getCommandUsage());
}
return;
}
int totalPages = (int) Math.ceil(availableCommands.size() / (this.itemsPerPage + 0.0));
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
sender.sendMessage(ChatColor.AQUA + " Add a '" + ChatColor.DARK_PURPLE + "?" + ChatColor.AQUA + "' after a command to see more about it.");
this.showPage(filterObject.getPage(), sender, availableCommands);
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,169 +7,66 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.pneumaticraft.commandhandler.CommandHandler;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static org.bukkit.World.*;
/**
* Imports a new world of the specified type.
*/
public class ImportCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@CommandAlias("mv")
public class ImportCommand extends MultiverseCoreCommand {
public ImportCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Import World");
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE]");
this.setArgRange(2, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvimport");
this.addKey("mvim");
this.addKey("mv import");
this.addCommandExample("/mv import " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal");
this.addCommandExample("/mv import " + ChatColor.GOLD + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
this.addCommandExample("/mv import " + ChatColor.GOLD + "hell_world" + ChatColor.GREEN + " nether");
this.addCommandExample("/mv import " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " CleanRoomGenerator");
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
this.setFlagGroup(FlagGroup.of(CoreFlags.GENERATOR, CoreFlags.SPAWN_ADJUST));
}
/**
* A very basic check to see if a folder has a level.dat file.
* If it does, we can safely assume it's a world folder.
*
* @param worldFolder The File that may be a world.
* @return True if it looks like a world, false if not.
*/
private boolean checkIfIsWorld(File worldFolder) {
if (worldFolder.isDirectory()) {
File[] files = worldFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return name.equalsIgnoreCase("level.dat");
}
});
if (files != null && files.length > 0) {
return true;
}
}
return false;
}
@Subcommand("import")
@CommandPermission("multiverse.core.import")
@Syntax("<name> <env> -g [generator[:id]] [-n]")
@CommandCompletion("@potentialWorlds @environments @flags")
@Description("Imports a new world into multiverse.")
public void onImportCommand(@NotNull CommandSender sender,
private String getPotentialWorlds() {
File worldFolder = this.plugin.getServer().getWorldContainer();
if (worldFolder == null) {
return "";
}
File[] files = worldFolder.listFiles();
String worldList = "";
Collection<MultiverseWorld> worlds = this.worldManager.getMVWorlds();
List<String> worldStrings = new ArrayList<String>();
for (MultiverseWorld world : worlds) {
worldStrings.add(world.getName());
}
for (String world : this.worldManager.getUnloadedWorlds()) {
worldStrings.add(world);
}
ChatColor currColor = ChatColor.WHITE;
for (File file : files) {
if (file.isDirectory() && checkIfIsWorld(file) && !worldStrings.contains(file.getName())) {
worldList += currColor + file.getName() + " ";
if (currColor == ChatColor.WHITE) {
currColor = ChatColor.YELLOW;
} else {
currColor = ChatColor.WHITE;
}
}
}
return worldList;
}
@Syntax("<name>")
@Description("Folder name of the world.")
@NotNull @co.aikar.commands.annotation.Flags("trim") @Conditions("importableWorldName") String worldName,
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
@NotNull
@Syntax("<env>")
@Description("The world's environment. See: /mv env")
Environment environment,
if (worldName.toLowerCase().equals("--list") || worldName.toLowerCase().equals("-l")) {
String worldList = this.getPotentialWorlds();
if (worldList.length() > 2) {
sender.sendMessage(ChatColor.AQUA + "====[ These look like worlds ]====");
sender.sendMessage(worldList);
} else {
sender.sendMessage(ChatColor.RED + "No potential worlds found. Sorry!");
}
return;
}
// Since we made an exception for the list, we have to make sure they have at least 2 params:
// Note the exception is --list, which is covered above.
if (args.size() == 1) {
this.showHelp(sender);
return;
}
@Nullable
@Syntax("-g [generator[:id]] [-n]")
@Description("Other world settings. See: http://gg.gg/nn8c2")
String[] flagsArray) {
// Make sure we don't already know about this world.
if (this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.GREEN + "Multiverse" + ChatColor.WHITE
+ " already knows about '" + ChatColor.AQUA + worldName + ChatColor.WHITE + "'!");
return;
}
FlagResult flags = this.getFlagGroup().calculateResult(flagsArray);
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
String generator = CommandHandler.getFlag("-g", args);
String typeString = CommandHandler.getFlag("-t", args);
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
String env = args.get(1);
Environment environment = EnvironmentCommand.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
// If they didn't specify a type, default to NORMAL
if (typeString == null) {
typeString = "NORMAL";
}
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
if (type == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
EnvironmentCommand.showWorldTypes(sender);
return;
}
if (worldFile.exists() && env != null) {
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
if (this.worldManager.addWorld(worldName, environment, null, type, generator, useSpawnAdjust))
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
else
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
} else if (env == null) {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world environment did not exist.");
sender.sendMessage("For a list of available world types, type: " + ChatColor.AQUA + "/mvenv");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
String worldList = this.getPotentialWorlds();
sender.sendMessage("That world folder does not exist. These look like worlds to me:");
sender.sendMessage(worldList);
}
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
Command.broadcastCommandMessage(sender, (this.plugin.getMVWorldManager().addWorld(worldName,
environment,
null,
null,
null,
flags.getValue(CoreFlags.GENERATOR),
flags.getValue(CoreFlags.SPAWN_ADJUST))
)
? String.format("%sComplete!", ChatColor.GREEN)
: String.format("%sFailed! See console for more details.", ChatColor.RED));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,251 +7,141 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.FancyText;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
import com.onarandombox.MultiverseCore.utils.FancyHeader;
import com.onarandombox.MultiverseCore.utils.FancyMessage;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
import org.bukkit.ChatColor;
import org.bukkit.Location;
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;
// Will use when we can compile with JDK 6
//import com.sun.xml.internal.ws.util.StringUtils;
/**
* Returns detailed information about a world.
*/
public class InfoCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@CommandAlias("mv")
public class InfoCommand extends MultiverseCoreCommand {
public InfoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Information");
this.setCommandUsage("/mv info" + ChatColor.GOLD + " [WORLD] [PAGE]");
this.setArgRange(0, 2);
this.addKey("mvinfo");
this.addKey("mvi");
this.addKey("mv info");
this.addCommandExample("/mv info " + ChatColor.GOLD + "1");
this.addCommandExample("/mv info " + ChatColor.GOLD + "3");
this.setPermission("multiverse.core.info", "Returns detailed information on the world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
String worldName = "";
int pageNum = 0;
@Subcommand("info")
@CommandPermission("multiverse.core.info")
@Syntax("[world] [page]")
@CommandCompletion("@MVWorlds @range:1-5")
@Description("Display detailed information of the world.")
public void onInfoCommand(@NotNull CommandSender sender,
if (args.size() == 0) {
if (sender instanceof Player) {
Player p = (Player) sender;
worldName = p.getWorld().getName();
} else {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
} else if (args.size() == 1) {
if (this.worldManager.getMVWorld(args.get(0)) != null) {
// then we have a world!
worldName = args.get(0);
} else {
if (sender instanceof Player) {
Player p = (Player) sender;
worldName = p.getWorld().getName();
try {
pageNum = Integer.parseInt(args.get(0)) - 1;
} catch (NumberFormatException e) {
pageNum = 0;
}
} else {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
}
} else if (args.size() == 2) {
worldName = args.get(0);
try {
pageNum = Integer.parseInt(args.get(1)) - 1;
} catch (NumberFormatException e) {
pageNum = 0;
}
}
@NotNull
@Syntax("[world]")
@Description("World you want to see info.")
@Flags("other,defaultself,fallbackself") MultiverseWorld world,
if (this.worldManager.isMVWorld(worldName)) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
} else if (this.plugin.getServer().getWorld(worldName) != null) {
sender.sendMessage("That world exists, but multiverse does not know about it!");
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
}
@Syntax("[page]")
@Description("Info page to display.")
@Default("1") int page) {
new ContentDisplay.Builder<Collection<String>>()
.sender(sender)
.contents(buildWorldInfoContent(world))
.displayHandler(DisplayHandlers.PAGE_LIST)
.colorTool(ColorAlternator.with(ChatColor.YELLOW, ChatColor.AQUA)).setting(DisplaySettings.SHOW_PAGE, page)
.display();
}
private List<List<FancyText>> buildEntireCommand(MultiverseWorld world, Player p) {
List<FancyText> message = new ArrayList<FancyText>();
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
private List<String> buildWorldInfoContent(MultiverseWorld world) {
List<String> contents = new ArrayList<>(38);
// Page 1
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
message.add(new FancyHeader("General Info", colors));
message.add(new FancyMessage("World Name: ", world.getName(), colors));
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
Location spawn = world.getSpawnLocation();
message.add(new FancyMessage("Spawn Location: ", LocationManipulation.strCoords(spawn), colors));
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
if (world.getPrice() > 0) {
message.add(new FancyMessage("Price to enter this world: ",
this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency()), colors));
} else {
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
}
contents.add(parseHeader("General Info"));
contents.add(String.format("World Name: %s%s", ChatColor.WHITE, world.getName()));
contents.add(String.format("World Alias: %s%s", ChatColor.WHITE, world.getColoredWorldString()));
contents.add(String.format("Game Mode: %s%s", ChatColor.WHITE, world.getGameMode().toString()));
contents.add(String.format("Difficulty: %s%s", ChatColor.WHITE, world.getDifficulty().toString()));
contents.add(String.format("Spawn Location: %s%s", ChatColor.WHITE, this.plugin.getLocationManipulation().strCoords(world.getSpawnLocation())));
contents.add(String.format("World Seed: %s%s", ChatColor.WHITE, world.getSeed()));
String priceString = (world.getPrice() == 0)
? String.format("%sFREE!", ChatColor.GREEN)
: plugin.getEconomist().formatPrice(-world.getPrice(), world.getCurrency());
contents.add(String.format((world.getPrice() >= 0)
? "Price to enter this world: %s%s"
: "Reward for entering this world: %s%s", ChatColor.WHITE, priceString));
World respawnWorld = world.getRespawnToWorld();
MultiverseWorld respawn = this.plugin.getMVWorldManager().getMVWorld(respawnWorld);
String respawnWorldString = (respawn != null)
? respawn.getColoredWorldString()
: ChatColor.RED + "!!INVALID!!";
contents.add(String.format("Players will respawn in: %s%s", ChatColor.WHITE, respawnWorldString));
contents.add(ContentDisplay.LINE_BREAK);
if (world.getRespawnToWorld() != null) {
MultiverseWorld respawn = this.worldManager.getMVWorld(world.getRespawnToWorld());
if (respawn != null) {
message.add(new FancyMessage("Players will respawn in: ", respawn.getColoredWorldString(), colors));
} else {
message.add(new FancyMessage("Players will respawn in: ", ChatColor.RED + "!!INVALID!!", colors));
}
}
worldInfo.add(message);
// Page 2
message = new ArrayList<FancyText>();
message.add(new FancyHeader("More World Settings", colors));
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
message.add(new FancyHeader("PVP Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.isPVPEnabled() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
worldInfo.add(message);
contents.add(parseHeader("More World Settings"));
contents.add(String.format("World UID: %s%s", ChatColor.WHITE, world.getCBWorld().getUID()));
contents.add(String.format("World Type: %s%s", ChatColor.WHITE, world.getWorldType().toString()));
contents.add(String.format("World Scale: %s%s", ChatColor.WHITE, world.getScaling()));
contents.add(String.format("Generator: %s%s", ChatColor.WHITE, world.getGenerator()));
contents.add(String.format("Structures: %s%s", ChatColor.WHITE, world.getCBWorld().canGenerateStructures()));
contents.add(String.format("Weather: %s%s", ChatColor.WHITE, world.isWeatherEnabled()));
contents.add(String.format("Players will get hungry: %s%s", ChatColor.WHITE, world.getHunger()));
contents.add(String.format("Keep spawn in memory: %s%s", ChatColor.WHITE, world.isKeepingSpawnInMemory()));
contents.add(ContentDisplay.LINE_BREAK);
// Page 3
message = new ArrayList<FancyText>();
message.add(new FancyHeader("Monster Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.canMonstersSpawn() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowMonsters() + "", colors));
if (world.getMonsterList().size() > 0) {
if (world.canMonstersSpawn()) {
message.add(new FancyMessage("Monsters that" + ChatColor.RED + " CAN NOT "
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getMonsterList()), colors));
} else {
message.add(new FancyMessage("Monsters that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getMonsterList()), colors));
}
} else {
message.add(new FancyMessage("Monsters that CAN spawn: ", world.canMonstersSpawn() ? "ALL" : "NONE", colors));
}
worldInfo.add(message);
contents.add(parseHeader("PVP Settings"));
contents.add(String.format("Multiverse Setting: %s%s", ChatColor.WHITE, world.isPVPEnabled()));
contents.add(String.format("Bukkit Setting: %s%s", ChatColor.WHITE, world.getCBWorld().getPVP()));
contents.add(ContentDisplay.LINE_BREAK);
// Page 4
message = new ArrayList<FancyText>();
message.add(new FancyHeader("Animal Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.canAnimalsSpawn() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowAnimals() + "", colors));
if (world.getMonsterList().size() > 0) {
if (world.canMonstersSpawn()) {
message.add(new FancyMessage("Animals that" + ChatColor.RED + " CAN NOT "
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getAnimalList()), colors));
} else {
message.add(new FancyMessage("Animals that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getAnimalList()), colors));
}
} else {
message.add(new FancyMessage("Animals that CAN spawn: ", world.canAnimalsSpawn() ? "ALL" : "NONE", colors));
}
worldInfo.add(message);
contents.add(parseHeader("Monster Settings"));
contents.add(String.format("Multiverse Setting: %s%s", ChatColor.WHITE, world.canMonstersSpawn()));
contents.add(String.format("Bukkit Setting: %s%s", ChatColor.WHITE, world.getCBWorld().getAllowMonsters()));
contents.add((world.canMonstersSpawn())
? String.format("Monsters that %scannot spawn: %s%s", ChatColor.RED, ChatColor.WHITE, toCommaSeparated(world.getMonsterList()))
: String.format("Monsters that %scan spawn: %s%s", ChatColor.GREEN, ChatColor.WHITE, toCommaSeparated(world.getMonsterList())));
contents.add(ContentDisplay.LINE_BREAK);
return worldInfo;
// Page 5
contents.add(parseHeader("Animal Settings"));
contents.add(String.format("Multiverse Setting: %s%s", ChatColor.WHITE, world.canAnimalsSpawn()));
contents.add(String.format("Bukkit Setting: %s%s", ChatColor.WHITE, world.getCBWorld().getAllowAnimals()));
contents.add((world.canAnimalsSpawn())
? String.format("Animals that %scannot spawn: %s%s", ChatColor.RED, ChatColor.WHITE, toCommaSeparated(world.getAnimalList()))
: String.format("Animals that %scan spawn: %s%s", ChatColor.GREEN, ChatColor.WHITE, toCommaSeparated(world.getAnimalList())));
return contents;
}
private String toCommaSeperated(List<String> list) {
private String parseHeader(String header) {
return String.format("%s===[ %s %s]===", ChatColor.AQUA, header, ChatColor.AQUA);
}
private static String toCommaSeparated(List<String> list) {
if (list == null || list.size() == 0) {
return "";
return ChatColor.GRAY + ChatColor.ITALIC.toString() + "none";
}
if (list.size() == 1) {
return list.get(0);
}
String result = list.get(0);
StringBuilder result = new StringBuilder(list.get(0));
for (int i = 1; i < list.size() - 1; i++) {
result += ", " + list.get(i);
result.append(", ").append(list.get(i));
}
result += " and " + list.get(list.size() - 1);
return result;
result.append(" and ").append(list.get(list.size() - 1));
return result.toString();
}
/**
* Gets a "positive" or "negative" {@link ChatColor}.
*
* @param positive Whether this {@link ChatColor} should be "positive".
* @return The {@link ChatColor}.
*/
protected ChatColor getChatColor(boolean positive) {
return positive ? ChatColor.GREEN : ChatColor.RED;
}
private void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
page = page < 0 ? 0 : page;
page = page > doc.size() - 1 ? doc.size() - 1 : page;
boolean altColor = false;
boolean appendedPageNum = false;
if (sender instanceof Player) {
List<FancyText> list = doc.get(page);
for (FancyText fancyT : list) {
if (fancyT instanceof FancyMessage) {
FancyMessage text = (FancyMessage) fancyT;
text.setAltColor(altColor);
altColor = !altColor;
sender.sendMessage(text.getFancyText());
} else if (fancyT instanceof FancyHeader) {
FancyHeader text = (FancyHeader) fancyT;
if (!appendedPageNum) {
text.appendText(ChatColor.DARK_PURPLE + " [ Page " + (page + 1) + " of " + doc.size() + " ]");
appendedPageNum = true;
}
sender.sendMessage(text.getFancyText());
altColor = false;
}
}
} else {
for (List<FancyText> list : doc) {
for (FancyText fancyT : list) {
if (fancyT instanceof FancyMessage) {
FancyMessage text = (FancyMessage) fancyT;
text.setAltColor(altColor);
altColor = !altColor;
sender.sendMessage(text.getFancyText());
} else {
FancyText text = fancyT;
if (appendedPageNum) {
sender.sendMessage(" ");
} else {
appendedPageNum = true;
}
sender.sendMessage(text.getFancyText());
altColor = false;
}
}
}
}
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,122 +7,96 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
import org.bukkit.ChatColor;
import org.bukkit.World.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;
/**
* Displays a listing of all worlds that a player can enter.
*/
public class ListCommand extends PaginatedCoreCommand<String> {
@CommandAlias("mv")
public class ListCommand extends MultiverseCoreCommand {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mv list");
this.setArgRange(0, 2);
this.addKey("mvlist");
this.addKey("mvl");
this.addKey("mv list");
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
private List<String> getFancyWorldList(Player p) {
List<String> worldList = new ArrayList<String>();
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
@Subcommand("list")
@CommandPermission("multiverse.core.list.worlds")
@Syntax("[filter] [page]")
@Description("Displays a listing of all worlds that you can enter.")
public void onListCommand(@NotNull CommandSender sender,
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
}
@NotNull PageFilter pageFilter) {
new ContentDisplay.Builder<Collection<String>>()
.sender(sender)
.header("%s====[ Multiverse World List ]====", ChatColor.GOLD)
.contents(getListContents(sender))
.displayHandler(DisplayHandlers.PAGE_LIST)
.colorTool(ColorAlternator.with(ChatColor.AQUA, ChatColor.GOLD))
.setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
.display();
}
private List<String> getListContents(@NotNull CommandSender sender) {
Player player = (sender instanceof Player) ? (Player) sender : null;
List<String> worldList = new ArrayList<>();
this.plugin.getMVWorldManager().getMVWorlds().stream()
.filter(world -> player == null || plugin.getMVPerms().canEnterWorld(player, world))
.filter(world -> canSeeWorld(player, world))
.map(world -> hiddenText(world) + world.getColoredWorldString() + " - " + parseColouredEnvironment(world.getEnvironment()))
.sorted()
.forEach(worldList::add);
this.plugin.getMVWorldManager().getUnloadedWorlds().stream()
.filter(world -> plugin.getMVPerms().hasPermission(sender, "multiverse.access." + world, true))
.map(world -> ChatColor.GRAY + world + " - UNLOADED")
.sorted()
.forEach(worldList::add);
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;
}
String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment();
if (world.isHidden()) {
if (p == null || p.hasPermission("multiverse.core.modify")) {
// Prefix hidden worlds with an "[H]"
worldList.add(ChatColor.GRAY + "[H]" + outputCache);
}
} else {
worldList.add(outputCache);
}
}
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;
private boolean canSeeWorld(Player player, MultiverseWorld world) {
return !world.isHidden()
|| player == null
|| this.plugin.getMVPerms().hasPermission(player, "multiverse.core.modify", true);
}
@Override
protected String getItemText(String item) {
return item;
private String hiddenText(MultiverseWorld world) {
return (world.isHidden()) ? String.format("%s[H] ", ChatColor.GRAY) : "";
}
@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;
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;
}
FilterObject filterObject = this.getPageAndFilter(args);
List<String> availableWorlds = new ArrayList<String>(this.getFancyWorldList(p));
if (filterObject.getFilter().length() > 0) {
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
if (availableWorlds.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No worlds matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
}
if (!(sender instanceof Player)) {
for (String c : availableWorlds) {
sender.sendMessage(c);
}
return;
}
int totalPages = (int) Math.ceil(availableWorlds.size() / (this.itemsPerPage + 0.0));
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
this.showPage(filterObject.getPage(), sender, availableWorlds);
return color + env.toString();
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,36 +7,43 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Loads a world into Multiverse.
*/
public class LoadCommand extends MultiverseCommand {
@CommandAlias("mv")
public class LoadCommand extends MultiverseCoreCommand {
public LoadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Load World");
this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvload");
this.addKey("mv load");
this.addCommandExample("/mv load " + ChatColor.GREEN + "MyUnloadedWorld");
this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) {
Command.broadcastCommandMessage(sender, "Loaded world '" + args.get(0) + "'!");
} else {
sender.sendMessage("Error trying to load world '" + args.get(0) + "'!");
@Subcommand("load")
@CommandPermission("multiverse.core.load")
@Syntax("<world>")
@CommandCompletion("@unloadedWorlds")
@Description("Loads a world. World must be already in worlds.yml, else please use /mv import.")
public void onLoadCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<world>")
@Description("Name of world you want to load.")
@Flags("type=world name")
@Conditions("isUnloadedWorld") String worldName) {
if (!this.plugin.getMVWorldManager().loadWorld(worldName)) {
sender.sendMessage(String.format("Error trying to load world '%s'!", worldName));
return;
}
Command.broadcastCommandMessage(sender, String.format("Loaded world '%s'!", worldName));
}
}
@@ -1,91 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
// This will contain all the properties that support the ADD/REMOVE
// Anything not in here will only support the SET action
/**
* Used to modify various aspects of worlds.
*/
public class ModifyAddCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ModifyAddCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Add a value)");
this.setCommandUsage("/mv modify " + ChatColor.GREEN + "add {VALUE} {PROPERTY}" + ChatColor.GOLD + " [WORLD] ");
this.setArgRange(2, 3);
this.addKey("mvm add");
this.addKey("mvmadd");
this.addKey("mv modify add");
this.addKey("mvmodify add");
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Add, property)) {
sender.sendMessage("Sorry, you can't ADD to " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.addToVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA
+ value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
} else {
sender.sendMessage(value + " could not be added to " + property);
}
}
}
@@ -1,88 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Removes all values from a world-property.
*/
public class ModifyClearCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ModifyClearCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Clear a property)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " clear {PROPERTY}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 2);
this.addKey("mvm clear");
this.addKey("mvmclear");
this.addKey("mv modify clear");
this.addKey("mvmodify clear");
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "animals");
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "monsters");
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "worldblacklist");
this.setPermission("multiverse.core.modify.clear",
"Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String property = args.get(0);
if (args.size() == 1) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(1));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Clear, property)) {
sender.sendMessage("Sorry, you can't use CLEAR with " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
return;
}
if (world.clearList(property)) {
sender.sendMessage(property + " was cleared. It contains 0 values now.");
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was "
+ ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
} else {
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property
+ ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
}
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,70 +7,228 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.enums.AddProperties;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Used to modify various aspects of worlds.
*/
public class ModifyCommand extends MultiverseCommand {
@CommandAlias("mv")
@Subcommand("modify")
//TODO API: Think why properties method for MultiverseWorld is deprecated.
public class ModifyCommand extends MultiverseCoreCommand {
public ModifyCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " {set|add|remove|clear} ...");
this.setArgRange(2, 3);
this.addKey("mvm");
this.addKey("mvmodify");
this.addKey("mv modify");
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put("multiverse.core.modify.add", true);
children.put("multiverse.core.modify.modify", true);
children.put("multiverse.core.modify.clear", true);
children.put("multiverse.core.modify.remove", true);
Permission modify = new Permission("multiverse.core.modify",
"Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children);
this.addCommandExample(ChatColor.AQUA + "/mv modify set ?");
this.addCommandExample(ChatColor.GREEN + "/mv modify add ?");
this.addCommandExample(ChatColor.BLUE + "/mv modify clear ?");
this.addCommandExample(ChatColor.RED + "/mv modify remove ?");
this.setPermission(modify);
}
/**
* Validates the specified action.
*
* @param action The {@link Action}.
* @param property The property.
* @return Whether this action is valid.
*/
protected static boolean validateAction(Action action, String property) {
if (action != Action.Set) {
try {
AddProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
@Subcommand("set")
@CommandPermission("multiverse.core.modify.set")
@Syntax("<property> <value> [world]")
@CommandCompletion("@setProperties @empty @MVWorlds")
@Description("Modify various aspects of worlds by setting a property. For more info; https://tinyurl.com/nehhzp6")
public void onModifySetCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<property>")
@Description("Property option key.")
@Flags("type=property")
@Conditions("validAddProperty:set") String property,
@NotNull
@Syntax("<value>")
@Description("New property value.")
@Flags("type=property value") String value,
@NotNull
@Syntax("[world]")
@Description("World that you want property change to apply.")
@Flags("other,defaultself") MultiverseWorld world) {
if ((property.equalsIgnoreCase("aliascolor")
|| property.equalsIgnoreCase("color"))
&& !EnglishChatColor.isValidAliasColor(value)) {
sender.sendMessage(String.format("%s'%s' is not a valid color. Please pick one of the following:",
ChatColor.RED, value));
sender.sendMessage(EnglishChatColor.getAllColors());
return;
}
try {
if (!world.setPropertyValue(property, value)) {
sender.sendMessage(ChatColor.RED + world.getPropertyHelp(property));
return;
}
}
return false;
catch (PropertyDoesNotExistException e) {
sender.sendMessage(String.format("%sSorry, You can't set '%s%s%s'!", ChatColor.RED, ChatColor.GRAY, property, ChatColor.RED));
sender.sendMessage(String.format("Valid world-properties: %s", world.getAllPropertyNames()));
return;
}
sender.sendMessage(String.format("%sSuccess! %sProperty %s%s %swas set to %s%s%s.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, property, ChatColor.WHITE, ChatColor.GREEN, value, ChatColor.WHITE));
saveWorldConfig();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// This is just a place holder. The real commands are in:
// ModifyAddCommand
// ModifyRemoveCommand
// ModifySetCommand
// ModifyClearCommand
@Subcommand("add")
@CommandPermission("multiverse.core.modify.add")
@Syntax("<property> <value> [world]")
@CommandCompletion("@addProperties @empty @MVWorlds")
@Description("Modify various aspects of worlds by adding a property. For more info: https://tinyurl.com/nehhzp6")
public void onModifyAddCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<property>")
@Description("Property option key.")
@Flags("type=property")
@Conditions("validAddProperty:add") String property,
@NotNull
@Syntax("<value>")
@Description("Property value to add.")
@Flags("type=property value") String value,
@NotNull
@Syntax("[world]")
@Description("World that you want property change to apply.")
@Flags("other,defaultself") MultiverseWorld world) {
if (!world.addToVariable(property, value)) {
sender.sendMessage(String.format("%s %scould not be added to %s%s%s.",
value, ChatColor.RED, ChatColor.AQUA, property, ChatColor.RED));
return;
}
sender.sendMessage(String.format("%sSuccess! %s%s%s was added to %s%s%s.",
ChatColor.GREEN, ChatColor.AQUA, value, ChatColor.WHITE, ChatColor.GREEN, property, ChatColor.WHITE));
saveWorldConfig();
}
@Subcommand("remove")
@CommandPermission("multiverse.core.modify.remove")
@Syntax("<property> <value> [world]")
@CommandCompletion("@addProperties @empty @MVWorlds")
@Description("Modify various aspects of worlds by removing a property. For more info: https://tinyurl.com/nehhzp6")
public void onModifyRemoveCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<property>")
@Description("Property option key.")
@Flags("type=property")
@Conditions("validAddProperty:remove") String property,
@NotNull
@Syntax("<value>")
@Description("Property value to remove.")
@Flags("type=property value") String value,
@NotNull
@Syntax("[world]")
@Description("World that you want property change to apply.")
@Flags("other,defaultself") MultiverseWorld world) {
if (!world.removeFromVariable(property, value)) {
sender.sendMessage(String.format("%sThere was an error removing %s%s%s from %s%s%s!",
ChatColor.RED, ChatColor.GRAY, value, ChatColor.RED, ChatColor.GRAY, property, ChatColor.RED));
return;
}
sender.sendMessage(String.format("%sSuccess! %s%s%s was %sremoved %sfrom %s%s%s.",
ChatColor.GREEN, ChatColor.AQUA, value, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.GREEN, property, ChatColor.WHITE));
saveWorldConfig();
}
@Subcommand("clear")
@CommandPermission("multiverse.core.modify.clear")
@Syntax("<property> <value> [world]")
@CommandCompletion("@addProperties @empty @MVWorlds")
@Description("Modify various aspects of worlds by clearing a property. For more info: https://tinyurl.com/nehhzp6")
public void onModifyClearCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<property>")
@Description("Property option key.")
@Flags("type=property") @Conditions("validAddProperty:clear") String property,
@NotNull
@Syntax("[world]")
@Description("World that you want property be cleared.")
@Flags("other,defaultself") MultiverseWorld world) {
if (!world.clearList(property)) {
sender.sendMessage(String.format("%sThere was an error clearing %s%s%s.",
ChatColor.RED, ChatColor.GOLD, property, ChatColor.RED));
}
sender.sendMessage(String.format("%s%s%s was cleared. It contains 0 values now.",
ChatColor.GOLD, property, ChatColor.WHITE));
saveWorldConfig();
}
@Subcommand("list")
@CommandPermission("multiverse.core.modify.list")
@Syntax("[world] [filter]")
@CommandCompletion("@MVWorlds")
@Description("Show properties available to set.")
public void onModifyListCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("[world]")
@Description("World that you want to see current property values set.")
@Flags("other,defaultself,fallbackself") MultiverseWorld world,
@NotNull ContentFilter filter) {
new ContentDisplay.Builder<Map<String, Object>>()
.sender(sender)
.header("%s===[ Property Values for %s%s ]===", ChatColor.GOLD, world.getColoredWorldString(), ChatColor.GOLD)
.contents(generateModifyList(world))
.emptyMessage("No properties found.")
.displayHandler(DisplayHandlers.INLINE_MAP)
.filter(filter)
.display();
}
private Map<String, Object> generateModifyList(MultiverseWorld world) {
Collection<String> properties = world.getAllPropertyTypes();
Map<String, Object> propMap = new HashMap<>(properties.size());
for (String property : properties) {
String value;
try {
value = world.getPropertyValue(property);
} catch (PropertyDoesNotExistException ignored) {
value = String.format("%s!!INAVLID!!", ChatColor.RED);
}
propMap.put(property, value);
}
return propMap;
}
private void saveWorldConfig() {
if (!this.plugin.saveWorldConfig()) {
throw new InvalidCommandArgument("There was an issue saving worlds.yml! Your changes will only be temporary.", false);
}
}
}
@@ -1,93 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Removes values from a world-property.
*/
public class ModifyRemoveCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Remove a value)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " remove {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mvm remove");
this.addKey("mvmremove");
this.addKey("mv modify remove");
this.addKey("mvmodify remove");
this.addKey("mvm delete");
this.addKey("mvmdelete");
this.addKey("mv modify delete");
this.addKey("mvmodify delete");
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Remove, property)) {
sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.removeFromVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE
+ " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
} else {
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY
+ value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
}
}
}
@@ -1,123 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Used to set world-properties.
*/
public class ModifySetCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ModifySetCommand(MultiverseCore plugin) {
super(plugin);
this.worldManager = this.plugin.getMVWorldManager();
this.setName("Modify a World (Set a value)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 3);
this.addKey("mvm set");
this.addKey("mvmset");
this.addKey("mv modify set");
this.addKey("mvmodify set");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "mode " + ChatColor.RED + "creative");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "animals " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "monsters " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "alias " + ChatColor.RED + "MyWorld");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "color " + ChatColor.RED + "green");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "curr " + ChatColor.RED + "3");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "price " + ChatColor.RED + "5");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "scale " + ChatColor.RED + "1.2");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "memory " + ChatColor.RED + "true");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "diff " + ChatColor.RED + "hard");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hunger " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hidden " + ChatColor.RED + "true");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "pvp " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "heal " + ChatColor.RED + "true");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "adjustspawn " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "spawn");
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Special case for spawn:
if (args.size() == 1) {
if (!(sender instanceof Player)) {
sender.sendMessage("You must be a player to set the" + ChatColor.GREEN + " spawn");
return;
}
if (args.get(0).equalsIgnoreCase("spawn")) {
SetSpawnCommand c = new SetSpawnCommand(this.plugin);
c.setWorldSpawn(sender);
} else {
sender.sendMessage("Spawn is the only param with no" + ChatColor.GREEN + " VALUE");
sender.sendMessage("Type " + ChatColor.GREEN + "/mv modify ?" + ChatColor.WHITE + " For help.");
}
return;
}
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage("From the command line, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String value = args.get(1);
String property = args.get(0);
if (args.size() == 2) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
sender.sendMessage(value + " is not a valid color. Please pick one of the following:");
sender.sendMessage(EnglishChatColor.getAllColors());
return;
}
try {
if (world.setProperty(property, value, sender)) {
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
} else {
sender.sendMessage(world.getProperty(property, Object.class).getHelp());
}
} catch (PropertyDoesNotExistException e) {
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
// TODO: Display the list
sender.sendMessage(ChatColor.GOLD + "For a full list of thingys, see our wiki.");
}
}
}
@@ -1,40 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
import java.util.List;
/**
* A generic Multiverse-command.
*/
public abstract class MultiverseCommand extends Command {
/**
* The reference to the core.
*/
protected MultiverseCore plugin;
/**
* The reference to {@link MVMessaging}.
*/
protected MVMessaging messaging;
public MultiverseCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
this.messaging = this.plugin.getMessaging();
}
@Override
public abstract void runCommand(CommandSender sender, List<String> args);
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -8,19 +8,13 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
/**
* A generic paginated Multiverse-command.
* @param <T> The type of items on the page.
*/
public abstract class PaginatedCoreCommand<T> extends PaginatedCommand<T> {
/**
* The reference to the core.
*/
protected MultiverseCore plugin;
public abstract class MultiverseCoreCommand extends MultiverseCommand {
public PaginatedCoreCommand(MultiverseCore plugin) {
super(plugin);
protected final MultiverseCore plugin;
protected MultiverseCoreCommand(MultiverseCore plugin) {
this.plugin = plugin;
}
}
@@ -1,164 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
/**
* A generic paginated command.
* @param <T> The type of items on the page.
*/
public abstract class PaginatedCommand<T> extends Command {
private static final int DEFAULT_ITEMS_PER_PAGE = 9;
/**
* The number of items per page.
*/
protected int itemsPerPage = DEFAULT_ITEMS_PER_PAGE;
public PaginatedCommand(JavaPlugin plugin) {
super(plugin);
}
/**
* Set the number of items per page.
*
* @param items The new number of items per page.
*/
protected void setItemsPerPage(int items) {
itemsPerPage = items;
}
/**
* Gets filtered items.
* @param availableItems All available items.
* @param filter The filter-{@link String}.
* @return A list of items that match the filter.
*/
protected abstract List<T> getFilteredItems(List<T> availableItems, String filter);
/**
* Constructs a single string from a list of strings.
*
* @param list The {@link List} of strings.
* @return A single {@link String}.
*/
protected String stitchThisString(List<String> list) {
StringBuilder builder = new StringBuilder();
for (String s : list) {
builder.append(s);
builder.append(' ');
}
return builder.toString();
}
/**
* Shows a page.
*
* @param page The number of the page to show.
* @param sender The {@link CommandSender} that wants to see the page.
* @param cmds The items that should be displayed on the page.
*/
protected void showPage(int page, CommandSender sender, List<T> cmds) {
// Ensure the page is at least 1.
page = (page <= 0) ? 1 : page;
int start = (page - 1) * itemsPerPage;
int end = start + itemsPerPage;
for (int i = start; i < end; i++) {
// For consistancy, print some extra lines if it's a player:
if (i < cmds.size()) {
sender.sendMessage(this.getItemText(cmds.get(i)));
} else if (sender instanceof Player) {
sender.sendMessage(" ");
}
}
}
/**
* Converts an item into a string.
*
* @param item The item.
* @return A {@link String}.
*/
protected abstract String getItemText(T item);
/**
* Constructs a {@link FilterObject} from a {@link List} of arguments.
*
* @param args The {@link List} of arguments.
* @return The {@link FilterObject}.
*/
protected FilterObject getPageAndFilter(List<String> args) {
int page = 1;
String filter = "";
if (args.size() == 0) {
filter = "";
page = 1;
} else if (args.size() == 1) {
try {
page = Integer.parseInt(args.get(0));
} catch (NumberFormatException ex) {
filter = args.get(0);
page = 1;
}
} else if (args.size() == 2) {
filter = args.get(0);
try {
page = Integer.parseInt(args.get(1));
} catch (NumberFormatException ex) {
page = 1;
}
}
return new FilterObject(page, filter);
}
/**
* "Key-Object" containing information about the page and the filter that were requested.
*/
protected class FilterObject {
private Integer page;
private String filter;
public FilterObject(Integer page, String filter) {
this.page = page;
this.filter = filter;
}
/**
* Gets the page.
* @return The page.
*/
public Integer getPage() {
return this.page;
}
/**
* Sets the page.
*
* @param page The new page.
*/
public void setPage(int page) {
this.page = page;
}
/**
* Gets the filter.
* @return The filter.
*/
public String getFilter() {
return this.filter;
}
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,86 +7,77 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Split;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import org.bukkit.ChatColor;
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.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Removes a type of mob from a world.
*/
public class PurgeCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@CommandAlias("mv")
public class PurgeCommand extends MultiverseCoreCommand {
public PurgeCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Purge World of Creatures");
this.setCommandUsage("/mv purge" + ChatColor.GOLD + " [WORLD|all] " + ChatColor.GREEN + "{all|animals|monsters|MOBNAME}");
this.setArgRange(1, 2);
this.addKey("mvpurge");
this.addKey("mv purge");
this.addCommandExample("/mv purge " + ChatColor.GREEN + "all");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "all");
this.addCommandExample("/mv purge " + ChatColor.GREEN + "monsters");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "animals");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld " + ChatColor.GREEN + "squid");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld_nether " + ChatColor.GREEN + "ghast");
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage("This command requires a WORLD when being run from the console!");
sender.sendMessage(this.getCommandUsage());
return;
}
String worldName = null;
String deathName = null;
if (args.size() == 1) {
worldName = p.getWorld().getName();
deathName = args.get(0);
} else {
worldName = args.get(0);
deathName = args.get(1);
}
@Subcommand("purgeall")
@CommandPermission("multiverse.core.purge.all")
@Syntax("<all|animals|monsters|mobname>")
@CommandCompletion("all|animals|monsters|@livingEntities")
@Description("Removed the specified type of mob from all worlds.")
public void onPurgeAllCommand(@NotNull CommandSender sender,
if (!worldName.equalsIgnoreCase("all") && !this.worldManager.isMVWorld(worldName)) {
((MultiverseCore) this.plugin).showNotMVWorldMessage(sender, worldName);
sender.sendMessage("It cannot be purged.");
return;
}
@NotNull
@Syntax("<entities>")
@Description("Entity types that you want to remove from all worlds.")
@Split(",") String[] targetEntities) {
List<MultiverseWorld> worldsToRemoveEntitiesFrom = new ArrayList<MultiverseWorld>();
// Handle all case any user who names a world "all" should know better...
if (worldName.equalsIgnoreCase("all")) {
worldsToRemoveEntitiesFrom.addAll(this.worldManager.getMVWorlds());
} else {
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
}
doPurge(sender, this.plugin.getMVWorldManager().getMVWorlds(), targetEntities);
}
PurgeWorlds purger = this.worldManager.getWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>();
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
} else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
}
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(sender, w, thingsToKill, false, false);
}
@Subcommand("purge")
@CommandPermission("multiverse.core.purge")
@Syntax("<all|animals|monsters|mobname>")
@CommandCompletion("@MVWorlds|all|animals|monsters|@livingEntities all|animals|monsters|@livingEntities")
@Description("Removed the specified type of mob from the specified world.")
public void onPurgeCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("[world]")
@Description("World that you want to remove entities.")
@Flags("other,defaultself,fallbackself") MultiverseWorld world,
@NotNull
@Syntax("<entities>")
@Description("Entity types that you want to remove from a world.")
@Split(",") String[] targetEntities) {
doPurge(sender, Collections.singleton(world), targetEntities);
}
private void doPurge(@NotNull CommandSender sender,
@NotNull Collection<MultiverseWorld> targetWorlds,
@NotNull String[] targetEntities) {
List<String> thingsToKill = Arrays.stream(targetEntities)
.map(String::toUpperCase)
.collect(Collectors.toList());
targetWorlds.forEach(w -> this.plugin.getMVWorldManager()
.getTheWorldPurger()
.purgeWorld(w, thingsToKill, false, false, sender));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,47 +7,75 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* Regenerates a world.
*/
public class RegenCommand extends MultiverseCommand {
@CommandAlias("mv")
public class RegenCommand extends MultiverseCoreCommand {
public RegenCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Regenerates a World");
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]]");
this.setArgRange(1, 3);
this.addKey("mvregen");
this.addKey("mv regen");
this.addCommandExample("You can use the -s with no args to get a new seed:");
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s");
this.addCommandExample("or specifiy a seed to get that one:");
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s" + ChatColor.AQUA + " gargamel");
this.setPermission("multiverse.core.regen", "Regenerates a world on your server. The previous state will be lost "
+ ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
this.setFlagGroup(FlagGroup.of(CoreFlags.RANDOM_SEED));
}
@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) : "";
@Subcommand("regen")
@CommandPermission("multiverse.core.regen")
@Syntax("<world> [-s [seed]]")
@CommandCompletion("@MVWorlds @worldFlags:-s")
@Description("Regenerates a world on your server. The previous state will be lost PERMANENTLY.")
public void onRegenCommand(@NotNull CommandSender sender,
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!");
@NotNull
@Syntax("<world>")
@Description("World that you want to regen.")
@Flags("other") MultiverseWorld world,
@Nullable
@Syntax("[-s [seed]]")
@Description("Other world settings. See: http://gg.gg/nn8lk")
String[] flagsArray) {
FlagResult flags = this.getFlagGroup().calculateResult(flagsArray);
this.plugin.getMVCommandManager().getQueueManager().addToQueue(new QueuedCommand.Builder()
.sender(sender)
.action(regenRunnable(sender, world, flags))
.prompt("Are you sure you want to regen world '%s'?", world.getColoredWorldString())
.build()
);
}
private Runnable regenRunnable(@NotNull CommandSender sender,
@NotNull MultiverseWorld world,
@NotNull FlagResult flags) {
return () -> {
sender.sendMessage(String.format("Regening world '%s'...", world.getName()));
//TODO: API should allow regen of unloaded worlds.
sender.sendMessage((this.plugin.getMVWorldManager().regenWorld(
world.getName(),
!flags.isDefaulted(CoreFlags.RANDOM_SEED),
!flags.isByUserInput(CoreFlags.RANDOM_SEED),
flags.getValue(CoreFlags.RANDOM_SEED))
)
? String.format("%sWorld Regenerated!", ChatColor.GREEN)
: String.format("%sWorld could not be regenerated!", ChatColor.RED));
};
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,51 +7,44 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* Reloads worlds.yml and config.yml.
*/
public class ReloadCommand extends MultiverseCommand {
@CommandAlias("mv")
public class ReloadCommand extends MultiverseCoreCommand {
public ReloadCommand(MultiverseCore plugin) {
public ReloadCommand(@NotNull MultiverseCore plugin) {
super(plugin);
this.setName("Reload Configs");
this.setCommandUsage("/mv reload");
this.setArgRange(0, 0);
this.addKey("mvreload");
this.addKey("mv reload");
this.addCommandExample("/mv reload");
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
@Subcommand("reload")
@CommandPermission("multiverse.core.reload")
@Description("Reloads config files for all multiverse modules.")
public void onReloadCommand(@NotNull CommandSender sender) {
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
this.plugin.loadConfigs();
this.plugin.getAnchorManager().loadAnchors();
this.plugin.getMVWorldManager().loadWorlds(true);
List<String> configsLoaded = new ArrayList<String>();
List<String> configsLoaded = new ArrayList<>();
configsLoaded.add("Multiverse-Core - config.yml");
configsLoaded.add("Multiverse-Core - worlds.yml");
configsLoaded.add("Multiverse-Core - anchors.yml");
// Create the event
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
// Fire it off
this.plugin.getServer().getPluginManager().callEvent(configReload);
for (String s : configReload.getAllConfigsLoaded()) {
sender.sendMessage(s);
}
sender.sendMessage(ChatColor.GREEN + "Reload Complete!");
configReload.getAllConfigsLoaded().forEach(sender::sendMessage);
sender.sendMessage(String.format("%sReload Complete!", ChatColor.GREEN));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,36 +7,43 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Unloads a world and removes it from the config.
*/
public class RemoveCommand extends MultiverseCommand {
@CommandAlias("mv")
public class RemoveCommand extends MultiverseCoreCommand {
public RemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Remove World");
this.setCommandUsage("/mv remove" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvremove");
this.addKey("mv remove");
this.addCommandExample("/mv remove " + ChatColor.GREEN + "MyWorld");
this.setPermission("multiverse.core.remove",
"Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().removeWorldFromConfig(args.get(0))) {
sender.sendMessage("World removed from config!");
} else {
sender.sendMessage("Error trying to remove world from config!");
}
@Subcommand("remove")
@CommandPermission("multiverse.core.remove")
@CommandCompletion("@MVWorlds|@unloadedWorlds")
@Syntax("<world>")
@Description("Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.")
public void onRemoveCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<world>")
@Description("World you want to remove from mv's knowledge.")
@Flags("type=world name")
@Conditions("isWorldInConfig")
@Single String worldName) {
sender.sendMessage((this.plugin.getMVWorldManager().removeWorldFromConfig(worldName))
? String.format("World '%s' is removed from config!", worldName)
: String.format("%sError trying to remove world from config!", ChatColor.RED));
}
}
@@ -0,0 +1,25 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class RootCommand extends MultiverseCoreCommand {
public RootCommand(MultiverseCore plugin) {
super(plugin);
}
@CommandAlias("mv")
public void onRootCommand(@NotNull CommandSender sender) {
this.plugin.getMVCommandManager().showPluginInfo(
sender,
this.plugin.getDescription(),
ColorAlternator.with(ChatColor.GOLD, ChatColor.YELLOW),
"mv"
);
}
}
@@ -0,0 +1,63 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import buscript.Buscript;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@CommandAlias("mv")
public class ScriptCommand extends MultiverseCoreCommand {
public ScriptCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("script")
@CommandPermission("multiverse.core.script")
@Syntax("<script> <player>")
@CommandCompletion("@scripts @players")
@Description("Runs a script.")
public void onScriptCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<script>")
@Description("Script name that you want to run.")
String targetScript,
@NotNull
@Syntax("<player>")
@Description("Player that you want to execute the script on.")
RequiredPlayer player) {
Buscript scriptAPI = this.plugin.getScriptAPI();
if (scriptAPI == null) {
throw new InvalidCommandArgument("Buscript failed to load while server was starting! Scripts cannot be run.", false);
}
File file = new File(scriptAPI.getScriptFolder(), targetScript);
if (!file.exists()) {
throw new InvalidCommandArgument("That script file does not exist in the Multiverse-Core scripts directory!");
}
scriptAPI.executeScript(file, targetScript, player.get());
sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,71 +7,164 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.BlockSafety;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class SetSpawnCommand extends MultiverseCoreCommand {
/**
* Sets the spawn for a world.
*/
public class SetSpawnCommand extends MultiverseCommand {
public SetSpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Set World Spawn");
this.setCommandUsage("/mv setspawn");
this.setArgRange(0, 0);
this.addKey("mvsetspawn");
this.addKey("mvss");
this.addKey("mv set spawn");
this.addKey("mv setspawn");
this.addKey("mvset spawn");
this.addCommandExample("/mv set spawn");
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
setWorldSpawn(sender);
@CommandAlias("mv")
public class SetSpawn extends BaseCommand {
@Subcommand("setspawn")
@CommandPermission("multiverse.core.spawn.set")
@Syntax("[world x y z [yaw pitch]]")
@CommandCompletion("@MVWorlds @location:x @location:y @location:z @location:yaw @location:pitch")
@Description("Sets the spawn for the current world.")
public void onSetSpawnCommand(@NotNull CommandSender sender,
@Nullable @Optional Player player,
@NotNull
@Syntax("[world x y z [yaw pitch]]")
@Description("New location of spawn.")
@Flags("other,defaultself") MultiverseWorld world,
@Nullable @Optional Double x,
@Nullable @Optional Double y,
@Nullable @Optional Double z,
@Nullable @Optional Float yaw,
@Nullable @Optional Float pitch) {
doSpawnSet(sender, world, parseLocation(player, world, x, y, z, yaw, pitch));
}
@Subcommand("modify set spawn")
@CommandPermission("multiverse.core.spawn.set")
@Syntax("[world x y z [yaw pitch]]")
@CommandCompletion("@MVWorlds @location:x @location:y @location:z @location:yaw @location:pitch")
@Description("Sets the spawn for the current world.")
public void onModifySetSpawnCommand(@NotNull CommandSender sender,
@Nullable @Optional Player player,
@NotNull
@Syntax("[world x y z [yaw pitch]]")
@Description("New location of spawn.")
@Flags("other,defaultself") MultiverseWorld world,
@Nullable @Optional Double x,
@Nullable @Optional Double y,
@Nullable @Optional Double z,
@Nullable @Optional Float yaw,
@Nullable @Optional Float pitch) {
doSpawnSet(sender, world, parseLocation(player, world, x, y, z, yaw, pitch));
}
}
/**
* Does the actual spawn-setting-work.
*
* @param sender The {@link CommandSender} that's setting the spawn.
*/
protected void setWorldSpawn(CommandSender sender) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location l = p.getLocation();
World w = p.getWorld();
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
if (foundWorld != null) {
foundWorld.setSpawnLocation(p.getLocation());
BlockSafety bs = new BlockSafety();
if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) {
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
sender.sendMessage("If you want this turned back on just do:");
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
foundWorld.setAdjustSpawn(false);
}
sender.sendMessage("Spawn was set to: " + LocationManipulation.strCoords(p.getLocation()));
} else {
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
@CommandAlias("mvsetspawn")
public class AliasSetSpawn extends BaseCommand {
@CommandAlias("mvsetspawn")
@CommandPermission("multiverse.core.spawn.set")
@Syntax("[world x y z [yaw pitch]]")
@CommandCompletion("@MVWorlds @location:x @location:y @location:z @location:yaw @location:pitch @empty")
@Description("Sets the spawn for the current world.")
public void onAliasSetSpawnCommand(@NotNull CommandSender sender,
@Nullable @Optional Player player,
@NotNull
@Syntax("[world x y z [yaw pitch]]")
@Description("New location of spawn.")
@Flags("other,defaultself") MultiverseWorld world,
@Nullable @Optional Double x,
@Nullable @Optional Double y,
@Nullable @Optional Double z,
@Nullable @Optional Float yaw,
@Nullable @Optional Float pitch) {
doSpawnSet(sender, world, parseLocation(player, world, x, y, z, yaw, pitch));
}
}
@NotNull
private Location parseLocation(@Nullable Player player,
@NotNull MultiverseWorld world,
@Nullable Double x,
@Nullable Double y,
@Nullable Double z,
@Nullable Float yaw,
@Nullable Float pitch) {
if (x == null) {
if (player == null) {
throw new InvalidCommandArgument("You need to specify a location from console.");
}
return player.getLocation();
}
if (y == null) {
throw new InvalidCommandArgument("You need to specify y and z axis as well.");
}
if (z == null) {
throw new InvalidCommandArgument("You need to specify z axis as well.");
}
if (yaw == null) {
return new Location(world.getCBWorld(), x, y, z);
}
if (pitch == null) {
throw new InvalidCommandArgument("You need to specify pitch as well.");
}
} else {
sender.sendMessage("You cannot use this command from the console.");
return new Location(world.getCBWorld(), x, y, z, yaw, pitch);
}
private void doSpawnSet(@NotNull CommandSender sender,
@NotNull MultiverseWorld world,
@NotNull Location location) {
World bukkitWorld = location.getWorld();
if (bukkitWorld == null) {
sender.sendMessage("No world found for the spawn location your tried to set.");
return;
}
world.setSpawnLocation(location);
BlockSafety blockSafety = this.plugin.getBlockSafety();
if (!blockSafety.playerCanSpawnHereSafely(location) && world.getAdjustSpawn()) {
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
sender.sendMessage(String.format("If you want turn this back on, just do %s/mv modify set adjustspawn true %s", ChatColor.AQUA, world.getName()));
world.setAdjustSpawn(false);
}
sender.sendMessage((sender instanceof Player && ((Player) sender).getWorld().equals(world.getCBWorld()))
? "Spawn of this world is set to:"
: String.format("Spawn for %s is set to:", world.getColoredWorldString()));
sender.sendMessage(plugin.getLocationManipulation().strCoords(location));
if (!plugin.saveWorldConfig()) {
sender.sendMessage(String.format("%sThere was an issue saving worlds.yml! Your changes will only be temporary!", ChatColor.RED));
}
}
}
@@ -0,0 +1,56 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@CommandAlias("mv")
public class SilentCommand extends MultiverseCoreCommand {
public SilentCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("silent")
@CommandPermission("multiverse.core.silent")
@Description("Show current state of silent mode.")
public void onShowSilentCommand(@NotNull CommandSender sender) {
displaySilentMode(sender);
}
@Subcommand("silent")
@CommandPermission("multiverse.core.silent")
@Syntax("<true|false>")
@CommandCompletion("true|false")
@Description("Reduces the amount of startup messages.")
public void onChangeSilentCommand(@NotNull CommandSender sender,
boolean silent) {
plugin.getMVConfig().setSilentStart(silent);
if (!plugin.saveMVConfigs()) {
sender.sendMessage(String.format("%sFailed to save config! Check your console for details.", ChatColor.RED));
}
displaySilentMode(sender);
}
private void displaySilentMode(CommandSender sender) {
sender.sendMessage((plugin.getMVConfig().getSilentStart())
? String.format("Multiverse Silent Start mode is %sOn", ChatColor.GREEN)
: String.format("Multiverse Silent Start mode is %sOff", ChatColor.RED));
}
}
@@ -1,42 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Takes the player to the latest bed he's slept in.
*/
public class SleepCommand extends MultiverseCommand {
public SleepCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Go to Sleep");
this.setCommandUsage("/mv sleep");
this.setArgRange(0, 0);
this.addKey("mv sleep");
this.setPermission("multiverse.core.sleep", "Takes you the latest bed you've slept in (Currently BROKEN).", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (p == null) {
return;
}
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,84 +7,68 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Teleports a player to the spawn.
*/
public class SpawnCommand extends MultiverseCommand {
@CommandAlias("mv")
public class SpawnCommand extends MultiverseCoreCommand {
public SpawnCommand(MultiverseCore plugin) {
super(plugin);
Permission otherPerm = new Permission("multiverse.core.spawn.other",
"Teleports another player to the spawn of the world they are in.", PermissionDefault.OP);
this.setName("Spawn");
this.setCommandUsage("/mv spawn" + ChatColor.GOLD + " [PLAYER]");
this.setArgRange(0, 1);
this.addKey("mvspawn");
this.addKey("mv spawn");
this.addKey("mvs");
this.setPermission("multiverse.core.spawn.self", "Teleports you to the Spawn Point of the world you are in.", PermissionDefault.OP);
this.addAdditonalPermission(otherPerm);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
// If a persons name was passed in, you must be A. the console, or B have permissions
if (args.size() == 1) {
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.other", true)) {
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.core.spawn.other)");
return;
}
Player target = this.plugin.getServer().getPlayer(args.get(0));
if (target != null) {
target.sendMessage("Teleporting to this world's spawn...");
spawnAccurately(target);
if (player != null) {
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
} else {
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
}
} else {
sender.sendMessage(args.get(0) + " is not logged on right now!");
}
} else {
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.core.spawn.self)");
return;
}
if (player != null) {
player.sendMessage("Teleporting to this world's spawn...");
spawnAccurately(player);
} else {
sender.sendMessage("From the console, you must provide a PLAYER.");
}
}
@Subcommand("spawn")
@CommandPermission("multiverse.core.spawn.self")
@Description("Teleport yourself to the spawn of the world.")
public void onSpawnCommand(@NotNull Player player) {
doSpawn(player, player);
}
private void spawnAccurately(Player player) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName());
Location spawnLocation;
if (world != null) {
spawnLocation = world.getSpawnLocation();
} else {
spawnLocation = player.getWorld().getSpawnLocation();
@CommandAlias("spawn")
@CommandPermission("multiverse.core.spawn.other")
@Syntax("[player]")
@CommandCompletion("@players")
@Description("Teleport another player to the spawn of the world they are in.")
public void onSpawnCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("[player]")
@Description("Target player to teleport to spawn.")
RequiredPlayer player) {
doSpawn(sender, player.get());
}
private void doSpawn(@NotNull CommandSender sender,
@NotNull Player player) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld());
Location spawnLocation = (world == null) ? player.getWorld().getSpawnLocation() : world.getSpawnLocation();
this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false);
if (sender.equals(player)) {
player.sendMessage("Teleported to this world's spawn.");
return;
}
this.plugin.getTeleporter().safelyTeleport(player, player, spawnLocation, false);
String senderName = (sender instanceof ConsoleCommandSender)
? String.format("%sconsole%s", ChatColor.LIGHT_PURPLE, ChatColor.RESET)
: String.format("%s%s%s", ChatColor.YELLOW, sender.getName(), ChatColor.RESET);
player.sendMessage("You were teleported by " + senderName + "to spawn.");
}
}
@@ -1,65 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.getspout.spoutapi.gui.GenericButton;
import org.getspout.spoutapi.gui.GenericPopup;
import org.getspout.spoutapi.gui.PopupScreen;
import org.getspout.spoutapi.player.SpoutPlayer;
import java.util.List;
/**
* Edit a world with spout.
*/
public class SpoutCommand extends MultiverseCommand {
public SpoutCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Edit World with Spout");
this.setCommandUsage("/mv spout");
this.setArgRange(0, 0);
this.addKey("mv spout");
this.setPermission("multiverse.core.spout", "Edit a world with spout.", PermissionDefault.OP);
this.addCommandExample("/mv spout");
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command must be run as a player!");
return;
}
if (plugin.getSpout() == null) {
sender.sendMessage(ChatColor.RED + "You need spout installed on this server to use it with Multiverse!");
return;
}
SpoutPlayer p = (SpoutPlayer) sender;
if (!p.isSpoutCraftEnabled()) {
sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!");
return;
}
PopupScreen pop = new GenericPopup();
GenericButton button = new GenericButton("Fish");
// TODO maybe use constants for these
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
button.setX(50);
button.setY(50);
button.setWidth(100);
button.setHeight(40);
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
pop.attachWidget(this.plugin, button);
sender.sendMessage(ChatColor.GREEN + "YAY!");
p.getMainScreen().attachPopupScreen(pop);
}
}
@@ -0,0 +1,79 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandHelp;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.HelpCommand;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class SubModulesCommand {
public static class NetherPortals extends BaseCommand {
@HelpCommand
@CommandAlias("mvnp")
@CommandPermission("multiverse.core.submodules")
@Description("Suggest download for Multiverse-NetherPortals.")
public void onSuggestCommand(@NotNull CommandSender sender,
@NotNull CommandHelp help) {
suggestDownload(
sender,
"Multiverse-NetherPortals",
ColorAlternator.with(ChatColor.DARK_PURPLE, ChatColor.LIGHT_PURPLE),
"https://dev.bukkit.org/projects/multiverse-netherportals"
);
}
}
public static class Portals extends BaseCommand {
@HelpCommand
@CommandAlias("mvp")
@CommandPermission("multiverse.core.submodules")
@Description("Suggest download for Multiverse-Portals.")
public void onSuggestCommand(@NotNull CommandSender sender,
@NotNull CommandHelp help) {
suggestDownload(
sender,
"Multiverse-Portals",
ColorAlternator.with(ChatColor.DARK_RED, ChatColor.RED),
"https://dev.bukkit.org/projects/multiverse-portals"
);
}
}
public static class Inventories extends BaseCommand {
@HelpCommand
@CommandAlias("mvinv")
@CommandPermission("multiverse.core.submodules")
@Description("Suggest download for Multiverse-Inventories.")
public void onSuggestCommand(@NotNull CommandSender sender,
@NotNull CommandHelp help) {
suggestDownload(
sender,
"Multiverse-Inventories",
ColorAlternator.with(ChatColor.DARK_AQUA, ChatColor.AQUA),
"https://dev.bukkit.org/projects/multiverse-inventories"
);
}
}
private static void suggestDownload(@NotNull CommandSender sender,
@NotNull String pluginName,
@NotNull ColorAlternator colours,
@NotNull String downloadLink) {
sender.sendMessage(String.format("%s%s%s is not installed on this server. You can learn more and download it at:",
colours.getThisColor(), pluginName, ChatColor.WHITE));
sender.sendMessage(String.format("%s%s", colours.getThatColor(), downloadLink));
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,201 +7,215 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.Teleporter;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import com.onarandombox.MultiverseCore.destination.CustomTeleporterDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.destination.WorldDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.Set;
/**
* Used to teleport players.
*/
public class TeleportCommand extends MultiverseCommand {
private SafeTTeleporter playerTeleporter;
public class TeleportCommand extends MultiverseCoreCommand {
private final SafeTTeleporter playerTeleporter;
private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 300; // In ticks
public TeleportCommand(MultiverseCore plugin) {
super(plugin);
Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
this.setName("Teleport");
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 2);
this.addKey("mvtp");
this.addKey("mv tp");
this.playerTeleporter = new SafeTTeleporter(this.plugin);
this.setPermission(menu);
this.playerTeleporter = this.plugin.getSafeTTeleporter();
}
private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 15;
@CommandAlias("mv")
public class Teleport extends BaseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
CommandSender teleporter = sender;
Player teleportee = null;
if (sender instanceof Player) {
teleporter = (Player) sender;
@Subcommand("tp|teleport")
@Syntax("[player] <destination>")
@CommandCompletion("@players|@MVWorlds:playerOnly|@destinations:playerOnly @players|@MVWorlds|@destinations")
@Description("Allows you to the teleport to a location on your server!")
public void doTeleportCommand(@NotNull CommandSender sender,
@Syntax("[player]")
@Description("Target player to teleport.")
@NotNull @Flags("other,defaultself,fallbackself") Player player,
@Syntax("<destination>")
@Description("Location, can be a world name.")
@NotNull @Flags("type=destination") String destinationName) {
doTeleport(sender, player, destinationName);
}
String destinationName;
if (args.size() == 2) {
teleportee = this.plugin.getServer().getPlayer(args.get(0));
if (teleportee == null) {
this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s",
ChatColor.GOLD, args.get(0)), false);
return;
}
destinationName = args.get(1);
} else {
destinationName = args.get(0);
if (!(sender instanceof Player)) {
this.messaging.sendMessage(sender, String.format("From the console, you must specify a player to teleport"), false);
return;
}
teleportee = (Player) sender;
@Override
public Set<String> getRequiredPermissions() {
return destPerms();
}
// Special case for cannons:
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
String[] cannonSpeed = destinationName.split("-");
try {
double speed = Double.parseDouble(cannonSpeed[1]);
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX()
+ "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":"
+ teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
} catch (Exception e) {
destinationName = "i:invalid";
}
}
public class AliasTeleport extends BaseCommand {
@CommandAlias("mvtp")
@Syntax("[player] <destination>")
@CommandCompletion("@players|@MVWorlds:playerOnly|@destinations:playerOnly @MVWorlds|@destinations")
@Description("Alias for /mv tp")
public void doTeleportCommand(@NotNull CommandSender sender,
@Syntax("[player]")
@Description("Target player to teleport.")
@NotNull @Flags("other,defaultself,fallbackself") Player player,
@Syntax("<destination>")
@Description("Location, can be a world name.")
@NotNull @Flags("type=destination") String destinationName) {
doTeleport(sender, player, destinationName);
}
DestinationFactory df = this.plugin.getDestFactory();
MVDestination d = df.getDestination(destinationName);
@Override
public Set<String> getRequiredPermissions() {
return destPerms();
}
}
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
private Set<String> destPerms() {
return this.plugin.getDestFactory().getPermissions();
}
private void doTeleport(@NotNull CommandSender teleporter,
@NotNull Player teleportee,
@NotNull String destinationName) {
MVDestination destination = this.plugin.getDestFactory().getPlayerAwareDestination(teleportee, destinationName);
MVTeleportEvent teleportEvent = new MVTeleportEvent(destination, teleportee, teleporter, true);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) {
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
Logging.fine("Someone else cancelled the MVTeleport Event!!!");
return;
}
if (d != null && d instanceof InvalidDestination) {
this.messaging.sendMessage(sender, String.format("Multiverse does not know how to take you to %s%s",
ChatColor.RED, destinationName), false);
if (destination instanceof InvalidDestination) {
teleporter.sendMessage(String.format("Multiverse does not know how to take you to %s%s", ChatColor.RED, destinationName));
return;
}
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
if (!this.checkSendPermissions(teleporter, teleportee, destination)) {
return;
}
if (MultiverseCore.EnforceAccess && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD
+ teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
}
return;
} else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
if (teleportee.equals(teleporter)) {
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...",
ChatColor.GREEN, d.toString(), ChatColor.WHITE), false);
} else {
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED), false);
}
if (this.plugin.getMVConfig().getEnforceAccess() && !this.plugin.getMVPerms().canEnterDestination(teleportee, destination)) {
teleporter.sendMessage((teleportee.equals(teleporter))
? "Doesn't look like you're allowed to go " + ChatColor.RED + "there..."
: "Doesn't look like you're allowed to send " + ChatColor.GOLD + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
return;
}
// Special check to verify if players are tryint to teleport to the same
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
if (d instanceof WorldDestination) {
World w = d.getLocation(teleportee).getWorld();
if (teleportee.getWorld().equals(w)) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to go to the world spawn!"),
String.format("%s (multiverse.core.spawn.self)",
ChatColor.RED) }, false);
return;
}
} else {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to send %s to the world spawn!",
teleportee.getDisplayName()),
String.format("%s (multiverse.core.spawn.other)",
ChatColor.RED) }, false);
return;
}
}
}
}
if (d.getLocation(teleportee) == null) {
this.messaging.sendMessage(teleporter, "Sorry Boss, I tried everything, but just couldn't teleport ya there!", false);
if (!this.plugin.getMVPerms().canTravelFromLocation(teleporter, destination.getLocation(teleportee))) {
teleporter.sendMessage((teleportee.equals(teleporter))
? String.format("Doh! Doesn't look like you can get to %s%s %sfrom where you are...",
ChatColor.GREEN, destination.toString(), ChatColor.WHITE)
: String.format("Doh! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED));
return;
}
TeleportResult result = this.playerTeleporter.safelyTeleport(teleporter, teleportee, d);
// Special check to verify if players are trying to teleport to the same WORLD Destination
// as the world they're in, that they ALSO have multiverse.core.spawn.self
if (destination instanceof WorldDestination
&& teleportee.getWorld().equals(destination.getLocation(teleportee).getWorld())
&& !checkSpawnPermissions(teleporter, teleportee)) {
return;
}
if (destination.getLocation(teleportee) == null) {
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
return;
}
Teleporter teleportObject = (destination instanceof CustomTeleporterDestination)
? ((CustomTeleporterDestination) destination).getTeleporter()
: this.playerTeleporter;
TeleportResult result = teleportObject.teleport(teleporter, teleportee, destination);
if (result == TeleportResult.FAIL_UNSAFE) {
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + LocationManipulation.strCoordsRaw(d.getLocation(teleportee)));
this.plugin.log(Level.FINE, "Queueing Command");
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List<Object> items = new ArrayList<Object>();
items.add(teleporter);
items.add(teleportee);
items.add(d.getLocation(teleportee));
String player = "you";
if (!teleportee.equals(teleporter)) {
player = teleportee.getName();
}
String message = String.format("%sMultiverse %sdid not teleport %s%s%sto %s%s%sbecause it was unsafe.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
Logging.fine("Could not teleport %s to %s.",
teleportee.getName(), this.plugin.getLocationManipulation().strCoordsRaw(destination.getLocation(teleportee)));
this.plugin.getMVCommandManager().getQueueManager().addToQueue(new QueuedCommand.Builder()
.sender(teleporter)
.action(unsafeTeleportRunnable(teleporter, teleportee, destination.getLocation(teleportee)))
.prompt("The location you are trying to teleport to is deemed unsafe, do you still want to try?")
.validDuration(UNSAFE_TELEPORT_EXPIRE_DELAY)
.build()
);
}
// else: Player was teleported successfully (or the tp event was fired I should say)
}
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
private boolean checkSendPermissions(@NotNull CommandSender teleporter,
@NotNull Player teleportee,
@NotNull MVDestination destination) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("%sYou don't have permission to teleport %syourself %sto a %s%s %sDestination",
ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, destination.getType(), ChatColor.WHITE),
String.format("%s (multiverse.teleport.self.%s)",
ChatColor.RED, destination.getIdentifier()) }, false);
return false;
}
} else {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("You don't have permission to teleport another player to a %s%s Destination.",
ChatColor.GREEN, destination.getType()),
String.format("%s(multiverse.teleport.other.%s)",
ChatColor.RED, destination.getIdentifier()) }, false);
teleporter.sendMessage(String.format("%sYou don't have permission to teleport %syourself %sto a %s%s %sDestination", ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, destination.getType(), ChatColor.WHITE));
teleporter.sendMessage(String.format("%s (multiverse.teleport.self.%s)", ChatColor.RED, destination.getIdentifier()));
return false;
}
return true;
}
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
teleporter.sendMessage(String.format("You don't have permission to teleport another player to a %s%s Destination.", ChatColor.GREEN, destination.getType()));
teleporter.sendMessage(String.format("%s(multiverse.teleport.other.%s)", ChatColor.RED, destination.getIdentifier()));
return false;
}
return true;
}
private boolean checkSpawnPermissions(@NotNull CommandSender teleporter,
@NotNull Player teleportee) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
teleporter.sendMessage(String.format("Sorry you don't have permission to go to the world spawn!"));
teleporter.sendMessage(String.format("%s (multiverse.core.spawn.self)", ChatColor.RED));
return false;
}
return true;
}
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
teleporter.sendMessage(String.format("Sorry you don't have permission to send %s to the world spawn!", teleportee.getDisplayName()));
teleporter.sendMessage(String.format("%s (multiverse.core.spawn.other)", ChatColor.RED));
return false;
}
return true;
}
@NotNull
private Runnable unsafeTeleportRunnable(@NotNull CommandSender teleporter,
@NotNull Player teleportee,
@NotNull Location location) {
return () -> this.plugin.getSafeTTeleporter().safelyTeleport(teleporter, teleportee, location, false);
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,36 +7,44 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Unloads worlds from Multiverse.
*/
public class UnloadCommand extends MultiverseCommand {
@CommandAlias("mv")
public class UnloadCommand extends MultiverseCoreCommand {
public UnloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Unload World");
this.setCommandUsage("/mv unload" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvunload");
this.addKey("mv unload");
this.setPermission("multiverse.core.unload",
"Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().unloadWorld(args.get(0))) {
Command.broadcastCommandMessage(sender, "Unloaded world '" + args.get(0) + "'!");
} else {
sender.sendMessage("Error trying to unload world '" + args.get(0) + "'!");
@Subcommand("unload")
@CommandPermission("multiverse.core.unload")
@Syntax("<world>")
@CommandCompletion("@MVWorlds")
@Description("Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.")
public void onUnloadCommand(@NotNull CommandSender sender,
@NotNull
@Syntax("<world>")
@Description("Name of world you want to unload.")
@Flags("other") MultiverseWorld world) {
//TODO API: Should be able to use MVWorld object directly
if (!this.plugin.getMVWorldManager().unloadWorld(world.getName())) {
sender.sendMessage(String.format("Error unloading world '%s'! See console for more details.",
world.getColoredWorldString()));
return;
}
Command.broadcastCommandMessage(sender, String.format("Unloaded world '%s'!", world.getColoredWorldString()));
}
}
@@ -0,0 +1,37 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.CommandHelp;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.HelpCommand;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.jetbrains.annotations.NotNull;
@CommandAlias("mv")
public class UsageCommand extends MultiverseCoreCommand {
public UsageCommand(MultiverseCore plugin) {
super(plugin);
}
@HelpCommand
@Subcommand("help")
@CommandPermission("multiverse.core.help")
@Syntax("[filter] [page]")
@CommandCompletion("@subCommands:mv")
@Description("Show Multiverse-Core Command usage.")
public void onUsageCommand(@NotNull CommandHelp help) {
this.plugin.getMVCommandManager().showUsage(help);
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,103 +7,177 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagResult;
import com.onarandombox.MultiverseCore.commandtools.flag.CoreFlags;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteFailedException;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteService;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceFactory;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortener;
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortenerFactory;
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortenerType;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.logging.Level;
import java.io.File;
import java.util.Arrays;
import java.util.Map;
/**
* Dumps version info to the console.
*/
public class VersionCommand extends MultiverseCommand {
@CommandAlias("mv")
public class VersionCommand extends MultiverseCoreCommand {
private static final URLShortener SHORTENER = URLShortenerFactory.getService(URLShortenerType.BITLY);
public VersionCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Multiverse Version");
this.setCommandUsage("/mv version " + ChatColor.GOLD + "-[pb]");
this.setArgRange(0, 1);
this.addKey("mv version");
this.addKey("mvv");
this.addKey("mvversion");
this.setPermission("multiverse.core.version",
"Dumps version info to the console, optionally to pastie.org with -p or pastebin.com with a -b.", PermissionDefault.TRUE);
this.setFlagGroup(FlagGroup.of(
CoreFlags.PASTE_SERVICE_TYPE,
CoreFlags.INCLUDE_PLUGIN_LIST
));
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
if (sender instanceof Player) {
sender.sendMessage("Version info dumped to console. Please check your server logs.");
}
@Subcommand("version")
@CommandPermission("multiverse.core.version")
@Syntax("--paste [pastebin|hastebin|pastegg] [--include-plugin-list]")
@CommandCompletion("@flags")
@Description("Dumps version info to the console, optionally to pastal service.")
public void onVersionCommand(@NotNull CommandSender sender,
StringBuilder buffer = new StringBuilder();
buffer.append("[Multiverse-Core] Multiverse-Core Version: ").append(this.plugin.getDescription().getVersion()).append('\n');
buffer.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n');
buffer.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds().size()).append('\n');
buffer.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n');
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
.append(this.plugin.getMVConfiguration().getDouble("version", -1)).append(")").append('\n');
buffer.append("[Multiverse-Core] messagecooldown: ").append(this.plugin.getMessaging().getCooldown()).append('\n');
buffer.append("[Multiverse-Core] teleportcooldown: ").append("Not yet IMPLEMENTED").append('\n');
buffer.append("[Multiverse-Core] worldnameprefix: ").append(MultiverseCore.PrefixChat).append('\n');
buffer.append("[Multiverse-Core] enforceaccess: ").append(MultiverseCore.EnforceAccess).append('\n');
buffer.append("[Multiverse-Core] displaypermerrors: ").append(MultiverseCore.DisplayPermErrors).append('\n');
buffer.append("[Multiverse-Core] teleportintercept: ").append(MultiverseCore.TeleportIntercept).append('\n');
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(MultiverseCore.FirstSpawnOverride).append('\n');
buffer.append("[Multiverse-Core] firstspawnworld: ").append(this.plugin.getMVConfiguration().getString("firstspawnworld", "NOT SET")).append('\n');
buffer.append("[Multiverse-Core] debug: ").append(MultiverseCore.GlobalDebug).append('\n');
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
@NotNull
@Syntax("[paste-service]")
@Description("Website to upload your version info to.")
String[] flagsArray) {
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
FlagResult flags = FlagResult.parse(flagsArray, this.getFlagGroup());
MVVersionEvent versionEvent = new MVVersionEvent();
this.addVersionInfoToEvent(versionEvent);
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
// log to console
String data = versionEvent.getVersionInfo();
String[] lines = data.split("\n");
for (String line : lines) {
this.plugin.log(Level.INFO, line);
if (flags.getValue(CoreFlags.INCLUDE_PLUGIN_LIST)) {
versionEvent.appendVersionInfo('\n' + "Plugins: " + getPluginList());
versionEvent.putDetailedVersionInfo("plugins.txt", "Plugins: " + getPluginList());
}
if (args.size() == 1) {
String pasteUrl = "";
if (args.get(0).equalsIgnoreCase("-p")) {
pasteUrl = postToService(PasteServiceType.PASTIE, true, data); // private post to pastie
} else if (args.get(0).equalsIgnoreCase("-b")) {
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, data); // private post to pastie
} else {
return;
String versionInfo = versionEvent.getVersionInfo();
versionEvent.putDetailedVersionInfo("version.txt", versionInfo);
Map<String, String> files = versionEvent.getDetailedVersionInfo();
logToConsole(versionInfo);
PasteServiceType pasteType = flags.getValue(CoreFlags.PASTE_SERVICE_TYPE);
if (pasteType == PasteServiceType.NONE && !(sender instanceof ConsoleCommandSender)) {
sender.sendMessage("Version info dumped to console! Please check your server logs.");
return;
}
BukkitRunnable logPoster = new BukkitRunnable() {
@Override
public void run() {
String pasteUrl = postToService(pasteType, true, versionInfo, files);
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
}
};
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
this.plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
}
// Run the log posting operation asynchronously, since we don't know how long it will take.
logPoster.runTaskAsynchronously(this.plugin);
}
private void logToConsole(String versionInfo) {
Arrays.stream(versionInfo.split("\\r?\\n"))
.filter(line -> !line.isEmpty())
.forEach(this.plugin.getServer().getLogger()::info);
}
private void addVersionInfoToEvent(MVVersionEvent event) {
// add the legacy version info
event.appendVersionInfo(this.getLegacyString());
// add the legacy file, but as markdown so it's readable
// TODO API: Readd this in 5.0.0
// event.putDetailedVersionInfo("version.md", this.getMarkdownString());
// add config.yml
File configFile = new File(this.plugin.getDataFolder(), "config.yml");
event.putDetailedVersionInfo("multiverse-core/config.yml", configFile);
// add worlds.yml
File worldsFile = new File(this.plugin.getDataFolder(), "worlds.yml");
event.putDetailedVersionInfo("multiverse-core/worlds.yml", worldsFile);
}
/**
* Send the current contents of this.pasteBinBuffer to a web service.
*
* @param type Service type to send to
* @param isPrivate Should the paste be marked as private.
* @param type Service type to send paste data to.
* @param isPrivate Should the paste be marked as private.
* @param pasteData Legacy string only data to post to a service.
* @param pasteFiles Map of filenames/contents of debug info.
* @return URL of visible paste
*/
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData) {
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData, Map<String, String> pasteFiles) {
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
try {
return ps.postData(ps.encodeData(pasteData), ps.getPostURL());
} catch (PasteFailedException e) {
System.out.print(e);
return "Error posting to service";
String result = (ps.supportsMultiFile())
? ps.postData(pasteFiles)
: ps.postData(pasteData);
return (SHORTENER != null) ? SHORTENER.shorten(result) : result;
}
catch (PasteFailedException e) {
e.printStackTrace();
return String.format("%sError posting to service.", ChatColor.RED);
}
catch (NullPointerException e) {
e.printStackTrace();
return String.format("%sThat service isn't supported yet.", ChatColor.RED);
}
}
private String getLegacyString() {
return "[Multiverse-Core] Multiverse-Core Version: " + this.plugin.getDescription().getVersion() + '\n'
+ "[Multiverse-Core] Bukkit Version: " + this.plugin.getServer().getVersion() + '\n'
+ "[Multiverse-Core] Loaded Worlds: " + this.plugin.getMVWorldManager().getMVWorlds() + '\n'
+ "[Multiverse-Core] Multiverse Plugins Loaded: " + this.plugin.getPluginCount() + '\n'
+ "[Multiverse-Core] Economy being used: " + plugin.getEconomist().getEconomyName() + '\n'
+ "[Multiverse-Core] Permissions Plugin: " + this.plugin.getMVPerms().getType() + '\n'
+ "[Multiverse-Core] Dumping Config Values: (version " + this.plugin.getMVConfig().getVersion() + ")" + '\n'
+ "[Multiverse-Core] enforceaccess: " + this.plugin.getMVConfig().getEnforceAccess() + '\n'
+ "[Multiverse-Core] prefixchat: " + this.plugin.getMVConfig().getPrefixChat() + '\n'
+ "[Multiverse-Core] prefixchatformat: " + this.plugin.getMVConfig().getPrefixChatFormat() + '\n'
+ "[Multiverse-Core] useasyncchat: " + this.plugin.getMVConfig().getUseAsyncChat() + '\n'
+ "[Multiverse-Core] teleportintercept: " + this.plugin.getMVConfig().getTeleportIntercept() + '\n'
+ "[Multiverse-Core] firstspawnoverride: " + this.plugin.getMVConfig().getFirstSpawnOverride() + '\n'
+ "[Multiverse-Core] displaypermerrors: " + this.plugin.getMVConfig().getDisplayPermErrors() + '\n'
+ "[Multiverse-Core] globaldebug: " + this.plugin.getMVConfig().getGlobalDebug() + '\n'
+ "[Multiverse-Core] enablebuscript: " + plugin.getMVConfig().getEnableBuscript() + '\n'
+ "[Multiverse-Core] silentstart: " + this.plugin.getMVConfig().getSilentStart() + '\n'
+ "[Multiverse-Core] messagecooldown: " + this.plugin.getMessaging().getCooldown() + '\n'
+ "[Multiverse-Core] version: " + this.plugin.getMVConfig().getVersion() + '\n'
+ "[Multiverse-Core] firstspawnworld: " + this.plugin.getMVConfig().getFirstSpawnWorld() + '\n'
+ "[Multiverse-Core] teleportcooldown: " + this.plugin.getMVConfig().getTeleportCooldown() + '\n'
+ "[Multiverse-Core] defaultportalsearch: " +this. plugin.getMVConfig().isUsingDefaultPortalSearch() + '\n'
+ "[Multiverse-Core] portalsearchradius: " + this.plugin.getMVConfig().getPortalSearchRadius() + '\n'
+ "[Multiverse-Core] autopurge: " +this. plugin.getMVConfig().isAutoPurgeEnabled() + '\n'
+ "[Multiverse-Core] Special Code: FRN002" + '\n';
}
private String getPluginList() {
return StringUtils.join(this.plugin.getServer().getPluginManager().getPlugins(), ", ");
}
}
@@ -1,5 +1,5 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* 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. *
@@ -7,98 +7,123 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
import com.onarandombox.MultiverseCore.displaytools.ContentDisplay;
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
import com.onarandombox.MultiverseCore.displaytools.DisplayHandlers;
import com.onarandombox.MultiverseCore.displaytools.DisplaySettings;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* States who is in what world.
*/
public class WhoCommand extends MultiverseCommand {
private MVWorldManager worldManager;
@CommandAlias("mv")
public class WhoCommand extends MultiverseCoreCommand {
public WhoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Who?");
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(0, 1);
this.addKey("mv who");
this.addKey("mvw");
this.addKey("mvwho");
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// If this command was sent from a Player then we need to check Permissions
Player p = null;
// By default, show all from the console
boolean showAll = true;
if (sender instanceof Player) {
p = (Player) sender;
showAll = false;
}
@Subcommand("whoall")
@CommandPermission("multiverse.core.list.who.all")
@Syntax("[filter]")
public void onWhoAllCommand(@NotNull CommandSender sender,
List<MultiverseWorld> worlds = new ArrayList<MultiverseWorld>();
@NotNull
@Syntax("[filter] [page]")
@Description("Filter and paging.")
PageFilter pageFilter) {
if (args.size() > 0) {
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
showAll = true;
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
} else if (world != null) {
if (!world.isHidden()) {
worlds.add(world);
}
} else {
sender.sendMessage(ChatColor.RED + "World does not exist");
return;
}
} else {
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
}
Player player = (sender instanceof Player) ? (Player) sender : null;
Set<Player> visiblePlayers = getVisiblePlayers(player);
if (worlds.size() == 0) {
sender.sendMessage("Multiverse does not know about any of your worlds :(");
} else if (worlds.size() == 1) {
sender.sendMessage(ChatColor.AQUA + "--- Players in" + worlds.get(0).getColoredWorldString() + ChatColor.AQUA + " ---");
} else {
sender.sendMessage(ChatColor.AQUA + "--- There are players in ---");
}
new ContentDisplay.Builder<Collection<String>>()
.sender(sender)
.header("%s--- Worlds and their players --- %s%s/%s", ChatColor.GOLD, ChatColor.AQUA, visiblePlayers.size(), this.plugin.getServer().getMaxPlayers())
.contents(buildAllWorlds(player, visiblePlayers))
.displayHandler(DisplayHandlers.PAGE_LIST)
.filter(pageFilter.getFilter())
.setting(DisplaySettings.SHOW_PAGE, pageFilter.getPage())
.display();
}
for (MultiverseWorld world : worlds) {
if (!(this.worldManager.isMVWorld(world.getName()))) {
continue;
}
@Subcommand("who")
@CommandPermission("multiverse.core.list.who")
@Syntax("[world] [filter]")
@CommandCompletion("@MVWorlds")
public void onWhoCommand(@NotNull CommandSender sender,
@Nullable @Optional Player player,
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
}
List<Player> players = world.getCBWorld().getPlayers();
@NotNull
@Syntax("[world]")
@Description("World to show player list.")
@Flags("other,defaultself,fallbackself")
@Conditions("hasWorldAccess") MultiverseWorld world,
String result = "";
if (players.size() <= 0 && !showAll) {
continue;
}
@NotNull
@Syntax("[filter]")
@Description("Filter the player names.")
ContentFilter filter) {
if (players.size() <= 0) {
result = "Empty";
} else {
for (Player player : players) {
result += player.getDisplayName() + " " + ChatColor.WHITE;
}
}
Set<Player> visiblePlayers = getVisiblePlayers(player);
sender.sendMessage(world.getColoredWorldString() + ChatColor.WHITE + " - " + result);
}
new ContentDisplay.Builder<Collection<String>>()
.sender(sender)
.header("%s===[ Players in %s%s ]===", ChatColor.AQUA, world.getColoredWorldString(), ChatColor.AQUA)
.contents(buildPlayerList(world, visiblePlayers))
.emptyMessage("%sNo players found.", ChatColor.GRAY)
.displayHandler(DisplayHandlers.PAGE_LIST)
//TODO: Filter
.display();
}
private List<String> buildAllWorlds(@Nullable Player player,
@NotNull Set<Player> visiblePlayers) {
return this.plugin.getMVWorldManager().getMVWorlds().stream()
.filter(world -> player == null || this.plugin.getMVPerms().canEnterWorld(player, world))
.map(world -> getPLayersInWorld(world, visiblePlayers))
.collect(Collectors.toList());
}
private String getPLayersInWorld(@NotNull MultiverseWorld world,
@NotNull Set<Player> visiblePlayers) {
return String.format("%s%s - %s",
world.getColoredWorldString(), ChatColor.WHITE, buildPlayerList(world, visiblePlayers));
}
@NotNull
private List<String> buildPlayerList(@NotNull MultiverseWorld world,
@NotNull Set<Player> visiblePlayers) {
return world.getCBWorld().getPlayers().stream()
.filter(visiblePlayers::contains)
.map(Player::getDisplayName)
.collect(Collectors.toList());
}
@NotNull
private Set<Player> getVisiblePlayers(@Nullable Player player) {
return this.plugin.getServer().getOnlinePlayers().stream()
.filter(targetPLayer -> player == null || player.canSee(targetPLayer))
.collect(Collectors.toSet());
}
}
@@ -1,4 +1,4 @@
/**
* This package contains all Commands.
* Where all the commands are.
*/
package com.onarandombox.MultiverseCore.commands;
package com.onarandombox.MultiverseCore.commands;
@@ -0,0 +1,323 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools;
import buscript.Buscript;
import co.aikar.commands.BukkitCommandCompletionContext;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.PaperCommandCompletions;
import co.aikar.commands.RegisteredCommand;
import co.aikar.commands.RootCommand;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commandtools.flag.CommandFlag;
import com.onarandombox.MultiverseCore.commandtools.flag.CommandFlag.ValueRequirement;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
import com.onarandombox.MultiverseCore.enums.AddProperties;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
import org.bukkit.GameRule;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Generate tab-complete suggestion.
*/
public class MVCommandCompletions extends PaperCommandCompletions {
private final MultiverseCore plugin;
private final MVWorldManager worldManager;
private static final DecimalFormat df = new DecimalFormat();
static {
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
}
public MVCommandCompletions(@NotNull MVCommandManager manager,
@NotNull MultiverseCore plugin) {
super(manager);
this.plugin = plugin;
this.worldManager = plugin.getMVWorldManager();
registerAsyncCompletion("flags", this::suggestFlags);
registerAsyncCompletion("scripts", this::suggestScripts);
registerAsyncCompletion("subCommands", this::suggestSubCommands);
registerAsyncCompletion("MVWorlds", this::suggestMVWorlds);
registerAsyncCompletion("unloadedWorlds", this::suggestUnloadedWorlds);
registerAsyncCompletion("potentialWorlds", this::suggestPotentialWorlds);
registerAsyncCompletion("location", this::suggestLocation);
registerAsyncCompletion("destinations", this::suggestDestinations);
registerAsyncCompletion("anchors", this::suggestAnchors);
registerStaticCompletion("MVConfigs", this::suggestMVConfig);
registerStaticCompletion("gameRules", this::suggestGameRules);
registerStaticCompletion("environments", this::suggestEnvironments);
registerStaticCompletion("setProperties", this::suggestSetProperties);
registerStaticCompletion("addProperties", this::suggestAddProperties);
registerStaticCompletion("livingEntities", this::suggestEntities);
registerStaticCompletion("pasteTypes", this::suggestPasteTypes);
registerStaticCompletion("toggles", this::suggestToggles);
}
@NotNull
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
final MultiverseCommand command = MVCommandReflect.getCommandCompletionContextCommand(context);
if (command == null) {
Logging.warning("Unable to parse flags as MultiverseCommand not found!");
return Collections.emptyList();
}
FlagGroup flagGroup = command.getFlagGroup();
String[] args = context.getContextValue(String[].class);
CommandFlag<?> flag = (args.length <= 1) ? null : flagGroup.getByKey(args[args.length - 2]);
if (flag == null || flag.getValueRequirement() == ValueRequirement.NONE) {
// suggest new flags.
return getRemainingFlagIdentifiers(flagGroup, args);
}
Collection<String> flagSuggestions = flag.suggestValue();
if (flag.getValueRequirement() == ValueRequirement.OPTIONAL) {
// suggest new flags and values.
flagSuggestions.addAll(getRemainingFlagIdentifiers(flagGroup, args));
return flagSuggestions;
}
// suggest new values.
return flagSuggestions == null ? Collections.emptySet() : flagSuggestions;
}
private Collection<String> getRemainingFlagIdentifiers(FlagGroup flagGroup, String[] args) {
Set<String> identifiersRemaining = new HashSet<>(flagGroup.getFlagIdentifiers());
identifiersRemaining.removeAll(Arrays.asList(args));
return identifiersRemaining;
}
@NotNull
private Collection<String> suggestScripts(@NotNull BukkitCommandCompletionContext context) {
Buscript scriptAPI = this.plugin.getScriptAPI();
if (scriptAPI == null) {
return Collections.emptyList();
}
return Arrays.stream(scriptAPI.getScriptFolder().listFiles())
.unordered()
.filter(File::isFile)
.map(File::getName)
.filter(fileName -> !fileName.equals("scripts.bin"))
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestSubCommands(@NotNull BukkitCommandCompletionContext context) {
String rootCmdName = context.getConfig();
if (rootCmdName == null) {
return Collections.emptyList();
}
RootCommand rootCommand = this.plugin.getMVCommandManager().getRegisteredRootCommands().stream()
.unordered()
.filter(c -> c.getCommandName().equals(rootCmdName))
.findFirst()
.orElse(null);
if (rootCommand == null) {
return Collections.emptyList();
}
return rootCommand.getSubCommands().entries().stream()
.unordered()
.filter(entry -> checkPerms(context.getIssuer(), entry.getValue()))
.map(Map.Entry::getKey)
.filter(cmdName -> !cmdName.startsWith("__"))
.collect(Collectors.toList());
}
private boolean checkPerms(@NotNull CommandIssuer issuer,
@NotNull RegisteredCommand<?> cmd) {
return this.plugin.getMVCommandManager().hasPermission(issuer, cmd.getRequiredPermissions());
}
@NotNull
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
if (isPlayerOnly(context)) {
return Collections.emptyList();
}
return this.worldManager.getMVWorlds().parallelStream()
.unordered()
.map(MultiverseWorld::getName)
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestUnloadedWorlds(@NotNull BukkitCommandCompletionContext context) {
if (isPlayerOnly(context)) {
return Collections.emptyList();
}
return this.worldManager.getUnloadedWorlds();
}
@NotNull
private Collection<String> suggestPotentialWorlds(@NotNull BukkitCommandCompletionContext context) {
if (isPlayerOnly(context)) {
return Collections.emptyList();
}
Collection<MultiverseWorld> worlds = this.worldManager.getMVWorlds();
Set<String> knownWorlds = worlds.parallelStream()
.unordered()
.map(MultiverseWorld::getName)
.collect(Collectors.toCollection(() -> new HashSet<>(worlds.size())));
return Arrays.stream(this.plugin.getServer().getWorldContainer().listFiles()).parallel()
.unordered()
.filter(File::isDirectory)
.filter(file -> !knownWorlds.contains(file.getName()))
.map(File::getName)
.filter(this.worldManager::isValidWorld)
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestLocation(@NotNull BukkitCommandCompletionContext context) {
if (isPlayerOnly(context)) {
return Collections.emptyList();
}
Player player = context.getPlayer();
if (player == null) {
return Collections.emptyList();
}
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
Location playerLocation = player.getLocation();
double coordValue;
switch (context.getConfig()) {
case "x":
coordValue = playerLocation.getX();
break;
case "y":
coordValue = playerLocation.getY();
break;
case "z":
coordValue = playerLocation.getZ();
break;
case "yaw":
coordValue = playerLocation.getYaw();
break;
case "pitch":
coordValue = playerLocation.getPitch();
break;
default:
return Collections.emptyList();
}
return Collections.singletonList(df.format(coordValue));
}
@NotNull
private Collection<String> suggestDestinations(@NotNull BukkitCommandCompletionContext context) {
if (isPlayerOnly(context)) {
return Collections.emptyList();
}
return this.plugin.getDestFactory().getIdentifiers().parallelStream()
.unordered()
.filter(id -> !id.isEmpty())
.map(id -> id + ":")
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestAnchors(@NotNull BukkitCommandCompletionContext context) {
if (isPlayerOnly(context)) {
return Collections.emptyList();
}
return this.plugin.getAnchorManager().getAnchors(context.getPlayer());
}
private boolean isPlayerOnly(@NotNull BukkitCommandCompletionContext context) {
String config = context.getConfig();
return config != null && context.getPlayer() == null && config.equals("playerOnly");
}
@NotNull
private Collection<String> suggestMVConfig() {
final Set<String> configOptions = this.plugin.getMVConfig().serialize().keySet();
configOptions.remove("version");
return configOptions;
}
@NotNull
private Collection<String> suggestGameRules() {
return Arrays.stream(GameRule.values())
.map(GameRule::getName)
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestEnvironments() {
return Arrays.stream(World.Environment.values())
.map(e -> e.toString().toLowerCase())
.collect(Collectors.toList());
}
private Collection<String> suggestSetProperties() {
return this.worldManager.getMVWorlds().iterator().next().getAllPropertyTypes();
}
@NotNull
private Collection<String> suggestAddProperties() {
return Arrays.stream(AddProperties.values())
.map(p -> p.toString().toLowerCase())
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestEntities() {
return Arrays.stream(EntityType.values())
.filter(e -> e.isAlive() && e.isSpawnable())
.map(e -> e.toString().toLowerCase())
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestPasteTypes() {
return Arrays.stream(PasteServiceType.values())
.filter(pt -> pt != PasteServiceType.GITHUB && pt != PasteServiceType.NONE)
.map(p -> p.toString().toLowerCase())
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestToggles() {
return Arrays.asList("on", "off");
}
}
@@ -0,0 +1,196 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.BukkitCommandExecutionContext;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.BukkitConditionContext;
import co.aikar.commands.CommandConditions;
import co.aikar.commands.ConditionContext;
import co.aikar.commands.ConditionFailedException;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.AddProperties;
import com.onarandombox.MultiverseCore.enums.WorldValidationResult;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* Args input validation.
*/
public class MVCommandConditions {
private final MultiverseCore plugin;
private final MVWorldManager worldManager;
public MVCommandConditions(@NotNull MultiverseCore plugin,
@NotNull CommandConditions<BukkitCommandIssuer, BukkitCommandExecutionContext, BukkitConditionContext> conditions) {
this.plugin = plugin;
this.worldManager = plugin.getMVWorldManager();
conditions.addCondition(String.class, "isMVWorld", this::checkIsMVWorld);
conditions.addCondition(String.class, "isUnloadedWorld", this::checkIsUnloadedWorld);
conditions.addCondition(String.class, "isWorldInConfig", this::checkIsWorldInConfig);
conditions.addCondition(String.class, "creatableWorldName", this::checkCreatableWorldName);
conditions.addCondition(String.class, "importableWorldName", this::checkImportableWorldName);
conditions.addCondition(String.class, "validWorldFolder", this::checkValidWorldFolder);
conditions.addCondition(String.class, "validAddProperty", this::checkValidAddProperty);
conditions.addCondition(MultiverseWorld.class, "hasWorldAccess", this::checkHasWorldAccess);
}
private void checkIsMVWorld(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String worldName) {
if (!this.worldManager.isMVWorld(worldName)) {
throw new ConditionFailedException(String.format("World '%s' not found.", worldName));
}
}
private void checkIsUnloadedWorld(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String worldName) {
if (this.worldManager.isMVWorld(worldName)) {
throw new ConditionFailedException(String.format("World '%s' is already loaded.", worldName));
}
if (!this.worldManager.getUnloadedWorlds().contains(worldName)) {
if (this.worldManager.isValidWorld(worldName)) {
CommandSender sender = executionContext.getSender();
sender.sendMessage(String.format("%sMultiverse does not know about world '%s' yet. Please import it with %s/mv import %s <env>%s.",
ChatColor.RED, worldName, ChatColor.AQUA, worldName, ChatColor.RED));
sender.sendMessage(String.format("See %s/mv help import %sfor more info.",
ChatColor.AQUA, ChatColor.WHITE));
throw new ConditionFailedException();
}
throw new ConditionFailedException(String.format("World '%s' not found.", worldName));
}
}
private void checkIsWorldInConfig(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String worldName) {
if (!this.worldManager.hasUnloadedWorld(worldName, true)) {
throw new ConditionFailedException(String.format("World '%s' not found.", worldName));
}
}
private void checkCreatableWorldName(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String worldName) {
if (this.worldManager.isMVWorld(worldName)) {
throw new ConditionFailedException(String.format("%sMultiverse cannot create %sanother %s%sworld named '%s'.",
ChatColor.RED, ChatColor.GOLD, ChatColor.RESET, ChatColor.RED, worldName));
}
WorldValidationResult validationResult = this.worldManager.validateWorld(worldName);
validateWorldNameResult(validationResult);
if (validationResult != WorldValidationResult.DOES_NOT_EXIST && validationResult != WorldValidationResult.NOT_A_DIRECTORY) {
CommandSender sender = executionContext.getSender();
if (validationResult == WorldValidationResult.VALID) {
sender.sendMessage(String.format("%sWorld Folder '%s' already look like a world to me! You can try importing it with %s/mv import%s.",
ChatColor.RED, worldName, ChatColor.AQUA, ChatColor.RED));
sender.sendMessage(String.format("See %s/mv help import %sfor more info.",
ChatColor.AQUA, ChatColor.WHITE));
throw new ConditionFailedException();
}
sender.sendMessage(String.format("%sA folder already exists with this name!", ChatColor.RED));
throw new ConditionFailedException();
}
}
private void checkImportableWorldName(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String worldName) {
if (this.worldManager.isMVWorld(worldName)) {
executionContext.getSender().sendMessage(String.format("%sMultiverse %s already knows about %s%s%s!",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, worldName, ChatColor.WHITE));
throw new ConditionFailedException();
}
checkValidWorldFolder(context, executionContext, worldName);
}
private void checkValidWorldFolder(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String worldName) {
WorldValidationResult validationResult = this.worldManager.validateWorld(worldName);
validateWorldNameResult(validationResult);
validateWorldFolderResult(validationResult, worldName);
}
private void validateWorldNameResult(WorldValidationResult validationResult) {
switch (validationResult) {
case NAME_BLACKLISTED:
throw new ConditionFailedException("World should not be in reserved server folders.");
case NAME_CONTAINS_DAT:
throw new ConditionFailedException("Multiverse cannot have a world name that contains '.dat'.");
case NAME_INVALID:
throw new ConditionFailedException("World name should not contain spaces or special characters! Please rename your world folder.");
}
}
private void validateWorldFolderResult(@NotNull WorldValidationResult validationResult,
@NotNull String worldName) {
switch (validationResult) {
case DOES_NOT_EXIST:
case NOT_A_DIRECTORY:
throw new ConditionFailedException(String.format("World folder '%s' does not exist.", worldName));
case FOLDER_LACK_DAT:
throw new ConditionFailedException(String.format("'%s' does not appear to be a world! It is lacking .dat file.", worldName));
}
}
private void checkValidAddProperty (@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull String property) {
String actionType = context.getConfig();
if (actionType.equalsIgnoreCase("set")) {
return;
}
try {
AddProperties.valueOf(property);
}
catch (IllegalArgumentException e) {
CommandSender sender = executionContext.getSender();
sender.sendMessage(String.format("%sSorry, you can't use %s with '%s'.",
ChatColor.RED, actionType, property));
sender.sendMessage(String.format("%sPlease visit our Github Wiki for more information: https://goo.gl/q1h01S",
ChatColor.AQUA));
throw new ConditionFailedException();
}
}
private void checkHasWorldAccess(@NotNull ConditionContext<BukkitCommandIssuer> context,
@NotNull BukkitCommandExecutionContext executionContext,
@NotNull MultiverseWorld world) {
Player player = executionContext.getPlayer();
if (player == null) {
return;
}
if (!this.plugin.getMVPerms().canEnterWorld(player, world)) {
throw new ConditionFailedException(String.format("You aren't allowed to access to world '%s%s'!",
world.getColoredWorldString(), ChatColor.RED));
}
}
}
@@ -0,0 +1,416 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.BukkitCommandExecutionContext;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.PaperCommandContexts;
import co.aikar.commands.annotation.Values;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleProperty;
import com.onarandombox.MultiverseCore.commandtools.context.PageFilter;
import com.onarandombox.MultiverseCore.commandtools.context.RequiredPlayer;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Parse args into objects.
*/
public class MVCommandContexts extends PaperCommandContexts {
private final MultiverseCore plugin;
private final MVWorldManager worldManager;
private static final Pattern UUID_REGEX = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
private static final Pattern TRIM_REGEX = Pattern.compile("^[./\\\\]+");
public MVCommandContexts(@NotNull MVCommandManager manager,
@NotNull MultiverseCore plugin) {
super(manager);
this.plugin = plugin;
this.worldManager = plugin.getMVWorldManager();
registerContext(RequiredPlayer.class, this::deriveRequiredPlayer);
registerIssuerOnlyContext(Player.class, this::derivePlayer);
registerIssuerAwareContext(MultiverseWorld.class, this::deriveMultiverseWorld);
registerContext(World.Environment.class, this::deriveEnvironment);
registerIssuerAwareContext(GameRuleProperty.class, this::deriveGameRuleProperty);
registerIssuerAwareContext(MVDestination.class, this::deriveMVDestination);
registerIssuerAwareContext(PasteServiceType.class, this::derivePasteServiceType);
registerOptionalContext(String.class, this::deriveString);
registerIssuerAwareContext(ContentFilter.class, this::deriveContentFilter);
registerOptionalContext(PageFilter.class, this::derivePageFilter);
}
@NotNull
private Player derivePlayer(@NotNull BukkitCommandExecutionContext context) {
Player player = context.getPlayer();
if (player == null) {
throw new InvalidCommandArgument("You must be a player to run this command.");
}
return player;
}
@NotNull
private RequiredPlayer deriveRequiredPlayer(BukkitCommandExecutionContext context) {
String playerIdentifier = context.getFirstArg();
Player player = getPlayerFromValue(context.getSender(), playerIdentifier);
if (player == null) {
throw new InvalidCommandArgument("Invalid player name '" + playerIdentifier + "'!");
}
return new RequiredPlayer(player);
}
@Nullable
private MultiverseWorld deriveMultiverseWorld(@NotNull BukkitCommandExecutionContext context) {
if (!context.hasFlag("other")) {
return getPlayerWorld(
context.getPlayer(),
context.isOptional()
, "You cannot run this command from console."
);
}
String worldName = context.getFirstArg();
if (worldName == null) {
if (context.hasFlag("defaultself")) {
return getPlayerWorld(
context.getPlayer(),
context.isOptional()
, "You need to specific a world name from console."
);
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("You need to specific a world name.");
}
MultiverseWorld world = getWorld(context.getSender(), worldName, !context.hasFlag("ignoreunload"));
if (world == null) {
if (context.hasFlag("fallbackself")) {
return getPlayerWorld(context.getPlayer(),
context.isOptional(),
String.format("World '%s' not found.", worldName));
}
if (this.worldManager.isValidWorld(worldName)) {
CommandSender sender = context.getSender();
sender.sendMessage(String.format("%sMultiverse does not know about world '%s' yet. Please import it with %s/mv import %s <env>%s.",
ChatColor.RED, worldName, ChatColor.AQUA, worldName, ChatColor.RED));
sender.sendMessage(String.format("See %s/mv help import %sfor more info.",
ChatColor.AQUA, ChatColor.WHITE));
throw new InvalidCommandArgument();
}
throw new InvalidCommandArgument(String.format("World '%s' not found.", worldName), false);
}
context.popFirstArg();
return world;
}
@Nullable
private MultiverseWorld getWorld(@NotNull CommandSender sender,
@NotNull String worldName,
boolean checkUnloaded) {
MultiverseWorld targetWorld = this.worldManager.getMVWorld(worldName);
if (targetWorld != null) {
return targetWorld;
}
//TODO: API should have a isUnloadedWorld method.
if (checkUnloaded && this.worldManager.getUnloadedWorlds().contains(worldName)) {
sender.sendMessage(String.format("%sWorld '%s' exists, but it is unloaded!", ChatColor.RED, worldName));
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, worldName));
throw new InvalidCommandArgument();
}
return null;
}
@Nullable
private MultiverseWorld getPlayerWorld(@Nullable Player player,
boolean allowNull,
@NotNull String errorReason) {
if (player == null) {
if (allowNull) {
return null;
}
throw new InvalidCommandArgument(errorReason, false);
}
MultiverseWorld targetWorld = this.worldManager.getMVWorld(player.getWorld());
if (targetWorld == null) {
player.sendMessage(String.format("%sMultiverse doesn't know about world '%s%s%s' that '%s%s%s' is in.",
ChatColor.RED, ChatColor.DARK_AQUA, player.getWorld().getName(), ChatColor.RED,
ChatColor.AQUA, player.getName(), ChatColor.RED));
player.sendMessage(String.format("You need to import the world with %s/mv import %s %s",
ChatColor.DARK_AQUA, player.getWorld().getName(), player.getWorld().getEnvironment()));
throw new InvalidCommandArgument();
}
return targetWorld;
}
@Nullable
private Player getPlayerFromSelf(@NotNull BukkitCommandExecutionContext context, String errorReason) {
Player self = context.getPlayer();
if (self == null && !context.isOptional()) {
throw new InvalidCommandArgument(errorReason);
}
return self;
}
/**
* Parse Player from string.
* Supports player name, UUID and selectors.
*
* @param sender Sender use to parse vanilla selectors.
* @param playerIdentifier Text to parse into a Player object.
* @return A Player object if found, null otherwise.
*/
@Nullable
public Player getPlayerFromValue(@NotNull CommandSender sender,
@Nullable String playerIdentifier) {
if (playerIdentifier == null) {
return null;
}
Player player = getPlayerBySelector(sender, playerIdentifier);
if (player == null) {
player = Bukkit.getPlayerExact(playerIdentifier);
}
if (player == null) {
player = getPlayerByUUID(playerIdentifier);
}
return player;
}
@Nullable
private Player getPlayerBySelector(@NotNull CommandSender sender,
@NotNull String playerIdentifier) {
if (playerIdentifier.charAt(0) != '@') {
return null;
}
List<Player> matchedPlayers;
try {
matchedPlayers = this.plugin.getServer().selectEntities(sender, playerIdentifier).parallelStream()
.unordered()
.filter(e -> e instanceof Player)
.map(e -> ((Player) e))
.collect(Collectors.toList());
}
catch (IllegalArgumentException e) {
e.printStackTrace();
throw new InvalidCommandArgument(String.format("Error parsing selector '%s' for %s! See console for more details",
playerIdentifier, sender.getName()));
}
if (matchedPlayers.isEmpty()) {
throw new InvalidCommandArgument(String.format("No player found with selector '%s' for %s",
playerIdentifier, sender.getName()));
}
if (matchedPlayers.size() > 1) {
throw new InvalidCommandArgument(String.format("Error parsing selector '%s' for %s. ambiguous result (more than one player matched) - %s",
playerIdentifier, sender.getName(), matchedPlayers.toString()));
}
return matchedPlayers.get(0);
}
@Nullable
private Player getPlayerByUUID(@NotNull String playerIdentifier) {
if (!UUID_REGEX.matcher(playerIdentifier).matches()) {
return null;
}
UUID playerUUID;
try {
playerUUID = UUID.fromString(playerIdentifier);
} catch (Exception e) {
return null;
}
return Bukkit.getPlayer(playerUUID);
}
@NotNull
private World.Environment deriveEnvironment(@NotNull BukkitCommandExecutionContext context) {
String env = context.popFirstArg();
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD")) {
env = "NORMAL";
}
else if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER")) {
env = "NETHER";
}
else if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS")) {
env = "THE_END";
}
try {
return World.Environment.valueOf(env);
}
catch (IllegalArgumentException e) {
CommandSender sender = context.getSender();
sender.sendMessage(String.format("%s'%s' is not a valid environment.", ChatColor.RED, env));
EnvironmentCommand.showEnvironments(sender);
throw new InvalidCommandArgument(false);
}
}
@NotNull
private GameRuleProperty<?> deriveGameRuleProperty(@NotNull BukkitCommandExecutionContext context) {
int argLength = context.getArgs().size();
if (argLength == 0) {
throw new InvalidCommandArgument("You need to specify a game rule property and value to set.");
}
if (argLength == 1) {
throw new InvalidCommandArgument("You need to specify a value to set.");
}
String ruleString = context.popFirstArg();
GameRule<?> gameRule = GameRule.getByName(ruleString);
if (gameRule == null) {
throw new InvalidCommandArgument(String.format("'%s' is not a valid gamerule.", ruleString));
}
Class<?> ruleType = gameRule.getType();
String value = context.getFirstArg();
Object result = getResolver(ruleType).getContext(context);
if (result == null) {
context.getSender().sendMessage(String.format("%s'%s' is not a valid value.", ChatColor.RED, value));
context.getSender().sendMessage(String.format("%sValue need to be a %s", ChatColor.RED, ruleType.getTypeName()));
throw new InvalidCommandArgument();
}
if (result instanceof Integer && ((int) result) < 0) {
throw new InvalidCommandArgument("Value need to be a positive number.");
}
return new GameRuleProperty(gameRule, result);
}
@NotNull
private MVDestination deriveMVDestination(@NotNull BukkitCommandExecutionContext context) {
String destString = context.popFirstArg();
if (destString == null) {
throw new InvalidCommandArgument("Please specify a destination.");
}
MVDestination destination = this.plugin.getDestFactory().getDestination(destString);
if (destination instanceof InvalidDestination) {
throw new InvalidCommandArgument(String.format("No such destination '%s' found.", destString));
}
return destination;
}
@Nullable
private String deriveString(@NotNull BukkitCommandExecutionContext context) {
if (context.hasAnnotation(Values.class)) {
return context.popFirstArg();
}
String string = context.popFirstArg();
if (string == null) {
if (!context.isOptional()) {
String argType = context.getFlagValue("type", "string");
throw new InvalidCommandArgument(String.format("You need to specify a %s.", argType));
}
return null;
}
if (context.hasFlag("trim")) {
return trimWorldName(string);
}
return string;
}
@NotNull
private String trimWorldName(@NotNull String worldName) {
// Removes relative paths.
return TRIM_REGEX.matcher(worldName).replaceAll("");
}
@NotNull
private PasteServiceType derivePasteServiceType(BukkitCommandExecutionContext context) {
String pasteType = context.popFirstArg();
if (pasteType == null) {
return PasteServiceType.NONE;
}
try {
return PasteServiceType.valueOf(pasteType.toUpperCase());
}
catch (IllegalArgumentException e) {
throw new InvalidCommandArgument(String.format("Invalid paste service type '%s'.", pasteType));
}
}
@NotNull
private ContentFilter deriveContentFilter(@NotNull BukkitCommandExecutionContext context) {
String filterString = context.popFirstArg();
return (filterString == null) ? ContentFilter.DEFAULT : new ContentFilter(filterString);
}
@NotNull
private PageFilter derivePageFilter(@NotNull BukkitCommandExecutionContext context) {
int argLength = context.getArgs().size();
if (argLength == 0) {
return new PageFilter(ContentFilter.DEFAULT, 1);
}
if (argLength == 1) {
String pageOrFilter = context.popFirstArg();
Optional<Integer> page = tryParseInt(pageOrFilter);
return page.map(pageNum -> new PageFilter(ContentFilter.DEFAULT, pageNum))
.orElseGet(() -> new PageFilter(new ContentFilter(pageOrFilter), 1));
}
String filter = context.popFirstArg();
String pageString = context.popFirstArg();
Optional<Integer> page = tryParseInt(pageString);
if (!page.isPresent()) {
throw new InvalidCommandArgument(String.format("'%s' is not a number.", pageString), false);
}
return new PageFilter(new ContentFilter(filter), page.get());
}
private Optional<Integer> tryParseInt(String value) {
try {
return Optional.of(Integer.parseInt(value));
}
catch (NumberFormatException e) {
return Optional.empty();
}
}
}
@@ -0,0 +1,275 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandHelp;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.HelpEntry;
import co.aikar.commands.PaperCommandManager;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commands.AnchorCommand;
import com.onarandombox.MultiverseCore.commands.BedCommand;
import com.onarandombox.MultiverseCore.commands.CheckCommand;
import com.onarandombox.MultiverseCore.commands.CloneCommand;
import com.onarandombox.MultiverseCore.commands.ConfigCommand;
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
import com.onarandombox.MultiverseCore.commands.CoordCommand;
import com.onarandombox.MultiverseCore.commands.CreateCommand;
import com.onarandombox.MultiverseCore.commands.DebugCommand;
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
import com.onarandombox.MultiverseCore.commands.GameRuleCommand;
import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
import com.onarandombox.MultiverseCore.commands.ImportCommand;
import com.onarandombox.MultiverseCore.commands.InfoCommand;
import com.onarandombox.MultiverseCore.commands.ListCommand;
import com.onarandombox.MultiverseCore.commands.LoadCommand;
import com.onarandombox.MultiverseCore.commands.ModifyCommand;
import com.onarandombox.MultiverseCore.commands.PurgeCommand;
import com.onarandombox.MultiverseCore.commands.RegenCommand;
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
import com.onarandombox.MultiverseCore.commands.RootCommand;
import com.onarandombox.MultiverseCore.commands.ScriptCommand;
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
import com.onarandombox.MultiverseCore.commands.SilentCommand;
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
import com.onarandombox.MultiverseCore.commands.SubModulesCommand;
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
import com.onarandombox.MultiverseCore.commands.UsageCommand;
import com.onarandombox.MultiverseCore.commands.VersionCommand;
import com.onarandombox.MultiverseCore.commands.WhoCommand;
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
import com.onarandombox.MultiverseCore.displaytools.ColorAlternator;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
/**
* Heart of Multiverse Command Handler.
*/
public class MVCommandManager extends PaperCommandManager {
private final MultiverseCore plugin;
private final CommandQueueManager commandQueueManager;
private final Map<String, BaseCommand> subModuleRootCommands;
private static final Pattern PERMISSION_SPLIT = Pattern.compile(",");
public MVCommandManager(@NotNull MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
this.commandQueueManager = new CommandQueueManager(plugin);
this.subModuleRootCommands = new HashMap<>(3);
new MVCommandConditions(plugin, getCommandConditions());
// Setup help command
enableUnstableAPI("help");
setDefaultHelpPerPage(6);
// General plugin command
registerCommand(new RootCommand(this.plugin));
registerCommand(new UsageCommand(this.plugin));
registerCommand(new VersionCommand(this.plugin));
// World commands
registerCommand(new CreateCommand(this.plugin));
registerCommand(new ImportCommand(this.plugin));
registerCommand(new LoadCommand(this.plugin));
registerCommand(new UnloadCommand(this.plugin));
registerCommand(new RemoveCommand(this.plugin));
registerCommand(new CloneCommand(this.plugin));
registerCommand(new RegenCommand(this.plugin));
registerCommand(new DeleteCommand(this.plugin));
registerCommand(new ConfirmCommand(this.plugin));
// Properties management commands
registerCommand(new ConfigCommand(this.plugin));
registerCommand(new GameRuleCommand(this.plugin));
registerCommand(new ModifyCommand(this.plugin));
registerCommand(new SetSpawnCommand(this.plugin));
registerCommand(new PurgeCommand(this.plugin));
// Show information commands
registerCommand(new InfoCommand(this.plugin));
registerCommand(new CoordCommand(this.plugin));
registerCommand(new EnvironmentCommand(this.plugin));
registerCommand(new GeneratorCommand(this.plugin));
registerCommand(new ListCommand(this.plugin));
registerCommand(new WhoCommand(this.plugin));
// Teleport commands
registerCommand(new TeleportCommand(this.plugin));
registerCommand(new AnchorCommand(this.plugin));
registerCommand(new BedCommand(this.plugin));
registerCommand(new SpawnCommand(this.plugin));
// Misc commands
registerCommand(new DebugCommand(this.plugin));
registerCommand(new CheckCommand(this.plugin));
registerCommand(new ReloadCommand(this.plugin));
registerCommand(new SilentCommand(this.plugin));
registerCommand(new ScriptCommand(this.plugin));
// Sub-modules
addAvailableSubModule("mvnp", new SubModulesCommand.NetherPortals());
addAvailableSubModule("mvp", new SubModulesCommand.Portals());
addAvailableSubModule("mvinv", new SubModulesCommand.Inventories());
}
/**
* Use for download link suggestion for sub-module
*
* @param moduleName A sub-module for Multiverse.
* @param cmd Command to register.
*/
private void addAvailableSubModule(@NotNull String moduleName,
@NotNull BaseCommand cmd) {
subModuleRootCommands.put(moduleName, cmd);
registerCommand(cmd);
}
/**
* Replace suggest download with actual command from sub-module.
*
* @param moduleName A sub-module for Multiverse.
* @param cmd Command to register.
*/
public void registerSubModule(@NotNull String moduleName,
@NotNull BaseCommand cmd) {
unregisterCommand(subModuleRootCommands.remove(moduleName));
registerCommand(cmd);
}
@Override
public synchronized MVCommandContexts getCommandContexts() {
if (this.contexts == null) {
this.contexts = new MVCommandContexts(this, plugin);
}
return (MVCommandContexts) this.contexts;
}
@Override
public synchronized MVCommandCompletions getCommandCompletions() {
if (this.completions == null) {
this.completions = new MVCommandCompletions(this, plugin);
}
return (MVCommandCompletions) this.completions;
}
/**
* Change default implementation to be able to choose from OR / AND
*/
@Override
public boolean hasPermission(@NotNull CommandIssuer issuer,
@Nullable Set<String> permissions) {
if (permissions == null || permissions.isEmpty()) {
return true;
}
return (permissions.contains("AND"))
? andPermissionCheck(issuer, permissions)
: orPermissionCheck(issuer, permissions);
}
private boolean orPermissionCheck(@NotNull CommandIssuer issuer,
@NotNull Set<String> permissions) {
return permissions.stream()
.unordered()
.anyMatch(permission -> hasPermission(issuer, permission));
}
private boolean andPermissionCheck(@NotNull CommandIssuer issuer,
@NotNull Set<String> permissions) {
return permissions.stream()
.unordered()
.allMatch(permission -> hasPermission(issuer, permission));
}
/**
* Change default implementation to be able to choose from OR / AND
*/
@Override
public boolean hasPermission(@NotNull CommandIssuer issuer,
@Nullable String permission) {
if (permission == null || permission.isEmpty()) {
return true;
}
if (permission.startsWith("AND:")) {
return Arrays.stream(PERMISSION_SPLIT.split(permission.substring(4)))
.unordered()
.allMatch(issuer::hasPermission);
}
return Arrays.stream(PERMISSION_SPLIT.split(permission))
.unordered()
.anyMatch(issuer::hasPermission);
}
/**
* Gets {@link CommandQueueManager}.
*
* @return {@link CommandQueueManager}.
*/
public CommandQueueManager getQueueManager() {
return commandQueueManager;
}
/**
* Standardise usage command formatting for all mv modules.
*
* @param help The target {@link CommandHelp}.
*/
public void showUsage(@NotNull CommandHelp help) {
List<HelpEntry> entries = help.getHelpEntries();
if (entries.size() == 1) {
this.plugin.getMVCommandManager().getHelpFormatter().showDetailedHelp(help, entries.get(0));
return;
}
help.showHelp();
}
/**
* Standardise root command for all mv modules.
*
* @param sender Sender to send the info to.
* @param description mv-module's description and info.
* @param color Special colour for each mv-module.
* @param rootCmd mv-module's root command name.
*/
public void showPluginInfo(@NotNull CommandSender sender,
@NotNull PluginDescriptionFile description,
@NotNull ColorAlternator color,
@NotNull String rootCmd) {
sender.sendMessage(String.format("%s%s %s| %sv%s",
color.getThisColor(), description.getName(), ChatColor.DARK_GRAY,
color.getThatColor(), description.getVersion()));
sender.sendMessage(String.format("%sSee %s/%s help %sfor commands available.",
ChatColor.DARK_GREEN, ChatColor.GREEN, rootCmd, ChatColor.DARK_GREEN));
}
}
@@ -0,0 +1,23 @@
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.CommandCompletionContext;
import co.aikar.commands.RegisteredCommand;
import com.onarandombox.MultiverseCore.utils.ReflectHelper;
import java.lang.reflect.Field;
public class MVCommandReflect {
private static final Field commandScope;
private static final Field commandField;
static {
commandField = ReflectHelper.getField(CommandCompletionContext.class, "command");
commandScope = ReflectHelper.getField(RegisteredCommand.class, "scope");
}
public static MultiverseCommand getCommandCompletionContextCommand(CommandCompletionContext context) {
RegisteredCommand registeredCommand = ReflectHelper.getFieldValue(context, commandField);
return ReflectHelper.getFieldValue(registeredCommand, commandScope);
}
}
@@ -0,0 +1,21 @@
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.BaseCommand;
import com.onarandombox.MultiverseCore.commandtools.flag.FlagGroup;
public class MultiverseCommand extends BaseCommand {
private FlagGroup flagGroup;
public MultiverseCommand() {
super();
}
public FlagGroup getFlagGroup() {
return flagGroup;
}
public void setFlagGroup(FlagGroup flagGroup) {
this.flagGroup = flagGroup;
}
}
@@ -0,0 +1,39 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools.context;
import org.bukkit.GameRule;
import org.jetbrains.annotations.NotNull;
/**
* Single key value pair for a game rule.
*
* @param <T> Type of GameRule property.
*/
public class GameRuleProperty<T> {
private final GameRule<T> gameRule;
private final T value;
public GameRuleProperty(@NotNull GameRule<T> gameRule,
@NotNull T value) {
this.gameRule = gameRule;
this.value = value;
}
@NotNull
public GameRule<T> getGameRule() {
return gameRule;
}
@NotNull
public T getValue() {
return value;
}
}
@@ -0,0 +1,34 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2020. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commandtools.context;
import com.onarandombox.MultiverseCore.displaytools.ContentFilter;
import org.jetbrains.annotations.NotNull;
/**
* Filter and paging.
*/
public class PageFilter {
private final ContentFilter filter;
private final int page;
public PageFilter(@NotNull ContentFilter filter,
int page) {
this.filter = filter;
this.page = page;
}
@NotNull
public ContentFilter getFilter() {
return filter;
}
public int getPage() {
return page;
}
}
@@ -0,0 +1,16 @@
package com.onarandombox.MultiverseCore.commandtools.context;
import org.bukkit.entity.Player;
public class RequiredPlayer {
private final Player player;
public RequiredPlayer(Player player) {
this.player = player;
}
public Player get() {
return player;
}
}
@@ -0,0 +1,4 @@
/**
* Classes derived from parsing command args and context.
*/
package com.onarandombox.MultiverseCore.commandtools.context;
@@ -0,0 +1,162 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
* <p>Represents a flag that can be used in commands. This works as a key value pair.</p>
*
* <p>Key is the {@link #identifier} and {@link #aliases} set.</p>
* <p>Value is the {@link T} parsed based on 3 scenarios during command input:</p>
* <ol>
* <li>Flag completely not present. {@link #getDefaultValue()}</li>
* <li>Flag key present but no value. {@link #getValue()}</li>
* <li>Flag key and value present. {@link #getValue(String)}</li>
* </ol>
*
* @param <T> The flag Type.
*/
public abstract class CommandFlag<T> {
protected final String name;
protected final String identifier;
protected final Class<T> type;
protected final ValueRequirement valueRequirement;
protected final Collection<String> aliases;
protected CommandFlag(@NotNull String name,
@NotNull String identifier,
@NotNull Class<T> type,
@NotNull ValueRequirement valueRequirement) {
this.name = name;
this.identifier = identifier;
this.type = type;
this.valueRequirement = valueRequirement;
this.aliases = new ArrayList<>();
}
/**
* Gets name of the Command Flag.
*
* @return The Command Flag name.
*/
@NotNull
public String getName() {
return this.name;
}
/**
* Gets identifier of the Command Flag.
*
* @return The Command Flag identifier.
*/
@NotNull
public String getIdentifier() {
return this.identifier;
}
/**
* Gets {@link T} Type of the Command Flag.
*
* @return The Command Flag type.
*/
@NotNull
public Class<T> getType() {
return this.type;
}
/**
* Gets the requirements of this Command Flag user input value.
*
* @return The {@link ValueRequirement}.
*/
@NotNull
public ValueRequirement getValueRequirement() {
return this.valueRequirement;
}
/**
* Gets all the alternative key identifiers set for this Command Flag.
*
* @return Collection of aliases.
*/
@NotNull
public Collection<String> getAliases() {
return this.aliases;
}
/**
* Add alternative key identifiers for this Command Flag.
*
* @param aliases Alias(es) to be added.
* @return A {@link CommandFlag}.
*/
public CommandFlag<T> addAliases(String...aliases) {
Collections.addAll(this.aliases, aliases);
return this;
}
/**
* Tab-complete suggestion for this Command Flag values.
*
* @return Collection of suggested values available.
*/
public abstract Collection<String> suggestValue();
/**
* When this Command Flag can get value by a user input.
*
* @return The {@link T} value.
*/
public abstract T getValue(@NotNull String input) throws FlagParseFailedException;
/**
* When this Command Flag user input value is null/not present.
*
* @return The {@link T} value.
*/
public T getValue() throws FlagParseFailedException {
return null;
}
/**
* When this Command Flag is not present in command input.
*
* @return The {@link T} value.
*/
public T getDefaultValue() {
return null;
}
@Override
public String toString() {
return "CommandFlag{" +
"name='" + name + '\'' +
", identifier='" + identifier + '\'' +
", type=" + type +
", valueRequirement=" + valueRequirement +
", aliases=" + aliases +
'}';
}
public enum ValueRequirement {
/**
* No user input needed for value.
*/
NONE,
/**
* User input for value is optional.
*/
OPTIONAL,
/**
* User input is required for Command Flag value.
*/
REQUIRED
}
}
@@ -0,0 +1,221 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
import co.aikar.commands.InvalidCommandArgument;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
import org.bukkit.Bukkit;
import org.bukkit.WorldType;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
public class CoreFlags {
private static MultiverseCore multiverse;
public static void setCoreInstance(MultiverseCore plugin) {
multiverse = plugin;
}
/**
* Flag for custom seed.
*/
public static final CommandFlag<String> SEED = new RequiredCommandFlag<String>
("Seed", "--seed", String.class) {
@Override
public Collection<String> suggestValue() {
return Collections.singleton(String.valueOf(new Random().nextLong()));
}
@Override
public String getValue(@NotNull String input) throws FlagParseFailedException {
return input;
}
}.addAliases("-s");
/**
* Flag for custom seed. No value means random seed.
*/
public static final CommandFlag<String> RANDOM_SEED = new OptionalCommandFlag<String>
("Seed", "--seed", String.class) {
@Override
public Collection<String> suggestValue() {
return Collections.singletonList(String.valueOf(new Random().nextLong()));
}
@Override
public String getValue(@NotNull String input) throws FlagParseFailedException {
return input;
}
}.addAliases("-s");
/**
* Flag for world type used.
*/
public static final CommandFlag<WorldType> WORLD_TYPE = new RequiredCommandFlag<WorldType>
("WorldType", "--type", WorldType.class) {
private final Map<String, WorldType> typeAlias = new HashMap<String, WorldType>(4){{
put("normal", WorldType.NORMAL);
put("flat", WorldType.FLAT);
put("largebiomes", WorldType.LARGE_BIOMES);
put("amplified", WorldType.AMPLIFIED);
}};
@Override
public Collection<String> suggestValue() {
return typeAlias.keySet();
}
@Override
public WorldType getValue(@NotNull String input) throws FlagParseFailedException {
WorldType type = typeAlias.get(input);
if (type != null) {
return type;
}
try {
return WorldType.valueOf(input.toUpperCase());
}
catch (IllegalArgumentException e) {
throw new FlagParseFailedException("'%s' is not a valid. See /mv env for available World Type.", input);
}
}
@Override
public WorldType getDefaultValue() {
return WorldType.NORMAL;
}
}.addAliases("-t");
/**
* Flag for world generator.
*/
public static final CommandFlag<String> GENERATOR = new RequiredCommandFlag<String>
("Generator", "--gen", String.class) {
@Override
public Collection<String> suggestValue() {
return Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins())
.filter(Plugin::isEnabled)
.filter(plugin -> multiverse.getUnsafeCallWrapper().wrap(
() -> plugin.getDefaultWorldGenerator("world", ""),
plugin.getName(),
"Get generator"
) != null)
.map(plugin -> plugin.getDescription().getName())
.collect(Collectors.toList());
}
@Override
public String getValue(@NotNull String input) throws FlagParseFailedException {
String[] genArray = input.split(":");
String generator = genArray[0];
String generatorId = (genArray.length > 1) ? genArray[1] : "";
try {
if (multiverse.getMVWorldManager().getChunkGenerator(generator, generatorId, "test") == null) {
throw new Exception();
}
} catch (Exception e) {
throw new FlagParseFailedException("Invalid generator string '%s'. See /mv gens for available generators.", input);
}
return input;
}
}.addAliases("-g");
/**
* Flag to toggle if world should generate structures.
*/
public static final CommandFlag<Boolean> GENERATE_STRUCTURES = new RequiredCommandFlag<Boolean>
("GenerateStructures", "--structures", Boolean.class) {
@Override
public Collection<String> suggestValue() {
return Arrays.asList("true", "false");
}
@Override
public Boolean getValue(@NotNull String input) throws FlagParseFailedException {
return input.equalsIgnoreCase("true");
}
@Override
public Boolean getDefaultValue() {
return true;
}
}.addAliases("--structure", "-a");
/**
* Flag to toggle if world spawn should be adjusted.
*/
public static final CommandFlag<Boolean> SPAWN_ADJUST = new NoValueCommandFlag<Boolean>
("AdjustSpawn", "--dont-adjust-spawn", Boolean.class) {
@Override
public Boolean getValue() throws FlagParseFailedException {
return false;
}
@Override
public Boolean getDefaultValue() {
return true;
}
}.addAliases("-n");
/**
* Flag to specify a paste service.
*/
public static final CommandFlag<PasteServiceType> PASTE_SERVICE_TYPE = new OptionalCommandFlag<PasteServiceType>
("PasteServiceType", "--paste", PasteServiceType.class) {
private final List<String> pasteTypes = Arrays.stream(PasteServiceType.values())
.filter(pt -> pt != PasteServiceType.NONE)
.map(p -> p.toString().toLowerCase())
.collect(Collectors.toList());
@Override
public Collection<String> suggestValue() {
return pasteTypes;
}
@Override
public PasteServiceType getValue(@NotNull String input) throws FlagParseFailedException {
try {
return PasteServiceType.valueOf(input.toUpperCase());
}
catch (IllegalArgumentException e) {
throw new InvalidCommandArgument(String.format("Invalid paste service type '%s'.", input));
}
}
@Override
public PasteServiceType getValue() throws FlagParseFailedException {
return PasteServiceType.PASTEGG;
}
@Override
public PasteServiceType getDefaultValue() {
return PasteServiceType.NONE;
}
}.addAliases("-p");
/**
* Flag to toggle if plugin list should be included.
*/
public static final CommandFlag<Boolean> INCLUDE_PLUGIN_LIST = new NoValueCommandFlag<Boolean>
("IncludePlugins", "--include-plugin-list", Boolean.class) {
@Override
public Boolean getValue() throws FlagParseFailedException {
return true;
}
@Override
public Boolean getDefaultValue() {
return true;
}
}.addAliases("-pl");
}
@@ -0,0 +1,59 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FlagGroup {
public static FlagGroup of(CommandFlag<?>...flags) {
return new FlagGroup(flags);
}
private final List<String> flagIdentifiers;
private final Map<String, CommandFlag<?>> flagKeyMap;
private FlagGroup(CommandFlag<?>[] commandFlags) {
this.flagIdentifiers = new ArrayList<>(commandFlags.length);
this.flagKeyMap = new HashMap<>();
for (CommandFlag<?> flag : commandFlags) {
addFlag(flag);
}
}
private void addFlag(CommandFlag<?> flag) {
this.flagIdentifiers.add(flag.getIdentifier());
this.flagKeyMap.put(flag.getIdentifier(), flag);
for (String flagAlias : flag.getAliases()) {
this.flagKeyMap.put(flagAlias, flag);
}
}
@NotNull
public FlagResult calculateResult(String[] args) {
return FlagResult.parse(args,this);
}
@Nullable
public CommandFlag<?> getByKey(String key) {
return this.flagKeyMap.get(key);
}
@NotNull
public Collection<String> getFlagIdentifiers() {
return flagIdentifiers;
}
@Override
public String toString() {
return "FlagGroup{" +
"flagIdentifiers=" + flagIdentifiers +
", keyFlagMap=" + flagKeyMap +
'}';
}
}
@@ -0,0 +1,13 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
import co.aikar.commands.InvalidCommandArgument;
public class FlagParseFailedException extends InvalidCommandArgument {
public FlagParseFailedException() {
}
public FlagParseFailedException(String message, Object...replacements) {
super(String.format(message, replacements), true);
}
}
@@ -0,0 +1,146 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import static com.onarandombox.MultiverseCore.commandtools.flag.CommandFlag.ValueRequirement;
public class FlagResult {
public static FlagResult parse(@Nullable String[] args,
@NotNull FlagGroup flagGroup) throws FlagParseFailedException {
FlagResult flagResult = new FlagResult();
// No args to parse.
if (args == null || args.length <= 0) {
return flagResult;
}
// First arg must be a flag.
CommandFlag<?> currentFlag = flagGroup.getByKey(args[0]);
boolean completed = false;
// Parse the arguments.
for (int i = 1, argsLength = args.length; i <= argsLength; i++) {
// Don't allow null flag obviously.
if (currentFlag == null) {
throw new FlagParseFailedException("%s is not a valid flag.", args[i-1]);
}
// THis ensures that flag is not null during final parse.
if (i >= argsLength) {
break;
}
CommandFlag<?> nextFlag = flagGroup.getByKey(args[i]);
switch (currentFlag.getValueRequirement()) {
case NONE:
// Arg must be a flag key.
flagResult.add(currentFlag, currentFlag.getValue(), false);
currentFlag = nextFlag;
break;
case OPTIONAL:
// Arg can be a flag key or value.
if (nextFlag != null) {
// It's a key.
flagResult.add(currentFlag, currentFlag.getValue(), false);
currentFlag = nextFlag;
break;
}
// It's a value.
flagResult.add(currentFlag, currentFlag.getValue(args[i]), true);
if (i == argsLength - 1) {
completed = true;
break;
}
currentFlag = flagGroup.getByKey(args[++i]);
break;
case REQUIRED:
// Arg must be a flag value.
if (nextFlag != null) {
// It's a key.
throw new FlagParseFailedException("%s flag '%s' requires a value input.",
currentFlag.getName(), currentFlag.getIdentifier());
}
// It's a value.
flagResult.add(currentFlag, currentFlag.getValue(args[i]), true);
if (i == argsLength - 1) {
completed = true;
break;
}
currentFlag = flagGroup.getByKey(args[++i]);
break;
}
}
// Parse final flag.
if (!completed) {
if (currentFlag.getValueRequirement() == ValueRequirement.REQUIRED) {
throw new FlagParseFailedException("%s flag '%s' requires a value input.",
currentFlag.getName(), currentFlag.getIdentifier());
}
flagResult.add(currentFlag, currentFlag.getValue(), false);
}
return flagResult;
}
private final Map<CommandFlag<?>, SingleFlagResult<?>> resultMap;
public FlagResult() {
resultMap = new HashMap<>();
}
private void add(CommandFlag<?> flag, Object value, boolean fromInput) {
resultMap.put(flag, new SingleFlagResult<>(value, fromInput));
}
public <T> T getValue(CommandFlag<T> flag) {
SingleFlagResult<?> result = resultMap.get(flag);
if (result == null) {
return flag.getDefaultValue();
}
return (T) result.value;
}
public boolean isByUserInput(CommandFlag<?> flag) {
SingleFlagResult<?> result = resultMap.get(flag);
if (result == null) {
return false;
}
return result.fromInput;
}
public boolean isDefaulted(CommandFlag<?> flag) {
return resultMap.get(flag) != null;
}
@Override
public String toString() {
return "FlagResult{" +
"resultMap=" + resultMap +
'}';
}
private class SingleFlagResult<T> {
private final T value;
private final boolean fromInput;
private SingleFlagResult(T value, boolean fromInput) {
this.fromInput = fromInput;
this.value = value;
}
@Override
public String toString() {
return "SingleFlagResult{" +
"value=" + value +
", fromInput=" + fromInput +
'}';
}
}
}
@@ -0,0 +1,37 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Collections;
/**
* Command Flag with {@link ValueRequirement#NONE}.
* This flag will always not require a user input to parse value.
*
* @param <T> The flag Type.
*/
public abstract class NoValueCommandFlag<T> extends CommandFlag<T> {
public NoValueCommandFlag(String name, String identifier, Class<T> type) {
super(name, identifier, type, ValueRequirement.NONE);
}
/**
* {@link NoValueCommandFlag} will always not require a user input to parse value.
* Thus, no value suggestion needed.
*/
@Override
public final Collection<String> suggestValue() {
return Collections.emptyList();
}
/**
* {@link NoValueCommandFlag} will always not require a user input to parse value.
* Thus, this operation is not allowed.
*/
@Override
public final T getValue(@NotNull String input) throws FlagParseFailedException {
throw new FlagParseFailedException("%s flag '%s' does not require a value.", this.name, this.identifier);
}
}
@@ -0,0 +1,13 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
/**
* Command Flag with {@link ValueRequirement#OPTIONAL}.
*
* @param <T> The flag Type.
*/
public abstract class OptionalCommandFlag<T> extends CommandFlag<T> {
public OptionalCommandFlag(String name, String identifier, Class<T> type) {
super(name, identifier, type, ValueRequirement.OPTIONAL);
}
}
@@ -0,0 +1,23 @@
package com.onarandombox.MultiverseCore.commandtools.flag;
/**
* Command Flag with {@link ValueRequirement#REQUIRED}.
* This flag will always require a user input to parse value.
*
* @param <T> The flag Type.
*/
public abstract class RequiredCommandFlag<T> extends CommandFlag<T> {
public RequiredCommandFlag(String name, String identifier, Class<T> type) {
super(name, identifier, type, ValueRequirement.REQUIRED);
}
/**
* {@link RequiredCommandFlag} will always require a user input to parse value.
* Thus, this operation is not allowed.
*/
@Override
public final T getValue() throws FlagParseFailedException {
throw new FlagParseFailedException("%s flag '%s' requires a value input.", this.name, this.identifier);
}
}
@@ -0,0 +1,4 @@
/**
* Main classes used to manage commands.
*/
package com.onarandombox.MultiverseCore.commandtools;
@@ -0,0 +1,107 @@
/******************************************************************************
* 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.command.CommandSender;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.WeakHashMap;
/**
* Queue dangerous commands, with the need to use '/mv confirm' before executing.
*/
public class CommandQueueManager {
private final MultiverseCore plugin;
private final Map<CommandSender, QueuedCommand> queuedCommandMap;
public CommandQueueManager(@NotNull MultiverseCore plugin) {
this.plugin = plugin;
this.queuedCommandMap = new WeakHashMap<>();
}
public void addToQueue(QueuedCommand queuedCommand) {
CommandSender sender = queuedCommand.getSender();
this.cancelPreviousInQueue(sender);
this.queuedCommandMap.put(sender, queuedCommand);
queuedCommand.setExpireTask(runExpireLater(queuedCommand));
sender.sendMessage(queuedCommand.getPrompt());
sender.sendMessage(String.format("Run %s/mv confirm %sto continue.", ChatColor.GREEN, ChatColor.WHITE));
}
/**
* Since only one command is stored in queue per sender, we remove the old one.
*
* @param sender {@link CommandSender} that executed the command.
*/
private void cancelPreviousInQueue(@NotNull CommandSender sender) {
QueuedCommand previousCommand = queuedCommandMap.get(sender);
if (previousCommand == null) {
return;
}
previousCommand.getExpireTask().cancel();
this.queuedCommandMap.remove(sender);
}
/**
* Expire task that remove {@link QueuedCommand} from queue after expiry.
*
* @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()
);
}
@NotNull
private Runnable expireRunnable(@NotNull QueuedCommand queuedCommand) {
return () -> {
QueuedCommand matchingQueuedCommand = this.queuedCommandMap.get(queuedCommand.getSender());
if (!queuedCommand.equals(matchingQueuedCommand)) {
Logging.finer("This is an old command already.");
return;
}
Logging.finer("Command has expired, removing...");
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 of queued command ran successfully, false otherwise.
*/
public boolean runQueuedCommand(@NotNull CommandSender sender) {
CommandSender targetSender = QueuedCommand.parseSender(sender);
QueuedCommand queuedCommand = this.queuedCommandMap.get(targetSender);
if (queuedCommand == null) {
sender.sendMessage("You do not have any commands in queue.");
return false;
}
Logging.finer("Running queued command...");
queuedCommand.getAction().run();
queuedCommand.getExpireTask().cancel();
this.queuedCommandMap.remove(targetSender);
return true;
}
}
@@ -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() {
return true;
}
@Override
public void setOp(boolean value) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,122 @@
/******************************************************************************
* 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 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;
/**
* Represents a single command in {@link CommandQueueManager}.
*/
public class QueuedCommand {
private static final DummyCommandBlockSender COMMAND_BLOCK = new DummyCommandBlockSender();
private static final String DEFAULT_PROMPT_MESSAGE = "The command you are trying to run is deemed dangerous.";
private static final int DEFAULT_VALID_TIME = 200; // In ticks, 20 ticks = 1s
/**
* To allow all CommandBlocks to be a common sender with use of {@link DummyCommandBlockSender}.
* So confirm command can be used for a queue command on another command block.
*/
@NotNull
static CommandSender parseSender(@NotNull CommandSender sender) {
Logging.fine(sender.getClass().getName());
if (isCommandBlock(sender)) {
Logging.finer("Is command block.");
return COMMAND_BLOCK;
}
return sender;
}
/**
* Check if sender is a command block.
*/
static boolean isCommandBlock(@NotNull CommandSender sender) {
return sender instanceof BlockCommandSender
&& ((BlockCommandSender) sender).getBlock().getBlockData() instanceof CommandBlock;
}
private CommandSender sender;
private String prompt = DEFAULT_PROMPT_MESSAGE;
private int validDuration = DEFAULT_VALID_TIME;
private Runnable action;
private BukkitTask expireTask;
private QueuedCommand() { }
@NotNull
public CommandSender getSender() {
return sender;
}
@NotNull
public String getPrompt() {
return prompt;
}
public int getValidDuration() {
return validDuration;
}
@NotNull
public Runnable getAction() {
return action;
}
@NotNull
public BukkitTask getExpireTask() {
return expireTask;
}
public void setExpireTask(@NotNull BukkitTask expireTask) {
this.expireTask = expireTask;
}
public static class Builder {
private final QueuedCommand command;
@NotNull
public Builder() {
this.command = new QueuedCommand();
}
@NotNull
public Builder sender(@NotNull CommandSender sender) {
this.command.sender = sender;
return this;
}
@NotNull
public Builder action(@NotNull Runnable action) {
this.command.action = action;
return this;
}
@NotNull
public Builder prompt(@NotNull String prompt, Object...replacements) {
this.command.prompt = String.format(prompt, replacements);
return this;
}
@NotNull
public Builder validDuration(int validDuration) {
this.command.validDuration = validDuration;
return this;
}
@NotNull
public QueuedCommand build() {
return this.command;
}
}
}
@@ -0,0 +1,4 @@
/**
* Manager queuing of dangerous commands in need of confirmation.
*/
package com.onarandombox.MultiverseCore.commandtools.queue;
@@ -1,115 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.configuration;
/**
* A {@link String} config-property that will NOT be saved to the config.
*/
public class ActiveStringConfigProperty implements MVActiveConfigProperty<String> {
private String name;
private String value;
private String method;
private String help;
public ActiveStringConfigProperty(String name, String defaultValue, String help) {
this.name = name;
this.help = help;
this.value = defaultValue;
this.parseValue(defaultValue);
}
public ActiveStringConfigProperty(String name, String defaultValue, String help, String method) {
this(name, defaultValue, help);
this.method = method;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public String getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public String getMethod() {
return this.method;
}
/**
* {@inheritDoc}
*/
@Override
public void setMethod(String methodName) {
this.method = methodName;
}
/**
* {@inheritDoc}
*/
@Override
public Class<?> getPropertyClass() {
return String.class;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
if (value == null) {
return false;
}
this.setValue(value);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return "";
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(String value) {
if (value == null) {
return false;
}
this.value = value;
return true;
}
@Override
public String toString() {
return value;
}
}
Loaded 100 of 224 files, more files were not shown because too many files have changed in this diff. Show more