Compare commits

...
454 Commits
Author SHA1 Message Date
Ben Woo 2754c6ea0d Use version dbo-upload-action v0.1.0 2023-08-20 21:22:22 +08:00
Ben Woo ef6cd16e91 Remove end comma 2023-08-20 21:02:04 +08:00
Ben Woo b2691e979e Better format for project relation 2023-08-20 21:01:29 +08:00
Ben Woo 21e905fc83 Remove some game version that DBO doesnt have 2023-08-20 20:26:00 +08:00
Ben Woo bd6c44279d use game version by name 2023-08-20 20:13:22 +08:00
Ben Woo 743e741a92 Remove the fail 2023-08-20 16:36:17 +08:00
Ben Woo d841d9d5d0 Test without to json 2023-08-20 16:34:35 +08:00
Ben Woo 32d0e39866 Fix display name version 2023-08-20 16:28:04 +08:00
Ben Woo 71fe3de39a Use output version 2023-08-20 16:14:46 +08:00
Ben Woo b973292d0e Fix some upload field keys 2023-08-20 15:53:24 +08:00
Ben Woo 6db2cc25d6 Fix typo multiverse 2023-08-20 15:46:22 +08:00
Ben Woo c24777d282 Update regex 2023-08-20 15:45:29 +08:00
Ben Woo eeb58a05b1 Use regex 2023-08-20 15:41:39 +08:00
Ben Woo 0dd8ecaa84 Use latest version and fix copy paste issue 2023-08-20 15:39:49 +08:00
Ben Woo 01cc8e5177 Try dbo upload action 2023-08-20 15:36:10 +08:00
Ben Woo bd78b441ba Merge pull request #2929 from Multiverse/config_update
feat: Extract generic handler for config with ConfigurationSection
2023-06-29 11:03:14 +08:00
Ben Woo 3b384dbe6d docs: Add docs to new config classes 2023-06-28 20:18:26 +08:00
Ben Woo d1370bfb8c feat: Extract generic handler for config with ConfigurationSection 2023-06-28 19:41:33 +08:00
Ben Woo 314ce11630 Merge pull request #2930 from Multiverse/bump_papi
chore: Bump papi to 2.11.3
2023-06-28 19:40:19 +08:00
Ben Woo c2b943cf0a chore: Bump papi to 2.11.3 2023-06-28 19:37:36 +08:00
Ben Woo 33457ac5d5 Merge pull request #2904 from Multiverse/config-validation
Use Try<Void> for config validation
2023-04-03 10:57:24 +08:00
Ben Woo fac79e0780 fix: Double print error message for getting config value 2023-03-31 23:10:46 +08:00
Ben Woo 16e81ec141 refactor: Use Try<Void> for config validation 2023-03-31 23:08:56 +08:00
Ben Woo ffb238bf24 fix: Enable unstable api help for UsageCommand 2023-03-30 23:51:00 +08:00
Ben Woo 14472f5740 Merge pull request #2903 from Multiverse/improve-config-revamp
Improve config revamp
2023-03-30 23:41:44 +08:00
Ben Woo d9cf933d14 Merge pull request #2898 from Multiverse/async-teleport
feat: Add support for async teleport
2023-03-30 23:32:37 +08:00
Jeremy Wood 15ac39c3c2 Merge pull request #2897 from Multiverse/teleport-queue
refactor: Move teleport queue into seperate class
2023-03-30 08:41:29 -04:00
Jeremy Wood 8a05b3b815 Merge pull request #2899 from Multiverse/remove-serverfolder
refactor: Remove serverFolder value
2023-03-30 08:35:55 -04:00
benwoo1110 bfedc268d4 refactor: Improve setProperty onFailure output 2023-03-30 17:29:39 +08:00
benwoo1110 272c950f3e fix: Resolve context for MVCommandIssuer class 2023-03-30 13:54:13 +08:00
Jeremy Wood aac01b9e7e Merge pull request #2900 from Multiverse/better-revamp-config
refactor: Abstract handle class and improve node handling
2023-03-30 01:43:41 -04:00
Jeremy Wood 259189f23e Use specific exception for not found node. 2023-03-30 01:41:25 -04:00
Jeremy Wood 2a5b670ce6 Merge remote-tracking branch 'origin/MV5' into better-revamp-config 2023-03-30 01:06:00 -04:00
Jeremy Wood b8c95dc71a Merge pull request #2895 from Multiverse/revamp-config
Revamp config
2023-03-30 01:05:27 -04:00
Jeremy Wood 3ffc63a003 Merge remote-tracking branch 'origin/MV5' into revamp-config
# Conflicts:
#	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
#	src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt
2023-03-30 01:02:26 -04:00
Jeremy Wood 3d7af96b41 Merge pull request #2902 from Multiverse/dumptruckman/localized_exceptions
Add localizable message bundles and exceptions.
2023-03-30 00:52:40 -04:00
Jeremy Wood dab8ac2bf8 Set up locales before registering commands. 2023-03-30 00:14:45 -04:00
Jeremy Wood 5dcc0651e4 Add MVCorei18n#bundle for creating Message objects. 2023-03-29 23:59:19 -04:00
Jeremy Wood 2cb134bdeb Add base exception class MultiverseException.
Allows for localized messages to be contained in our exceptions.
2023-03-29 23:58:41 -04:00
Jeremy Wood 032a8c366d Add send message methods to MVCommandIssuer. 2023-03-29 23:45:44 -04:00
Jeremy Wood 1f8f68c383 Add kotlin mockito dependency for tests. 2023-03-29 15:18:08 -04:00
Jeremy Wood 979e80e1bd Use a custom implementation of BukkitCommandIssuer. 2023-03-29 13:09:18 -04:00
Jeremy Wood 224435f6cd Add Message for bundling messages with their arguments. 2023-03-29 12:53:40 -04:00
Jeremy Wood 40d5417629 Make PluginLocales injectable. 2023-03-29 00:51:54 -04:00
Jeremy Wood c32b2a4b51 Update Javadoc for MVConfig. 2023-03-28 17:36:02 -04:00
Jeremy Wood e5bb6bc23b Use Try<Void> rather than Try<Boolean> for ConfigHandle#set. 2023-03-28 17:25:48 -04:00
Jeremy Wood 94251be048 Change call order in FileConfigHandle.get for consistency. 2023-03-28 17:02:20 -04:00
Jeremy Wood 0cc3f93e0b Use Option instead of Optional for ValueNode#getName.
Also clean up nullability annotations in ConfigNode and co.
2023-03-28 16:38:35 -04:00
Jeremy Wood 63078270bf Use Option instead of Optional in NodeGroup. 2023-03-28 16:22:50 -04:00
Ben Woo a19fe76cbc chore: Add docs and remove some unused methods 2023-03-28 17:50:00 +08:00
Ben Woo 5cc5e6828f refactor: Allow for nullable NodeGroup 2023-03-28 17:15:15 +08:00
Ben Woo 90a3388728 refactor: Abstract handle class and improve node handling 2023-03-28 16:56:30 +08:00
Ben Woo 33fcf1ba26 refactor: Remove serverFolder value 2023-03-28 14:38:44 +08:00
Ben Woo f76b9b0670 feat: Add support for async teleport 2023-03-28 12:20:30 +08:00
Ben Woo 985f2e8823 refactor: Move teleport queue into seperate class 2023-03-28 11:32:04 +08:00
Jeremy Wood 9bbf42f993 Rename test methods. 2023-03-27 09:51:27 -04:00
Jeremy Wood 55390952c9 Add additional test set up more idiomatically. 2023-03-27 08:39:18 -04:00
Ben Woo 2f834ebfd6 fix: Relocation of acf dependency 2023-03-27 18:30:38 +08:00
Ben Woo 8f9df0294d chore: Improve logging in ConfigHandle 2023-03-27 18:29:34 +08:00
Ben Woo a5ae29c91a test: Implement test for config 2023-03-27 14:10:49 +08:00
Ben Woo 624d5ad117 fix: Get version without default fallback 2023-03-27 14:10:22 +08:00
Ben Woo 98fc0178aa fix: Migrate from old config on every load 2023-03-27 14:09:36 +08:00
Jeremy Wood 61cd593844 Fix a couple nits. 2023-03-27 01:03:21 -04:00
Jeremy Wood 7b39d78bfd Remove MultiverseCore dependency from DebugCommand. 2023-03-27 00:53:36 -04:00
Jeremy Wood 5a0957d894 Remove unused MultiverseConfigurationException. 2023-03-27 00:51:55 -04:00
Ben Woo 9f1ddcc81e refactor: Remove use of MVCoreConfigProvider 2023-03-27 12:25:13 +08:00
Ben Woo a8c8ef7a6b refactor: Move MVCoreConfigNodes to a non-static context 2023-03-27 11:39:11 +08:00
Ben Woo ce9d53c6e9 refactor: Rename to MVCoreConfig 2023-03-27 11:14:58 +08:00
Ben Woo 7af22c451e chore Remove unused MultiverseCoreConfiguration.java 2023-03-27 10:49:07 +08:00
Ben Woo db9879af8d refactor: Move DefaultMVConfig and MVConfigNodes to config package 2023-03-27 10:48:46 +08:00
Ben Woo f05092076f fix: Don't need to check version before removing serialisation value 2023-03-27 10:39:29 +08:00
Jeremy Wood 7f9c45d8e1 Use DI for new config. 2023-03-26 19:16:14 -04:00
Jeremy Wood a45e95c7fd Merge remote-tracking branch 'origin/MV5' into revamp-config
# Conflicts:
#	build.gradle
#	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
#	src/main/java/com/onarandombox/MultiverseCore/MultiverseCoreConfiguration.java
#	src/main/java/com/onarandombox/MultiverseCore/api/MVConfig.java
#	src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java
#	src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandContexts.java
#	src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java
#	src/main/java/com/onarandombox/MultiverseCore/listeners/MVEntityListener.java
#	src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerListener.java
#	src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorld.java
#	src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java
2023-03-26 19:09:37 -04:00
Jeremy Wood 43c6945710 Merge pull request #2886 from Multiverse/dumptruckman/inject
Implement simple dependency injection using hk2.
2023-03-26 16:12:16 -04:00
Jeremy Wood edea4aff4b Fix PAPI registration. 2023-03-26 14:48:30 -04:00
Jeremy Wood 44dacdceb1 Use consistency for exception param names. 2023-03-26 14:11:05 -04:00
Jeremy Wood 75998ae2c3 Remove EagerlyLoaded. 2023-03-26 14:10:26 -04:00
Jeremy Wood 16db616546 Remove EagerlyLoaded from SimpleMVWorldManager. 2023-03-26 14:09:40 -04:00
Jeremy Wood 4c94af5f08 Remove EagerlyLoaded from UnsafeCallWrapper. 2023-03-26 14:08:58 -04:00
Jeremy Wood e91bcb9658 Remove EagerlyLoaded from MVPermissions. 2023-03-26 14:08:28 -04:00
Jeremy Wood 0836badea6 Remove EagerlyLoaded from SimpleSafeTTeleporter. 2023-03-26 14:02:06 -04:00
Jeremy Wood 426d7639bb Remove EagerlyLoaded from SimpleLocationManipulation. 2023-03-26 14:01:02 -04:00
Jeremy Wood a74aeb53d0 Remove EagerlyLoaded from SimpleBlockSafety. 2023-03-26 14:00:22 -04:00
Jeremy Wood 52a2ff78c8 Remove EagerlyLoaded from MVEconomist. 2023-03-26 13:59:15 -04:00
Jeremy Wood 6f86416310 Remove EagerlyLoaded from MVCoreConfigProvider. 2023-03-26 13:55:21 -04:00
Jeremy Wood 1f134d4501 Use Provider for MultiverseCorePlaceholders in MultiverseCore. 2023-03-26 13:52:36 -04:00
Jeremy Wood 573b424efe Use vavr for registering listeners. 2023-03-26 13:51:54 -04:00
Jeremy Wood f2347cb620 Use Provider for MetricsConfigurator in MultiverseCore. 2023-03-26 13:33:01 -04:00
Jeremy Wood a8ec599b35 Remove direct getService usage for DestinationsProvider. 2023-03-26 13:18:20 -04:00
Jeremy Wood a8b44dff78 Remove additional direct getService usage for MVCommandProvider. 2023-03-26 13:09:43 -04:00
Jeremy Wood e8a33c0cdf Remove EagerlyLoaded from MVCommandManager. 2023-03-26 13:01:08 -04:00
Jeremy Wood 8b244e7d3b Remove EagerlyLoaded from AnchorManager. 2023-03-26 12:45:14 -04:00
Jeremy Wood 472742dde8 Manually initialize metrics. 2023-03-25 16:49:04 -04:00
Ben Woo cd260b0f5e feat: Fully implement working migration and validation 2023-03-26 00:31:36 +08:00
Jeremy Wood 372569ed6c Don't eagerly load MultiverseCorePlaceholders. 2023-03-25 09:38:15 -04:00
Jeremy Wood aa023f3c44 Use injection in MultiverseCorePlaceholders. 2023-03-25 09:28:27 -04:00
Jeremy Wood 93ac4fffcc Merge remote-tracking branch 'origin/MV5' into dumptruckman/inject
# Conflicts:
#	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
2023-03-25 08:42:20 -04:00
Jeremy Wood 750460fff0 Eagerly load core services. 2023-03-25 00:27:30 -04:00
Jeremy Wood add73be4fc Rename AutoLoadedService to EagerlyLoaded. 2023-03-25 00:17:08 -04:00
Jeremy Wood c65a945203 Fix listener registration. 2023-03-25 00:15:56 -04:00
Jeremy Wood cbc3bace58 Remove InjectionFeature loading. 2023-03-25 00:02:48 -04:00
Jeremy Wood 376fc8db18 Revert "Add API for creating auto-registering services."
This reverts commit b2171717ad.
2023-03-24 23:32:14 -04:00
Jeremy Wood 4aa1782cfd Revert "Add automatic listener registration through ListenerFeature."
This reverts commit d03063f2b9.
2023-03-24 23:31:58 -04:00
Jeremy Wood e38796f492 Revert "Add automatic command registration through BaseCommandFeature."
This reverts commit 0c97aea3dc.
2023-03-24 23:31:37 -04:00
Jeremy Wood 5d2e68a362 Revert "Add automatic destination registration through DestinationFeature."
This reverts commit c6a2cee050.
2023-03-24 23:31:30 -04:00
Ben Woo 358404b407 feat: Add a runnable when value is set. 2023-03-24 23:42:49 +08:00
Ben Woo 3ccdfd7cf5 refactor: Move to configuration package and rename MVSettings -> ConfigHandle 2023-03-24 22:32:10 +08:00
Ben Woo 274a7ed82b docs: Add more docstrings to methods implemented 2023-03-24 22:26:38 +08:00
Ben Woo ba2be24362 docs: Fix inheritDoc more typo 2023-03-24 22:20:56 +08:00
Ben Woo c8ae27894e refactor: Change name to optional and fix inheritDoc typo 2023-03-24 22:20:03 +08:00
Ben Woo cb5877b206 docs: Add docstrings to methods implemented 2023-03-24 22:09:10 +08:00
Ben Woo d126b3d31a feat: Add config for papi hook 2023-03-24 15:47:12 +08:00
Ben Woo 2edf955332 refactor: Rename config methods to align with new structure 2023-03-24 14:39:58 +08:00
Ben Woo 136bd3cbe2 fix: Clean up config migration logging 2023-03-24 14:16:03 +08:00
Ben Woo 433160f187 fix: Java 11 compatibility with instanceof pattern 2023-03-24 14:12:26 +08:00
Ben Woo e3e3c039c3 feat: Fully implement config command 2023-03-24 13:00:29 +08:00
Ben Woo d321851f0d fix: Donation and migration of various node path 2023-03-24 00:14:16 +08:00
Ben Woo 7759a37b4e feat: Implement config names and basic config command 2023-03-23 23:59:19 +08:00
Ben Woo f1a9d3a723 Merge remote-tracking branch 'origin/MV5' into revamp-config 2023-03-22 22:53:50 +08:00
Ben Woo 9ae2cddfda refactor: Flip boolean for custom portal search config 2023-03-22 22:53:16 +08:00
Ben Woo 6cc169cb55 feat: Fully replace with new config api 2023-03-22 22:48:24 +08:00
Ben Woo 783038ffb4 feat: Implement get/set methods from previous MVConfig class 2023-03-18 23:27:57 +08:00
Ben Woo db0e9f3142 feat: Implement migration from old mv config.yml 2023-03-18 23:09:10 +08:00
Zax71andBen Woo 95c3b034ec feat: Add PlaceholderAPI Support (#2888)
* feat:Add PlaceholderAPI Support

Signed-off-by: zax71 <zabax32@gmail.com>

* Implement requested changes

Signed-off-by: zax71 <zabax32@gmail.com>

* Add separate world functionality and half-baked i18n support.

Signed-off-by: zax71 <zabax32@gmail.com>

* refactor: Simplify papi world parsing

* Fix spelling and remove unused i18n.

Signed-off-by: zax71 <zabax32@gmail.com>

* chore: Add warnings

* chore: Remove unused imports

* chore: Setup papi before log enable message

---------

Signed-off-by: zax71 <zabax32@gmail.com>
Co-authored-by: Ben Woo <30431861+benwoo1110@users.noreply.github.com>
2023-03-16 20:18:36 +08:00
Ben Woo 9ce648d06a refactor: Version migrator code 2023-03-16 11:18:31 +08:00
Jeremy Wood 2a504f4360 Add annotation processing for tests. 2023-03-12 17:30:46 -04:00
Jeremy Wood 1d5d7a9ce2 Add hamkrest test dependency. 2023-03-12 17:04:38 -04:00
Jeremy Wood 0601c05761 Revert "Simplify PluginInjection by removing unneeded population."
This reverts commit f7bd538049.
2023-03-12 00:02:46 -05:00
Jeremy Wood c6a2cee050 Add automatic destination registration through DestinationFeature. 2023-03-11 23:56:49 -05:00
Jeremy Wood 0c97aea3dc Add automatic command registration through BaseCommandFeature. 2023-03-11 23:46:15 -05:00
Jeremy Wood 7dcada0c2d MultiverseCore#getAllServices should not instantiate services. 2023-03-11 23:37:03 -05:00
Jeremy Wood d03063f2b9 Add automatic listener registration through ListenerFeature. 2023-03-11 12:30:09 -05:00
Jeremy Wood 485d2428ed Rename PluginService to AutoLoadedService. 2023-03-11 11:40:37 -05:00
Jeremy Wood b2171717ad Add API for creating auto-registering services. 2023-03-11 11:37:33 -05:00
Jeremy Wood 49c23d31b0 MultiverseCore#getService should not instantiate services. 2023-03-11 11:24:24 -05:00
Jeremy Wood f7bd538049 Simplify PluginInjection by removing unneeded population. 2023-03-11 11:05:35 -05:00
Jeremy Wood 9f650d683d Add PluginService and InjectionFeature loading. 2023-03-10 02:07:44 -05:00
Jeremy Wood b40ded9806 Fix relocations and exported maven dependencies. 2023-03-09 15:57:55 -05:00
Jeremy Wood 93b82ae825 Inject MVCoreConfigProvider directly into MultiverseCore. 2023-03-09 11:34:41 -05:00
Jeremy Wood ecec80dfe3 Correctly rename hk2 metadata file. 2023-03-09 11:31:32 -05:00
Jeremy Wood 2f1a3bcc22 Use Provider for MVCoreConfigProvider in MultiverseCore. 2023-03-09 09:24:55 -05:00
Jeremy Wood 1ea88615c7 Don't rename hk2 metadata file. 2023-03-09 09:05:03 -05:00
Jeremy Wood 7fe50d2171 Temporarily throw exception on enable to reveal testing issue. 2023-03-09 08:53:37 -05:00
Jeremy Wood a81e045598 Use getter in MultiverseCore for config provider. 2023-03-09 08:52:51 -05:00
Jeremy Wood eac2fa53cb Stop relocating and minimizing for hk2. 2023-03-09 08:50:16 -05:00
Jeremy Wood 0f1d1adeb2 Remove Service/Contract from MVConfig and impl. 2023-03-09 08:49:29 -05:00
Jeremy Wood d4f43853f5 Skip checkstyle and javadoc in test workflow. 2023-03-08 23:52:39 -05:00
Jeremy Wood d7f907b40c Enable full exception format for gradle test. 2023-03-08 23:52:24 -05:00
Jeremy Wood 686c4a4b16 Simplify config provider usage. 2023-03-08 23:02:17 -05:00
Jeremy Wood ea07a490a6 Update Java version used in GHA. 2023-03-08 15:19:50 -05:00
Jeremy Wood 3d1c3f81f6 Fix relocations and minimize shadow jar. 2023-03-08 13:50:07 -05:00
Jeremy Wood 7fc78d81bc Remove faulty javadoc from CannonDestination. 2023-03-08 13:48:03 -05:00
Jeremy Wood 47002061db Remove some unused imports. 2023-03-08 13:37:41 -05:00
Jeremy Wood 1ea6df4a27 Merge remote-tracking branch 'origin/MV5' into dumptruckman/inject
# Conflicts:
#	src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java
#	src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java
2023-03-08 13:32:59 -05:00
Jeremy Wood 23693835ca Remove PluginDataFolder. 2023-03-08 13:19:31 -05:00
Jeremy Wood 8e7e0ef566 Replace all service getters with DI. 2023-03-08 13:16:18 -05:00
Jeremy Wood dd93223eb1 Use DI for command classes. 2023-03-08 08:43:40 -05:00
Jeremy Wood e6f304fd25 Use specific dependencies in SimpleMVWorldManager and SimpleMVWorld. 2023-03-08 07:39:18 -05:00
Jeremy Wood b6a0d272df Use specific dependencies in UnsafeCallWrapper. 2023-03-07 19:02:11 -05:00
Jeremy Wood 177adf80cb Use specific dependencies in SimpleSafeTTeleporter. 2023-03-07 19:00:06 -05:00
Jeremy Wood 160f49bbae Use specific dependencies in MVPermissions. 2023-03-07 18:54:33 -05:00
Jeremy Wood 397101f712 Use specific dependencies in DestinationsProvider. 2023-03-07 18:49:13 -05:00
Jeremy Wood d1f59e3d86 Use specific dependencies in SimpleBlockSafety. 2023-03-07 18:40:37 -05:00
Jeremy Wood bab0ccd3f2 Use specific dependencies in AnchorManager. 2023-03-07 17:00:24 -05:00
Jeremy Wood 015c58421d Add MVCoreConfigProvider#getConfigUnsafe. 2023-03-07 16:58:29 -05:00
Jeremy Wood a57a83a047 Add injectable wrapper for plugin data folder. 2023-03-07 16:49:14 -05:00
Jeremy Wood 6362a97aaf Move configuration loading/saving into injectable MVCoreConfigProvider. 2023-03-07 16:10:34 -05:00
Jeremy Wood 0db90dc0b9 Set up DI for primary dependencies of MultiverseCore. 2023-03-07 14:39:11 -05:00
Jeremy Wood 6a434746c9 Also bind plugin logger in PluginBinder. 2023-03-07 14:16:58 -05:00
Ben Woo c76652f0a2 feat: Test out new commentedconfiguration 2023-03-07 23:33:35 +08:00
Ben Woo e314539847 dep: Bump CommentedConfiguration to 1.0.1 2023-03-07 23:32:09 +08:00
Jeremy Wood de6b25db35 Also bind MultiverseCore to MVCore and MVPlugin. 2023-03-07 02:24:00 -05:00
Jeremy Wood 40637e6a88 Enable basic dependency injection. 2023-03-07 01:59:48 -05:00
Jeremy Wood 7ad0b04787 Abstract TestWithMockBukkit out of MockBukkitTest. 2023-03-07 00:20:26 -05:00
Jeremy Wood 00554fefc3 Add vavr dependency. 2023-03-06 22:55:36 -05:00
Jeremy Wood 0082287a5d Enable hk2 annotation processing. 2023-03-06 20:41:27 -05:00
Ben Woo 84730e0fcd Merge branch 'main' into MV5 2023-03-06 19:43:46 +08:00
Ben Woo 9dba558ffd Merge pull request #2884 from Lildirt/ld/command-i18n
i18n for strings directly in commands
2023-03-06 16:45:40 +08:00
Lildirt 1f1c8240d9 i18n: move RootCommand further down 2023-03-05 13:00:31 -05:00
Jeremy Wood 4576ca99c9 Add hk2 dependency. 2023-03-04 10:26:49 -05:00
Lildirt eaa8b1ee56 i18n: last bit of colorizing 2023-03-03 12:23:50 -05:00
Lildirt 10c910f00f i18n: fix prompt message mappings 2023-03-03 12:23:43 -05:00
Lildirt 3bd6712f0e i18n: Move mv-core.debug 2023-03-03 12:23:36 -05:00
Lildirt 6a5e8d2522 i18n: Register root command 2023-03-03 12:23:11 -05:00
Lildirt 1dadaa1a73 i18n: use error message levels 2023-03-03 12:23:11 -05:00
Lildirt ef3a50f32b i18n: section out the string file with comments 2023-03-03 12:22:58 -05:00
Lildirt ac31a66a45 i18n: Preserve original string colorization. 2023-03-03 12:22:58 -05:00
Lildirt 992ce7cff5 i18n: more sections & missing confirm description 2023-03-03 12:22:58 -05:00
Lildirt fd237243a4 i18n: Usage command 2023-03-03 12:22:58 -05:00
Lildirt 0512fa1820 i18n: Unload command 2023-03-03 12:22:58 -05:00
Lildirt a9896df2a7 i18n: Teleport command 2023-03-03 12:22:58 -05:00
Lildirt 216adf5fa9 i18n: MV Root command 2023-03-03 12:22:58 -05:00
Lildirt 12f6ceb622 i18n: Remove command 2023-03-03 12:22:58 -05:00
Lildirt ca0f6febb5 i18n: Reload command 2023-03-03 12:22:58 -05:00
Lildirt 3e468dba4d i18n: Regen command 2023-03-03 12:22:58 -05:00
Lildirt 8b450910ba i18n: Load command 2023-03-03 12:22:58 -05:00
Lildirt 38002261b7 i18n: Import command 2023-03-03 12:22:58 -05:00
Lildirt 9e5fb2cf4b i18n: Gamerule command 2023-03-03 12:22:58 -05:00
Lildirt fa0e9f4268 i18n: Delete command 2023-03-03 12:22:58 -05:00
Lildirt 5e4e925bb1 i18n: Clone command 2023-03-03 12:21:19 -05:00
Lildirt c9bb6180bd i18n: Check command 2023-03-03 12:21:14 -05:00
Jeremy Wood 8a69d6ad43 Merge pull request #2883 from Multiverse/artifact_pr_build
build: Add artifacting of PR build
2023-03-03 11:30:37 -05:00
Ben Woo 3b44ea218d build: Fix PR build number 2023-03-03 23:28:55 +08:00
Ben Woo 68c97f7ae6 build: Add artifacting of PR build 2023-03-03 23:21:36 +08:00
Ben Woo 3f6c3047d8 fix: Restore locales setup method (#2881) 2023-03-03 22:23:39 +08:00
Jeremy Wood e4fd23709f Merge pull request #2882 from Multiverse/dumptruckman/fix_mock_bukkit
Downgrade MockBukkit to 2.141.0.
2023-03-03 08:29:57 -05:00
Jeremy Wood a255f55b6f Downgrade MockBukkit to 2.141.0. 2023-03-03 08:27:12 -05:00
Jeremy Wood e0e2a0f0c2 Merge pull request #2879 from Multiverse/dumptruckman/new_tests
Add new test module using Kotlin and JUnit 5.
2023-03-02 08:56:39 -05:00
Jeremy Wood a4e84ad581 Use ServerMock instead of Server. 2023-03-02 08:36:43 -05:00
Jeremy Wood 65cb3f7037 Put test method after tearDown. 2023-03-02 08:35:52 -05:00
Jeremy Wood fc7509cca6 Use a better test method name. 2023-03-02 08:35:30 -05:00
Jeremy Wood eebb4a4a6d Implement initial test using MockBukkit. 2023-03-02 02:22:47 -05:00
Jeremy Wood 698d1c7954 Switch to JUnit 5 for new tests. 2023-03-02 02:10:36 -05:00
Jeremy Wood ed73fd059e Add Kotlin dependency for tests only. 2023-03-02 02:07:38 -05:00
Jeremy Wood 87225b1c65 Move old tests to old-test. 2023-03-02 01:20:38 -05:00
Jeremy Wood 6362d9fb17 Merge pull request #2878 from Multiverse/dumptruckman/merge_main
Merge main branch into MV5
2023-03-02 00:58:37 -05:00
Jeremy Wood d5ba55716b Merge remote-tracking branch 'origin/main' into dumptruckman/merge_main
# Conflicts:
#	build.gradle
2023-03-02 00:56:34 -05:00
Jeremy Wood 4eca331430 Merge pull request #2877 from Multiverse/dumptruckman/separate_test_deps
Use a separate API version for running tests.
2023-03-02 00:53:24 -05:00
Jeremy Wood b6574245b8 Remove junit exclusion from compileOnly bukkit. 2023-03-02 00:48:54 -05:00
Jeremy Wood 85d744d79f Run tests against spigot-api 1.19.3. 2023-03-02 00:44:32 -05:00
Jeremy Wood e536dff1a8 Use a separate bukkit dependency for tests. 2023-03-02 00:37:30 -05:00
Jeremy Wood 39287f55ef Delete CODEOWNERS. 2023-03-01 23:36:41 -05:00
Ben WooandJeremy Wood d5ebde53b9 Add maven central to repositories (#2859)
Co-authored-by: Jeremy Wood <farachan@gmail.com>
2023-03-02 12:32:07 +08:00
Jeremy Wood 101ddae443 Create CODEOWNERS. 2023-02-28 23:03:50 -05:00
Ben Woo e58de8d74d Merge pull request #2843 from Multiverse/help-command
feat: Implement help command
2023-02-28 23:21:36 +08:00
Ben Woo 974afb4751 feat: Implement help command 2023-02-28 23:16:09 +08:00
Ben Woo d819153690 Merge pull request #2842 from Multiverse/file-locales
feat: Improve locale support
2023-02-28 23:13:23 +08:00
Ben Woo 7dbd29b838 refactor: Shift classes and add javadocs 2023-02-28 23:07:19 +08:00
Ben Woo 560e3ab201 refactor: Make FileResClassLoader usable for other file paths. 2023-02-28 23:07:19 +08:00
Ben Woo ffc4c600c5 feat: Enable per player locale support 2023-02-28 23:07:18 +08:00
Ben Woo 44904eaef4 feat: Allow for custom locale folder path 2023-02-28 23:07:18 +08:00
Ben Woo 47a92deffd refactor: Use '&' for chat color formatting 2023-02-28 23:07:17 +08:00
Ben Woo b4549c6791 feat: Add support for loading locales from plugin dir 2023-02-28 23:07:17 +08:00
Jeremy Wood 2b97f7310f Use pull_request_target for auto labeler. 2023-02-25 20:39:56 -05:00
Jeremy Wood 073091525b Label PRs automatically as prerelease. 2023-02-25 20:34:19 -05:00
Jeremy Wood 79b9c12319 Change job name for manually promoting releases. 2023-02-25 20:29:04 -05:00
Jeremy Wood 01f745b027 Skip checking PR labels. 2023-02-25 19:39:14 -05:00
Jeremy Wood 9725bdfeeb Use ref input. 2023-02-25 14:02:01 -05:00
Jeremy Wood cdf9767959 Use target_commitish for GITHUA_SHA. 2023-02-25 13:41:26 -05:00
Jeremy Wood 66e21da6b2 Add version to publish action as well. 2023-02-25 13:39:59 -05:00
Jeremy Wood 87b14d3944 Add publish and upload. 2023-02-25 13:34:24 -05:00
Jeremy Wood 7bbeb90320 Remove dry_run. 2023-02-25 13:34:10 -05:00
Jeremy Wood cd895d03dc Remove extra } in bump_version_scheme. 2023-02-25 13:32:08 -05:00
Jeremy Wood ee2a304148 Reorder version bump types. 2023-02-25 13:31:49 -05:00
Jeremy Wood 06e9e33da4 Workflow requires version bump type. 2023-02-25 13:28:36 -05:00
Jeremy Wood 7065ffaea2 Remove checkstyle from promote workflow. 2023-02-25 13:24:24 -05:00
Jeremy Wood 1bc4e68ff9 Use promote scheme for manual workflow. 2023-02-25 13:20:40 -05:00
Jeremy Wood 4e53d13290 Add workflow for manually promoting a release. 2023-02-25 13:10:53 -05:00
Jeremy Wood 90344d36df Merge pull request #2867 from Multiverse/no_version_bump
Use "no version bump" label instead of "no release".
2023-02-24 13:19:16 -05:00
Jeremy Wood f36a56e854 Use "no version bump" label instead of "no release". 2023-02-24 13:17:39 -05:00
Jeremy Wood 5d4bacc80e Merge pull request #2866 from Multiverse/test_prerelease_2
Remove space to test pre-releases
2023-02-24 12:40:57 -05:00
Jeremy Wood d88bf6e137 Remove space to test pre-releases 2023-02-24 12:40:36 -05:00
Jeremy Wood 63f5d769d8 Merge pull request #2865 from Multiverse/prerelease-test
Add space to trigger release.
2023-02-24 11:57:39 -05:00
Jeremy Wood 9a9bfc03b9 Add space to trigger release. 2023-02-24 11:57:02 -05:00
Jeremy Wood 28112ef4d8 Merge pull request #2864 from Multiverse/simplify_release_name
Drop "Release" prefix on release names.
2023-02-24 11:46:47 -05:00
Jeremy Wood 7e5a3238b8 Drop "Release" prefix on release names. 2023-02-24 11:44:06 -05:00
Jeremy Wood 3279a6a38d Merge pull request #2863 from Multiverse/prerelease_snapshot
Check if the tag name contains pre instead of checking PR labels.
2023-02-24 11:34:18 -05:00
Jeremy Wood b64e48769d Check if the tag name contains pre instead of checking PR labels. 2023-02-24 11:29:28 -05:00
Jeremy Wood ff8002fc13 Merge pull request #2862 from Multiverse/prerelease_snapshot
Publish prerelease versions as snapshots.
2023-02-24 11:21:09 -05:00
Jeremy Wood 2af835f0c3 Publish prerelease versions as snapshots. 2023-02-24 11:15:36 -05:00
Jeremy Wood bf25b65f09 Merge pull request #2861 from Multiverse/test_prerelease
Test prerelease workflow.
2023-02-24 10:53:54 -05:00
Jeremy Wood 52eb3d820f Test out the prerelease action. 2023-02-24 09:58:10 -05:00
Ben Woo d90210d70f Merge pull request #2855 from Multiverse/gradle-build
build: Make MV5 build with gradle
2023-02-20 20:34:56 +08:00
Ben Woo ec254c2989 build: Make MV5 build with gradle 2023-02-20 20:29:08 +08:00
Ben Woo 36549294b7 Merge branch 'main' into gradle-build 2023-02-20 20:25:47 +08:00
Jeremy Wood 908fcb1e44 Merge pull request #2854 from Multiverse/dumptruckman/fix_release_8
Combine release and publish into a single workflow.
2023-02-20 07:20:05 -05:00
Jeremy Wood 73cd26aea3 Combine release and publish into a single workflow. 2023-02-20 07:17:37 -05:00
Jeremy Wood 758d25812b Merge pull request #2853 from Multiverse/fix-gha-release
Fix upload release artifact
2023-02-20 06:42:31 -05:00
Ben Woo fa0ef421c7 Merge branch 'main' into fix-gha-release 2023-02-20 14:57:52 +08:00
Ben Woo e936a6271f Fix upload release artifact 2023-02-20 14:57:01 +08:00
Jeremy Wood 7362e543da Merge pull request #2851 from Multiverse/dumptruckman/fix_release_7
Use new action for uploading artifact.
2023-02-20 00:58:06 -05:00
Jeremy Wood 8a46d70301 Use new action for uploading artifact. 2023-02-20 00:57:21 -05:00
Jeremy Wood a168e5cb48 Merge pull request #2850 from Multiverse/dumptruckman/fix_release_6
Massage the strange release upload url.
2023-02-20 00:38:53 -05:00
Jeremy Wood ae578f9491 Massage the strange release upload url. 2023-02-20 00:36:45 -05:00
Jeremy Wood e72122378d Merge pull request #2849 from Multiverse/dumptruckman/fix_release_5
Fix name of consumed output variable on get_release in more places.
2023-02-20 00:06:05 -05:00
Jeremy Wood fd2ea3df09 Remove tag prefix. 2023-02-20 00:04:43 -05:00
Jeremy Wood e94e071c6e Fix name of consumed output variable on get_release in more places. 2023-02-19 23:58:26 -05:00
Jeremy Wood 0e19236cdc Merge pull request #2848 from Multiverse/dumptruckman/fix_release_4
Use lowercase artifact id.
2023-02-19 23:53:45 -05:00
Jeremy Wood 1c12756acf Use lowercase artifact id. 2023-02-19 23:51:14 -05:00
Jeremy Wood bcfde80c07 Merge pull request #2847 from Multiverse/dumptruckman/fix_release_3
Fix name for consumed output variable on get_release.
2023-02-19 23:39:16 -05:00
Jeremy Wood 8dc9e864eb Fix name for consumed output variable on get_release. 2023-02-19 23:37:25 -05:00
Jeremy Wood fec820f4ba Merge pull request #2846 from Multiverse/dumptruckman/fix_release_2
Use PAT to create release.
2023-02-19 23:27:49 -05:00
Jeremy Wood ff9ffad302 Use organization PAT for creating release. 2023-02-19 23:25:10 -05:00
Jeremy Wood fc2cb6aeae Move publish jobs back into publish action. 2023-02-19 23:24:44 -05:00
Jeremy Wood d2776ef448 Merge pull request #2844 from Multiverse/dumptruckman/fix_release
Fix build & publish.
2023-02-19 22:55:44 -05:00
Jeremy Wood 36ef41b710 Release and publish in the same action. 2023-02-19 22:51:30 -05:00
Jeremy Wood 9258ebd8c7 Remove Intellij gradle plugin. :( 2023-02-19 21:57:13 -05:00
Jeremy Wood d528cbcafd Merge pull request #2826 from Multiverse/dumptruckman/gradle
Switch from Maven to Gradle.
2023-02-19 20:48:01 -05:00
Jeremy Wood 760c193b0e Readd test workflow. 2023-02-19 19:36:20 -05:00
Jeremy Wood 7c6edcb081 Fix the required label names. 2023-02-19 19:09:02 -05:00
Jeremy Wood 009a94f74d Publish releases. 2023-02-19 19:03:45 -05:00
Jeremy Wood bd6fb4e51c Correctly disable useless IntelliJ plugin tasks. 2023-02-19 19:03:40 -05:00
Jeremy Wood 2fdef44744 Create release on push to main branch. 2023-02-19 19:03:40 -05:00
Jeremy Wood 5b991f44e2 Require release related label on PRs against main branch. 2023-02-19 19:03:39 -05:00
zax71 871ba16b67 Implement requested changes 2023-02-19 19:03:39 -05:00
zax71 e90c50d170 Add Caching to GitHub actions and update README.md to reflect Gradle 2023-02-19 19:03:39 -05:00
zax71 d1be3bd0be Update GitHub Actions to Gradle 2023-02-19 19:03:37 -05:00
Jeremy Wood 4d40b3f7e4 Switch from Maven to Gradle. 2023-02-19 19:02:52 -05:00
Ben Woo 20ba6f130a feat: Implement remove and import command (#2839)
* feat: Implement remove and import command

* chore: Improve some description strings
2023-02-18 14:03:05 +08:00
Ben Woo d8fff0ae15 chore: Up protocol version to 50 2023-02-18 14:03:04 +08:00
Ben Woo 3da1b7e8c4 refactor: Remove AbstractMVPlugin entirely 2023-02-16 11:12:03 +08:00
Ben Woo 79ae8754dc feat: Properly cleanup AbstractMVPlugin 2023-02-16 10:46:01 +08:00
Ben Woo 3fc3663d5d feat: Improve SpawnLocation toString
This helps in debug logs not showing world=null for spawn location
2023-02-15 20:27:59 +08:00
Ben Woo 5d1d71baf2 refactor: Add shortcut methods to ParsedDestination 2023-02-15 19:47:11 +08:00
Ben Woo 71367d2d69 fix: Arg pop issue with * worlds selection 2023-02-15 14:06:41 +08:00
Ben Woo 09d8790804 chore: Refactor and fix some bugs with content display 2023-02-15 12:16:24 +08:00
Ben Woo 53f453b7ac refactor: Reorder gamerules completion alphabetically 2023-02-15 11:24:56 +08:00
Ben Woo 9a255555a6 feat: Set default completions 2023-02-15 11:24:09 +08:00
Ben Woo 28d71f7bc1 feat: Add support for comma separated MVWorlds 2023-02-15 11:10:35 +08:00
Ben Woo bf5ab8d1b3 refactor!: Remove MVPlayerSession (#2838)
Remove teleport / message cooldown along with it
2023-02-15 10:30:05 +08:00
Ben Woo c05d866f2f refactor: Remove buscript entirely (#2837) 2023-02-15 10:28:56 +08:00
Zax71andBen Woo 9cf2c68fe8 feat: Implement gamerule command (#2840)
* Feat: Add /gamerule

Signed-off-by: Ben Woo <30431861+benwoo1110@users.noreply.github.com>

* Chore: Accept sugguestion

Co-authored-by: Ben Woo <30431861+benwoo1110@users.noreply.github.com>

* Chore: Implement (most) suggestions from Ben

* feat: Implement gamerule context

* feat: Implement MVworld[] array context

* feat: Implement context for gamerule value

---------

Signed-off-by: Ben Woo <30431861+benwoo1110@users.noreply.github.com>
Co-authored-by: Ben Woo <30431861+benwoo1110@users.noreply.github.com>
2023-02-15 10:25:53 +08:00
Ben Woo 15ae0ea54f fix: Improve error handling for regex filter 2023-02-14 00:30:44 +08:00
Ben Woo 1e711ac258 fix: Missing pop arg when resolving mvworld 2023-02-14 00:19:30 +08:00
Ben Woo 706338bb0c feat: Add support for issuer with queued command 2023-02-13 23:59:46 +08:00
Ben Woo 1c89b6458f feat: Improve content display API
- Change ContentProvider to return a list instead of add to existing
- Add prefix for inline handler
- Change from CommandSender to BukkitCommandIssuer, prep for locale
2023-02-13 23:31:26 +08:00
Ben Woo 7978193d88 feat: Add support for resolving MVWorld based on issuer 2023-02-13 16:42:15 +08:00
Ben Woo 9efbbe7a4b feat: Add ContentFilter context 2023-02-13 16:38:15 +08:00
Ben Woo afaed87a67 refactor: Split into abstract MultiverseCommand and MultiverseCoreCommand 2023-02-10 21:58:11 +08:00
Ben Woo f3addfbf4e refactor: Use better nesting for locales key 2023-02-10 17:11:05 +08:00
Ben Woo 19ad1db5fb feat: Add reload command 2023-02-10 16:09:31 +08:00
Ben Woo 16096acc34 refactor: Make world name condition check id clearer 2023-02-09 17:09:28 +08:00
Ben Woo 1f907d93af refactor: Cleanup player finder
Add a getMulti method without command sender
2023-02-09 14:21:41 +08:00
Ben Woo aed0e178ea feat: Add support for teleporting multiple players 2023-02-09 14:16:29 +08:00
Ben Woo 6694c02650 refactor!: Rename back to MVWorldManager 2023-02-09 14:02:00 +08:00
Ben Woo 10ef838d3f feat: Implement create, delete, clone, regen, load and unload (#2835)
* feat: Implement create, delete, clone, regen, load and unload

* chore: Some formatting update

* chore: Implement suggested command changes

* feat: Add world name validation

* feat: Implement locale support for create command

* fix: World exist checking should include unloaded worlds

* fix: Add default null to generator output

* fix: Allow Unloaded worlds to be cloned

* chore: Make annotation order consistent
2023-02-09 13:50:36 +08:00
Ben Woo 5b25cf4f6c chore: Update vault and json dependency 2023-02-08 16:41:25 +08:00
Ben Woo 24596419e5 refactor!: Reorganise the entire MV 2023-02-08 16:19:33 +08:00
Ben Woo a403380375 refactor!: MultiverseCore plugin mess 2023-02-08 15:33:59 +08:00
Ben Woo a6ee8a55ca refactor!: Move queue command manager to command manager class 2023-02-08 14:00:20 +08:00
Ben Woo 6fba6715ba refactor!: Remove deprecated world purger 2023-02-08 13:54:38 +08:00
Ben Woo 6495b72a53 refactor!: Remove unused messaging classes 2023-02-08 13:54:20 +08:00
Ben Woo 5dba9f156d refactor!: Remove old command handler and commands 2023-02-08 13:41:38 +08:00
Ben Woo a8590df9d4 feat: Implementation of new destination API (#2833)
* feat: Basic implementation of new destination API

* feat!: Move all destinations to new API

* feat: Fully implement teleport and check command

* chore: Improve autocomplete permission checking

* chore: Fine tune tab completion

* chore: Implement suggested changes

* docs: Add javadocs to added api methods
2023-02-08 12:43:59 +08:00
Chris 1877479094 Update github actions dependencies (#2825)
* Update Actions

* Trigger Test Build

* Fix build

* Remove Test build Trigger
2023-02-08 12:37:01 +08:00
Ben Woo 747cab75fd feat: Implement command flag system (#2827)
* feat: Implement command flag system

* docs: Add javadocs and annotation

* chore: Implement suggested improvements

* chore: Add shortcuts for flaggroup in MultiverseCommand

* chore: Add check if flaggroup already registered
2023-02-06 21:04:34 +08:00
Ben Woo fe8118854e refactor!: Remove deprecated debug log 2023-02-04 16:49:11 +08:00
Ben Woo 3377c1dbe5 refactor!: Remove deprecated logging (#2523) 2023-02-03 22:45:55 +08:00
Ben Woo 3ec22fc578 refactor!: Remove deprecated WorldManager methods (#2526) 2023-02-03 22:40:42 +08:00
Ben Woo 17351e66c1 refactor!: Remove deprecated getStaticConfig (#2525) 2023-02-03 22:39:23 +08:00
Ben Woo 0166b8d139 refactor!: Remove deprecated LocationManipulation class (#2528) 2023-02-03 22:38:51 +08:00
Ben Woo 2acca7f330 refactor!: Remove deprecated PlayChatEvent option (#2828) 2023-02-03 22:33:44 +08:00
Ben Woo 4ad6c53ba9 refactor!: Remove redundant MapInitializeEvent (#2507) 2023-02-03 22:11:38 +08:00
Ben Woo 0117159159 feat: @benwoo1110 Revamp content display API
commit 1211dfb057
Author: Ben Woo <30431861+benwoo1110@users.noreply.github.com>
Date:   Tue Aug 17 16:29:31 2021 +0800

    Implement suggested improvements.

    * Use singleton pattern for DefaultContentFilter with getInstance method.
    * Have a default SendHandler.
    * Don't need streams for small dataset.
    * Private WorldListContentParser class to improve readability.

commit 562eed8255
Author: Ben Woo <30431861+benwoo1110@users.noreply.github.com>
Date:   Tue Aug 17 00:26:57 2021 +0800

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

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

* Add @FunctionalInterface annotation to displaytools interfaces.

* Use static factory method to create Builder with contents.

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

* Rename Builder#display to show and require CommandSender.

* Rename package from displaytools to display.

* Move DisplayHandler impls into their own package.

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

* Pass CommandSender to send command.

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

* Rename ContentDisplay#send to #show.

* Split DisplaySettings into separate classes.

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

Please consider updating this default setting. It will save a lot of us trouble in the future 🙏
2021-04-06 14:19:38 +10:00
nicegamer7 a2c5bf70f0 Merge pull request #2597 from Multiverse/cleanup
Cleanup
2021-03-18 10:52:28 -04:00
benwoo1110 ea19006465 Fix selector log level. 2021-03-18 16:40:47 +08:00
benwoo1110 89f685ff9a Add missing javadocs in DestinationFactory. 2021-03-10 17:45:39 +08:00
benwoo1110 ecc76033dc Remove redundant line that was moved to WorldNameChecker. 2021-03-10 17:41:56 +08:00
Ben Woo e843b0711d Merge pull request #2590 from Multiverse/small-wm-updates
Small WorldManager updates
2021-03-10 06:41:18 +08:00
Ben Woo eddfaf7df0 Merge pull request #2593 from Multiverse/destination-id
Add method to get registered destination identifiers.
2021-03-10 06:39:31 +08:00
nicegamer7 d1150ab5f8 Merge pull request #2591 from Multiverse/uuid-regex
Make UUID regex less restrictive.
2021-03-09 09:46:33 -05:00
benwoo1110 cc3996ca76 Implement new queue command system. 2021-03-09 20:54:42 +08:00
benwoo1110 1965aecfba Add method to get registered destination identifiers. 2021-03-09 20:05:23 +08:00
benwoo1110 ce34ae44d8 Make UUID regex less restrictive. 2021-03-09 11:48:26 +08:00
benwoo1110 f5a2d7bc47 Add getPotentialWorlds method to WorldManager. 2021-03-09 10:40:46 +08:00
benwoo1110 24295025ef Add option to lookup mvworlds without checking for aliases. 2021-03-09 10:35:42 +08:00
Ben Woo e3f56f6498 Merge pull request #2586 from Multiverse/reflect-helper
Add ReflectHelper class to better facilitate various reflection actions.
2021-03-09 01:18:29 +08:00
Ben Woo bd0c3cff3f Merge pull request #2587 from Multiverse/player-desination
Player destination
2021-03-09 00:32:20 +08:00
Ben Woo 7c4ab035a0 Merge pull request #2588 from Multiverse/world-name-check
Implement new WorldNameChecker
2021-03-09 00:31:58 +08:00
Ben Woo 2593080f77 Merge pull request #2567 from Multiverse/player-utils
Add support to find players based on name, UUID or selectors.
2021-03-09 00:29:22 +08:00
benwoo1110 0d4595d511 Implement new WorldNameChecker for better preliminary checks of world name. 2021-03-08 18:03:35 +08:00
benwoo1110 bf820c2c27 Add getPlayerAwareDestination to DestinationFactory. 2021-03-08 17:09:03 +08:00
benwoo1110 a12718d354 Add ReflectHelper class to better facilitate various reflection actions. 2021-03-08 16:25:33 +08:00
benwoo1110 b23c1ae606 Update unload message logging. 2021-03-04 16:00:53 +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 62b789dff5 Add support to find players based on name, UUID or selectors. 2021-02-21 16:47:13 +08:00
benwoo1110 84a9db597a Add respawn anchor support. 2021-02-19 00:57:19 +08:00
benwoo1110 9741b1794c Update readme with more project details 2020-12-31 00:42:22 +08: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
benwoo1110 5d3d732c25 Fix issue where special chars cause PatternSyntaxException
Escape regex special chars for help command
2020-10-09 12:19:32 +08:00
Jonathan Leitschuh 59b6522d59 Use HTTPS instead of HTTP to resolve dependencies
This fixes a security vulnerability in this project where the `pom.xml`
files were configuring Maven to resolve dependencies over HTTP instead of
HTTPS.

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

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
name: 🐛 Report a Bug
description: Report a problem with Multiverse-Core.
title: "[Bug]: "
labels: ["Bug: Unconfirmed"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
If you are having issues with other submodules of Multiverse, please go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
Not sure if this is a bug with Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
When completing the report, please ensure all fields are filled with the correct details requested. Failure to do so will result in your issue being closed.
- type: input
id: mutliverse-version-info
attributes:
label: '`/mv version -p` output'
description: Run `/mv version -p` in the console, then copy and paste the link from the output of the command into this box.
validations:
required: true
- type: input
id: server-logs
attributes:
label: Server logs
description: >
Include full startup log and console error (if any). upload all relevant logs to either https://paste.gg
or https://gist.github.com, save and the paste the link in this box.
validations:
required: true
- type: textarea
id: server-version
attributes:
label: Server Version
description: Output of `/version` command.
placeholder: server version info
render: shell
validations:
required: true
- type: textarea
id: bug-description
attributes:
label: Bug Description
description: Describe in detail what the bug is about. Include the expected behaviour and actual behaviour.
placeholder: "Example: When running `/mv` it cause the server to crash..."
validations:
required: true
- type: textarea
id: reproduce-steps
attributes:
label: Steps to reproduce
description: Provide detailed intructions to trigger the bug.
placeholder: |
Example:
1. Start a server with only multiverse installed.
2. Run `/mv` command.
3. Players all get kicked with a "server closed" message.
...
validations:
required: true
- type: checkboxes
id: agreements
attributes:
label: Agreements
description: Ensure you have done the following being submitting this issue.
options:
- label: I have searched for and ensured there isn't already an open or resolved issue(s) regarding this.
required: true
- label: >
I was able to reproduce my issue on a freshly setup and up-to-date server with the latest
version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
required: true
+1 -1
View File
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 💬 ​Multiverse Discord Server
- name: 💬 Multiverse Discord Server
url: https://discord.gg/NZtfKky
about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help!
@@ -0,0 +1,41 @@
name: 💡 Request a Feature
description: Suggest a feature you want to see in Multiverse-Core!
title: "[Idea]: "
labels: ["Type: Idea"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to share your ideas!
If you are look for other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky
- type: textarea
id: feature-description
attributes:
label: Describe the feature
description: What feature are you suggesting?
placeholder: "Example: I hope multiverse can implement random teleport feature..."
validations:
required: true
- type: textarea
id: feature-reasoning
attributes:
label: How is the feature useful to all Multiverse users?
description: How is the feature useful to all players, server owners and/or developers?
placeholder: "Example: Random teleporting can be integrated into many multiverse modules such as mv-portals..."
validations:
required: true
- type: checkboxes
id: agreements
attributes:
label: Agreements
description: Ensure you have done the following being submitting this issue.
options:
- label: I have searched for and ensured there isn't already an open issue regarding this.
required: true
-56
View File
@@ -1,56 +0,0 @@
---
name: ❓ Help!
about: Encountered a problem with Multiverse-Core? Not sure how to fix it?
title: ''
labels: 'Type: Assistance'
assignees: ''
---
<!-- Multiverse-Core help guide
Don't write inside the arrows as they will be hidden when you post your issue.
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
If you need help other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
Or come join our Discord server to get help sooner: https://discord.gg/NZtfKky
If you're happy to wait (or you were sent here from Discord), read on:
1. Check the Usage and FAQ pages to see if it answers your queries:
https://github.com/Multiverse/Multiverse-Core/wiki/Basics
https://github.com/Multiverse/Multiverse-Core/wiki/FAQ
2. Fill out the template.
This will help us understand what problem you've encountered and help us
find a solution.
3. When linking files, do not attach them to the post!
Copy and paste any logs into https://gist.github.com/ or other similar service.
4. Delete this line and all above lines before posting your issue! -->
### Information
* **Server version:** <!-- Insert output of `/version` command -->
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
### Help request
**Problem**
<!-- What problem did you encounter? -->
**What I have tried**
<!-- What have you tried so far? -->
**Screenshots**
<!-- If relevant, include any screenshots here. -->
-59
View File
@@ -1,59 +0,0 @@
---
name: 🐛 Report a Bug
about: Report a Multiverse-Core bug. Only use this if you're 100% sure it's something wrong with Multiverse-Core - otherwise, try "Help!".
title: ''
labels: 'Bug: Unconfirmed'
assignees: ''
---
<!-- Multiverse-Core bug reporting guide
Don't put anything inside this block, as it won't be included in the issue.
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
If you are having issues with other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
If you are reporting a bug, please follow the following steps:
1. Fill out the template in full.
Run the commands in the console. Don't just put "latest" as a version,
or we will ignore it.
2. When linking files, do not attach them to the post!
Copy and paste any logs into https://gist.github.com/, then paste a
link to them in the relevant parts of the template.
**DO NOT drag files into this box!**
3. Make sure not to write between the arrows, as anything there will be
hidden.
4. Delete this line and all above lines before posting your issue! -->
### Information
* **Server version:** <!-- Insert output of `/version` command -->
* **Full output of `/mv version -p`:** <!-- Replace this with the command output's https://paste.gg/ link -->
* **Server log:** <!-- Upload `logs/latest.log` to https://gist.github.com/ -->
### Details
I was **`<able / not able>`** to reproduce my issue on a freshly setup and up-to-date server with the latest version of Multiverse plugins with no other plugins and with no kinds of other server or client mods.
**Description**
<!-- Replace this with a brief summary of the bug. -->
**Steps to reproduce**
<!-- Replace this with exactly what you did to cause the bug. -->
**Expected behavior**
<!-- Replace this with what you expected to happen. -->
**Screenshots**
<!-- Replace this with screenshots, if necessary. -->
@@ -1,54 +0,0 @@
---
name: 💡 Request a Feature
about: Suggest a feature you want to see in Multiverse-Core!
title: ''
labels: 'Type: Idea'
assignees: ''
---
<!-- Multiverse-Core feature request guide
Fill out the template. Don't write inside the arrows as they will be hidden
when you post your issue.
Get latest build from: http://ci.onarandombox.com/view/Multiverse/
If you are look for other submodules of Multiverse, go to their respective git repo:
Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues
Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues
Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues
Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues
Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord
server: https://discord.gg/NZtfKky
If you have a feature suggestion for Multiverse-Core, read the following tips:
1. Fill out the template.
This will help us understand what you're requesting and why you want us
to add it.
2. Keep it simple.
Make sure it's easy to understand what you're requesting. A good way is
to keep it to one request per GitHub issue, as we can then easily track
feature requests.
3. Check whether it has already been asked or added.
You can search the issue tracker to see if your feature has already been
requested at https://github.com/Multiverse/Multiverse-Core/issues.
4. Ask yourself: "Does this belong in Multiverse-Core?"
There are lots of features that we reject because most servers won't
need or use them. If your feature is very specific or already exists in
another plugin, it might not be a good fit for Multiverse-Core.
5. Delete this line and all above lines before posting your issue! -->
### Feature request
**Feature description**
<!-- What feature are you suggesting? -->
**How the feature is useful**
<!-- How is the feature useful to players, server owners and/or developers? -->
+2
View File
@@ -0,0 +1,2 @@
prerelease:
- '*'
+38
View File
@@ -0,0 +1,38 @@
name: Create Release Version & Publish Package
on:
push:
branches: [dbo-test]
jobs:
dbo_upload_test:
runs-on: ubuntu-latest
steps:
- name: Download release artifact
id: release-artifact
uses: dsaltares/fetch-gh-release-asset@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
# version: tags/${{ github.event.inputs.version }}
regex: true
file: multiverse-core-(.*)\.jar
target: 'subdir/'
- name: Upload to dev.bukkit.org
uses: benwoo1110/dbo-upload-action@v0.1.0
with:
api_token: ${{ secrets.DBO_UPLOAD_API_TOKEN }}
project_id: 30765
changelog: ${{ steps.release-artifact.outputs.body }}
changelog_type: markdown
display_name: ${{ steps.release-artifact.outputs.version }}
game_versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1
project_relations: >
[
{"slug": "multiverse-portals", "type": "optionalDependency"},
{"slug": "multiverse-netherportals", "type": "optionalDependency"},
{"slug": "multiverse-signportals", "type": "optionalDependency"},
{"slug": "multiverse-inventories", "type": "optionalDependency"}
]
file_path: ${{ github.workspace }}/subdir/multiverse-core-${{ steps.release-artifact.outputs.version }}.jar
debug: true
+17
View File
@@ -0,0 +1,17 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened]
branches: [main]
jobs:
prerelease_labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
+90
View File
@@ -0,0 +1,90 @@
name: Manually promote last prerelease to release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to promote'
required: true
version-bump:
description: 'Version bump to apply - should usually match the version bump used for the prerelease since last release'
required: true
type: choice
options:
- 'patch'
- 'minor'
- 'major'
jobs:
manually_promote_release:
runs-on: ubuntu-latest
steps:
- name: Verify input version is prerelease
run: |
if [[ "${{ github.event.inputs.version }}" != *"pre"* ]]; then
echo "Version must be a prerelease"
exit 1
fi
- name: Get release info
id: get-release
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ github.event.inputs.version }}
- uses: actions/checkout@v3
with:
ref: ${{ steps.get-release.outputs.tag_name }}
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Remove prerelease tag
run: |
echo "Removing prerelease tag from version"
echo "VERSION=$(echo ${{ steps.get-release.outputs.tag_name }} | sed -E 's/-pre.*//')" >> $GITHUB_ENV
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x test -x checkstyleMain -x checkstyleTest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_VERSION: ${{ env.VERSION }}
- name: Create release
id: release
uses: Multiverse/release-on-push-action@skip_prs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
bump_version_scheme: ${{ github.event.inputs.version-bump }}
tag_prefix: ''
release_name: "<RELEASE_VERSION>"
use_github_release_notes: true
ref: ${{ steps.get-release.outputs.target_commitish }}
skip_prs: true
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_VERSION: ${{ env.VERSION }}
- name: Upload release artifact
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/libs/multiverse-core-${{ env.VERSION }}.jar
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
tag: ${{ steps.release.outputs.tag_name }}
+64
View File
@@ -0,0 +1,64 @@
name: Create Release Version & Publish Package
on:
push:
branches: [main]
jobs:
release_on_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Test & Build
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x assemble -x shadowJar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: release
uses: Multiverse/release-on-push-action@support_prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
bump_version_scheme: norelease
tag_prefix: ''
release_name: "<RELEASE_VERSION>"
use_github_release_notes: true
- name: Modify version scheme
run: |
if [[ "${{ steps.release.outputs.tag_name }}" == *"pre"* ]]; then
echo "Replacing prerelease version scheme with SNAPSHOT"
echo "VERSION=$(echo ${{ steps.release.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV
else
echo "Using release version scheme"
echo "VERSION=${{ steps.release.outputs.tag_name }}" >> $GITHUB_ENV
fi
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release artifact
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/libs/multiverse-core-${{ env.VERSION }}.jar
asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar
tag: ${{ steps.release.outputs.tag_name }}
+18
View File
@@ -0,0 +1,18 @@
name: Require PR Labels
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [main]
jobs:
require_label:
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
mode: exactly
count: 1
labels: "release:major, release:minor, release:patch, no version bump"
+36
View File
@@ -0,0 +1,36 @@
name: Run unit tests against all PRs
on:
pull_request:
types: [opened, synchronize]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Run unit tests
uses: gradle/gradle-build-action@v2
with:
arguments: build -x checkstyleMain -x checkstyleTest -x javadoc
env:
GITHUB_VERSION: pr${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Artifact output
uses: actions/upload-artifact@v3
with:
name: multiverse-core-pr${{ github.event.pull_request.number }}
path: build/libs/multiverse-core-pr${{ github.event.pull_request.number }}.jar
+3
View File
@@ -43,3 +43,6 @@ debug.log
# Doxygen
/docs/html
debug.txt
# Gradle
.gradle
-6
View File
@@ -1,6 +0,0 @@
language: java
jdk:
- oraclejdk8
notifications:
email: false
dist: trusty
+6
View File
@@ -0,0 +1,6 @@
Copyright (c) 2011, The Multiverse Team All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+38 -10
View File
@@ -1,16 +1,44 @@
![Multiverse 2](config/multiverse2-long.png)
[![Maven CI/CD](https://github.com/Multiverse/Multiverse-Core/actions/workflows/build.yml/badge.svg)](https://github.com/Multiverse/Multiverse-Core/actions/workflows/build.yml)
[![Release](https://img.shields.io/nexus/r/com.onarandombox.multiversecore/Multiverse-Core?label=release&server=https%3A%2F%2Frepo.onarandombox.com%2F)](https://dev.bukkit.org/projects/multiverse-core)
[![Dev builds](https://img.shields.io/nexus/s/com.onarandombox.multiversecore/Multiverse-Core?label=dev%20builds&server=http%3A%2F%2Frepo.onarandombox.com%2F)](https://ci.onarandombox.com/job/Multiverse-Core/)
[![Discord](https://img.shields.io/discord/325459248047980545?label=discord&logo=discord)](https://discord.gg/NZtfKky)
[![Support me on Patreon](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Ddumptruckman%26type%3Dpatrons&style=flat)](https://patreon.com/dumptruckman)
[![License](https://img.shields.io/github/license/Multiverse/Multiverse-Core)](LICENSE.md)
About
========
[Multiverse](https://dev.bukkit.org/projects/multiverse-core) was created at the dawn of Bukkit multiworld support. It has since then grown into a **complete world management solution!** Multiverse provides the easiest to use world management solution for your Minecraft server, big or small, and with great addons like [Portals](https://dev.bukkit.org/projects/multiverse-portals) and [NetherPortals](https://dev.bukkit.org/projects/multiverse-netherportals/), what's not to love!
<br><br>
Now it's time to create your very own Multiverse server, do check out our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) and [Usage Guide](https://github.com/Multiverse/Multiverse-Core/wiki/Basics) to get started. Feel free to hop onto our [Discord](https://discord.gg/NZtfKky) if you have any question or just want to have a chat with us!
### Amazing sub-modules available:
* [Multiverse-NetherPortals](https://github.com/Multiverse/Multiverse-NetherPortals) -> Have separate nether and end worlds for each of your overworlds!
* [Multiverse-Portals](https://github.com/Multiverse/Multiverse-Portals) -> Make custom portals to go to any destination!
* [Multiverse-Inventories](https://github.com/Multiverse/Multiverse-Inventories) -> Have separated players stats and inventories per world or per group of worlds.
* [Multiverse-SignPortals](https://github.com/Multiverse/Multiverse-SignPortals) -> Signs as teleprompters!
Building
========
Simply build the source with maven:
$ mvn install
Simply build the source with Gradle:
```
./gradlew build
```
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
Contributing
=======
**Want to help improve Multiverse?** There are several ways you can support and contribute to the project.
* Take a look at our "Bug: Unconfirmed" issues, where you can find issues that need extra testing and investigation.
* Want others to love Multiverse too? You can join the [Multiverse Discord community](https://discord.gg/NZtfKky) and help others with issues and setup!
* A Multiverse guru? You can update our [Wiki](https://github.com/Multiverse/Multiverse-Core/wiki) with your latest tip, tricks and guides! The wiki open for all to edit and improve.
* Love coding? You could look at ["State: Open to PR"](https://github.com/Multiverse/Multiverse-Core/labels/State%3A%20Open%20to%20PR) and ["Resolution: Accepted"](https://github.com/Multiverse/Multiverse-Core/labels/Resolution%3A%20Accepted) issues. We're always happy to receive bug fixes and feature additions as [pull requests](https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github-3/).
* If you'd like to make a financial contribution to the project, do consider joining our [patreon](https://www.patreon.com/dumptruckman) or make a one-time donation [here](https://paypal.me/dumptruckman)!
Additionally, we would like to give a big thanks to everyone that has supported Multiverse over the years, as well as those in the years to come. Thank you!
License
=======
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.
Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info.
+286
View File
@@ -0,0 +1,286 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java-library'
id 'maven-publish'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id "org.jetbrains.kotlin.jvm" version "1.8.10"
}
version = System.getenv('GITHUB_VERSION') ?: 'local'
group = 'com.onarandombox.multiversecore'
description = 'Multiverse-Core'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
maven {
url = uri('https://repo.onarandombox.com/content/groups/public')
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/groups/public/')
}
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.minebench.de/')
}
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
maven {
name = 'aikar repo'
url = uri('https://repo.aikar.co/content/groups/aikar/')
}
maven {
name = 'glaremasters repo'
url = 'https://repo.glaremasters.me/repository/towny/'
}
maven {
name = 'PlaceholderAPI'
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
}
configurations {
oldTestImplementation.extendsFrom implementation
oldTestRuntime.extendsFrom runtime
relocatedApi
compileClasspath.extendsFrom relocatedApi
runtimeClasspath.extendsFrom relocatedApi
testCompileClasspath.extendsFrom relocatedApi
testRuntimeClasspath.extendsFrom relocatedApi
oldTestCompileClasspath.extendsFrom relocatedApi
oldTestRuntimeClasspath.extendsFrom relocatedApi
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
// Economy
implementation('com.github.MilkBowl:VaultAPI:1.7.1') {
exclude group: 'org.bukkit', module: 'bukkit'
}
// PlaceholderAPI
implementation 'me.clip:placeholderapi:2.11.3'
// Command Framework
relocatedApi 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
// Config
relocatedApi('me.main__.util:SerializationConfig:1.7') {
exclude group: 'org.bukkit', module: 'bukkit'
}
relocatedApi('io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.1') {
exclude group: 'org.spigotmc', module: 'spigot-api'
}
// Utils
relocatedApi 'io.vavr:vavr:0.10.4'
relocatedApi 'org.glassfish.hk2:hk2-locator:3.0.3'
relocatedApi('com.dumptruckman.minecraft:Logging:1.1.1') {
exclude group: 'junit', module: 'junit'
}
relocatedApi 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
relocatedApi 'org.bstats:bstats-bukkit:2.2.1'
relocatedApi 'net.minidev:json-smart:2.4.8'
relocatedApi 'org.jetbrains:annotations:22.0.0'
relocatedApi 'io.papermc:paperlib:1.0.8'
// Tests
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.141.0'
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'com.natpryce:hamkrest:1.8.0.1'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0'
// Old Tests
oldTestImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
oldTestImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
oldTestImplementation 'junit:junit:4.13.1'
oldTestImplementation 'org.mockito:mockito-core:3.11.2'
oldTestImplementation 'commons-io:commons-io:2.7'
// Annotation Processors
annotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
testAnnotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(shadowJar)
}
}
sourceSets {
oldTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/old-test/java')
}
resources.srcDir file('src/old-test/resources')
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Core"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
ext.bitlyAccessToken = System.getenv('BITLY_ACCESS_TOKEN') ?: 'bitly-access-token'
task prepareSource(type: Sync) {
inputs.property 'bitlyAccessToken', bitlyAccessToken
from sourceSets.main.java
into "$buildDir/src"
filter(ReplaceTokens, tokens: [
'bitly-access-token': bitlyAccessToken,
])
}
compileJava {
source = prepareSource.outputs
}
tasks.withType(JavaCompile) {
configure(options) {
options.compilerArgs << '-Aorg.glassfish.hk2.metadata.location=META-INF/hk2-locator/Multiverse-Core'
}
}
compileKotlin {
// We're not using Kotlin in the plugin itself, just tests!
enabled = false
}
configurations.findAll { !it.name.startsWith('test') }.each {
it.exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}
processResources {
def props = [version: "${project.version}"]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
// This task should never be skipped. The tests depend on this having been run but we want the new version number
// that is created after tests are run and before we run again to publish.
outputs.upToDateWhen { false }
}
checkstyle {
toolVersion = '6.1.1'
configFile file('config/mv_checks.xml')
ignoreFailures = true
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
}
project.configurations.api.canBeResolved = true
shadowJar {
relocate 'co.aikar.commands', 'com.onarandombox.acf'
relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.MultiverseCore.utils.CoreLogging'
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.MultiverseCore.utils.DebugFileLogger'
relocate 'de.themoep.idconverter', 'com.onarandombox.idconverter'
relocate 'io.github.townyadvanced.commentedconfiguration', 'com.onarandombox.commentedconfiguration'
relocate 'me.main__.util', 'com.onarandombox.serializationconfig'
relocate 'org.bstats', 'com.onarandombox.bstats'
relocate 'com.sun', 'com.onarandombox.sun'
relocate 'net.minidev', 'com.onarandombox.minidev'
relocate 'org.objectweb', 'com.onarandombox.objectweb'
relocate 'io.vavr', 'com.onarandombox.vavr'
relocate 'jakarta', 'com.onarandombox.jakarta'
relocate 'javassist', 'com.onarandombox.javassist'
relocate 'org.aopalliance', 'com.onarandombox.aopalliance'
relocate 'org.glassfish', 'com.onarandombox.glassfish'
relocate 'org.jvnet', 'com.onarandombox.jvnet'
relocate 'org.intellij', 'com.onarandombox.intellij'
relocate 'org.jetbrains', 'com.onarandombox.jetbrains'
relocate 'io.papermc.lib', 'com.onarandombox.paperlib'
configurations = [project.configurations.api, project.configurations.relocatedApi]
archiveFileName = "$baseName-$version.$extension"
dependencies {
exclude(dependency {
it.moduleGroup == 'org.jetbrains.kotlin'
})
}
}
build.dependsOn shadowJar
jar.enabled = false
test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
+1 -1
View File
@@ -69,7 +69,7 @@
<module name="TypeName"/>
<module name="AvoidStarImport">
<property name="severity" value="warning"/>
<property name="excludes" value="com.onarandombox.MultiverseCore.utils,com.onarandombox.MultiverseCore.configuration,com.onarandombox.MultiverseCore.commands,com.onarandombox.MultiverseCore.destination"/>
<property name="excludes" value="com.onarandombox.MultiverseCore.utils,com.onarandombox.MultiverseCore.configuration,com.onarandombox.MultiverseCore.commandsold,com.onarandombox.MultiverseCore.destination"/>
</module>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+244
View File
@@ -0,0 +1,244 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
-397
View File
@@ -1,397 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>4.2.3-SNAPSHOT</version>
<name>Multiverse-Core</name>
<description>World Management Plugin</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>UNKNOWN</project.build.number>
<project.bitly-access-token>bitly-access-token</project.bitly-access-token>
</properties>
<repositories>
<!-- Spigot -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
<repository>
<id>spigot</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>doodleproject-repo</id>
<name>DoodleProject Maven 2 Repository</name>
<url>http://doodleproject.sourceforge.net/maven2/release</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<ciManagement>
<system>jenkins</system>
<url>http://ci.onarandombox.com</url>
</ciManagement>
<!-- Profiles are used to detect whether this is a local or Jenkins build
and adjust the build number accordingly -->
<profiles>
<profile>
<id>jenkins</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
</properties>
</profile>
<profile>
<id>bitly</id>
<activation>
<property>
<name>env.BITLY_ACCESS_TOKEN</name>
</property>
</activation>
<properties>
<project.bitly-access-token>${env.BITLY_ACCESS_TOKEN}</project.bitly-access-token>
</properties>
</profile>
</profiles>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>replace-bitly-access-token</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<basedir>${project.build.sourceDirectory}</basedir>
<includes>
<include>com/onarandombox/MultiverseCore/utils/webpaste/BitlyURLShortener.java</include>
</includes>
<replacements>
<replacement>
<token>bitly-access-token</token>
<value>${project.bitly-access-token}</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>replace-maven-version-number</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<basedir>${project.build.directory}/classes</basedir>
<includes>
<include>plugin.yml</include>
</includes>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-b${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestEntries>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
<excludes>
<exclude>**/TestCommandSender.java</exclude>
<exclude>**/TestInstanceCreator.java</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<enableRulesSummary>true</enableRulesSummary>
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>javadoc-jar</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<failOnError>false</failOnError>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>me.main__.util</pattern>
<shadedPattern>com.onarandombox.serializationconfig</shadedPattern>
</relocation>
<relocation>
<pattern>com.pneumaticraft.commandhandler</pattern>
<shadedPattern>com.onarandombox.commandhandler</shadedPattern>
</relocation>
<relocation>
<pattern>buscript</pattern>
<shadedPattern>com.onarandombox.buscript</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.onarandombox.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
</relocation>
<relocation>
<pattern>org.codehaus.jettison</pattern>
<shadedPattern>com.onarandombox.jettison</shadedPattern>
</relocation>
<relocation>
<pattern>de.themoep.idconverter</pattern>
<shadedPattern>com.onarandombox.idconverter</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>se.eris</groupId>
<artifactId>notnull-instrumenter-maven-plugin</artifactId>
<version>0.6.8</version>
<executions>
<execution>
<goals>
<goal>instrument</goal>
<goal>tests-instrument</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- SerializationConfig Dependency -->
<dependency>
<groupId>me.main__.util</groupId>
<artifactId>SerializationConfig</artifactId>
<version>1.7</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- End of SerializationConfig Dependency -->
<!-- Start of Economy Dependency -->
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- End of Economy Dependency -->
<!-- Start of CommandHandler Dependency -->
<dependency>
<groupId>com.pneumaticraft.commandhandler</groupId>
<artifactId>CommandHandler</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>buscript</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.8</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>Logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.2</version>
</dependency>
<dependency>
<groupId>de.themoep.idconverter</groupId>
<artifactId>mappings</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<!-- Start of Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.0</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>2.0.0</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.0</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>4.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
</repository>
<snapshotRepository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
+5
View File
@@ -0,0 +1,5 @@
/*
* This file was generated by the Gradle 'init' task.
*/
rootProject.name = 'multiverse-core'
@@ -0,0 +1,13 @@
package co.aikar.commands;
import org.bukkit.command.CommandSender;
/**
* Exists just so we can extend BukkitCommandIssuer since it has a package-private constructor.
*/
public abstract class OpenBukkitCommandIssuer extends BukkitCommandIssuer {
protected OpenBukkitCommandIssuer(BukkitCommandManager manager, CommandSender sender) {
super(manager, sender);
}
}
File diff suppressed because it is too large. Load diff
@@ -1,366 +0,0 @@
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 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;
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 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,18 @@
package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.inject.binder.JavaPluginBinder;
import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder;
import org.jetbrains.annotations.NotNull;
class MultiverseCorePluginBinder extends JavaPluginBinder<MultiverseCore> {
protected MultiverseCorePluginBinder(@NotNull MultiverseCore plugin) {
super(plugin);
}
@Override
protected ScopedBindingBuilder<MultiverseCore> bindPluginClass(ScopedBindingBuilder<MultiverseCore> bindingBuilder) {
return super.bindPluginClass(bindingBuilder).to(MVCore.class).to(MultiverseCore.class);
}
}
@@ -5,15 +5,20 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
package com.onarandombox.MultiverseCore.anchor;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
import jakarta.inject.Inject;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jvnet.hk2.annotations.Service;
import java.io.File;
import java.io.IOException;
@@ -22,18 +27,29 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
/**
* Manages anchors.
*/
@Service
public class AnchorManager {
private MultiverseCore plugin;
private Map<String, Location> anchors;
private FileConfiguration anchorConfig;
public AnchorManager(MultiverseCore plugin) {
private final Plugin plugin;
private final LocationManipulation locationManipulation;
private final MVCoreConfig config;
@Inject
public AnchorManager(
MultiverseCore plugin,
LocationManipulation locationManipulation,
MVCoreConfig config
) {
this.plugin = plugin;
this.locationManipulation = locationManipulation;
this.config = config;
this.anchors = new HashMap<String, Location>();
}
@@ -48,7 +64,7 @@ public class AnchorManager {
Set<String> anchorKeys = anchorsSection.getKeys(false);
for (String key : anchorKeys) {
//world:x,y,z:pitch:yaw
Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, ""));
Location anchorLocation = this.locationManipulation.stringToLocation(anchorsSection.getString(key, ""));
if (anchorLocation != null) {
Logging.config("Loading anchor: '%s'...", key);
this.anchors.put(key, anchorLocation);
@@ -98,7 +114,7 @@ public class AnchorManager {
* @return True if the anchor was successfully saved.
*/
public boolean saveAnchorLocation(String anchor, String location) {
Location parsed = plugin.getLocationManipulation().stringToLocation(location);
Location parsed = this.locationManipulation.stringToLocation(location);
return parsed != null && this.saveAnchorLocation(anchor, parsed);
}
@@ -112,7 +128,7 @@ public class AnchorManager {
if (l == null) {
return false;
}
this.anchorConfig.set("anchors." + anchor, plugin.getLocationManipulation().locationToString(l));
this.anchorConfig.set("anchors." + anchor, this.locationManipulation.locationToString(l));
this.anchors.put(anchor, l);
return this.saveAnchors();
}
@@ -144,8 +160,8 @@ public class AnchorManager {
// Add to the list if we're not enforcing access
// OR
// We are enforcing access and the user has the permission.
if (!this.plugin.getMVConfig().getEnforceAccess() ||
(this.plugin.getMVConfig().getEnforceAccess() && p.hasPermission(worldPerm))) {
if (!config.getEnforceAccess() ||
(config.getEnforceAccess() && p.hasPermission(worldPerm))) {
myAnchors.add(anchor);
} else {
Logging.finer(String.format("Not adding anchor %s to the list, user %s doesn't have the %s " +
@@ -0,0 +1,4 @@
/**
* this package contains the classes that are used for the anchor system.
*/
package com.onarandombox.MultiverseCore.anchor;
@@ -4,10 +4,12 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle;
import org.jvnet.hk2.annotations.Contract;
/**
* Used to get block/location-related information.
*/
@Contract
public interface BlockSafety {
/**
* This function checks whether the block at the given coordinates are above air or not.
@@ -1,217 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import buscript.Buscript;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.entity.Player;
/**
* Multiverse 2 Core API
* <p>
* This API contains a bunch of useful things you can get out of Multiverse in general!
*/
public interface Core {
/**
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
* interfacing with Vault.
*
* @return the Vault handler for Multiverse.
* @deprecated we are now using {@link #getEconomist()} for all economy needs.
*/
@Deprecated
VaultHandler getVaultHandler();
/**
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without
* worrying about any of the messy details.
*
* @return the economy manager for Multiverse.
*/
MVEconomist getEconomist();
/**
* Reloads the Multiverse Configuration files:
* worlds.yml and config.yml.
*/
void loadConfigs();
/**
* Gets the Multiverse message system. This allows you to send messages
* to users at specified intervals.
*
* @return The loaded {@link MultiverseMessaging}.
*/
MultiverseMessaging getMessaging();
/**
* Gets the {@link MVPlayerSession} for the given player.
* This will also create a player session if one does not exist
* for a player.
*
* @param player The player's session to grab.
*
* @return The corresponding {@link MVPlayerSession}.
*/
MVPlayerSession getPlayerSession(Player player);
/**
* Multiverse uses an advanced permissions setup, this object
* simplifies getting/setting permissions.
*
* @return A non-null {@link MVPermissions}.
*/
MVPermissions getMVPerms();
/**
* Multiverse uses {@link CommandHandler} to make adding and using commands
* a piece of cake.
*
* @return A non-null {@link CommandHandler}.
*/
CommandHandler getCommandHandler();
/**
* Gets the factory class responsible for loading many different destinations
* on demand.
*
* @return A valid {@link DestinationFactory}.
*/
DestinationFactory getDestFactory();
/**
* Gets the primary class responsible for managing Multiverse Worlds.
*
* @return {@link MVWorldManager}.
*/
MVWorldManager getMVWorldManager();
/**
* Saves all configs.
*
* @return Whether the config was successfully saved
*/
boolean saveMVConfigs();
/**
* Gets the {@link AnchorManager}.
*
* @return The {@link AnchorManager}
*/
AnchorManager getAnchorManager();
/**
* Used by queued commands to regenerate a world on a delay.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String)} instead.
*/
@Deprecated
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
/**
* Decrements the number of plugins that have specifically hooked into core.
*/
void decrementPluginCount();
/**
* Increments the number of plugins that have specifically hooked into core.
*/
void incrementPluginCount();
/**
* Returns the number of plugins that have specifically hooked into core.
*
* @return The number if plugins that have hooked into core.
*/
int getPluginCount();
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return The readable authors-{@link String}
*/
String getAuthors();
/**
* Gets the {@link BlockSafety} this {@link Core} is using.
* @return The {@link BlockSafety} this {@link Core} is using.
* @see BlockSafety
* @see SimpleBlockSafety
*/
BlockSafety getBlockSafety();
/**
* Sets the {@link BlockSafety} this {@link Core} is using.
* @param blockSafety The new {@link BlockSafety}.
* @see BlockSafety
* @see SimpleBlockSafety
*/
void setBlockSafety(BlockSafety blockSafety);
/**
* Gets the {@link LocationManipulation} this {@link Core} is using.
* @return The {@link LocationManipulation} this {@link Core} is using.
* @see LocationManipulation
* @see SimpleLocationManipulation
*/
LocationManipulation getLocationManipulation();
/**
* Sets the {@link LocationManipulation} this {@link Core} is using.
* @param locationManipulation The new {@link LocationManipulation}.
* @see LocationManipulation
* @see SimpleLocationManipulation
*/
void setLocationManipulation(LocationManipulation locationManipulation);
/**
* Gets the {@link SafeTTeleporter} this {@link Core} is using.
* @return The {@link SafeTTeleporter} this {@link Core} is using.
* @see SafeTTeleporter
* @see SimpleSafeTTeleporter
*/
SafeTTeleporter getSafeTTeleporter();
/**
* Sets the {@link SafeTTeleporter} this {@link Core} is using.
* @param safeTTeleporter The new {@link SafeTTeleporter}.
* @see SafeTTeleporter
* @see SimpleSafeTTeleporter
*/
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
/**
* Gets the {@link MultiverseCoreConfig}.
* @return The configuration.
*/
MultiverseCoreConfig getMVConfig();
/**
* Gets the buscript object for Multiverse. This is what handles Javascript processing.
*
* @return The Multiverse buscript object.
*/
Buscript getScriptAPI();
}
@@ -0,0 +1,58 @@
package com.onarandombox.MultiverseCore.api;
import java.util.Collection;
import co.aikar.commands.BukkitCommandIssuer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jvnet.hk2.annotations.Contract;
@Contract
public interface Destination<T extends DestinationInstance> {
/**
* Returns the identifier or prefix that is required for this destination.
*
* <p>Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
* Please check the wiki when adding a custom destination!</p>
*
* @return The identifier or prefix that is required for this destination.
*/
@NotNull String getIdentifier();
/**
* Returns the destination instance for the given destination parameters.
*
* @param destinationParams The destination parameters. ex: p:MyPortal:nw
* @return The destination instance, or null if the destination parameters are invalid.
*/
@Nullable T getDestinationInstance(@Nullable String destinationParams);
/**
* Returns a list of possible destinations for the given destination parameters.
*
* @param issuer The command issuer.
* @param destinationParams The destination parameters. ex: p:MyPortal:nw
* @return A list of possible destinations.
*/
@NotNull Collection<String> suggestDestinations(@NotNull BukkitCommandIssuer issuer, @Nullable String destinationParams);
/**
* Should the Multiverse SafeTeleporter be used?
*
* <p>If not, MV will blindly take people to the location specified.</p>
*
* @return True if the SafeTeleporter will be used, false if not.
*/
boolean checkTeleportSafety();
/**
* Returns the teleporter to use for this destination.
*
* <p>By default, Multiverse will automatically use SafeTeleporter. If you want to use a different teleporter, you can
* override this method.</p>
*
* @return The custom teleporter to use for this destination. Return null to use the default teleporter.
*/
@Nullable Teleporter getTeleporter();
}
@@ -0,0 +1,45 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface DestinationInstance {
/**
* Gets the exact location to teleport an entity to.
*
* @param teleportee The entity to teleport.
* @return The location to teleport to.
*/
@Nullable Location getLocation(@NotNull Entity teleportee);
/**
* Gets the velocity to apply to an entity after teleporting.
*
* @param teleportee The entity to teleport.
* @return A vector representing the speed/direction the player should travel when arriving at the destination.
*/
@Nullable Vector getVelocity(@NotNull Entity teleportee);
/**
* Gets the permission suffix to check for when teleporting to this destination.
* This is used for finer per world/player permissions, such as "multiverse.teleport.self.worldname".
*
* <p>For example, if the destination is "w:world", the permission suffix is "world".</p>
*
* @return The permission suffix.
*/
@Nullable String getFinerPermissionSuffix();
/**
* Serialises the destination instance to a savable string.
*
* <p>This is used when plugins save destinations to configuration,
* and when the destination is displayed to the user.</p>
*
* @return The serialised destination instance.
*/
@NotNull String serialise();
}
@@ -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();
}
@@ -3,10 +3,12 @@ package com.onarandombox.MultiverseCore.api;
import org.bukkit.Location;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;
import org.jvnet.hk2.annotations.Contract;
/**
* Used to manipulate locations.
*/
@Contract
public interface LocationManipulation {
/**
* Convert a Location into a Colon separated string to allow us to store it in text.
@@ -1,36 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Server;
import java.util.logging.Level;
/**
* A simple API to require plugins to have a log method.
*
* @deprecated Replaced by {@link Logging}.
* */
@Deprecated
public interface LoggablePlugin {
/**
* Logs a message at the specified level.
*
* @param level The Log-{@link Level}.
* @param msg The message to log.
*/
void log(Level level, String msg);
/**
* Gets the server instance that this plugin is attached to.
*
* @return A {@link Server} instance.
*/
Server getServer();
}
@@ -1,102 +1,93 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import com.onarandombox.MultiverseCore.configuration.node.NodeGroup;
import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders;
import io.vavr.control.Try;
import org.jvnet.hk2.annotations.Contract;
/**
* 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);
@Contract
public interface MVConfig {
/**
* Sets portalCooldown.
* @param portalCooldown The new value.
* Loads the config from disk.
* @return True if the config was loaded successfully.
*/
void setTeleportCooldown(int portalCooldown);
boolean load();
/**
* Gets portalCooldown.
* @return portalCooldown.
* Whether the config has been loaded.
* @return True if the config has been loaded.
*/
int getTeleportCooldown();
boolean isLoaded();
/**
* Sets firstSpawnWorld.
* @param firstSpawnWorld The new value.
* Saves the config to disk.
*/
void setFirstSpawnWorld(String firstSpawnWorld);
boolean save();
/**
* Gets firstSpawnWorld.
* @return firstSpawnWorld.
* Gets the nodes for the config.
*
* @return The nodes for the config.
*/
String getFirstSpawnWorld();
NodeGroup getNodes();
/**
* Sets version.
* @param version The new value.
* Gets a property from the config.
*
* @param name The name of the property.
* @return A {@link Try} with the value of the property, otherwise a {@link Try.Failure} if there is no property by
* that name.
*/
void setVersion(int version);
Try<Object> getProperty(String name);
/**
* Gets version.
* @return version.
* Sets a property in the config.
*
* @param name The name of the property.
* @param value The value of the property.
* @return An empty {@link Try} if the property was set successfully, otherwise a {@link Try.Failure} with the
* exception explaining why the property could not be set.
*/
double getVersion();
Try<Void> setProperty(String name, Object value);
/**
* Sets messageCooldown.
* @param messageCooldown The new value.
* Sets world access permissions should be enforced.
* @param enforceAccess The new value.
*/
void setMessageCooldown(int messageCooldown);
void setEnforceAccess(boolean enforceAccess);
/**
* Gets messageCooldown.
* @return messageCooldown.
* Gets enforceAccess.
* @return enforceAccess.
*/
int getMessageCooldown();
boolean getEnforceAccess();
/**
* Sets globalDebug.
* @param globalDebug The new value.
* Sets whether the game mode should be enforced.
* @param enforceGameMode The new value.
*/
void setGlobalDebug(int globalDebug);
void setEnforceGameMode(boolean enforceGameMode);
/**
* Gets globalDebug.
* @return globalDebug.
* Gets enforceGameMode value.
* @return True if game mode should be enforced.
*/
int getGlobalDebug();
boolean getEnforceGameMode();
/**
* Sets displayPermErrors.
* @param displayPermErrors The new value.
* Sets whether or not the automatic purge of entities is enabled.
*
* @param autopurge True if automatic purge should be enabled.
*/
void setDisplayPermErrors(boolean displayPermErrors);
void setAutoPurgeEntities(boolean autopurge);
/**
* Gets displayPermErrors.
* @return displayPermErrors.
* Gets whether or not the automatic purge of entities is enabled.
*
* @return True if automatic purge is enabled.
*/
boolean getDisplayPermErrors();
/**
* Sets firstSpawnOverride.
* @param firstSpawnOverride The new value.
*/
void setFirstSpawnOverride(boolean firstSpawnOverride);
/**
* Gets firstSpawnOverride.
* @return firstSpawnOverride.
*/
boolean getFirstSpawnOverride();
boolean isAutoPurgeEntities();
/**
* Sets teleportIntercept.
@@ -110,18 +101,70 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
*/
boolean getTeleportIntercept();
/**
* Sets firstSpawnOverride.
* @param firstSpawnOverride The new value.
*/
void setFirstSpawnOverride(boolean firstSpawnOverride);
/**
* Gets firstSpawnOverride.
* @return firstSpawnOverride.
*/
boolean getFirstSpawnOverride();
/**
* Sets firstSpawnWorld.
* @param firstSpawnWorld The new value.
*/
void setFirstSpawnLocation(String firstSpawnWorld);
/**
* Gets firstSpawnWorld.
* @return firstSpawnWorld.
*/
String getFirstSpawnLocation();
/**
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
*
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
*/
void setUseCustomPortalSearch(boolean useDefaultPortalSearch);
/**
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
*
* @return True means Bukkit will use its own default values.
*/
boolean isUsingCustomPortalSearch();
/**
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
*
* @param searchRadius The portal search radius.
*/
void setCustomPortalSearchRadius(int searchRadius);
/**
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
*
* @return The portal search radius.
*/
int getCustomPortalSearchRadius();
/**
* Sets prefixChat.
* @param prefixChat The new value.
*/
void setPrefixChat(boolean prefixChat);
void setEnablePrefixChat(boolean prefixChat);
/**
* Gets prefixChat.
* @return prefixChat.
*/
boolean getPrefixChat();
boolean isEnablePrefixChat();
/**
* Sets prefixChatFormat.
* @param prefixChatFormat The new value.
@@ -135,28 +178,28 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
String getPrefixChatFormat();
/**
* Sets enforceAccess.
* @param enforceAccess The new value.
* Sets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
* @param registerPapiHook The new value.
*/
void setEnforceAccess(boolean enforceAccess);
void setRegisterPapiHook(boolean registerPapiHook);
/**
* Gets enforceAccess.
* @return enforceAccess.
* Gets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
* @return registerPapiHook.
*/
boolean getEnforceAccess();
boolean isRegisterPapiHook();
/**
* Sets useasyncchat.
* @param useAsyncChat The new value.
* Sets globalDebug.
* @param globalDebug The new value.
*/
void setUseAsyncChat(boolean useAsyncChat);
void setGlobalDebug(int globalDebug);
/**
* Gets useasyncchat.
* @return useasyncchat.
* Gets globalDebug.
* @return globalDebug.
*/
boolean getUseAsyncChat();
int getGlobalDebug();
/**
* Sets whether to suppress startup messages.
@@ -173,46 +216,11 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
boolean getSilentStart();
/**
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
* Sets whether or not the donation/patreon messages are shown.
*
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
* @param idonotwanttodonate True if donation/patreon messages should be shown.
*/
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);
void setShowDonateMessage(boolean idonotwanttodonate);
/**
* Gets whether or not the donation/patreon messages are shown.
@@ -220,11 +228,4 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
* @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,40 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
/**
* Multiverse 2 Core API
* <p>
* This API contains a bunch of useful things you can get out of Multiverse in general!
*/
public interface MVCore extends MVPlugin {
/**
* Saves all configs.
*
* @return Whether the config was successfully saved
*/
boolean saveAllConfigs();
/**
* Decrements the number of plugins that have specifically hooked into core.
*/
void decrementPluginCount();
/**
* Increments the number of plugins that have specifically hooked into core.
*/
void incrementPluginCount();
/**
* Returns the number of plugins that have specifically hooked into core.
*
* @return The number if plugins that have hooked into core.
*/
int getPluginCount();
}
@@ -16,6 +16,7 @@ import org.bukkit.util.Vector;
* A destination API for Multiverse
* Any plugin can add these to MV and when they are, any action that uses them (portals, MVTP, etc.) can use them!
*/
@Deprecated
public interface MVDestination {
/**
* Returns the identifier or prefix that is required for this destination.
@@ -7,39 +7,16 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
/**
* This interface is implemented by every official Multiverse-plugin.
*/
public interface MVPlugin extends LoggablePlugin {
/**
* Adds This plugin's version information to the buffer and returns the new string.
*
* @param buffer The string that contains Core and all other MV plugins' versions.
*
* @return A modified buffer that contains this MVPlugin's version information.
*
* @deprecated This is now deprecated, nobody needs it any longer.
* All version info-dumping is now done with {@link MVVersionEvent}.
*/
@Deprecated
String dumpVersionInfo(String buffer);
public interface MVPlugin {
/**
* Gets the reference to MultiverseCore.
*
* @return A valid {@link com.onarandombox.MultiverseCore}.
*/
MultiverseCore getCore();
/**
* Sets the reference to MultiverseCore.
*
* @param core A valid {@link com.onarandombox.MultiverseCore}.
*/
void setCore(MultiverseCore core);
MVCore getCore();
/**
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This
@@ -49,4 +26,11 @@ public interface MVPlugin extends LoggablePlugin {
* @return The Integer protocol version.
*/
int getProtocolVersion();
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return The readable authors-{@link String}
*/
String getAuthors();
}
@@ -7,8 +7,12 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
import java.util.List;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.world.configuration.AddProperties;
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatColor;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@@ -16,16 +20,13 @@ 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.List;
/**
* The API for a Multiverse Handled World.
*/
public interface MultiverseWorld {
public interface MVWorld {
/**
* Returns the Bukkit world object that this world describes.
*
@@ -156,9 +157,9 @@ public interface MultiverseWorld {
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}.
* Adds a value to the given property. The property must be a {@link AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
* @param property The name of a {@link 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.
@@ -167,9 +168,9 @@ public interface MultiverseWorld {
boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
* Removes a value from the given property. The property must be a {@link AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
* @param property The name of a {@link 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.
@@ -179,9 +180,9 @@ public interface MultiverseWorld {
boolean removeFromVariable(String property, String value);
/**
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
* Removes all values from the given property. The property must be a {@link AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
* @param property The name of a {@link 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.
*/
@@ -279,7 +280,7 @@ public interface MultiverseWorld {
* @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 This has been moved: {@link EnglishChatColor#isValidAliasColor(String)}
*/
@Deprecated
boolean isValidAliasColor(String color);
@@ -7,17 +7,15 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
import java.util.Collection;
import java.util.List;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.util.Collection;
import java.util.List;
import org.jvnet.hk2.annotations.Contract;
/**
* Multiverse 2 World Manager API
@@ -25,6 +23,7 @@ import java.util.List;
* This API contains all of the world managing
* functions that your heart desires!
*/
@Contract
public interface MVWorldManager {
/**
* Add a new World to the Multiverse Setup.
@@ -59,18 +58,6 @@ public interface MVWorldManager {
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
String generator, boolean useSpawnAdjust);
/**
* Make a copy of a world.
*
* @param oldName Name of world to be copied
* @param newName Name of world to be created
* @param generator The Custom generator plugin to use. Ignored.
* @return True if the world is copied successfully, false if not.
* @deprecated Use {@link #cloneWorld(String, String)} instead.
*/
@Deprecated
boolean cloneWorld(String oldName, String newName, String generator);
/**
* Make a copy of a world.
*
@@ -160,30 +147,41 @@ public interface MVWorldManager {
/**
* Returns a list of all the worlds Multiverse knows about.
*
* @return A list of {@link MultiverseWorld}.
* @return A list of {@link MVWorld}.
*/
Collection<MultiverseWorld> getMVWorlds();
Collection<MVWorld> getMVWorlds();
/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
* Returns a {@link MVWorld} if it exists, and null if it does not.
* This will search name AND alias.
*
* @param name The name or alias of the world to get.
* @return A {@link MultiverseWorld} or null.
* @return A {@link MVWorld} or null.
*/
MultiverseWorld getMVWorld(String name);
MVWorld getMVWorld(String name);
/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
* Returns a {@link MVWorld} if the world with name given exists, and null if it does not.
* This will search optionally for alias names.
*
* @param name The name or optionally the alias of the world to get.
* @param checkAliases Indicates whether to check for world alias name.
* @return A {@link MVWorld} or null.
*/
MVWorld getMVWorld(String name, boolean checkAliases);
/**
* Returns a {@link MVWorld} if it exists, and null if it does not.
*
* @param world The Bukkit world to check.
* @return A {@link MultiverseWorld} or null.
* @return A {@link MVWorld} or null.
*/
MultiverseWorld getMVWorld(World world);
MVWorld getMVWorld(World world);
/**
* Checks to see if the given name is a valid {@link MultiverseWorld}.
* Checks to see if the given name is a valid {@link MVWorld}
* Searches based on world name AND alias.
*
* @param name The name or alias of the world to check.
* @return True if the world exists, false if not.
@@ -191,7 +189,17 @@ public interface MVWorldManager {
boolean isMVWorld(String name);
/**
* Checks to see if the given world is a valid {@link MultiverseWorld}.
* Checks to see if the given name is a valid {@link MVWorld}.
* Optionally searches by alias is specified.
*
* @param name The name or alias of the world to check.
* @param checkAliases Indicates whether to check for world alias name.
* @return True if the world exists, false if not.
*/
boolean isMVWorld(String name, boolean checkAliases);
/**
* Checks to see if the given world is a valid {@link MVWorld}.
*
* @param world The Bukkit world to check.
* @return True if the world has been loaded into MV2, false if not.
@@ -213,32 +221,13 @@ public interface MVWorldManager {
*/
void loadDefaultWorlds();
/**
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
* @deprecated {@link PurgeWorlds} is deprecated!
*/
@Deprecated
PurgeWorlds getWorldPurger();
/**
* Gets the {@link WorldPurger}.
* <p>
* TODO: Remove {@link #getWorldPurger()} and replace it with this method.
* @return The {@link WorldPurger} this {@link MVWorldManager} is using.
* @see WorldPurger
* @see SimpleWorldPurger
*/
WorldPurger getTheWorldPurger();
/**
* Gets the world players will spawn in on first join.
* Currently this always returns worlds.get(0) from Bukkit.
*
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
*/
MultiverseWorld getSpawnWorld();
MVWorld getSpawnWorld();
/**
* Gets the list of worlds in the config, but unloaded.
@@ -255,10 +244,9 @@ public interface MVWorldManager {
/**
* Load the config from a file.
*
* @param file The file to load.
* @return A loaded configuration.
*/
FileConfiguration loadWorldConfig(File file);
FileConfiguration loadWorldsConfig();
/**
* Saves the world config to disk.
@@ -285,22 +273,35 @@ public interface MVWorldManager {
/**
* Gets the world players should spawn in first.
*
* @return The {@link MultiverseWorld} new players should spawn in.
* @return The {@link MVWorld} new players should spawn in.
*/
MultiverseWorld getFirstSpawnWorld();
MVWorld 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.
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
/**
* Regenerates a world.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed If the new seed should be random
* @param seed The seed of the world.
* @param keepGameRules If GameRules should be kept on world regen.
*
* @return True if success, false if fail.
*/
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules);
boolean isKeepingSpawnInMemory(World world);
/**
@@ -314,4 +315,11 @@ public interface MVWorldManager {
* does not exist. {@code includeLoaded} if the world exists and is loaded.
*/
boolean hasUnloadedWorld(String name, boolean includeLoaded);
/**
* Get all the possible worlds that Multiverse has detected to be importable.
*
* @return A collection of world names that are deemed importable.
*/
Collection<String> getPotentialWorlds();
}
@@ -1,56 +0,0 @@
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();
}
@@ -1,161 +0,0 @@
package com.onarandombox.MultiverseCore.api;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import com.pneumaticraft.commandhandler.CommandHandler;
/**
* Make things easier for MV-Plugins!
*/
public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
private MultiverseCore core;
/**
* Prefix for standard log entrys.
*/
protected String logTag;
private DebugLog debugLog;
/**
* {@inheritDoc}
*
* Note: You can't override this, use {@link #onPluginEnable()} instead!
* @see #onPluginEnable()
*/
@Override
public final void onEnable() {
MultiverseCore theCore = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
if (theCore == null) {
this.getLogger().severe("Core not found! The plugin dev needs to add a dependency!");
this.getLogger().severe("Disabling!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
if (theCore.getProtocolVersion() < this.getProtocolVersion()) {
this.getLogger().severe("You need a newer version of Multiverse-Core!");
this.getLogger().severe("Disabling!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.setCore(theCore);
this.getServer().getLogger().info(String.format("%s - Version %s enabled - By %s",
this.getDescription().getName(), this.getDescription().getVersion(), getAuthors()));
getDataFolder().mkdirs();
File debugLogFile = new File(getDataFolder(), "debug.log");
try {
debugLogFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
debugLog = new DebugLog(this.getDescription().getName(), getDataFolder() + File.separator + "debug.log");
debugLog.setTag(String.format("[%s-Debug]", this.getDescription().getName()));
this.onPluginEnable();
}
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return The readable authors-{@link String}
*/
protected String getAuthors() {
String authors = "";
List<String> auths = this.getDescription().getAuthors();
if (auths.size() == 0) {
return "";
}
if (auths.size() == 1) {
return auths.get(0);
}
for (int i = 0; i < auths.size(); i++) {
if (i == this.getDescription().getAuthors().size() - 1) {
authors += " and " + this.getDescription().getAuthors().get(i);
} else {
authors += ", " + this.getDescription().getAuthors().get(i);
}
}
return authors.substring(2);
}
/**
* Called when the plugin is enabled.
* @see #onEnable()
*/
protected abstract void onPluginEnable();
/**
* You can register commands here.
* @param handler The CommandHandler.
*/
protected abstract void registerCommands(CommandHandler handler);
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!this.isEnabled()) {
sender.sendMessage("This plugin is Disabled!");
return true;
}
ArrayList<String> allArgs = new ArrayList<String>(args.length + 1);
allArgs.add(command.getName());
allArgs.addAll(Arrays.asList(args));
return this.getCore().getCommandHandler().locateAndRunCommand(sender, allArgs);
}
@Override
public void log(Level level, String msg) {
int debugLevel = this.getCore().getMVConfig().getGlobalDebug();
if ((level == Level.FINE && debugLevel >= 1) || (level == Level.FINER && debugLevel >= 2)
|| (level == Level.FINEST && debugLevel >= 3)) {
debugLog.log(level, msg);
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
String message = new StringBuilder(getLogTag()).append(msg).toString();
this.getServer().getLogger().log(level, message);
debugLog.log(level, message);
}
}
private String getLogTag() {
if (logTag == null)
logTag = String.format("[%s]", this.getDescription().getName());
return logTag;
}
/**
* Sets the debug log-tag.
* @param tag The new tag.
*/
protected final void setDebugLogTag(String tag) {
this.debugLog.setTag(tag);
}
@Override
public final String dumpVersionInfo(String buffer) {
throw new UnsupportedOperationException("This is gone.");
}
@Override
public final MultiverseCore getCore() {
if (this.core == null)
throw new IllegalStateException("Core is null!");
return this.core;
}
@Override
public final void setCore(MultiverseCore core) {
this.core = core;
}
}
@@ -1,14 +1,19 @@
package com.onarandombox.MultiverseCore.api;
import java.util.concurrent.CompletableFuture;
import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import org.jvnet.hk2.annotations.Contract;
/**
* Used to safely teleport people.
*/
@Contract
public interface SafeTTeleporter extends Teleporter {
/**
@@ -31,12 +36,24 @@ public interface SafeTTeleporter extends Teleporter {
* 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
* @param teleporter Person who performed the teleport command.
* @param teleportee Entity to teleport
* @param destination Destination to teleport them to
* @return true for success, false for failure
*/
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d);
@Deprecated
TeleportResult safelyTeleport(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
/**
* 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 destination Destination to teleport them to
* @return true for success, false for failure
*/
CompletableFuture<TeleportResult> safelyTeleportAsync(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
/**
* Safely teleport the entity to the Location. This may perform checks to
@@ -55,11 +72,11 @@ public interface SafeTTeleporter extends Teleporter {
/**
* 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.
* @param entity The entity to spawn
* @param destination The MVDestination to take the entity to.
* @return A new location to spawn the entity at.
*/
Location getSafeLocation(Entity e, MVDestination d);
Location getSafeLocation(Entity entity, DestinationInstance destination);
/**
* Finds a portal-block next to the specified {@link Location}.
@@ -67,5 +84,4 @@ public interface SafeTTeleporter extends Teleporter {
* @return The next portal-block's {@link Location}.
*/
Location findPortalBlockNextTo(Location l);
}
@@ -1,10 +1,33 @@
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;
import java.util.concurrent.CompletableFuture;
import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
import org.bukkit.entity.Entity;
import org.jvnet.hk2.annotations.Contract;
@Contract
public interface Teleporter {
TeleportResult teleport(CommandSender teleporter, Player teleportee, MVDestination destination);
/**
* Teleport the entity to the Multiverse Destination.
*
* @param teleporter Person who performed the teleport command.
* @param teleportee Entity to teleport
* @param destination Destination to teleport them to
* @return true for success, false for failure
*/
@Deprecated
TeleportResult teleport(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
/**
* Teleport the entity to the Multiverse Destination.
*
* @param teleporter Person who performed the teleport command.
* @param teleportee Entity to teleport
* @param destination Destination to teleport them to
* @return true for success, false for failure
*/
CompletableFuture<TeleportResult> teleportAsync(BukkitCommandIssuer teleporter, Entity teleportee, ParsedDestination<?> destination);
}
@@ -4,47 +4,49 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.jvnet.hk2.annotations.Contract;
/**
* Used to remove animals from worlds that don't belong there.
*/
@Contract
public interface WorldPurger {
/**
* Synchronizes the given worlds with their settings.
*
* @param worlds A list of {@link MultiverseWorld}
* @param worlds A list of {@link MVWorld}
*/
void purgeWorlds(List<MultiverseWorld> worlds);
void purgeWorlds(List<MVWorld> worlds);
/**
* Convenience method for {@link #purgeWorld(MultiverseWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
* Convenience method for {@link #purgeWorld(MVWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
*
* @param world The {@link MultiverseWorld}.
* @param world The {@link MVWorld}.
*/
void purgeWorld(MultiverseWorld world);
void purgeWorld(MVWorld world);
/**
* Clear all animals/monsters that do not belong to a world according to the config.
*
* @param mvworld The {@link MultiverseWorld}.
* @param mvworld The {@link MVWorld}.
* @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);
void purgeWorld(MVWorld 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 mvworld The {@link MVWorld}.
* @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);
void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, CommandSender sender);
/**
* Determines whether the specified creature should be killed.
@@ -64,5 +66,5 @@ public interface WorldPurger {
* @param e The creature.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e);
boolean shouldWeKillThisCreature(MVWorld w, Entity e);
}
@@ -1,162 +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.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Allows management of Anchor Destinations.
*/
public class AnchorCommand extends PaginatedCoreCommand<String> {
public AnchorCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create, Delete and Manage Anchor Destinations.");
this.setCommandUsage("/mv anchor " + ChatColor.GREEN + "{name}" + ChatColor.GOLD + " [-d]");
this.setArgRange(0, 2);
this.addKey("mv anchor");
this.addKey("mv anchors");
this.addKey("mvanchor");
this.addKey("mvanchors");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
this.addCommandExample("/mv anchors ");
this.setPermission("multiverse.core.anchor.list", "Allows a player to list all anchors.", PermissionDefault.OP);
this.addAdditonalPermission(new Permission("multiverse.core.anchor.create",
"Allows a player to create anchors.", PermissionDefault.OP));
this.addAdditonalPermission(new Permission("multiverse.core.anchor.delete",
"Allows a player to delete anchors.", PermissionDefault.OP));
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
private List<String> getFancyAnchorList(Player p) {
List<String> anchorList = new ArrayList<String>();
ChatColor color = ChatColor.GREEN;
for (String anchor : this.plugin.getAnchorManager().getAnchors(p)) {
anchorList.add(color + anchor);
color = (color == ChatColor.GREEN) ? ChatColor.GOLD : ChatColor.GREEN;
}
return anchorList;
}
private void showList(CommandSender sender, List<String> args) {
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.list", true)) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to list anchors!");
return;
}
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
FilterObject filterObject = this.getPageAndFilter(args);
List<String> availableAnchors = new ArrayList<String>(this.getFancyAnchorList(p));
if (filterObject.getFilter().length() > 0) {
availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
if (availableAnchors.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
} else {
if (availableAnchors.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors were defined.");
return;
}
}
if (!(sender instanceof Player)) {
for (String c : availableAnchors) {
sender.sendMessage(c);
}
return;
}
int totalPages = (int) Math.ceil(availableAnchors.size() / (this.itemsPerPage + 0.0));
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
} else if (filterObject.getPage() < 1) {
filterObject.setPage(1);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
this.showPage(filterObject.getPage(), sender, availableAnchors);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 0) {
this.showList(sender, args);
return;
}
if (args.size() == 1 && (this.getPageAndFilter(args).getPage() != 1 || args.get(0).equals("1"))) {
this.showList(sender, args);
return;
}
if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!");
} else {
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
}
}
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("You must be a player to create Anchors.");
return;
}
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!");
} else {
Player player = (Player) sender;
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
}
}
}
@Override
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
List<String> filtered = new ArrayList<String>();
for (String s : availableItems) {
if (s.matches("(?i).*" + filter + ".*")) {
filtered.add(s);
}
}
return filtered;
}
@Override
protected String getItemText(String item) {
return item;
}
}
@@ -1,57 +1,53 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import co.aikar.commands.BukkitCommandIssuer;
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.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
/**
* Checks to see if a player can go to a destination.
*/
@Service
@CommandAlias("mv")
public class CheckCommand extends MultiverseCommand {
public CheckCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Help you validate your multiverse settings");
this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}");
this.setArgRange(2, 2);
this.addKey("mv check");
this.addKey("mvcheck");
this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld");
this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
private final DestinationsProvider destinationsProvider;
@Inject
public CheckCommand(@NotNull MVCommandManager commandManager, @NotNull DestinationsProvider destinationsProvider) {
super(commandManager);
this.destinationsProvider = destinationsProvider;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = this.plugin.getServer().getPlayerExact(args.get(0));
if (p == null) {
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
sender.sendMessage("Are they online?");
return;
}
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
if (dest instanceof InvalidDestination) {
sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,",
args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE));
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
return;
}
@Subcommand("check")
@CommandPermission("multiverse.core.check")
@CommandCompletion("@players @destinations|@mvworlds")
@Syntax("<player> <destination>")
@Description("{@@mv-core.check.description}")
public void onCheckCommand(BukkitCommandIssuer issuer,
MVPermissions perms = this.plugin.getMVPerms();
perms.tellMeWhyICantDoThis(sender, p, dest);
@Syntax("<player>")
@Description("{@@mv-core.check.player.description}")
Player player,
@Syntax("<destination>")
@Description("{@@mv-core.check.destination.description}")
ParsedDestination<?> destination
) {
issuer.sendInfo(MVCorei18n.CHECK_CHECKING,
"{player}", player.getName(),
"{destination}", destination.toString());
//TODO More detailed output on permissions required.
this.destinationsProvider.checkTeleportPermissions(issuer, player, destination);
}
}
@@ -1,55 +1,61 @@
/******************************************************************************
* 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 java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MultiverseCore;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
/**
* Creates a clone of a world.
*/
@Service
@CommandAlias("mv")
public class CloneCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public CloneCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Clone World");
this.setCommandUsage("/mv clone" + ChatColor.GREEN + " {TARGET} {NAME}" + ChatColor.GOLD + " -g [GENERATOR[:ID]]");
this.setArgRange(2, 4); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvclone");
this.addKey("mvcl");
this.addKey("mv cl");
this.addKey("mv clone");
this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup");
this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock");
this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
private final MVWorldManager worldManager;
@Inject
public CloneCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
super(commandManager);
this.worldManager = worldManager;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String oldName = args.get(0);
if (!this.worldManager.hasUnloadedWorld(oldName, true)) {
// If no world was found, we can't clone.
sender.sendMessage("Sorry, Multiverse doesn't know about world " + oldName + ", so we can't clone it!");
sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed.");
@Subcommand("clone")
@CommandPermission("multiverse.core.clone")
@CommandCompletion("@mvworlds:scope=both @empty")
@Syntax("<world> <new world name>")
@Description("{@@mv-core.clone.description}")
public void onCloneCommand(CommandIssuer issuer,
@Conditions("validWorldName:scope=both")
@Syntax("<world>")
@Description("{@@mv-core.clone.world.description}")
String worldName,
@Single
@Conditions("validWorldName:scope=new")
@Syntax("<new world name>")
@Description("{@@mv-core.clone.newWorld.description}")
String newWorldName
) {
issuer.sendInfo(MVCorei18n.CLONE_CLONING,
"{world}", worldName,
"{newWorld}", newWorldName);
if (!this.worldManager.cloneWorld(worldName, newWorldName)) {
issuer.sendError(MVCorei18n.CLONE_FAILED);
return;
}
if (this.plugin.getMVWorldManager().cloneWorld(oldName, args.get(1))) {
sender.sendMessage(ChatColor.GREEN + "World cloned!");
} else {
sender.sendMessage(ChatColor.RED + "World could NOT be cloned!");
}
issuer.sendInfo(MVCorei18n.CLONE_SUCCESS,
"{world}", newWorldName);
}
}
@@ -1,72 +1,73 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import 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.Optional;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.commandtools.MVCommandIssuer;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.commandtools.context.MVConfigValue;
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
import com.onarandombox.MultiverseCore.exceptions.MultiverseException;
import io.vavr.control.Option;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
import java.util.Map;
/**
* Allows you to set Global MV Variables.
*/
@Service
@CommandAlias("mv")
public class ConfigCommand extends MultiverseCommand {
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Configuration");
this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
this.setArgRange(1, 2);
this.addKey("mv config");
this.addKey("mvconfig");
this.addKey("mv conf");
this.addKey("mvconf");
this.addCommandExample("/mv config show");
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
private final MVCoreConfig config;
@Inject
public ConfigCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) {
super(commandManager);
this.config = config;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() <= 1) {
StringBuilder builder = new StringBuilder();
Map<String, Object> serializedConfig = this.plugin.getMVConfig().serialize();
for (Map.Entry<String, Object> entry : serializedConfig.entrySet()) {
builder.append(ChatColor.GREEN);
builder.append(entry.getKey());
builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
builder.append(entry.getValue().toString());
builder.append(ChatColor.WHITE).append(", ");
}
String message = builder.toString();
message = message.substring(0, message.length() - 2);
sender.sendMessage(message);
return;
}
if (!this.plugin.getMVConfig().setConfigProperty(args.get(0).toLowerCase(), args.get(1))) {
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
@Subcommand("config")
@CommandPermission("multiverse.core.config")
@CommandCompletion("@mvconfigs")
@Syntax("<name> [new-value]")
@Description("") //TODO
public void onConfigCommand(MVCommandIssuer issuer,
@Syntax("<name>")
@Description("") //TODO
String name,
@Optional
@Single
@Syntax("[new-value]")
@Description("") //TODO
MVConfigValue value
) {
if (value == null) {
showConfigValue(issuer, name);
return;
}
updateConfigValue(issuer, name, value.getValue());
}
// special rule
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
// Don't forget to set the world!
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
}
private void showConfigValue(MVCommandIssuer issuer, String name) {
config.getProperty(name)
.onSuccess(value -> issuer.sendMessage(name + "is currently set to " + value))
.onFailure(e -> issuer.sendMessage(e.getMessage()));
}
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!");
}
private void updateConfigValue(MVCommandIssuer issuer, String name, Object value) {
config.setProperty(name, value)
.onSuccess(ignore -> {
config.save();
issuer.sendMessage("Successfully set " + name + " to " + value);
})
.onFailure(ignore -> issuer.sendMessage("Unable to set " + name + " to " + value + "."))
.onFailure(MultiverseException.class, e -> Option.of(e.getMVMessage()).peek(issuer::sendError));
}
}
@@ -1,39 +1,29 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import co.aikar.commands.BukkitCommandIssuer;
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.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
/**
* Confirms actions.
*/
@Service
@CommandAlias("mv")
public class ConfirmCommand extends MultiverseCommand {
public ConfirmCommand(MultiverseCore plugin) {
super(plugin);
// Any command that is dangerous should require op
this.setName("Confirms a command that could destroy life, the universe and everything.");
this.setCommandUsage("/mv confirm");
this.setArgRange(0, 0);
this.addKey("mvconfirm");
this.addKey("mv confirm");
this.addCommandExample("/mv confirm");
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
@Inject
public ConfirmCommand(@NotNull MVCommandManager commandManager) {
super(commandManager);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
@Subcommand("confirm")
@CommandPermission("multiverse.core.confirm")
@Description("{@@mv-core.confirm.description}")
public void onConfirmCommand(@NotNull BukkitCommandIssuer issuer) {
this.commandManager.getCommandQueueManager().runQueuedCommand(issuer.getIssuer());
}
}
@@ -1,70 +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 org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.text.DecimalFormat;
import java.util.List;
/**
* Returns detailed information on the Players where abouts.
*/
public class CoordCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public CoordCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Coordinates");
this.setCommandUsage("/mv coord");
this.setArgRange(0, 0);
this.addKey("mv coord");
this.addKey("mvcoord");
this.addKey("mvco");
this.addCommandExample("/mv coord");
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
if (sender instanceof Player) {
Player p = (Player) sender;
World world = p.getWorld();
if (!this.worldManager.isMVWorld(world.getName())) {
this.plugin.showNotMVWorldMessage(sender, world.getName());
return;
}
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + world.getBlockAt(p.getLocation()).getType());
} else {
sender.sendMessage("This command needs to be used from a Player.");
}
}
}
@@ -1,120 +1,143 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
/**
* Creates a new world and loads it.
*/
import co.aikar.commands.BukkitCommandIssuer;
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.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import jakarta.inject.Inject;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
@Service
@CommandAlias("mv")
public class CreateCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public CreateCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create World");
this.setCommandUsage(String.format("/mv create %s{NAME} {ENV} %s-s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n] -a [true|false]",
ChatColor.GREEN, ChatColor.GOLD));
this.setArgRange(2, 11); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
this.setPermission("multiverse.core.create", "Creates a new world and loads it.", PermissionDefault.OP);
this.addCommandExample("/mv create " + ChatColor.GOLD + "world" + ChatColor.GREEN + " normal");
this.addCommandExample("/mv create " + ChatColor.GOLD + "lavaland" + ChatColor.RED + " nether");
this.addCommandExample("/mv create " + ChatColor.GOLD + "starwars" + ChatColor.AQUA + " end");
this.addCommandExample("/mv create " + ChatColor.GOLD + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
this.addCommandExample("/mv create " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -s gargamel");
this.addCommandExample("/mv create " + ChatColor.GOLD + "moonworld" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -g BukkitFullOfMoon");
this.worldManager = this.plugin.getMVWorldManager();
private final MVWorldManager worldManager;
@Inject
public CreateCommand(
@NotNull MVCommandManager commandManager,
@NotNull MVWorldManager worldManager,
@NotNull UnsafeCallWrapper unsafeCallWrapper
) {
super(commandManager);
this.worldManager = worldManager;
registerFlagGroup(CommandFlagGroup.builder("mvcreate")
.add(CommandValueFlag.builder("--seed", String.class)
.addAlias("-s")
.completion(() -> Collections.singleton(String.valueOf(new Random().nextLong())))
.build())
.add(CommandValueFlag.builder("--generator", String.class)
.addAlias("-g")
.completion(() -> Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins())
.filter(Plugin::isEnabled)
.filter(genplugin -> unsafeCallWrapper.wrap(
() -> genplugin.getDefaultWorldGenerator("world", ""),
genplugin.getName(),
"Get generator"
) != null)
.map(genplugin -> genplugin.getDescription().getName())
.collect(Collectors.toList()))
.build())
.add(CommandValueFlag.builder("--world-type", WorldType.class)
.addAlias("-t")
.context((value) -> {
try {
return WorldType.valueOf(value.toUpperCase());
} catch (IllegalArgumentException e) {
throw new InvalidCommandArgument("Invalid world type: " + value);
}
})
.completion(() -> {
List<String> types = new ArrayList<>();
for (WorldType type : WorldType.values()) {
types.add(type.name().toLowerCase());
}
return types;
})
.build())
.add(CommandFlag.builder("--adjust-spawn")
.addAlias("-n")
.build())
.add(CommandFlag.builder("--no-structures")
.addAlias("-a")
.build())
.build());
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
boolean allowStructures = true;
String structureString = CommandHandler.getFlag("-a", args);
if (structureString != null) {
allowStructures = Boolean.parseBoolean(structureString);
}
String typeString = CommandHandler.getFlag("-t", args);
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
@Subcommand("create")
@CommandPermission("multiverse.core.create")
@CommandCompletion("@empty @flags:groupName=mvcreate")
@Syntax("<name> <environment> --seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures")
@Description("{@@mv-core.create.description}")
public void onCreateCommand(BukkitCommandIssuer issuer,
if (this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "Multiverse cannot create " + ChatColor.GOLD + ChatColor.UNDERLINE
+ "another" + ChatColor.RESET + ChatColor.RED + " world named " + worldName);
@Conditions("validWorldName:scope=new")
@Syntax("<name>")
@Description("{@@mv-core.create.name.description}")
String worldName,
@Syntax("<environment>")
@Description("{@@mv-core.create.environment.description}")
World.Environment environment,
@Optional
@Syntax("--seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures")
@Description("{@@mv-core.create.flags.description}")
String[] flags
) {
ParsedCommandFlags parsedFlags = parseFlags(flags);
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES, "{worldName}", worldName);
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ENVIRONMENT, "{environment}", environment.name());
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_SEED, "{seed}", parsedFlags.flagValue("--seed", "RANDOM", String.class));
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_WORLDTYPE, "{worldType}", parsedFlags.flagValue("--world-type", WorldType.NORMAL, WorldType.class).name());
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ADJUSTSPAWN, "{adjustSpawn}", String.valueOf(parsedFlags.hasFlag("--adjust-spawn")));
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_GENERATOR, "{generator}", parsedFlags.flagValue("--generator", "null", String.class));
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_STRUCTURES, "{structures}", String.valueOf(!parsedFlags.hasFlag("--no-structures")));
issuer.sendInfo(MVCorei18n.CREATE_LOADING);
if (!worldManager.addWorld(
worldName,
environment,
parsedFlags.flagValue("--seed", String.class),
parsedFlags.flagValue("--world-type", WorldType.NORMAL, WorldType.class),
parsedFlags.hasFlag("--adjust-spawn"),
parsedFlags.flagValue("--generator", String.class),
parsedFlags.hasFlag("--no-structures")
)) {
issuer.sendError(MVCorei18n.CREATE_FAILED, "{worldName}", worldName);
return;
}
if (worldFile.exists()) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
return;
}
Environment environment = EnvironmentCommand.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
// If they didn't specify a type, default to NORMAL
if (typeString == null) {
typeString = "NORMAL";
}
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
if (type == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
EnvironmentCommand.showWorldTypes(sender);
return;
}
// Determine if the generator is valid. #918
if (generator != null) {
List<String> genarray = new ArrayList<String>(Arrays.asList(generator.split(":")));
if (genarray.size() < 2) {
// If there was only one arg specified, pad with another empty one.
genarray.add("");
}
if (this.worldManager.getChunkGenerator(genarray.get(0), genarray.get(1), "test") == null) {
// We have an invalid generator.
sender.sendMessage("Invalid generator! '" + generator + "'. " + ChatColor.RED + "Aborting world creation.");
return;
}
}
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
Command.broadcastCommandMessage(sender, "Complete!");
} else {
Command.broadcastCommandMessage(sender, "FAILED.");
}
issuer.sendInfo(MVCorei18n.CREATE_SUCCESS, "{worldName}", worldName);
}
}
@@ -1,67 +1,63 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.BukkitCommandIssuer;
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.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
import java.util.logging.Level;
/**
* Enables debug-information.
*/
@Service
@CommandAlias("mv")
public class DebugCommand extends MultiverseCommand {
public DebugCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn Debug on/off?");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]");
this.setArgRange(0, 1);
this.addKey("mv debug");
this.addKey("mv d");
this.addKey("mvdebug");
this.addCommandExample("/mv debug " + ChatColor.GOLD + "2");
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
private final MVCoreConfig config;
@Inject
public DebugCommand(@NotNull MVCommandManager commandManager, @NotNull MVCoreConfig config) {
super(commandManager);
this.config = config;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("off")) {
plugin.getMVConfig().setGlobalDebug(0);
} else {
try {
int debugLevel = Integer.parseInt(args.get(0));
if (debugLevel > 3 || debugLevel < 0) {
throw new NumberFormatException();
}
plugin.getMVConfig().setGlobalDebug(debugLevel);
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
}
}
plugin.saveMVConfigs();
}
this.displayDebugMode(sender);
@Subcommand("debug")
@CommandPermission("multiverse.core.debug")
@Description("{@@mv-core.debug.info.description}")
public void onShowDebugCommand(BukkitCommandIssuer issuer) {
this.displayDebugMode(issuer);
}
private void displayDebugMode(CommandSender sender) {
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
@Subcommand("debug")
@CommandPermission("multiverse.core.debug")
@CommandCompletion("@range:3")
@Syntax("<{@@mv-core.debug.change.syntax}>")
@Description("{@@mv-core.debug.change.description}")
public void onChangeDebugCommand(BukkitCommandIssuer issuer,
@Syntax("<{@@mv-core.debug.change.syntax}>")
@Description("{@@mv-core.debug.change.level.description}")
int level) {
config.setGlobalDebug(level);
config.save();
this.displayDebugMode(issuer);
}
private void displayDebugMode(BukkitCommandIssuer issuer) {
final int debugLevel = config.getGlobalDebug();
if (debugLevel == 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
Logging.fine("Multiverse Debug ENABLED");
issuer.sendInfo(MVCorei18n.DEBUG_INFO_OFF);
return;
}
issuer.sendInfo(MVCorei18n.DEBUG_INFO_ON, "{level}", String.valueOf(debugLevel));
Logging.fine("Multiverse Debug ENABLED.");
}
}
@@ -1,45 +1,67 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.MessageType;
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.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Deletes worlds.
*/
@Service
@CommandAlias("mv")
public class DeleteCommand extends MultiverseCommand {
public DeleteCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Delete World");
this.setCommandUsage("/mv delete" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvdelete");
this.addKey("mv delete");
this.addCommandExample("/mv delete " + ChatColor.GOLD + "MyWorld");
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
private final MVWorldManager worldManager;
@Inject
public DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
super(commandManager);
this.worldManager = worldManager;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
@Subcommand("delete")
@CommandPermission("multiverse.core.delete")
@CommandCompletion("@mvworlds:scope=both")
@Syntax("<world>")
@Description("{@@mv-core.delete.description}")
public void onDeleteCommand(BukkitCommandIssuer issuer,
Class<?>[] paramTypes = {String.class};
List<Object> objectArgs = new ArrayList<Object>(args);
this.plugin.getCommandHandler()
.queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World '" + worldName + "' Deleted!",
ChatColor.RED + "World '" + worldName + "' could NOT be deleted!");
@Single
@Conditions("validWorldName:scope=both")
@Syntax("<world>")
@Description("The world you want to delete.")
String worldName
) {
this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand(
issuer.getIssuer(),
() -> {
issuer.sendInfo(MVCorei18n.DELETE_DELETING,
"{world}", worldName);
if (!this.worldManager.deleteWorld(worldName)) {
issuer.sendError(MVCorei18n.DELETE_FAILED,
"{world}", worldName);
return;
}
issuer.sendInfo(MVCorei18n.DELETE_SUCCESS,
"{world}", worldName);
},
this.commandManager.formatMessage(
issuer,
MessageType.INFO,
MVCorei18n.DELETE_PROMPT,
"{world}", worldName)
));
}
}
@@ -1,118 +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.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Lists valid known environments.
*/
public class EnvironmentCommand extends MultiverseCommand {
public EnvironmentCommand(MultiverseCore plugin) {
super(plugin);
this.setName("List Environments");
this.setCommandUsage("/mv env");
this.setArgRange(0, 0);
this.addKey("mvenv");
this.addKey("mv env");
this.addKey("mv type");
this.addKey("mv environment");
this.addKey("mv environments");
this.addCommandExample("/mv env");
this.setPermission("multiverse.core.list.environments", "Lists valid known environments/world types.", PermissionDefault.OP);
}
/**
* Shows all valid known environments to a {@link CommandSender}.
*
* @param sender The {@link CommandSender}.
*/
public static void showEnvironments(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
sender.sendMessage(ChatColor.GREEN + "NORMAL");
sender.sendMessage(ChatColor.RED + "NETHER");
sender.sendMessage(ChatColor.AQUA + "END");
}
/**
* Shows all valid known world types to a {@link CommandSender}.
*
* @param sender The {@link CommandSender}.
*/
public static void showWorldTypes(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT, %sLARGEBIOMES %sor %sVERSION_1_1",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
EnvironmentCommand.showEnvironments(sender);
EnvironmentCommand.showWorldTypes(sender);
}
/**
* Converts a {@link String} into a {@link WorldType}.
*
* @param type The WorldType as a {@link String}
* @return The WorldType as a {@link WorldType}
*/
public static WorldType getWorldTypeFromString(String type) {
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (type.equalsIgnoreCase("normal")) {
type = "NORMAL";
} else if (type.equalsIgnoreCase("flat")) {
type = "FLAT";
} else if (type.equalsIgnoreCase("largebiomes")) {
type = "LARGE_BIOMES";
} else if (type.equalsIgnoreCase("amplified")) {
type = "AMPLIFIED";
}
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
return WorldType.valueOf(type);
} catch (IllegalArgumentException e) {
return null;
}
}
/**
* Converts a {@link String} into an {@link org.bukkit.World.Environment}.
*
* @param env The environment as {@link String}
* @return The environment as {@link org.bukkit.World.Environment}
*/
public static World.Environment getEnvFromString(String env) {
env = env.toUpperCase();
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
env = "NETHER";
if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS"))
env = "THE_END";
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
env = "NORMAL";
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
return World.Environment.valueOf(env);
} catch (IllegalArgumentException e) {
return null;
}
}
}
@@ -1,116 +1,79 @@
/******************************************************************************
* 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.Bukkit;
import org.bukkit.ChatColor;
import co.aikar.commands.BukkitCommandIssuer;
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.api.MVWorld;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleValue;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.bukkit.GameRule;
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.jvnet.hk2.annotations.Service;
import java.util.List;
/**
* Allows management of Anchor Destinations.
*/
@Service
@CommandAlias("mv")
public class GameruleCommand extends MultiverseCommand {
public GameruleCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Set a Minecraft Game Rule for a World.");
this.setCommandUsage("/mv gamerule " + ChatColor.GREEN + "{RULE} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mv gamerule");
this.addKey("mv rule");
this.addKey("mvgamerule");
this.addKey("mvrule");
this.addCommandExample("/mv gamerule " + ChatColor.GREEN + "doMobLoot false");
this.addCommandExample("/mvrule " + ChatColor.GREEN + "keepInventory true " + ChatColor.RED + "world_nether");
this.setPermission("multiverse.core.gamerule.set", "Allows a player to set a gamerule.", PermissionDefault.OP);
@Inject
public GameruleCommand(@NotNull MVCommandManager commandManager) {
super(commandManager);
}
@Subcommand("gamerule")
@CommandPermission("multiverse.core.gamerule")
@CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*")
@Syntax("<Gamerule> <Gamerule value> [World or *]")
@Description("{@@mv-core.gamerule.description}")
public void onGameruleCommand(BukkitCommandIssuer issuer,
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
final Player p;
if (sender instanceof Player) {
p = (Player) sender;
} else {
p = null;
}
@Syntax("<Gamerule>")
@Description("{@@mv-core.gamerule.gamerule.description}")
GameRule gamerule,
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;
}
@Syntax("<Value>")
@Description("{@@mv-core.gamerule.value.description}")
GameRuleValue gameRuleValue,
final GameRule gameRule = GameRule.getByName(args.get(0));
final String value = args.get(1);
final World world;
if (args.size() == 2) {
world = p.getWorld();
} else {
world = Bukkit.getWorld(args.get(2));
if (world == null) {
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " World " + ChatColor.AQUA + args.get(2)
+ ChatColor.WHITE + " does not exist.");
return;
@Flags("resolve=issuerAware")
@Syntax("[World or *]")
@Description("{@@mv-core.gamerule.world.description}")
MVWorld[] worlds
) {
Object value = gameRuleValue.getValue();
boolean success = true;
for(MVWorld world : worlds) {
// Set gamerules and add false to list if it fails
if (!world.getCBWorld().setGameRule(gamerule, value)) {
issuer.sendError(MVCorei18n.GAMERULE_FAILED,
"{gamerule}", gamerule.getName(),
"{value}", value.toString(),
"{world}", world.getName(),
"{type}", gamerule.getType().getName());
success = false;
}
}
if (gameRule == null) {
sender.sendMessage(ChatColor.RED + "Failure! " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE
+ " is not a valid gamerule.");
} else {
if (gameRule.getType() == Boolean.class) {
boolean booleanValue;
if (value.equalsIgnoreCase("true")) {
booleanValue = true;
} else if (value.equalsIgnoreCase("false")) {
booleanValue = false;
} else {
sender.sendMessage(getErrorMessage(gameRule.getName(), value) + "it can only be set to true or false.");
return;
}
if (!world.setGameRule(gameRule, booleanValue)) {
sender.sendMessage(getErrorMessage(gameRule.getName(), value) + "something went wrong.");
return;
}
} else if (gameRule.getType() == Integer.class) {
try {
if (!world.setGameRule(gameRule, Integer.parseInt(value))) {
throw new NumberFormatException();
}
} catch (NumberFormatException e) {
sender.sendMessage(getErrorMessage(gameRule.getName(), value) + "it can only be set to a positive integer.");
return;
}
} else {
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule.getName()
+ ChatColor.WHITE + " isn't supported yet, please let us know about it.");
return;
// Tell user if it was successful
if (success) {
if (worlds.length == 1) {
issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_SINGLE,
"{gamerule}", gamerule.getName(),
"{value}", value.toString(),
"{world}", worlds[0].getName());
}
else if (worlds.length > 1) {
issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_MULTIPLE,
"{gamerule}", gamerule.getName(),
"{value}", value.toString(),
"{count}", String.valueOf(worlds.length));
}
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule.getName()
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value + ChatColor.WHITE + ".");
}
}
private String getErrorMessage(String gameRule, String value) {
return ChatColor.RED + "Failure!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule
+ ChatColor.WHITE + " could not be set to " + ChatColor.RED + value + ChatColor.WHITE + ", ";
}
}
@@ -1,82 +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.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.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Allows management of Anchor Destinations.
*/
public class GamerulesCommand extends MultiverseCommand {
public GamerulesCommand(MultiverseCore plugin) {
super(plugin);
this.setName("List the Minecraft Game Rules for a World.");
this.setCommandUsage("/mv gamerules" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(0, 1);
this.addKey("mv gamerules");
this.addKey("mv rules");
this.addKey("mvgamerules");
this.addKey("mvrules");
this.addCommandExample("/mv gamerules");
this.addCommandExample("/mvrules " + ChatColor.RED + "world_nether");
this.setPermission("multiverse.core.gamerule.list", "Allows a player to list gamerules.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
final Player p;
if (sender instanceof Player) {
p = (Player) sender;
} else {
p = null;
}
if (args.size() == 0 && p == null) {
sender.sendMessage("From the command line, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
final World world;
if (args.size() == 0) {
world = p.getWorld();
} else {
world = Bukkit.getWorld(args.get(0));
if (world == null) {
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " World " + ChatColor.AQUA + args.get(0)
+ ChatColor.WHITE + " does not exist.");
return;
}
}
final StringBuilder gameRules = new StringBuilder();
for (final String gameRule : world.getGameRules()) {
if (gameRules.length() != 0) {
gameRules.append(ChatColor.WHITE).append(", ");
}
gameRules.append(ChatColor.AQUA).append(gameRule).append(ChatColor.WHITE).append(": ");
gameRules.append(ChatColor.GREEN).append(world.getGameRuleValue(GameRule.getByName(gameRule)));
}
sender.sendMessage("=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ===");
sender.sendMessage(gameRules.toString());
}
}
@@ -1,60 +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.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.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
/**
* Returns a list of loaded generator plugins.
*/
public class GeneratorCommand extends MultiverseCommand {
public GeneratorCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Information");
this.setCommandUsage("/mv generators");
this.setArgRange(0, 0);
this.addKey("mv generators");
this.addKey("mvgenerators");
this.addKey("mv gens");
this.addKey("mvgens");
this.addCommandExample("/mv generators");
this.setPermission("multiverse.core.generator", "Returns a list of Loaded Generator Plugins.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Logging.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);
}
}
@@ -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,171 +1,104 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import java.util.Arrays;
import java.util.stream.Collectors;
import co.aikar.commands.BukkitCommandIssuer;
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.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import jakarta.inject.Inject;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Imports a new world of the specified type.
*/
@Service
@CommandAlias("mv")
public class ImportCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ImportCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Import World");
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n]");
this.setArgRange(1, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvimport");
this.addKey("mvim");
this.addKey("mv import");
this.addCommandExample("/mv import " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal");
this.addCommandExample("/mv import " + ChatColor.GOLD + "hell_world" + ChatColor.GREEN + " nether");
this.addCommandExample("To import a world that uses a generator, you'll need the generator:");
this.addCommandExample("/mv import " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " CleanRoomGenerator");
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
private final MVWorldManager worldManager;
@Inject
public ImportCommand(
@NotNull MVCommandManager commandManager,
@NotNull MVWorldManager worldManager,
@NotNull UnsafeCallWrapper unsafeCallWrapper
) {
super(commandManager);
this.worldManager = worldManager;
registerFlagGroup(CommandFlagGroup.builder("mvimport")
.add(CommandValueFlag.builder("--generator", String.class)
.addAlias("-g")
.completion(() -> Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins())
.filter(Plugin::isEnabled)
.filter(genplugin -> unsafeCallWrapper.wrap(
() -> genplugin.getDefaultWorldGenerator("world", ""),
genplugin.getName(),
"Get generator"
) != null)
.map(genplugin -> genplugin.getDescription().getName())
.collect(Collectors.toList()))
.build())
.add(CommandFlag.builder("--adjust-spawn")
.addAlias("-a")
.build())
.build());
}
/**
* A very basic check to see if a folder has a level.dat file.
* If it does, we can safely assume it's a world folder.
*
* @param worldFolder The File that may be a world.
* @return True if it looks like a world, false if not.
*/
private static boolean checkIfIsWorld(File worldFolder) {
if (worldFolder.isDirectory()) {
File[] files = worldFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return name.toLowerCase().endsWith(".dat");
}
});
if (files != null && files.length > 0) {
return true;
}
}
return false;
}
@Subcommand("import")
@CommandPermission("multiverse.core.import")
@CommandCompletion("@mvworlds:scope=potential @flags:groupName=mvimport")
@Syntax("<name> <env> --generator [generator[:id]] --adjust-spawn")
@Description("{@@mv-core.import.description")
public void onImportCommand(BukkitCommandIssuer issuer,
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;
}
private String trimWorldName(String userInput) {
// Removes relative paths.
return userInput.replaceAll("^[./\\\\]+", "");
}
@Conditions("validWorldName:scope=new")
@Syntax("<name>")
@Description("{@@mv-core.import.name.description}")
String worldName,
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = trimWorldName(args.get(0));
@Syntax("<env>")
@Description("{@@mv-core.import.env.description}")
World.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!");
}
@Optional
@Syntax("--generator [generator[:id]] --adjust-spawn")
@Description("{@@mv-core.import.other.description}")
String[] flags) {
ParsedCommandFlags parsedFlags = parseFlags(flags);
issuer.sendInfo(MVCorei18n.IMPORT_IMPORTING,
"{world}", worldName);
if (!this.worldManager.addWorld(
worldName, environment,
null,
null,
null,
parsedFlags.flagValue("--generator", String.class),
parsedFlags.hasFlag("--adjust-spawn"))
) {
issuer.sendError(MVCorei18n.IMPORT_FAILED);
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 || worldName.length() < 1) {
this.showHelp(sender);
return;
}
// Make sure we don't already know about this world.
if (this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.GREEN + "Multiverse" + ChatColor.WHITE
+ " already knows about '" + ChatColor.AQUA + worldName + ChatColor.WHITE + "'!");
return;
}
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
String generator = CommandHandler.getFlag("-g", args);
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
String env = args.get(1);
Environment environment = EnvironmentCommand.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
if (!worldFile.exists()) {
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);
} else if (!checkIfIsWorld(worldFile)) {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage(String.format("'%s' does not appear to be a world. It is lacking a .dat file.",
worldName));
} 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 {
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
if (this.worldManager.addWorld(worldName, environment, null, null, null, generator, useSpawnAdjust))
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
else
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
}
issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS);
}
}
@@ -1,274 +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.FancyText;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
import com.onarandombox.MultiverseCore.utils.FancyHeader;
import com.onarandombox.MultiverseCore.utils.FancyMessage;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
// Will use when we can compile with JDK 6
//import com.sun.xml.internal.ws.util.StringUtils;
/**
* Returns detailed information about a world.
*/
public class InfoCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public InfoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Information");
this.setCommandUsage("/mv info" + ChatColor.GOLD + " [WORLD] [PAGE]");
this.setArgRange(0, 2);
this.addKey("mvinfo");
this.addKey("mvi");
this.addKey("mv info");
this.addCommandExample("/mv info " + ChatColor.GOLD + "1");
this.addCommandExample("/mv info " + ChatColor.GOLD + "3");
this.setPermission("multiverse.core.info", "Returns detailed information on the world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
String worldName = "";
int pageNum = 0;
if (args.size() == 0) {
if (sender instanceof Player) {
Player p = (Player) sender;
worldName = p.getWorld().getName();
} else {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
} else if (args.size() == 1) {
if (this.worldManager.isMVWorld(args.get(0))) {
// then we have a world!
worldName = args.get(0);
} else if (this.worldManager.getUnloadedWorlds().contains(args.get(0))) {
sender.sendMessage("That world exists, but it is unloaded!");
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, args.get(0)));
return;
} else {
if (sender instanceof Player) {
Player p = (Player) sender;
worldName = p.getWorld().getName();
try {
pageNum = Integer.parseInt(args.get(0)) - 1;
} catch (NumberFormatException e) {
sender.sendMessage("That world does not exist.");
return;
}
} else {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
}
} else if (args.size() == 2) {
worldName = args.get(0);
try {
pageNum = Integer.parseInt(args.get(1)) - 1;
} catch (NumberFormatException e) {
pageNum = 0;
}
}
if (this.worldManager.isMVWorld(worldName)) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
} else if (this.worldManager.getUnloadedWorlds().contains(worldName)) {
sender.sendMessage("That world exists, but it is unloaded!");
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, worldName));
} else if (this.plugin.getServer().getWorld(worldName) != null) {
sender.sendMessage("That world exists, but Multiverse does not know about it!");
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
}
}
private List<List<FancyText>> buildEntireCommand(MultiverseWorld world, Player p) {
List<FancyText> message = new ArrayList<FancyText>();
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
// Page 1
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
message.add(new FancyHeader("General Info", colors));
message.add(new FancyMessage("World Name: ", world.getName(), colors));
message.add(new FancyMessage("World UID: ", world.getCBWorld().getUID().toString(), colors));
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
Location spawn = world.getSpawnLocation();
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
message.add(new FancyMessage("World Scale: ", String.valueOf(world.getScaling()), colors));
message.add(new FancyMessage("World Seed: ", String.valueOf(world.getSeed()), colors));
if (world.getPrice() > 0) {
message.add(new FancyMessage("Price to enter this world: ",
plugin.getEconomist().formatPrice(world.getPrice(), world.getCurrency()),
colors));
} else if (world.getPrice() < 0) {
message.add(new FancyMessage("Reward for entering this world: ",
plugin.getEconomist().formatPrice(-world.getPrice(), world.getCurrency()),
colors));
} else {
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
}
if (world.getRespawnToWorld() != null) {
MultiverseWorld respawn = this.worldManager.getMVWorld(world.getRespawnToWorld());
if (respawn != null) {
message.add(new FancyMessage("Players will respawn in: ", respawn.getColoredWorldString(), colors));
} else {
message.add(new FancyMessage("Players will respawn in: ", ChatColor.RED + "!!INVALID!!", colors));
}
}
worldInfo.add(message);
// Page 2
message = new ArrayList<FancyText>();
message.add(new FancyHeader("More World Settings", colors));
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
message.add(new FancyMessage("Generator: ", world.getGenerator(), colors));
message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
message.add(new FancyHeader("PVP Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.isPVPEnabled() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
worldInfo.add(message);
// Page 3
message = new ArrayList<FancyText>();
message.add(new FancyHeader("Monster Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.canMonstersSpawn() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowMonsters() + "", colors));
if (world.getMonsterList().size() > 0) {
if (world.canMonstersSpawn()) {
message.add(new FancyMessage("Monsters that" + ChatColor.RED + " CAN NOT "
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getMonsterList()), colors));
} else {
message.add(new FancyMessage("Monsters that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getMonsterList()), colors));
}
} else {
message.add(new FancyMessage("Monsters that CAN spawn: ", world.canMonstersSpawn() ? "ALL" : "NONE", colors));
}
worldInfo.add(message);
// Page 4
message = new ArrayList<FancyText>();
message.add(new FancyHeader("Animal Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.canAnimalsSpawn() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowAnimals() + "", colors));
if (world.getAnimalList().size() > 0) {
if (world.canAnimalsSpawn()) {
message.add(new FancyMessage("Animals that" + ChatColor.RED + " CAN NOT "
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getAnimalList()), colors));
} else {
message.add(new FancyMessage("Animals that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getAnimalList()), colors));
}
} else {
message.add(new FancyMessage("Animals that CAN spawn: ", world.canAnimalsSpawn() ? "ALL" : "NONE", colors));
}
worldInfo.add(message);
return worldInfo;
}
private static String toCommaSeperated(List<String> list) {
if (list == null || list.size() == 0) {
return "";
}
if (list.size() == 1) {
return list.get(0);
}
String result = list.get(0);
for (int i = 1; i < list.size() - 1; i++) {
result += ", " + list.get(i);
}
result += " and " + list.get(list.size() - 1);
return result;
}
/**
* Gets a "positive" or "negative" {@link ChatColor}.
*
* @param positive Whether this {@link ChatColor} should be "positive".
* @return The {@link ChatColor}.
*/
protected ChatColor getChatColor(boolean positive) {
return positive ? ChatColor.GREEN : ChatColor.RED;
}
private static void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
page = page < 0 ? 0 : page;
page = page > doc.size() - 1 ? doc.size() - 1 : page;
boolean altColor = false;
boolean appendedPageNum = false;
if (sender instanceof Player) {
List<FancyText> list = doc.get(page);
for (FancyText fancyT : list) {
if (fancyT instanceof FancyMessage) {
FancyMessage text = (FancyMessage) fancyT;
text.setAltColor(altColor);
altColor = !altColor;
sender.sendMessage(text.getFancyText());
} else if (fancyT instanceof FancyHeader) {
FancyHeader text = (FancyHeader) fancyT;
if (!appendedPageNum) {
text.appendText(ChatColor.DARK_PURPLE + " [ Page " + (page + 1) + " of " + doc.size() + " ]");
appendedPageNum = true;
}
sender.sendMessage(text.getFancyText());
altColor = false;
}
}
} else {
for (List<FancyText> list : doc) {
for (FancyText fancyT : list) {
if (fancyT instanceof FancyMessage) {
FancyMessage text = (FancyMessage) fancyT;
text.setAltColor(altColor);
altColor = !altColor;
sender.sendMessage(text.getFancyText());
} else {
FancyText text = fancyT;
if (appendedPageNum) {
sender.sendMessage(" ");
} else {
appendedPageNum = true;
}
sender.sendMessage(text.getFancyText());
altColor = false;
}
}
}
}
}
}
@@ -1,130 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Displays a listing of all worlds that a player can enter.
*/
public class ListCommand extends PaginatedCoreCommand<String> {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mv list [page]");
this.setArgRange(0, 2);
this.addKey("mvlist");
this.addKey("mvl");
this.addKey("mv list");
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
private List<String> getFancyWorldList(Player p) {
List<String> worldList = new ArrayList<String>();
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
}
ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment();
if (env == Environment.NETHER) {
color = ChatColor.RED;
} else if (env == Environment.NORMAL) {
color = ChatColor.GREEN;
} else if (env == Environment.THE_END) {
color = ChatColor.AQUA;
}
StringBuilder builder = new StringBuilder();
builder.append(world.getColoredWorldString()).append(ChatColor.WHITE);
builder.append(" - ").append(color).append(world.getEnvironment());
if (world.isHidden()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) {
// Prefix hidden worlds with an "[H]"
worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
}
} else {
worldList.add(builder.toString());
}
}
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
}
}
return worldList;
}
@Override
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
List<String> filtered = new ArrayList<String>();
for (String s : availableItems) {
if (s.matches("(?i).*" + filter + ".*")) {
filtered.add(s);
}
}
return filtered;
}
@Override
protected String getItemText(String item) {
return item;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse World List ]====");
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
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);
}
}
@@ -1,42 +1,56 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import co.aikar.commands.BukkitCommandIssuer;
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.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
/**
* Loads a world into Multiverse.
*/
@Service
@CommandAlias("mv")
public class LoadCommand extends MultiverseCommand {
public LoadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Load World");
this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvload");
this.addKey("mv load");
this.addCommandExample("/mv load " + ChatColor.GREEN + "MyUnloadedWorld");
this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP);
private final MVWorldManager worldManager;
@Inject
public LoadCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
super(commandManager);
this.worldManager = worldManager;
}
@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")
@CommandCompletion("@mvworlds:scope=unloaded")
@Syntax("<world>")
@Description("{@@mv-core.load.description}")
public void onLoadCommand(BukkitCommandIssuer issuer,
@Single
@Conditions("validWorldName:scope=unloaded")
@Syntax("<world>")
@Description("{@@mv-core.load.world.description}")
String worldName
) {
issuer.sendInfo(MVCorei18n.LOAD_LOADING,
"{world}", worldName);
if (!this.worldManager.loadWorld(worldName)) {
issuer.sendError(MVCorei18n.LOAD_FAILED,
"{world}", worldName);
return;
}
issuer.sendInfo(MVCorei18n.LOAD_SUCCESS,
"{world}", worldName);
}
}
@@ -1,95 +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: https://goo.gl/OMGwzx");
return;
}
// TODO fix this
if (world.addToVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA
+ value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
if (!plugin.saveWorldConfig()) {
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
}
} else {
sender.sendMessage(value + " could not be added to " + property);
}
}
}
@@ -1,92 +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: https://goo.gl/q1h01S");
return;
}
// TODO fix this
if (world.clearList(property)) {
sender.sendMessage(property + " was cleared. It contains 0 values now.");
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was "
+ ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
if (!plugin.saveWorldConfig()) {
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
}
} else {
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property
+ ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
}
}
}
@@ -1,76 +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.enums.Action;
import com.onarandombox.MultiverseCore.enums.AddProperties;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Used to modify various aspects of worlds.
*/
public class ModifyCommand extends MultiverseCommand {
public ModifyCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " {set|add|remove|clear} ...");
this.setArgRange(2, 3);
this.addKey("mvm");
this.addKey("mvmodify");
this.addKey("mv modify");
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put("multiverse.core.modify.add", true);
children.put("multiverse.core.modify.modify", true);
children.put("multiverse.core.modify.clear", true);
children.put("multiverse.core.modify.remove", true);
Permission modify = new Permission("multiverse.core.modify",
"Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children);
this.addCommandExample(ChatColor.AQUA + "/mv modify set ?");
this.addCommandExample(ChatColor.GREEN + "/mv modify add ?");
this.addCommandExample(ChatColor.BLUE + "/mv modify clear ?");
this.addCommandExample(ChatColor.RED + "/mv modify remove ?");
this.setPermission(modify);
}
/**
* Validates the specified action.
*
* @param action The {@link Action}.
* @param property The property.
* @return Whether this action is valid.
*/
protected static boolean validateAction(Action action, String property) {
if (action != Action.Set) {
try {
AddProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
return false;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// This is just a place holder. The real commands are in:
// ModifyAddCommand
// ModifyRemoveCommand
// ModifySetCommand
// ModifyClearCommand
}
}
@@ -1,97 +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: https://goo.gl/OMGwzx");
return;
}
// TODO fix this
if (world.removeFromVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE
+ " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
if (!plugin.saveWorldConfig()) {
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
}
} else {
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY
+ value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
}
}
}
@@ -1,125 +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")) && !EnglishChatColor.isValidAliasColor(value)) {
sender.sendMessage(value + " is not a valid color. Please pick one of the following:");
sender.sendMessage(EnglishChatColor.getAllColors());
return;
}
try {
if (world.setPropertyValue(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
if (!plugin.saveWorldConfig()) {
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
}
} else {
sender.sendMessage(ChatColor.RED + world.getPropertyHelp(property));
}
} catch (PropertyDoesNotExistException e) {
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
sender.sendMessage("Valid world-properties: " + world.getAllPropertyNames());
}
}
}
@@ -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.api.MultiverseMessaging;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
import java.util.List;
/**
* A generic Multiverse-command.
*/
public abstract class MultiverseCommand extends Command {
/**
* The reference to the core.
*/
protected MultiverseCore plugin;
/**
* The reference to {@link MultiverseMessaging}.
*/
protected MultiverseMessaging messaging;
public MultiverseCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
this.messaging = this.plugin.getMessaging();
}
@Override
public abstract void runCommand(CommandSender sender, List<String> args);
}
@@ -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,26 +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;
/**
* A generic paginated Multiverse-command.
* @param <T> The type of items on the page.
*/
public abstract class PaginatedCoreCommand<T> extends PaginatedCommand<T> {
/**
* The reference to the core.
*/
protected MultiverseCore plugin;
public PaginatedCoreCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
}
}
@@ -1,92 +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.api.WorldPurger;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Removes a type of mob from a world.
*/
public class PurgeCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public PurgeCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Purge World of Creatures");
this.setCommandUsage("/mv purge" + ChatColor.GOLD + " [WORLD|all] " + ChatColor.GREEN + "{all|animals|monsters|MOBNAME}");
this.setArgRange(1, 2);
this.addKey("mvpurge");
this.addKey("mv purge");
this.addCommandExample("/mv purge " + ChatColor.GREEN + "all");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "all");
this.addCommandExample("/mv purge " + ChatColor.GREEN + "monsters");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "animals");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld " + ChatColor.GREEN + "squid");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld_nether " + ChatColor.GREEN + "ghast");
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage("This command requires a WORLD when being run from the console!");
sender.sendMessage(this.getCommandUsage());
return;
}
String worldName = null;
String deathName = null;
if (args.size() == 1) {
worldName = p.getWorld().getName();
deathName = args.get(0);
} else {
worldName = args.get(0);
deathName = args.get(1);
}
if (!worldName.equalsIgnoreCase("all") && !this.worldManager.isMVWorld(worldName)) {
this.plugin.showNotMVWorldMessage(sender, worldName);
sender.sendMessage("It cannot be purged.");
return;
}
List<MultiverseWorld> worldsToRemoveEntitiesFrom = new ArrayList<MultiverseWorld>();
// Handle all case any user who names a world "all" should know better...
if (worldName.equalsIgnoreCase("all")) {
worldsToRemoveEntitiesFrom.addAll(this.worldManager.getMVWorlds());
} else {
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
}
WorldPurger purger = this.worldManager.getTheWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>();
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
} else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
}
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(w, thingsToKill, false, false, sender);
}
}
}
@@ -1,53 +1,97 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.Collections;
import java.util.Random;
import java.util.ArrayList;
import java.util.List;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.MessageType;
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.Optional;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag;
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
/**
* Regenerates a world.
*/
@Service
@CommandAlias("mv")
public class RegenCommand extends MultiverseCommand {
public RegenCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Regenerates a World");
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]]");
this.setArgRange(1, 3);
this.addKey("mvregen");
this.addKey("mv regen");
this.addCommandExample("You can use the -s with no args to get a new seed:");
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s");
this.addCommandExample("or specifiy a seed to get that one:");
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s" + ChatColor.AQUA + " gargamel");
this.setPermission("multiverse.core.regen", "Regenerates a world on your server. The previous state will be lost "
+ ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
private final MVWorldManager worldManager;
@Inject
public RegenCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
super(commandManager);
this.worldManager = worldManager;
registerFlagGroup(CommandFlagGroup.builder("mvregen")
.add(CommandValueFlag.builder("--seed", String.class)
.addAlias("-s")
.completion(() -> Collections.singleton(String.valueOf(new Random().nextLong())))
.optional()
.build())
.add(CommandFlag.builder("--keep-gamerules")
.addAlias("-k")
.build())
.build());
}
@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")
@CommandCompletion("@mvworlds:scope=both @flags:groupName=mvregen")
@Syntax("<world> --seed [seed] --keep-gamerules")
@Description("{@@mv-core.regen.description}")
public void onRegenCommand(BukkitCommandIssuer issuer,
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!");
@Conditions("validWorldName:scope=both")
@Syntax("<world>")
@Description("{@@mv-core.regen.world.description}")
String worldName,
@Optional
@Syntax("--seed [seed] --keep-gamerules")
@Description("{@@mv-core.regen.other.description}")
String[] flags
) {
ParsedCommandFlags parsedFlags = parseFlags(flags);
this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand(
issuer.getIssuer(),
() -> {
issuer.sendInfo(MVCorei18n.REGEN_REGENERATING,
"{world}", worldName);
if (!this.worldManager.regenWorld(
worldName,
parsedFlags.hasFlag("--seed"),
!parsedFlags.hasFlagValue("--seed"),
parsedFlags.flagValue("--seed", String.class),
parsedFlags.hasFlag("--keep-gamerules")
)) {
issuer.sendError(MVCorei18n.REGEN_FAILED,
"{world}", worldName);
return;
}
issuer.sendInfo(MVCorei18n.REGEN_SUCCESS,
"{world}", worldName);
},
this.commandManager.formatMessage(
issuer,
MessageType.INFO,
MVCorei18n.REGEN_PROMPT,
"{world}", worldName)
));
}
}
@@ -1,58 +1,71 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Reloads worlds.yml and config.yml.
*/
import co.aikar.commands.BukkitCommandIssuer;
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.anchor.AnchorManager;
import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
@Service
@CommandAlias("mv")
public class ReloadCommand extends MultiverseCommand {
public ReloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Reload Configs");
this.setCommandUsage("/mv reload");
this.setArgRange(0, 0);
this.addKey("mvreload");
this.addKey("mvr");
this.addKey("mv reload");
this.addCommandExample("/mv reload");
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
private final MVCoreConfig config;
private final AnchorManager anchorManager;
private final MVWorldManager worldManager;
private final PluginManager pluginManager;
@Inject
public ReloadCommand(
@NotNull MVCommandManager commandManager,
@NotNull MVCoreConfig config,
@NotNull AnchorManager anchorManager,
@NotNull MVWorldManager worldManager,
@NotNull PluginManager pluginManager
) {
super(commandManager);
this.config = config;
this.anchorManager = anchorManager;
this.worldManager = worldManager;
this.pluginManager = pluginManager;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
this.plugin.loadConfigs();
this.plugin.getAnchorManager().loadAnchors();
this.plugin.getMVWorldManager().loadWorlds(true);
@Subcommand("reload")
@CommandPermission("multiverse.core.reload")
@Description("{@@mv-core.reload.description}")
public void onReloadCommand(@NotNull BukkitCommandIssuer issuer) {
issuer.sendInfo(MVCorei18n.RELOAD_RELOADING);
this.config.load();
this.worldManager.loadWorldsConfig();
this.worldManager.loadWorlds(true);
this.anchorManager.loadAnchors();
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);
}
this.pluginManager.callEvent(configReload);
sender.sendMessage(ChatColor.GREEN + "Reload Complete!");
// @TODO: replace this sendMessage and format the configsLoaded above, maybe?
configReload.getAllConfigsLoaded().forEach(issuer::sendMessage);
issuer.sendInfo(MVCorei18n.RELOAD_SUCCESS);
}
}
@@ -1,42 +1,52 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import co.aikar.commands.BukkitCommandIssuer;
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.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
/**
* Unloads a world and removes it from the config.
*/
@Service
@CommandAlias("mv")
public class RemoveCommand extends MultiverseCommand {
public RemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Remove World");
this.setCommandUsage("/mv remove" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvremove");
this.addKey("mv remove");
this.addCommandExample("/mv remove " + ChatColor.GREEN + "MyWorld");
this.setPermission("multiverse.core.remove",
"Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.", PermissionDefault.OP);
private final MVWorldManager worldManager;
@Inject
public RemoveCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
super(commandManager);
this.worldManager = worldManager;
}
@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:scope=both")
@Syntax("<world>")
@Description("{@@mv-core.remove.description}")
public void onRemoveCommand(BukkitCommandIssuer issuer,
@Single
@Conditions("mvworlds:scope=both")
@Syntax("<world>")
@Description("{@@mv-core.remove.world.description}")
String worldName
) {
if (!this.worldManager.removeWorldFromConfig(worldName)) {
issuer.sendError(MVCorei18n.REMOVE_FAILED);
return;
}
issuer.sendInfo(MVCorei18n.REMOVE_SUCCESS,
"{world}", worldName);
}
}
@@ -0,0 +1,34 @@
package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.annotation.CommandAlias;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
@Service
public class RootCommand extends MultiverseCommand {
private final Plugin plugin;
@Inject
public RootCommand(@NotNull MVCommandManager commandManager, @NotNull MultiverseCore plugin) {
super(commandManager);
this.plugin = plugin;
}
@CommandAlias("mv")
public void onRootCommand(CommandIssuer issuer) {
PluginDescriptionFile description = this.plugin.getDescription();
issuer.sendInfo(MVCorei18n.ROOT_TITLE,
"{name}", description.getName(),
"{version}", description.getVersion());
issuer.sendInfo(MVCorei18n.ROOT_HELP);
}
}
@@ -1,58 +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 java.io.File;
import java.util.List;
/**
* States who is in what world.
*/
public class ScriptCommand extends MultiverseCommand {
public ScriptCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Runs a script.");
this.setCommandUsage("/mv script" + ChatColor.GOLD + " {script} [target]");
this.setArgRange(1, 2);
this.addKey("mv script");
this.addKey("mvscript");
this.addCommandExample(String.format("/mv script %sscript.txt", ChatColor.GOLD));
this.addCommandExample(String.format("/mv script %stest.txt %ssomeplayer", ChatColor.GOLD, ChatColor.GREEN));
this.setPermission("multiverse.core.script", "Runs a script.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (plugin.getScriptAPI() == null) {
sender.sendMessage("Buscript failed to load while the server was starting. Scripts cannot be run.");
return;
}
File file = new File(plugin.getScriptAPI().getScriptFolder(), args.get(0));
if (!file.exists()) {
sender.sendMessage("That script file does not exist in the Multiverse-Core scripts directory!");
return;
}
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
String target = null;
if (args.size() == 2) {
target = args.get(1);
}
plugin.getScriptAPI().executeScript(file, target, player);
sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE));
}
}
@@ -1,148 +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.BlockSafety;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
import org.bukkit.Bukkit;
/**
* 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, 6);
this.addKey("mvsetspawn");
this.addKey("mvsets");
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);
}
/**
* Dispatches the user's command depending on the number of parameters
* @param sender The player who executes the command, may be console as well.
* @param args Command line parameters
*/
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.isEmpty()) {
setWorldSpawn(sender);
} else if (args.size() == 4) {
setWorldSpawn(sender, args.get(0), args.get(1), args.get(2), args.get(3));
} else if (args.size() == 6) {
setWorldSpawn(sender, args.get(0), args.get(1), args.get(2), args.get(3), args.get(4), args.get(5));
} else {
sender.sendMessage("Use no arguments for your current location, or world/x/y/z, or world/x/y/z/yaw/pitch!");
}
}
/**
* Set the world spawn when no parameters are given
* @param sender The {@link CommandSender} who executes the command.
* Everything not a {@link Player}, e.g. console, gets rejected, as we can't get coordinates from there.
*/
protected void setWorldSpawn(CommandSender sender) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location l = p.getLocation();
World w = p.getWorld();
setWorldSpawn(sender, w, l);
} else {
sender.sendMessage("You need to give coordinates to use this command from the console!");
}
}
/**
* Set the world spawn when 4 parameters are given
* @param sender The {@link CommandSender} who executes the command
* @param world The world to set the spawn in
* @param x X-coordinate to set the spawn to (as a {@link String} as it's from the command line, gets parsed into a double)
* @param y Y-coordinate to set the spawn to (as a {@link String} as it's from the command line, gets parsed into a double)
* @param z Z-coordinate to set the spawn to (as a {@link String} as it's from the command line, gets parsed into a double)
*/
protected void setWorldSpawn(CommandSender sender, String world, String x, String y, String z) {
setWorldSpawn(sender, world, x, y, z, "0", "0");
}
/**
* Set the world spawn when 6 parameters are given
* @param sender The {@link CommandSender} who executes the command
* @param world The world to set the spawn in
* @param x X-coordinate to set the spawn to (as a {@link String} as it's from the command line, gets parsed into a double)
* @param y Y-coordinate to set the spawn to (as a {@link String} as it's from the command line, gets parsed into a double)
* @param z Z-coordinate to set the spawn to (as a {@link String} as it's from the command line, gets parsed into a double)
* @param yaw Yaw a newly spawned player should look at (as a {@link String} as it's from the command line, gets parsed into a float)
* @param pitch Pitch a newly spawned player should look at (as a {@link String} as it's from the command line, gets parsed into a float)
*/
protected void setWorldSpawn(CommandSender sender, String world, String x, String y, String z, String yaw, String pitch) {
double dx, dy, dz;
float fpitch, fyaw;
World bukkitWorld = Bukkit.getWorld(world);
if (bukkitWorld == null) {
sender.sendMessage("World " + world + " is unknown!");
return;
}
try {
dx = Double.parseDouble(x);
dy = Double.parseDouble(y);
dz = Double.parseDouble(z);
fpitch = Float.parseFloat(pitch);
fyaw = Float.parseFloat(yaw);
} catch (NumberFormatException ex) {
sender.sendMessage("All coordinates must be numeric");
return;
}
Location l = new Location(bukkitWorld, dx, dy, dz, fyaw, fpitch);
setWorldSpawn(sender, bukkitWorld, l);
}
/**
* Does the actual spawn-setting-work.
*
* @param sender The {@link CommandSender} that's setting the spawn.
* @param w The {@link World} to set the spawn in
* @param l The {@link Location} to set the spawn to
*/
private void setWorldSpawn(CommandSender sender, World w, Location l) {
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
if (foundWorld != null) {
foundWorld.setSpawnLocation(l);
BlockSafety bs = this.plugin.getBlockSafety();
if (!bs.playerCanSpawnHereSafely(l) && foundWorld.getAdjustSpawn()) {
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
sender.sendMessage("If you want this turned back on just do:");
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
foundWorld.setAdjustSpawn(false);
}
sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(l));
if (!plugin.saveWorldConfig()) {
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
}
} 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).");
}
}
}
@@ -1,52 +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.permissions.PermissionDefault;
import java.util.List;
/**
* Enables debug-information.
*/
public class SilentCommand extends MultiverseCommand {
public SilentCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn silent mode on/off?");
this.setCommandUsage("/mv silent" + ChatColor.GOLD + " [true|false|on|off]");
this.setArgRange(0, 1);
this.addKey("mv silent");
this.addKey("mvsilent");
this.addCommandExample("/mv silent " + ChatColor.GOLD + "true");
this.setPermission("multiverse.core.silent", "Reduces the amount of startup messages.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("on")) {
args.set(0, "true");
}
plugin.getMVConfig().setSilentStart(Boolean.valueOf(args.get(0)));
plugin.saveMVConfigs();
}
this.displaySilentMode(sender);
}
private void displaySilentMode(CommandSender sender) {
if (plugin.getMVConfig().getSilentStart()) {
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.GREEN + "ON");
} else {
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.RED + "OFF");
}
}
}
@@ -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,90 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Teleports a player to the spawn.
*/
public class SpawnCommand extends MultiverseCommand {
public SpawnCommand(MultiverseCore plugin) {
super(plugin);
Permission otherPerm = new Permission("multiverse.core.spawn.other",
"Teleports another player to the spawn of the world they are in.", PermissionDefault.OP);
this.setName("Spawn");
this.setCommandUsage("/mv spawn" + ChatColor.GOLD + " [PLAYER]");
this.setArgRange(0, 1);
this.addKey("mvspawn");
this.addKey("mv spawn");
this.addKey("mvs");
this.setPermission("multiverse.core.spawn.self", "Teleports you to the Spawn Point of the world you are in.", PermissionDefault.OP);
this.addAdditonalPermission(otherPerm);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
// If a persons name was passed in, you must be A. the console, or B have permissions
if (args.size() == 1) {
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.other", true)) {
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.core.spawn.other)");
return;
}
Player target = this.plugin.getServer().getPlayerExact(args.get(0));
if (target != null) {
target.sendMessage("Teleporting to this world's spawn...");
spawnAccurately(target);
if (player != null) {
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
} else {
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
}
} else {
sender.sendMessage(args.get(0) + " is not logged on right now!");
}
} else {
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.core.spawn.self)");
return;
}
if (player != null) {
player.sendMessage("Teleporting to this world's spawn...");
spawnAccurately(player);
} else {
sender.sendMessage("From the console, you must provide a PLAYER.");
}
}
}
private void spawnAccurately(Player player) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName());
Location spawnLocation;
if (world != null) {
spawnLocation = world.getSpawnLocation();
} else {
spawnLocation = player.getWorld().getSpawnLocation();
}
this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false);
}
}
@@ -1,208 +1,69 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Teleporter;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.CustomTeleporterDestination;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.destination.WorldDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.CommandIssuer;
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.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.jvnet.hk2.annotations.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/**
* Used to teleport players.
*/
@Service
@CommandAlias("mv")
public class TeleportCommand extends MultiverseCommand {
private SafeTTeleporter playerTeleporter;
public TeleportCommand(MultiverseCore plugin) {
super(plugin);
Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
private final DestinationsProvider destinationsProvider;
this.setName("Teleport");
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {DESTINATION}");
this.setArgRange(1, 2);
this.addKey("mvtp");
this.addKey("mv tp");
this.playerTeleporter = this.plugin.getSafeTTeleporter();
this.setPermission(menu);
@Inject
public TeleportCommand(MVCommandManager commandManager, DestinationsProvider destinationsProvider) {
super(commandManager);
this.destinationsProvider = destinationsProvider;
}
private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 15;
@Subcommand("teleport|tp")
@CommandCompletion("@players|@mvworlds:playerOnly|@destinations:playerOnly @mvworlds|@destinations")
@Syntax("[player] <destination>")
@Description("{@@mv-core.teleport.description}")
public void onTeleportCommand(BukkitCommandIssuer issuer,
@Flags("resolve=issuerAware")
@Syntax("[player]")
@Description("{@@mv-core.teleport.player.description}")
Player[] players,
@Syntax("<destination>")
@Description("{@@mv-core.teleport.destination.description}")
ParsedDestination<?> destination
) {
// TODO Add warning if teleporting too many players at once.
CompletableFuture.allOf(Arrays.stream(players)
.map(player -> this.destinationsProvider.playerTeleportAsync(issuer, player, destination))
.toArray(CompletableFuture[]::new))
.thenRun(() -> {
String playerName = players.length == 1
? issuer.getPlayer() == players[0] ? "you" : players[0].getName()
: players.length + " players";
issuer.sendInfo(MVCorei18n.TELEPORT_SUCCESS,
"{player}", playerName, "{destination}", destination.toString());
});
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
CommandSender teleporter = sender;
Player teleportee = null;
String destinationName;
if (args.size() == 2) {
teleportee = this.plugin.getServer().getPlayerExact(args.get(0));
if (teleportee == null) {
this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s",
ChatColor.GOLD, args.get(0)), false);
return;
}
destinationName = args.get(1);
} else {
destinationName = args.get(0);
if (!(sender instanceof Player)) {
this.messaging.sendMessage(sender, String.format("From the console, you must specify a player to teleport"), false);
return;
}
teleportee = (Player) sender;
}
// Special case for cannons:
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
String[] cannonSpeed = destinationName.split("-");
try {
double speed = Double.parseDouble(cannonSpeed[1]);
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX()
+ "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":"
+ teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
} catch (Exception e) {
destinationName = "i:invalid";
}
}
DestinationFactory df = this.plugin.getDestFactory();
MVDestination d = df.getDestination(destinationName);
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) {
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);
return;
}
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
return;
}
if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD
+ teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
}
return;
} else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
if (teleportee.equals(teleporter)) {
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...",
ChatColor.GREEN, d.toString(), ChatColor.WHITE), false);
} else {
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED), false);
}
return;
}
// Special check to verify if players are tryint to teleport to the same
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
if (d instanceof WorldDestination) {
World w = d.getLocation(teleportee).getWorld();
if (teleportee.getWorld().equals(w)) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to go to the world spawn!"),
String.format("%s (multiverse.core.spawn.self)",
ChatColor.RED) }, false);
return;
}
} else {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to send %s to the world spawn!",
teleportee.getDisplayName()),
String.format("%s (multiverse.core.spawn.other)",
ChatColor.RED) }, false);
return;
}
}
}
}
if (d.getLocation(teleportee) == null) {
this.messaging.sendMessage(teleporter, "Sorry Boss, I tried everything, but just couldn't teleport ya there!", false);
return;
}
Teleporter teleportObject = (d instanceof CustomTeleporterDestination) ?
((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter;
TeleportResult result = teleportObject.teleport(teleporter, teleportee, d);
if (result == TeleportResult.FAIL_UNSAFE) {
Logging.fine("Could not teleport " + teleportee.getName()
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
Logging.fine("Queueing Command");
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List<Object> items = new ArrayList<Object>();
items.add(teleporter);
items.add(teleportee);
items.add(d.getLocation(teleportee));
String player = "you";
if (!teleportee.equals(teleporter)) {
player = teleportee.getName();
}
String message = String.format("%sMultiverse %sdid not teleport %s%s %sto %s%s %sbecause it was unsafe.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
}
// else: Player was teleported successfully (or the tp event was fired I should say)
}
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("%sYou don't have permission to teleport %syourself %sto a %s%s %sDestination",
ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, destination.getType(), ChatColor.WHITE),
String.format("%s (multiverse.teleport.self.%s)",
ChatColor.RED, destination.getIdentifier()) }, false);
return false;
}
} else {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("You don't have permission to teleport another player to a %s%s Destination.",
ChatColor.GREEN, destination.getType()),
String.format("%s(multiverse.teleport.other.%s)",
ChatColor.RED, destination.getIdentifier()) }, false);
return false;
}
}
return true;
public boolean hasPermission(CommandIssuer issuer) {
return this.destinationsProvider.hasAnyTeleportPermission(issuer);
}
}
@@ -1,42 +1,54 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import co.aikar.commands.BukkitCommandIssuer;
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.api.MVWorld;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import java.util.List;
/**
* Unloads worlds from Multiverse.
*/
@Service
@CommandAlias("mv")
public class UnloadCommand extends MultiverseCommand {
public UnloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Unload World");
this.setCommandUsage("/mv unload" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvunload");
this.addKey("mv unload");
this.setPermission("multiverse.core.unload",
"Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP);
private final MVWorldManager worldManager;
@Inject
public UnloadCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
super(commandManager);
this.worldManager = worldManager;
}
@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")
@CommandCompletion("@mvworlds")
@Syntax("<world>")
@Description("{@@mv-core.unload.description}")
public void onUnloadCommand(BukkitCommandIssuer issuer,
@Syntax("<world>")
@Description("{@@mv-core.unload.world.description}")
MVWorld world
) {
issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING,
"{world}", world.getColoredWorldString());
//TODO API: Should be able to use MVWorld object directly
if (!this.worldManager.unloadWorld(world.getName())) {
issuer.sendError(MVCorei18n.UNLOAD_FAILURE,
"{world}", world.getColoredWorldString());
return;
}
issuer.sendInfo(MVCorei18n.UNLOAD_SUCCESS,
"{world}", world.getColoredWorldString());
}
}
@@ -0,0 +1,39 @@
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.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
import jakarta.inject.Inject;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
@Service
@CommandAlias("mv")
public class UsageCommand extends MultiverseCommand {
@Inject
public UsageCommand(@NotNull MVCommandManager commandManager) {
super(commandManager);
}
@HelpCommand
@Subcommand("help")
@CommandPermission("multiverse.core.help")
@CommandCompletion("@commands:mv")
@Syntax("[filter] [page]")
@Description("{@@mv-core.usage.description}")
public void onUsageCommand(CommandHelp help) {
if (help.getIssuer().isPlayer()) {
// Prevent flooding the chat
help.setPerPage(4);
}
this.commandManager.showUsage(help);
}
}
@@ -1,221 +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.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
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 com.pneumaticraft.commandhandler.CommandHandler;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* Dumps version info to the console.
*/
public class VersionCommand extends MultiverseCommand {
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 + "[-b|-h|-p] [--include-plugin-list]");
this.setArgRange(0, 2);
this.addKey("mv version");
this.addKey("mvver");
this.addKey("mvv");
this.addKey("mvversion");
this.setPermission("multiverse.core.version",
"Dumps version info to the console, optionally to pastebin.com with -b, to hastebin.com using -h, or to paste.gg with -p.", PermissionDefault.TRUE);
}
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: " + plugin.getMVConfig().getEnforceAccess() + '\n'
+ "[Multiverse-Core] prefixchat: " + plugin.getMVConfig().getPrefixChat() + '\n'
+ "[Multiverse-Core] prefixchatformat: " + plugin.getMVConfig().getPrefixChatFormat() + '\n'
+ "[Multiverse-Core] useasyncchat: " + plugin.getMVConfig().getUseAsyncChat() + '\n'
+ "[Multiverse-Core] teleportintercept: " + plugin.getMVConfig().getTeleportIntercept() + '\n'
+ "[Multiverse-Core] firstspawnoverride: " + plugin.getMVConfig().getFirstSpawnOverride() + '\n'
+ "[Multiverse-Core] displaypermerrors: " + plugin.getMVConfig().getDisplayPermErrors() + '\n'
+ "[Multiverse-Core] globaldebug: " + plugin.getMVConfig().getGlobalDebug() + '\n'
+ "[Multiverse-Core] silentstart: " + plugin.getMVConfig().getSilentStart() + '\n'
+ "[Multiverse-Core] messagecooldown: " + plugin.getMessaging().getCooldown() + '\n'
+ "[Multiverse-Core] version: " + plugin.getMVConfig().getVersion() + '\n'
+ "[Multiverse-Core] firstspawnworld: " + plugin.getMVConfig().getFirstSpawnWorld() + '\n'
+ "[Multiverse-Core] teleportcooldown: " + plugin.getMVConfig().getTeleportCooldown() + '\n'
+ "[Multiverse-Core] defaultportalsearch: " + plugin.getMVConfig().isUsingDefaultPortalSearch() + '\n'
+ "[Multiverse-Core] portalsearchradius: " + plugin.getMVConfig().getPortalSearchRadius() + '\n'
+ "[Multiverse-Core] autopurge: " + plugin.getMVConfig().isAutoPurgeEnabled() + '\n'
+ "[Multiverse-Core] Special Code: FRN002" + '\n';
}
private String getMarkdownString() {
return "# Multiverse-Core" + '\n'
+ "## Overview" + '\n'
+ "| Name | Value |" + '\n'
+ "| --- | --- |" + '\n'
+ "| Multiverse-Core Version | `" + this.plugin.getDescription().getVersion() + "` |" + '\n'
+ "| Bukkit Version | `" + this.plugin.getServer().getVersion() + "` |" + '\n'
+ "| Loaded Worlds | `" + this.plugin.getMVWorldManager().getMVWorlds() + "` |" + '\n'
+ "| Multiverse Plugins Loaded | `" + this.plugin.getPluginCount() + "` |" + '\n'
+ "| Economy being used | `" + plugin.getEconomist().getEconomyName() + "` |" + '\n'
+ "| Permissions Plugin | `" + this.plugin.getMVPerms().getType() + "` |" + '\n'
+ "## Parsed Config" + '\n'
+ "These are what Multiverse thought the in-memory values of the config were." + "\n\n"
+ "| Config Key | Value |" + '\n'
+ "| --- | --- |" + '\n'
+ "| version | `" + this.plugin.getMVConfig().getVersion() + "` |" + '\n'
+ "| messagecooldown | `" + plugin.getMessaging().getCooldown() + "` |" + '\n'
+ "| teleportcooldown | `" + plugin.getMVConfig().getTeleportCooldown() + "` |" + '\n'
+ "| worldnameprefix | `" + plugin.getMVConfig().getPrefixChat() + "` |" + '\n'
+ "| worldnameprefixFormat | `" + plugin.getMVConfig().getPrefixChatFormat() + "` |" + '\n'
+ "| enforceaccess | `" + plugin.getMVConfig().getEnforceAccess() + "` |" + '\n'
+ "| displaypermerrors | `" + plugin.getMVConfig().getDisplayPermErrors() + "` |" + '\n'
+ "| teleportintercept | `" + plugin.getMVConfig().getTeleportIntercept() + "` |" + '\n'
+ "| firstspawnoverride | `" + plugin.getMVConfig().getFirstSpawnOverride() + "` |" + '\n'
+ "| firstspawnworld | `" + plugin.getMVConfig().getFirstSpawnWorld() + "` |" + '\n'
+ "| debug | `" + plugin.getMVConfig().getGlobalDebug() + "` |" + '\n';
}
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 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);
}
@Override
public void runCommand(final CommandSender sender, final List<String> args) {
// Check if the command was sent from a Player.
if (sender instanceof Player) {
sender.sendMessage("Version info dumped to console. Please check your server logs.");
}
MVVersionEvent versionEvent = new MVVersionEvent();
this.addVersionInfoToEvent(versionEvent);
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
if (CommandHandler.hasFlag("--include-plugin-list", args)) {
versionEvent.appendVersionInfo('\n' + "Plugins: " + getPluginList());
versionEvent.putDetailedVersionInfo("plugins.txt", "Plugins: " + getPluginList());
}
final String versionInfo = versionEvent.getVersionInfo();
versionEvent.putDetailedVersionInfo("version.txt", versionInfo);
final Map<String, String> files = versionEvent.getDetailedVersionInfo();
// log to console
String[] lines = versionInfo.split("\\r?\\n");
for (String line : lines) {
if (!line.isEmpty()) {
this.plugin.getServer().getLogger().info(line);
}
}
BukkitRunnable logPoster = new BukkitRunnable() {
@Override
public void run() {
if (args.size() > 0) {
String pasteUrl;
if (CommandHandler.hasFlag("-b", args)) {
// private post to pastebin
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, versionInfo, files);
} else if (CommandHandler.hasFlag("-g", args)) {
// private post to github
pasteUrl = postToService(PasteServiceType.GITHUB, true, versionInfo, files);
} else if (CommandHandler.hasFlag("-h", args)) {
// private post to hastebin
pasteUrl = postToService(PasteServiceType.HASTEBIN, true, versionInfo, files);
} else if (CommandHandler.hasFlag("-p", args)) {
// private post to paste.gg
pasteUrl = postToService(PasteServiceType.PASTEGG, true, versionInfo, files);
} else {
return;
}
if (!(sender instanceof ConsoleCommandSender)) {
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
}
Logging.info("Version info dumped here: %s", pasteUrl);
}
}
};
// Run the log posting operation asynchronously, since we don't know how long it will take.
logPoster.runTaskAsynchronously(this.plugin);
}
/**
* Send the current contents of this.pasteBinBuffer to a web service.
*
* @param type Service type to send paste data to.
* @param isPrivate Should the paste be marked as private.
* @param pasteData Legacy string only data to post to a service.
* @param pasteFiles Map of filenames/contents of debug info.
* @return URL of visible paste
*/
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData, Map<String, String> pasteFiles) {
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
try {
String result;
if (ps.supportsMultiFile()) {
result = ps.postData(pasteFiles);
} else {
result = ps.postData(pasteData);
}
if (SHORTENER != null) return SHORTENER.shorten(result);
return result;
} catch (PasteFailedException e) {
e.printStackTrace();
return "Error posting to service.";
} catch (NullPointerException e) {
e.printStackTrace();
return "That service isn't supported yet.";
}
}
private String getPluginList() {
return StringUtils.join(plugin.getServer().getPluginManager().getPlugins(), ", ");
}
}
@@ -1,118 +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 org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
/**
* States who is in what world.
*/
public class WhoCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public WhoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Who?");
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [WORLD|--all]");
this.setArgRange(0, 1);
this.addKey("mv who");
this.addKey("mvw");
this.addKey("mvwho");
this.addCommandExample("/mv who");
this.addCommandExample(String.format("/mv who %s--all", ChatColor.GREEN));
this.addCommandExample(String.format("/mv who %smyworld", ChatColor.GOLD));
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// If this command was sent from a Player then we need to check Permissions
Player p = null;
// By default, show all from the console
boolean showAll = true;
if (sender instanceof Player) {
p = (Player) sender;
showAll = false;
}
final Collection onlinePlayers = plugin.getServer().getOnlinePlayers();
final Collection<Player> visiblePlayers = new HashSet<Player>(onlinePlayers.size());
for (final Object player : onlinePlayers) {
if (player instanceof Player && (p == null || p.canSee((Player) player))) {
visiblePlayers.add((Player) player);
}
}
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
showAll = true;
} else {
// single world mode
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
if (world == null) {
sender.sendMessage(ChatColor.RED + "That world does not exist.");
return;
}
if (!this.plugin.getMVPerms().canEnterWorld(p, world)) {
sender.sendMessage(ChatColor.RED + "You aren't allowed to access to this world!");
return;
}
sender.sendMessage(String.format("%s--- Players in %s%s ---", ChatColor.AQUA,
world.getColoredWorldString(), ChatColor.AQUA));
sender.sendMessage(this.buildPlayerString(world, p, visiblePlayers));
return;
}
}
// multiworld mode
sender.sendMessage(ChatColor.AQUA + "--- Worlds and their players --- "
+ visiblePlayers.size() + "/" + plugin.getServer().getMaxPlayers());
boolean shownOne = false;
for (MultiverseWorld world : this.worldManager.getMVWorlds()) {
if (this.plugin.getMVPerms().canEnterWorld(p, world)) { // only show world if the player can access it
if (showAll || !world.getCBWorld().getPlayers().isEmpty()) { // either show all or show if the world is not empty
sender.sendMessage(String.format("%s%s - %s", world.getColoredWorldString(), ChatColor.WHITE, buildPlayerString(world, p, visiblePlayers)));
shownOne = true;
}
}
}
if (!shownOne) {
sender.sendMessage("No worlds found.");
}
return;
}
private static String buildPlayerString(MultiverseWorld world, Player viewer, final Collection<Player> visiblePlayers) {
// Retrieve the players in this world
List<Player> players = world.getCBWorld().getPlayers();
StringBuilder playerBuilder = new StringBuilder();
for (Player player : players) {
// If the viewer is the console or the viewier is allowed to see the player, show them.
// Make sure we're also ONLY showing online players.
// Since we already checked visible players, we'll just make sure who we're about to show is in that.
if (visiblePlayers.contains(player))
playerBuilder.append(player.getDisplayName()).append(", ");
}
String bString = playerBuilder.toString();
return (bString.length() == 0) ? "No players found." : bString.substring(0, bString.length() - 2);
}
}
@@ -1,4 +1,4 @@
/**
* This package contains all Commands.
* This package contains all the commands for Multiverse-Core.
*/
package com.onarandombox.MultiverseCore.commands;
@@ -0,0 +1,146 @@
package com.onarandombox.MultiverseCore.commandtools;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import co.aikar.commands.BukkitCommandCompletionContext;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.PaperCommandCompletions;
import co.aikar.commands.RegisteredCommand;
import co.aikar.commands.RootCommand;
import com.google.common.collect.Sets;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import jakarta.inject.Inject;
import org.bukkit.GameRule;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
@Service
public class MVCommandCompletions extends PaperCommandCompletions {
protected final MVCommandManager commandManager;
private final MVWorldManager worldManager;
private final DestinationsProvider destinationsProvider;
@Inject
public MVCommandCompletions(
@NotNull MVCommandManager mvCommandManager,
@NotNull MVWorldManager worldManager,
@NotNull DestinationsProvider destinationsProvider,
@NotNull MVCoreConfig config
) {
super(mvCommandManager);
this.commandManager = mvCommandManager;
this.worldManager = worldManager;
this.destinationsProvider = destinationsProvider;
registerAsyncCompletion("commands", this::suggestCommands);
registerAsyncCompletion("destinations", this::suggestDestinations);
registerAsyncCompletion("flags", this::suggestFlags);
registerStaticCompletion("gamerules", this::suggestGamerules);
registerStaticCompletion("mvconfigs", config.getNodes().getNames());
registerAsyncCompletion("mvworlds", this::suggestMVWorlds);
setDefaultCompletion("destinations", ParsedDestination.class);
setDefaultCompletion("flags", String[].class);
setDefaultCompletion("gamerules", GameRule.class);
setDefaultCompletion("mvworlds", MVWorld.class);
}
private Collection<String> suggestCommands(BukkitCommandCompletionContext context) {
String rootCmdName = context.getConfig();
if (rootCmdName == null) {
return Collections.emptyList();
}
RootCommand rootCommand = this.commandManager.getRegisteredRootCommands().stream()
.unordered()
.filter(c -> c.getCommandName().equals(rootCmdName))
.findFirst()
.orElse(null);
if (rootCommand == null) {
return Collections.emptyList();
}
return rootCommand.getSubCommands().entries().stream()
.filter(entry -> checkPerms(context.getIssuer(), entry.getValue()))
.map(Map.Entry::getKey)
.filter(cmdName -> !cmdName.startsWith("__"))
.collect(Collectors.toList());
}
private boolean checkPerms(CommandIssuer issuer, RegisteredCommand<?> command) {
return this.commandManager.hasPermission(issuer, command.getRequiredPermissions());
}
private Collection<String> suggestDestinations(BukkitCommandCompletionContext context) {
if (context.hasConfig("playerOnly") && !context.getIssuer().isPlayer()) {
return Collections.emptyList();
}
return this.destinationsProvider
.suggestDestinations((BukkitCommandIssuer)context.getIssuer(), context.getInput());
}
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
return this.commandManager.getFlagsManager().suggest(
context.getConfig("groupName", ""), context.getContextValue(String[].class));
}
private Collection<String> suggestGamerules() {
return Arrays.stream(GameRule.values()).map(GameRule::getName).collect(Collectors.toList());
}
private Collection<String> suggestMVWorlds(BukkitCommandCompletionContext context) {
if (context.hasConfig("playerOnly") && !context.getIssuer().isPlayer()) {
return Collections.emptyList();
}
if (!context.hasConfig("multiple")) {
return getMVWorldNames(context);
}
String input = context.getInput();
int lastComma = input.lastIndexOf(',');
String currentWorldsString = input.substring(0, lastComma + 1);
Set<String> currentWorlds = Sets.newHashSet(input.split(","));
return getMVWorldNames(context).stream()
.filter(world -> !currentWorlds.contains(world))
.map(world -> currentWorldsString + world)
.collect(Collectors.toList());
}
private List<String> getMVWorldNames(BukkitCommandCompletionContext context) {
String scope = context.getConfig("scope", "loaded");
List<String> worlds = new ArrayList<>();
switch (scope) {
case "both":
worlds.addAll(worldManager.getUnloadedWorlds());
case "loaded":
worldManager.getMVWorlds()
.stream()
.map(MVWorld::getName)
.forEach(worlds::add);
break;
case "unloaded":
worlds.addAll(worldManager.getUnloadedWorlds());
break;
case "potential":
worlds.addAll(worldManager.getPotentialWorlds());
break;
}
return worlds;
}
}
@@ -0,0 +1,80 @@
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.api.MVWorldManager;
import com.onarandombox.MultiverseCore.world.WorldNameChecker;
import jakarta.annotation.PostConstruct;
import org.jetbrains.annotations.NotNull;
public class MVCommandConditions {
static void load(MVCommandManager commandManager, MVWorldManager worldManager) {
new MVCommandConditions(commandManager, worldManager);
}
private final MVWorldManager worldManager;
private final MVCommandManager commandManager;
private MVCommandConditions(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) {
this.worldManager = worldManager;
this.commandManager = commandManager;
}
@PostConstruct
private void registerConditions() {
CommandConditions<BukkitCommandIssuer, BukkitCommandExecutionContext, BukkitConditionContext> conditions
= commandManager.getCommandConditions();
conditions.addCondition(String.class, "validWorldName", this::checkValidWorldName);
}
private void checkValidWorldName(ConditionContext<BukkitCommandIssuer> context,
BukkitCommandExecutionContext executionContext,
String worldName
) {
String scope = context.getConfigValue("scope", "loaded");
switch (scope) {
// Worlds that are loaded
case "loaded":
if (!this.worldManager.isMVWorld(worldName)) {
throw new ConditionFailedException("World with name '" + worldName + "' does not exist or is not loaded!");
}
break;
// Worlds that are unloaded
case "unloaded":
if (!this.worldManager.hasUnloadedWorld(worldName, false)) {
if (this.worldManager.isMVWorld(worldName)) {
throw new ConditionFailedException("World with name '" + worldName + "' is loaded already!");
}
throw new ConditionFailedException("World with name '" + worldName + "' does not exist!");
}
break;
// World that are loaded or unloaded
case "both":
if (!this.worldManager.hasUnloadedWorld(worldName, true)) {
throw new ConditionFailedException("World with name '" + worldName + "' does not exist!");
}
break;
// World that are does not exist
case "new":
if (this.worldManager.hasUnloadedWorld(worldName, true)) {
throw new ConditionFailedException("World with name '" + worldName + "' already exists!");
}
switch (WorldNameChecker.checkName(worldName)) {
case INVALID_CHARS:
throw new ConditionFailedException("World name '" + worldName + "' contains invalid characters!");
case BLACKLISTED:
throw new ConditionFailedException("World name '" + worldName + "' is used for critical server operations and is blacklisted!");
}
break;
// Probably a typo happened here
default:
throw new ConditionFailedException("Unknown scope '" + scope + "'!");
}
}
}
@@ -0,0 +1,356 @@
package com.onarandombox.MultiverseCore.commandtools;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import co.aikar.commands.BukkitCommandExecutionContext;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.PaperCommandContexts;
import co.aikar.commands.contexts.ContextResolver;
import com.google.common.base.Strings;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.context.GameRuleValue;
import com.onarandombox.MultiverseCore.commandtools.context.MVConfigValue;
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
import com.onarandombox.MultiverseCore.configuration.node.Node;
import com.onarandombox.MultiverseCore.configuration.node.ValueNode;
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.display.filters.ContentFilter;
import com.onarandombox.MultiverseCore.display.filters.DefaultContentFilter;
import com.onarandombox.MultiverseCore.display.filters.RegexContentFilter;
import com.onarandombox.MultiverseCore.utils.PlayerFinder;
import io.vavr.control.Option;
import jakarta.inject.Inject;
import org.bukkit.GameRule;
import org.bukkit.entity.Player;
import org.jvnet.hk2.annotations.Service;
@Service
public class MVCommandContexts extends PaperCommandContexts {
private final MVCommandManager mvCommandManager;
private final DestinationsProvider destinationsProvider;
private final MVWorldManager worldManager;
private final MVCoreConfig config;
@Inject
public MVCommandContexts(
MVCommandManager mvCommandManager,
DestinationsProvider destinationsProvider,
MVWorldManager worldManager,
MVCoreConfig config
) {
super(mvCommandManager);
this.mvCommandManager = mvCommandManager;
this.destinationsProvider = destinationsProvider;
this.worldManager = worldManager;
this.config = config;
registerIssuerOnlyContext(BukkitCommandIssuer.class, BukkitCommandExecutionContext::getIssuer);
registerIssuerOnlyContext(MVCommandIssuer.class, this::parseMVCommandIssuer);
registerOptionalContext(ContentFilter.class, this::parseContentFilter);
registerContext(ParsedDestination.class, this::parseDestination);
registerContext(GameRule.class, this::parseGameRule);
registerContext(GameRuleValue.class, this::parseGameRuleValue);
registerContext(MVConfigValue.class, this::parseMVConfigValue);
registerIssuerAwareContext(MVWorld.class, this::parseMVWorld);
registerIssuerAwareContext(MVWorld[].class, this::parseMVWorldArray);
registerIssuerAwareContext(Player.class, this::parsePlayer);
registerIssuerAwareContext(Player[].class, this::parsePlayerArray);
}
private MVCommandIssuer parseMVCommandIssuer(BukkitCommandExecutionContext context) {
if (context.getIssuer() instanceof MVCommandIssuer) {
return (MVCommandIssuer) context.getIssuer();
}
return mvCommandManager.getCommandIssuer(context.getSender());
}
private ContentFilter parseContentFilter(BukkitCommandExecutionContext context) {
if (Strings.isNullOrEmpty(context.getFirstArg())) {
return DefaultContentFilter.get();
}
String filterString = context.popFirstArg();
return RegexContentFilter.fromString(filterString);
}
private ParsedDestination<?> parseDestination(BukkitCommandExecutionContext context) {
String destination = context.popFirstArg();
if (Strings.isNullOrEmpty(destination)) {
throw new InvalidCommandArgument("No destination specified.");
}
ParsedDestination<?> parsedDestination = destinationsProvider.parseDestination(destination);
if (parsedDestination == null) {
throw new InvalidCommandArgument("The destination " + destination + " is not valid.");
}
return parsedDestination;
}
private GameRule<?> parseGameRule(BukkitCommandExecutionContext context) {
String gameRuleName = context.popFirstArg();
if (Strings.isNullOrEmpty(gameRuleName)) {
throw new InvalidCommandArgument("No game rule specified.");
}
GameRule<?> gameRule = GameRule.getByName(gameRuleName);
if (gameRule == null) {
throw new InvalidCommandArgument("The game rule " + gameRuleName + " is not valid.");
}
return gameRule;
}
private GameRuleValue parseGameRuleValue(BukkitCommandExecutionContext context) {
GameRule<?> gameRule = (GameRule<?>) context.getResolvedArg(GameRule.class);
if (gameRule == null) {
throw new InvalidCommandArgument("No game rule specified.");
}
String valueString = context.getFirstArg();
if (Strings.isNullOrEmpty(valueString)) {
throw new InvalidCommandArgument("No game rule value specified.");
}
ContextResolver<?, BukkitCommandExecutionContext> resolver = getResolver(gameRule.getType());
if (resolver == null) {
return new GameRuleValue(valueString);
}
Object resolvedValue = resolver.getContext(context);
if (resolvedValue == null) {
throw new InvalidCommandArgument("The game rule value " + valueString + " is not valid for game rule " + gameRule.getName() + ".");
}
return new GameRuleValue(resolvedValue);
}
private MVConfigValue parseMVConfigValue(BukkitCommandExecutionContext context) {
String configName = (String) context.getResolvedArg(String.class);
if (Strings.isNullOrEmpty(configName)) {
throw new InvalidCommandArgument("No config name specified.");
}
Option<Node> node = config.getNodes().findNode(configName);
if (node.isEmpty()) {
throw new InvalidCommandArgument("The config " + configName + " is not valid.");
}
String valueString = context.getFirstArg();
if (Strings.isNullOrEmpty(valueString)) {
throw new InvalidCommandArgument("No config value specified.");
}
if (!(node.get() instanceof ValueNode)) {
context.popFirstArg();
return new MVConfigValue(valueString);
}
ContextResolver<?, BukkitCommandExecutionContext> resolver = getResolver(((ValueNode<?>) node.get()).getType());
if (resolver == null) {
context.popFirstArg();
return new MVConfigValue(valueString);
}
Object resolvedValue = resolver.getContext(context);
if (resolvedValue == null) {
throw new InvalidCommandArgument("The config value " + valueString + " is not valid for config " + configName + ".");
}
return new MVConfigValue(resolvedValue);
}
private MVWorld parseMVWorld(BukkitCommandExecutionContext context) {
String resolve = context.getFlagValue("resolve", "");
// Get world based on sender only
if (resolve.equals("issuerOnly")) {
if (context.getIssuer().isPlayer()) {
return worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld());
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("This command can only be used by a player in a Multiverse World.");
}
String worldName = context.getFirstArg();
MVWorld world = worldManager.getMVWorld(worldName);
// Get world based on input, fallback to sender if input is not a world
if (resolve.equals("issuerAware")) {
if (world != null) {
context.popFirstArg();
return world;
}
if (context.getIssuer().isPlayer()) {
return worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld());
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("Player is not in a Multiverse World.");
}
// Get world based on input only
if (world != null) {
context.popFirstArg();
return world;
}
if (!context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("World " + worldName + " is not a loaded multiverse world.");
}
private MVWorld[] parseMVWorldArray(BukkitCommandExecutionContext context) {
String resolve = context.getFlagValue("resolve", "");
MVWorld playerWorld = null;
if (context.getIssuer().isPlayer()) {
playerWorld = worldManager.getMVWorld(context.getIssuer().getPlayer().getWorld());
}
// Get world based on sender only
if (resolve.equals("issuerOnly")) {
if (playerWorld != null) {
return new MVWorld[]{playerWorld};
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("This command can only be used by a player in a Multiverse World.");
}
String worldStrings = context.getFirstArg();
String[] worldNames = worldStrings.split(",");
Set<MVWorld> worlds = new HashSet<>(worldNames.length);
for (String worldName : worldNames) {
if ("*".equals(worldName)) {
worlds.addAll(worldManager.getMVWorlds());
break;
}
MVWorld world = worldManager.getMVWorld(worldName);
if (world == null) {
throw new InvalidCommandArgument("World " + worldName + " is not a loaded multiverse world.");
}
worlds.add(world);
}
// Get world based on input, fallback to sender if input is not a world
if (resolve.equals("issuerAware")) {
if (!worlds.isEmpty()) {
context.popFirstArg();
return worlds.toArray(new MVWorld[0]);
}
if (playerWorld != null) {
return new MVWorld[]{playerWorld};
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("Player is not in a Multiverse World.");
}
// Get world based on input only
if (!worlds.isEmpty()) {
context.popFirstArg();
return worlds.toArray(new MVWorld[0]);
}
if (!context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("World " + worldStrings + " is not a loaded multiverse world.");
}
private Player parsePlayer(BukkitCommandExecutionContext context) {
String resolve = context.getFlagValue("resolve", "");
// Get player based on sender only
if (resolve.equals("issuerOnly")) {
if (context.getIssuer().isPlayer()) {
return context.getIssuer().getPlayer();
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("This command can only be used by a player.");
}
String playerIdentifier = context.getFirstArg();
Player player = PlayerFinder.get(playerIdentifier, context.getSender());
// Get player based on input, fallback to sender if input is not a player
if (resolve.equals("issuerAware")) {
if (player != null) {
context.popFirstArg();
return player;
}
if (context.getIssuer().isPlayer()) {
return context.getIssuer().getPlayer();
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("Invalid player: " + playerIdentifier
+ ". Either specify an online player or use this command as a player.");
}
// Get player based on input only
if (player != null) {
context.popFirstArg();
return player;
}
if (!context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("Player " + playerIdentifier + " not found.");
}
private Player[] parsePlayerArray(BukkitCommandExecutionContext context) {
String resolve = context.getFlagValue("resolve", "");
// Get player based on sender only
if (resolve.equals("issuerOnly")) {
if (context.getIssuer().isPlayer()) {
return new Player[]{context.getIssuer().getPlayer()};
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("This command can only be used by a player.");
}
String playerIdentifier = context.getFirstArg();
Player[] players = PlayerFinder.getMulti(playerIdentifier, context.getSender()).toArray(new Player[0]);
// Get player based on input, fallback to sender if input is not a player
if (resolve.equals("issuerAware")) {
if (players.length > 0) {
context.popFirstArg();
return players;
}
if (context.getIssuer().isPlayer()) {
return new Player[]{context.getIssuer().getPlayer()};
}
if (context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("Invalid player: " + playerIdentifier
+ ". Either specify an online player or use this command as a player.");
}
// Get player based on input only
if (players.length > 0) {
context.popFirstArg();
return players;
}
if (!context.isOptional()) {
return null;
}
throw new InvalidCommandArgument("Player " + playerIdentifier + " not found.");
}
}
@@ -0,0 +1,48 @@
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.MessageType;
import co.aikar.commands.OpenBukkitCommandIssuer;
import co.aikar.locales.MessageKeyProvider;
import com.onarandombox.MultiverseCore.utils.message.Message;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class MVCommandIssuer extends OpenBukkitCommandIssuer {
private final MVCommandManager commandManager;
MVCommandIssuer(@NotNull MVCommandManager commandManager, @NotNull CommandSender sender) {
super(commandManager, sender);
this.commandManager = commandManager;
}
@Override
public MVCommandManager getManager() {
return commandManager;
}
public void sendError(Message message) {
sendMessage(MessageType.ERROR, message);
}
public void sendSyntax(Message message) {
sendMessage(MessageType.SYNTAX, message);
}
public void sendInfo(Message message) {
sendMessage(MessageType.INFO, message);
}
private void sendMessage(MessageType messageType, Message message) {
if (message instanceof MessageKeyProvider) {
sendMessage(messageType, (MessageKeyProvider) message, message.getReplacements());
} else {
var formatter = getManager().getFormat(messageType);
if (formatter != null) {
sendMessage(formatter.format(message.formatted()));
} else {
sendMessage(message.formatted());
}
}
}
}
@@ -0,0 +1,136 @@
package com.onarandombox.MultiverseCore.commandtools;
import java.util.List;
import co.aikar.commands.BukkitCommandCompletionContext;
import co.aikar.commands.BukkitCommandExecutionContext;
import co.aikar.commands.BukkitLocales;
import co.aikar.commands.CommandCompletions;
import co.aikar.commands.CommandContexts;
import co.aikar.commands.CommandHelp;
import co.aikar.commands.HelpEntry;
import co.aikar.commands.PaperCommandManager;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
/**
* Main class to manage permissions.
*/
@Service
public class MVCommandManager extends PaperCommandManager {
private final CommandFlagsManager flagsManager;
private final CommandQueueManager commandQueueManager;
private final Provider<MVCommandContexts> commandContextsProvider;
private final Provider<MVCommandCompletions> commandCompletionsProvider;
@Inject
public MVCommandManager(
@NotNull MultiverseCore plugin,
@NotNull CommandFlagsManager flagsManager,
@NotNull CommandQueueManager commandQueueManager,
@NotNull Provider<MVCommandContexts> commandContextsProvider,
@NotNull Provider<MVCommandCompletions> commandCompletionsProvider,
@NotNull MVWorldManager worldManager
) {
super(plugin);
this.flagsManager = flagsManager;
this.commandQueueManager = commandQueueManager;
this.commandContextsProvider = commandContextsProvider;
this.commandCompletionsProvider = commandCompletionsProvider;
MVCommandConditions.load(this, worldManager);
this.enableUnstableAPI("help");
}
void loadLanguages(PluginLocales locales) {
if (this.locales == null) {
this.locales = locales;
this.locales.loadLanguages();
}
}
@Override
public BukkitLocales getLocales() {
return this.locales;
}
/**
* Gets class responsible for flag handling.
*
* @return A not-null {@link CommandFlagsManager}.
*/
public synchronized @NotNull CommandFlagsManager getFlagsManager() {
return flagsManager;
}
/**
* Manager for command that requires /mv confirm before execution.
*
* @return A non-null {@link CommandQueueManager}.
*/
public synchronized @NotNull CommandQueueManager getCommandQueueManager() {
return commandQueueManager;
}
/**
* Gets class responsible for parsing string args into objects.
*
* @return A not-null {@link CommandContexts}.
*/
@Override
public synchronized @NotNull CommandContexts<BukkitCommandExecutionContext> getCommandContexts() {
if (this.contexts == null) {
this.contexts = commandContextsProvider.get();
}
return this.contexts;
}
/**
* Gets class responsible for tab-completion handling.
*
* @return A not-null {@link CommandCompletions}.
*/
@Override
public synchronized @NotNull CommandCompletions<BukkitCommandCompletionContext> getCommandCompletions() {
if (this.completions == null) {
this.completions = commandCompletionsProvider.get();
}
return this.completions;
}
/**
* 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) {
getHelpFormatter().showDetailedHelp(help, entries.get(0));
return;
}
help.showHelp();
}
public @NotNull MVCommandIssuer getConsoleCommandIssuer() {
return getCommandIssuer(Bukkit.getConsoleSender());
}
@Override
public @NotNull MVCommandIssuer getCommandIssuer(Object issuer) {
if (!(issuer instanceof CommandSender)) {
throw new IllegalArgumentException(issuer.getClass().getName() + " is not a Command Issuer.");
} else {
return new MVCommandIssuer(this, (CommandSender)issuer);
}
}
}
@@ -0,0 +1,35 @@
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.BaseCommand;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Contract;
@Contract
public abstract class MultiverseCommand extends BaseCommand {
protected final MVCommandManager commandManager;
private String flagGroupName;
protected MultiverseCommand(@NotNull MVCommandManager commandManager) {
this.commandManager = commandManager;
}
protected CommandFlagsManager getFlagsManager() {
return commandManager.getFlagsManager();
}
protected void registerFlagGroup(@NotNull CommandFlagGroup flagGroup) {
if (flagGroupName != null) {
throw new IllegalStateException("Flag group already registered! (name: " + flagGroupName + ")");
}
getFlagsManager().registerFlagGroup(flagGroup);
flagGroupName = flagGroup.getName();
}
protected @NotNull ParsedCommandFlags parseFlags(@NotNull String[] flags) {
return getFlagsManager().parse(flagGroupName, flags);
}
}
@@ -0,0 +1,49 @@
package com.onarandombox.MultiverseCore.commandtools;
import co.aikar.commands.BukkitLocales;
import com.onarandombox.MultiverseCore.utils.file.FileResClassLoader;
import jakarta.inject.Inject;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
/**
* Locale manager with additional methods for loading locales from plugin's locales folder.
*/
@Service
public class PluginLocales extends BukkitLocales {
private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales";
/**
* Creates a new instance of {@link PluginLocales}.
*
* @param manager The command manager.
*/
@Inject
public PluginLocales(MVCommandManager manager) {
super(manager);
manager.loadLanguages(this);
}
/**
* Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from.
*
* @param plugin The plugin.
* @return True if the class loader was added successfully.
*/
public boolean addFileResClassLoader(@NotNull Plugin plugin) {
return this.addBundleClassLoader(new FileResClassLoader(plugin, DEFAULT_LOCALE_FOLDER_PATH));
}
/**
* Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from.
*
* @param plugin The plugin.
* @param localesFolderPath The path to the folder containing the locales.
* @return True if the class loader was added successfully.
*/
public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) {
return this.addBundleClassLoader(new FileResClassLoader(plugin, localesFolderPath));
}
}
@@ -0,0 +1,13 @@
package com.onarandombox.MultiverseCore.commandtools.context;
public class GameRuleValue {
private final Object value;
public GameRuleValue(Object value) {
this.value = value;
}
public Object getValue() {
return value;
}
}
@@ -0,0 +1,13 @@
package com.onarandombox.MultiverseCore.commandtools.context;
public class MVConfigValue {
private final Object value;
public MVConfigValue(Object value) {
this.value = value;
}
public Object getValue() {
return value;
}
}
Loaded 100 of 279 files, more files were not shown because too many files have changed in this diff. Show more